Skip to content

WS-1 foundation: gpui-kit boot, window, Root, and the light/dark/system theme #307

Description

@LeadcodeDev

Part of #306. Batch 1 — every other workstream depends on this one.

Replace the Dioxus desktop shell with a gpui-kit application: boot, window,
Root wrapper, and the theme system including the System mode the kit does
not provide.

Owned files

  • src/app/root.rs (rewrite), src/app/window.rs (new)
  • src/theme/mod.rs (new), src/theme/persist.rs (new)
  • Deletes: src/components/** (13 dirs, 1 636 .rs + 2 440 .css),
    assets/dx-components-theme.css

Do NOT write: Cargo.toml, src/lib.rs, any mod.rs, src/app/state.rs
(orchestrator-owned — report the lines you need instead).

Deliverables

  1. Boot — gpui_kit::application().run(...) + gpui_kit::init(cx).
    There is no Application::new(). Window sized to 75% of the current
    monitor, centered, as today.
  2. Root — mandatory top-level wrapper. Root::render does not mount
    the dialog/sheet/notification layers; the root view must call
    Root::render_dialog_layer, render_sheet_layer,
    render_notification_layer itself.
    Isolate these three calls in one small file — 0.7.0 removes them with no
    documented replacement, and we want that migration to be a localised patch.
  3. Theme — ThemePref { Light, Dark, System }. The kit's ThemeMode has
    only Light | Dark and theme::init hard-sets Light; nothing observes
    the OS. Wire it:
    Theme::sync_system_appearance(Some(window), cx);
    window.observe_window_appearance(|w, cx| Theme::sync_system_appearance(Some(w), cx)).detach();
    After mutating Theme::global_mut, call Theme::sync_base(cx) — otherwise
    the gpui-base layer (scrollbars, resize handles) keeps the old values.
  4. Persistence — the preference is stored next to the recents, i.e.
    dirs::config_dir()/rustmotion/. Today the theme resets to System at
    every launch; it must survive a restart. Follow the shape of
    load_recents/push_recent in src/library/data.rs:233-266.
  5. Deletion — the whole src/components/ tree. gpui-kit is used directly,
    with no wrapper layer. All 6 live components have a kit equivalent.

Notes that will save you time

  • ActiveTheme must be imported from gpui_component, it is not re-exported
    at the kit root. Then cx.theme().background etc.
  • The token is danger, not destructive, on ThemeColor.
  • Map today's --rm-* tokens (defined in src/app/root.rs:28-79) onto the
    kit's semantic tokens. Note the current doc comment at line 25 contradicts
    the CSS
    : .rm-system is in the dark rule and swaps to light under
    prefers-color-scheme: light. The CSS is the behaviour to reproduce.
  • Two IconName enums exist. gpui_component::IconName (101 variants) is what
    gpui_kit_assets::Assets actually embeds; using a gpui_kit_assets::IconName
    variant (1830 Lucide) while registering only Assets silently fails to load.

Verify

CARGO_TARGET_DIR=/tmp/rm-ws1 rtk cargo build -p rustmotion-studio
CARGO_TARGET_DIR=/tmp/rm-ws1 rtk cargo test -p rustmotion-studio
CARGO_TARGET_DIR=/tmp/rm-ws1 rtk cargo clippy -p rustmotion-studio --all-targets -- -D warnings

Activity

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions