Skip to content

feat(tui): runtime theme-toggle hotkey (theme iter 3) #175

@gerchowl

Description

@gerchowl

Motivation

#137 (theme iter 2) explicitly scopes detection to session start ("Detection runs once on startup, result is fixed for the session") and tells users to restart the TUI on mid-session terminal-theme change. That's a reasonable v1 contract — but a one-keystroke flip is a high-value polish for users on dual-mode terminals (macOS auto-dark, base16-shell switches, dual-monitor light/dark) without paying the OSC 11 re-detection cost #137 deferred.

This issue is the runtime override that #137 deferred.

Scope

P0:

  • Hotkey T (or Ctrl+T) toggles between dalton-dark and dalton-light for the running session
  • Toggle is purely in-memory — does not write back to config, does not re-run detection
  • Status bar toast on toggle: theme: dalton-light (mirrors the startup toast from feat(tui): light mode + auto-detect (theme iter 2) #137 P1)
  • Toggle works from any view (handler in the global keymap, not per-view)

P1:

  • Optional: :theme <name> command-mode entry (if/when command mode lands) for explicit set rather than toggle
  • VHS tape exercising the toggle (captures both halves of the flip in one snapshot pair)

Pitfalls

  • 🟡 Keybind collision: t and T are not currently used in the global keymap (verify against `crates/scitadel-tui/src/app.rs` at issue time). `e` is taken in PaperDetail for annotation-edit; `T` should be safe but check.
  • 🟡 Cycle vs. binary toggle: today only two themes exist (dark, light). If `scitadel-light` / `scitadel-dark` extras land later, `T` should cycle through registered themes, not stay binary. Implement as cycle from day one to avoid the rewrite.
  • 🟡 Toggle vs. detection precedence: a runtime toggle overrides whatever `auto` resolved to. Don't re-trigger detection on the next startup based on the toggle — `auto` should still mean "detect at startup". The toggle is session-only.
  • 🟢 Persisting the choice is out of scope here; if the user wants their pick remembered, that's `ui.theme = light` in config or `--theme light` on launch.

Acceptance

  • `T` (or chosen key) toggles theme without restart
  • Toast confirms the new theme
  • Restart with `auto` re-runs detection (toggle is not persisted)
  • Cycle order is deterministic when more than two themes are registered

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort:smallLess than 1 hourfeatureNew feature or requestpriority:lowNice to have, do when capacity allowssemver:minorNew feature, backward-compatible

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions