Repository navigation
Web & UI: resolve system theme preference and default web to system theme - #382
GhostMitra wants to merge 1 commit into
Conversation
…t as PDF default (storytold#382) * Linux: accept file:// URI args so desktop launchers recognise pdfcraft as PDF default GNOME Files (and other freedesktop-spec launchers) only register an app as the default handler for a mimetype if its .desktop Exec accepts URIs (%u/%U), not just paths (%F). pdfcraft's entry used %F, so even after `xdg-mime default ai.storyteller.pdfcraft.desktop application/pdf`, double-clicking a PDF in Files silently fell back to another installed viewer. Switch Exec to %u and decode file:// args back to plain paths in main.rs before they reach the rest of the app, which only ever opens paths. Other schemes and plain CLI paths pass through unchanged. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * path_from_arg: file://localhost, foreign hosts left alone, Windows drive paths, no indexing; Exec %U (several files) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Dmitriy Bunakalya <dmitriy.bunakalya@appfollow.io> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
b0deeab to
5c33cf7
Compare
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the head of the diff: the web build resolves the system theme preference and defaults to it (app.ui.system_theme = true), the UI state gains a system_theme flag that defaults to false for the desktop, and the author is added to contributors/people.toml. It is the web counterpart of deckcraft#187 (follow the system appearance by default on the desktop), and the two add overlapping state (system_theme here, last_system_theme and Brightness::System there), so they should be merged into one mechanism before either lands. A stored user choice of Light or Dark must beat the default on the web too. I have not run it, and no exact-head CI result exists for this head. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
aiongg
left a comment
There was a problem hiding this comment.
AI-generated review (Opus). Not a maintainer decision.
Changes needed:
On the web, the interface now follows the browser's light/dark preference, and view.dark accepts on: "system". Manual Light/Dark choices go through view.dark and turn following off, which is correct. Some parts are unused or incomplete.
- crates/ui-egui/src/theme.rs:116
resolve_themeis never called. Remove it or use it in place of the inline check at crates/ui-egui/src/lib.rs:1536. - crates/ui-egui/src/widgets.rs:486
raster_to_alpha_maskis unused and is about icon tinting, not theme following. It belongs in a separate change together with code that uses it. - crates/ui-egui/src/dialogs.rs:144-158: the Preferences snapshot records only a dark boolean. Cancelling after toggling the checkbox runs
view.darkwith a bool, which clearssystem_theme, so the dialog does not restore system-following mode. - No control offers a System choice. The Account appearance combo (crates/ui-egui/src/backstage.rs:1342) and the Preferences checkbox (crates/ui-egui/src/dialogs.rs:2142) offer only Light/Dark, so after a manual choice the only way back to following the system is scripting.
- crates/ui-egui/src/lib.rs:381: the
view.darksignature still reads{on?: bool}and should mention "system". - The new
system_themeflag overlaps another proposed design that adds a System brightness value. One mechanism shared by desktop and web would avoid two kinds of state for the same setting. - crates/ui-egui/src/lib.rs:277: the new
system_themefield has no doc comment, unlike its neighbours.
Claims checked:
- contradicted: Resolves egui::ThemePreference::System against the context's raw.system_theme (crates/ui-egui/src/theme.rs:116 defines resolve_theme, but nothing calls it; the actual resolution is inline at crates/ui-egui/src/lib.rs:1535-1541 using a bool flag, not ThemePreference)
- contradicted: Adds raster_to_alpha_mask for theme-adaptive monochrome preview icons in widgets.rs (crates/ui-egui/src/widgets.rs:486 defines the function, but no code uses it, so no icon becomes theme-adaptive)
- verified: Web startup defaults to following the system theme (apps/deckcraft-web/src/web.rs:41 sets app.ui.system_theme = true; crates/ui-egui/src/lib.rs:1535-1541 maps raw.system_theme to brightness each frame and restyles on change)
- verified: view.dark supports on: "system" (crates/ui-egui/src/lib.rs:944-950 sets system_theme on "system" and clears it on an explicit or toggled value; the signature at crates/ui-egui/src/lib.rs:381 still reads {on?: bool})
Recommendation: update the pull request; it will be reviewed again.
Reviewed at 5c33cf7.
Summary
egui::ThemePreference::Systemagainst the host context'sctx.input(|i| i.raw.system_theme).raster_to_alpha_maskwith unit tests for theme-adaptive monochrome preview icons inwidgets.rs.apps/deckcraft-web/src/web.rs) to default tosystem_theme = true.view.darkcommand to supporton: "system".@GhostMitraincontributors/people.toml.Verification
cargo fmt --checkpassed.cargo clippy -p deckcraft-ui-egui -- -D warningspassed.cargo test -p deckcraft-ui-egui -- widgetspassed.