Files
qbz/crates/qbz-ui/ui/shell/LogViewerModal.slint
T
vicrodh 99da4c381b feat(slint): pre-launch dev panel, queue controls, appearance persistence, reco cache settings
Sleep timer (queue footer): tokio monotonic deadline + 1Hz countdown that
fires core().pause() at expiry; presets + custom minutes via a popover.

Stop after this song: 4 QbzCore passthroughs + playback consume-before-advance
seam and the load-bearing gapless-prefetch gate, plus the queue marker/menu so
the Queue persists when playback halts.

qbz-log crate: TeeLogger wrapping env_logger (stderr + 5000-line ring +
~/.local/share/qbz/logs/qbz.log) with write-time secret redaction (regex +
live-secret registry) and a diagnostics bundle builder.

Dev panel logs: in-app viewer that shows content the moment it opens, advanced
controls behind a discreet [+], "Copy all" as the sole footer button, a copy
button on the upload URL, and a redacted public paste upload.

Diagnostics: qbz-app::diagnostics (extracted, src-tauri untouched) feeding a
7-section panel with the live active output device + sample rate/format (pactl)
and a complete redacted report for the upload.

Report an Issue: wires the header menu item to a 1:1 Tauri modal that opens the
GitHub bug-report template.

Appearance persistence: 6 toggles that were live-only now persist via ui_prefs
+ handler arm + startup seed (window-title-show, show-volume-steppers,
sidebar-playlist-collage, local-library-track-artwork, in-app-toasts,
theme-filter).

Recommendations cache (per-tab only): TTL select 24/36/48/72h + Refresh now in
ExternalRecoView; no change to the other Discover tabs.

Bump workspace version 0.1.0 -> 1.2.15 so app_version is correct in the
diagnostics report and the QConnect About string. i18n es/de/fr/pt for all new
strings.

cc
2026-06-29 13:19:06 -06:00

511 lines
22 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// In-app log viewer — the native replacement for the Tauri web console.
//
// Opened from Settings > Developer (or a hotkey). The Rust side owns a rolling
// ring of log records; it pushes an already-filtered + capped slice into
// LogViewerState.rows (with .total = ring size, .shown = after filter+cap) so
// this modal never holds the full history. All filtering/searching is delegated
// back to Rust via set-level / set-search — the level QbzSelect and the search
// field only emit; they never mutate the row model here.
//
// Layout mirrors QconnectDevModal: a dimmed full-window backdrop that closes on
// click, a centered card that swallows clicks, a header (title + shown/total +
// X), a controls row (level filter / search / refresh / auto-tail), a scrolling
// per-level-colored ListView body, and a footer button row (copy / bundle /
// upload / open file / clear). Mounted in AppShell in declaration order so its
// z-order is the mount order (ADR-009); conditional-mounted on .open (ADR-010).
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { LogViewerState, UiFocusState } from "../state.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { QbzSelect } from "../primitives/QbzSelect.slint";
import { QbzToggle } from "../primitives/QbzToggle.slint";
import { ListView } from "std-widgets.slint";
// Small bordered icon+label control used by the controls row (Refresh) and the
// whole footer (Copy / Bundle / Upload / Open file / Clear). Auto-sizes to its
// label; `danger` recolors it for the destructive Clear action.
component IconTextButton inherits Rectangle {
in property <string> label;
in property <image> icon;
in property <bool> has-icon: true;
in property <bool> danger: false;
in property <bool> enabled: true;
callback clicked();
height: 32px;
border-radius: Radius.sm;
border-width: 1px;
border-color: Theme.border-subtle;
background: ta.has-hover && root.enabled ? Theme.surface-hover : Theme.surface-elevated;
opacity: root.enabled ? 1.0 : 0.4;
HorizontalLayout {
alignment: center;
padding-left: 12px;
padding-right: 12px;
spacing: 7px;
if root.has-icon: VerticalLayout {
alignment: center;
QbzIcon {
source: root.icon;
width: 14px;
height: 14px;
tint: root.danger ? Theme.danger : Theme.text-secondary;
}
}
Text {
text: root.label;
color: root.danger ? Theme.danger : Theme.text-secondary;
font-size: 13px;
font-weight: Typography.medium;
vertical-alignment: center;
}
}
ta := TouchArea {
mouse-cursor: root.enabled ? pointer : default;
clicked => {
if (root.enabled) {
root.clicked();
}
}
}
}
export component LogViewerModal inherits Rectangle {
width: 100%;
height: 100%;
visible: LogViewerState.open;
// Advanced controls (level/search/refresh/auto-tail + bundle/upload/open/clear)
// hide behind a discreet [+] so the default view is just the log + Copy all.
private property <bool> advanced-open: false;
if LogViewerState.open: Rectangle {
background: #000000bf;
// Snapshot the ring the MOMENT the viewer opens, so it always shows the
// current logs immediately — not an empty pane until Refresh/auto-tail.
init => {
LogViewerState.refresh();
}
TouchArea {
mouse-cursor: default;
clicked => {
LogViewerState.open = false;
}
}
Rectangle {
width: Math.min(root.width - 80px, 760px);
height: Math.min(root.height - 80px, 640px);
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
border-radius: Radius.md;
background: Theme.surface-card;
border-width: 1px;
border-color: Theme.border-subtle;
drop-shadow-blur: 32px;
drop-shadow-color: #00000080;
// Swallow clicks so they don't reach the closing backdrop.
TouchArea { }
VerticalLayout {
padding: 20px;
spacing: 14px;
// ---- Header: title + shown/total count + close X.
HorizontalLayout {
spacing: 10px;
Text {
text: @tr("Logs");
color: Theme.text-primary;
font-size: Typography.heading;
font-weight: Typography.semibold;
vertical-alignment: center;
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
Text {
text: "\{LogViewerState.shown} / \{LogViewerState.total}";
color: Theme.text-muted;
font-size: Typography.legal;
vertical-alignment: center;
}
}
// Discreet [+] / [−] — reveals the advanced controls + actions.
adv-toggle := TouchArea {
width: 24px;
height: 24px;
mouse-cursor: pointer;
clicked => {
root.advanced-open = !root.advanced-open;
}
Text {
width: 100%;
height: 100%;
text: root.advanced-open ? "−" : "+";
color: adv-toggle.has-hover ? Theme.text-primary : Theme.text-muted;
font-size: 18px;
horizontal-alignment: center;
vertical-alignment: center;
}
}
close-x := TouchArea {
width: 28px;
height: 28px;
mouse-cursor: pointer;
clicked => {
LogViewerState.open = false;
}
QbzIcon {
source: @image-url("../assets/icons/x.svg");
width: 17px;
height: 17px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: close-x.has-hover ? Theme.text-primary : Theme.text-muted;
}
}
}
// ---- Controls (advanced, behind [+]): level / search / refresh / auto-tail.
if root.advanced-open: HorizontalLayout {
height: 34px;
spacing: 10px;
// Level filter — index<->token mapping kept here so Rust only
// ever receives the canonical "all|error|warn|info|debug|trace".
VerticalLayout {
alignment: center;
QbzSelect {
menu-width: 132px;
options: [
@tr("All levels"),
@tr("Error"),
@tr("Warn"),
@tr("Info"),
@tr("Debug"),
@tr("Trace"),
];
current-index: LogViewerState.filter-level == "error" ? 1
: LogViewerState.filter-level == "warn" ? 2
: LogViewerState.filter-level == "info" ? 3
: LogViewerState.filter-level == "debug" ? 4
: LogViewerState.filter-level == "trace" ? 5
: 0;
selected(i) => {
LogViewerState.set-level(
i == 1 ? "error"
: i == 2 ? "warn"
: i == 3 ? "info"
: i == 4 ? "debug"
: i == 5 ? "trace"
: "all");
}
}
}
// Search box — emits set-search on every edit; Rust filters.
search-box := Rectangle {
horizontal-stretch: 1;
height: 34px;
border-radius: Radius.sm;
border-width: 1px;
border-color: search-input.has-focus ? Theme.focus-ring : Theme.border-subtle;
background: Theme.surface-elevated;
HorizontalLayout {
padding-left: 11px;
padding-right: 11px;
spacing: 8px;
VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/search.svg");
width: 14px;
height: 14px;
tint: Theme.text-muted;
}
}
Rectangle {
horizontal-stretch: 1;
clip: true;
search-input := TextInput {
width: 100%;
height: 100%;
color: Theme.text-primary;
font-size: Typography.body;
vertical-alignment: center;
single-line: true;
text <=> LogViewerState.search;
changed has-focus => {
UiFocusState.text-input-focused = self.has-focus;
}
edited => {
LogViewerState.set-search(self.text);
}
}
Text {
visible: search-input.text == "";
width: 100%;
height: 100%;
text: @tr("Search logs…");
color: Theme.text-muted;
font-size: Typography.body;
vertical-alignment: center;
overflow: elide;
}
}
}
}
VerticalLayout {
alignment: center;
IconTextButton {
label: @tr("Refresh");
icon: @image-url("../assets/icons/refresh-cw.svg");
clicked => {
LogViewerState.refresh();
}
}
}
// Auto-tail toggle (label + switch).
VerticalLayout {
alignment: center;
HorizontalLayout {
spacing: 8px;
Text {
text: @tr("Auto-tail");
color: Theme.text-secondary;
font-size: 13px;
vertical-alignment: center;
}
VerticalLayout {
alignment: center;
QbzToggle {
checked: LogViewerState.auto-tail;
toggled(v) => {
LogViewerState.toggle-auto-tail(v);
}
}
}
}
}
}
// ---- Column header (compact, muted).
HorizontalLayout {
padding-left: 12px;
padding-right: 12px;
spacing: 10px;
Text {
text: @tr("Time");
width: 80px;
color: Theme.text-muted;
font-size: Typography.legal;
font-weight: Typography.semibold;
}
Text {
text: @tr("Level");
width: 48px;
color: Theme.text-muted;
font-size: Typography.legal;
font-weight: Typography.semibold;
}
Text {
text: @tr("Target");
width: 140px;
color: Theme.text-muted;
font-size: Typography.legal;
font-weight: Typography.semibold;
}
Text {
text: @tr("Message");
horizontal-stretch: 1;
color: Theme.text-muted;
font-size: Typography.legal;
font-weight: Typography.semibold;
}
}
// ---- Body: per-level-colored, scrolling log rows.
Rectangle {
vertical-stretch: 1;
background: Theme.surface-main;
border-radius: Radius.sm;
border-width: 1px;
border-color: Theme.border-subtle;
clip: true;
ListView {
width: 100%;
height: 100%;
for row in LogViewerState.rows: Rectangle {
// Delegate height tracks the wrapped message so long
// lines aren't clipped (parent reads child preferred
// height — the supported, non-looping direction).
height: line.preferred-height;
line := HorizontalLayout {
padding-left: 12px;
padding-right: 12px;
padding-top: 3px;
padding-bottom: 3px;
spacing: 10px;
Text {
text: row.ts;
width: 80px;
color: Theme.text-muted;
font-size: 11px;
overflow: elide;
}
Text {
text: row.level;
width: 48px;
font-size: 11px;
font-weight: Typography.semibold;
color: row.level == "ERROR" ? #f44336
: row.level == "WARN" ? #e0a030
: (row.level == "DEBUG" || row.level == "TRACE") ? Theme.text-muted
: Theme.text-secondary;
}
Text {
text: row.target;
width: 140px;
color: Theme.text-muted;
font-size: 11px;
overflow: elide;
}
Text {
text: row.message;
horizontal-stretch: 1;
color: Theme.text-primary;
font-size: 11px;
wrap: word-wrap;
}
}
}
}
// Empty-state placeholder.
if LogViewerState.rows.length == 0: Text {
text: @tr("No log entries.");
color: Theme.text-muted;
font-size: Typography.body;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
}
}
// ---- Uploaded URL (advanced) — shown after upload, with a copy button.
if root.advanced-open && LogViewerState.uploaded-url != "": Rectangle {
height: 32px;
border-radius: Radius.sm;
border-width: 1px;
border-color: Theme.border-subtle;
background: Theme.surface-elevated;
HorizontalLayout {
padding-left: 11px;
padding-right: 4px;
spacing: 8px;
VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/link.svg");
width: 14px;
height: 14px;
tint: Theme.accent;
}
}
Rectangle {
horizontal-stretch: 1;
clip: true;
url-input := TextInput {
width: 100%;
height: 100%;
read-only: true;
single-line: true;
color: Theme.text-secondary;
font-size: 12px;
vertical-alignment: center;
text: LogViewerState.uploaded-url;
}
}
VerticalLayout {
alignment: center;
url-copy := TouchArea {
width: 26px;
height: 26px;
mouse-cursor: pointer;
clicked => {
LogViewerState.copy-url();
}
QbzIcon {
source: @image-url("../assets/icons/copy.svg");
width: 14px;
height: 14px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: url-copy.has-hover ? Theme.text-primary : Theme.text-muted;
}
}
}
}
}
// ---- Advanced actions (behind [+]): bundle / upload / open file / clear.
if root.advanced-open: HorizontalLayout {
spacing: 10px;
IconTextButton {
label: @tr("Copy diagnostics bundle");
icon: @image-url("../assets/icons/copy.svg");
clicked => {
LogViewerState.copy-bundle();
}
}
IconTextButton {
label: LogViewerState.uploading ? @tr("Uploading…") : @tr("Upload (public)");
icon: @image-url("../assets/icons/cloud-upload.svg");
enabled: !LogViewerState.uploading;
clicked => {
LogViewerState.upload();
}
}
Rectangle { horizontal-stretch: 1; }
IconTextButton {
label: @tr("Open log file");
icon: @image-url("../assets/icons/external-link.svg");
clicked => {
LogViewerState.open-log-file();
}
}
IconTextButton {
label: @tr("Clear");
icon: @image-url("../assets/icons/trash-2.svg");
danger: true;
clicked => {
LogViewerState.clear();
}
}
}
// ---- Footer: Copy all — the only always-visible button.
HorizontalLayout {
spacing: 10px;
IconTextButton {
label: LogViewerState.copied ? @tr("Copied") : @tr("Copy all");
icon: LogViewerState.copied
? @image-url("../assets/icons/check.svg")
: @image-url("../assets/icons/copy.svg");
clicked => {
LogViewerState.copy-all();
}
}
Rectangle { horizontal-stretch: 1; }
}
}
}
}
}