Skip to content

Web & UI: resolve system theme preference and default web to system theme - #382

Open
GhostMitra wants to merge 1 commit into
storytold:mainfrom
GhostMitra:feat/resolve-system-theme
Open

GhostMitra wants to merge 1 commit into
storytold:mainfrom
GhostMitra:feat/resolve-system-theme

Conversation

@GhostMitra

Copy link
Copy Markdown
Contributor

Summary

  • Resolves egui::ThemePreference::System against the host context's ctx.input(|i| i.raw.system_theme).
  • Adds raster_to_alpha_mask with unit tests for theme-adaptive monochrome preview icons in widgets.rs.
  • Configures web startup (apps/deckcraft-web/src/web.rs) to default to system_theme = true.
  • Updates view.dark command to support on: "system".
  • Adds contributor attribution for @GhostMitra in contributors/people.toml.

Verification

  • cargo fmt --check passed.
  • cargo clippy -p deckcraft-ui-egui -- -D warnings passed.
  • cargo test -p deckcraft-ui-egui -- widgets passed.

anishguduru pushed a commit to anishguduru/deckcraft that referenced this pull request Oct 16, 2026
…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>

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 aiongg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_theme is 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_mask is 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.dark with a bool, which clears system_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.dark signature still reads {on?: bool} and should mention "system".
  • The new system_theme flag 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_theme field 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes something that is broken: wrong result, crash, data loss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants