Skip to content

qt themes: Qt offers only the schemes it can draw; one failing setting no longer stops a start - #2115

Open
trissim wants to merge 1 commit into
mainfrom
fork-qt-theme-terminal-palette
Open

trissim wants to merge 1 commit into
mainfrom
fork-qt-theme-terminal-palette

Conversation

@trissim

@trissim trissim commented Nov 18, 2026 •

Copy link
Copy Markdown

The phone app stopped at every launch with ui_theme.colour.TerminalPaletteRequired: Query the terminal palette before resolving its colours (the phone's logs/errors/android_startup_2026-11-18T03_32_47*.txt).

Cause. The saved setting was "theme": "ansi-dark". Startup runs every setting's effect (QtToadApp.__init__ → SavedSettings.apply_all), and the theme effect calls follow_theme → restyle → ColorScheme.from_theme. That resolves the scheme's colours, and ansi-dark and ansi-light are drawn in the terminal's own colours (ColourScheme.from_terminal), which need a palette from a terminal. A Qt app has no terminal to ask. Qt offered ui_theme's whole catalog, so it let the theme be chosen, and since settings persist across installs every start died.

Changes

  • Qt's offer (toad.qt.theme.offered_schemes) leaves out the from_terminal schemes, using the fact ui_theme already declares. Across the 21-scheme catalog, from_terminal marks exactly the two that fail to resolve without a terminal. A saved one, such as the TUI's choice in the shared toad.json, takes follow_theme's existing not-offered path: a warning, and the current scheme kept.
  • Qt's picker lists the same offer. SchemeChoosing.scheme_names is abstract on the shared parent and each frontend answers its own. Qt answers offered_schemes; the TUI answers its colours' schemes. Before this, Qt's picker listed the bare catalog: every terminal scheme, and not pywal's.
  • One failing setting no longer stops the app. apply_setting_effect shows and saves a failing effect through the app's error owner (show_error, which writes logs/errors, titled Setting <path>) and the other settings still apply. This covers startup and live changes.
  • Gate. tools/android/shipped_run.py starts the shipped app with ansi-dark saved, as the phone had it. The shipped scenario then applies every scheme Qt offers in turn through the same ui.theme effect. A scheme that fails to draw leaves an error file, which fails the run.
  • Tests. tests/model/test_theme_offer.py: Qt's offer excludes the terminal schemes, and every scheme it offers resolves. tests/textual/test_textual_theme_offer.py: the TUI's offer includes them.

Evidence (desktop, offscreen, the phone's settings: a scratch XDG_CONFIG_HOME with {"ui": {"theme": "ansi-dark"}})

tree result
main 3c96183 startup fails: TerminalPaletteRequired, the phone's trace
this branch window opens; notice Theme 'ansi-dark' is not available; no error file
main + only the apply_setting_effect change window opens; notice Setting ui.theme: Query the terminal palette… and its error file, so the other settings still applied
this branch, dracula saved window opens; no notice, no error file

Gates, run once on 1a13e18

  • Ratchet: Textual-UI modules 11/11, widgets imports 0, bare Qt classes 21/21, copies 0.
  • shadow_check: 0. glyph_check: 0.
  • tools/android/check.sh with PYTHONFAULTHANDLER=1: exit 0. The shipped app started with ansi-dark saved and applied all 20 schemes Qt offers (textual-dark … atom-one-light, wal) with no error file. It then ran every view kind and bound key on a scratch bus.
  • Tests: both new tests pass. tests/guards/test_test_layers.py fails only on test_worker_failed_toasts.py importing toad.widgets.comms_chat, which fails the same way on main.

For the phone. The next APK opens with ansi-dark saved and keeps the default scheme, with the warning. No settings need editing on the device.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3

…g no longer stops a start

A saved ui.theme of ansi-dark stopped the phone app at every launch: Qt offered ui_theme's
whole catalog, including the schemes drawn in the terminal's own colours
(ColourScheme.from_terminal), and resolving one asks a terminal for its palette, which a Qt app
does not have (TerminalPaletteRequired). Settings persist across installs, so every start died.

- toad.qt.theme.offered_schemes leaves out from_terminal schemes. A saved one takes
  follow_theme's not-offered path: a warning, and the current scheme kept.
- Qt's theme picker lists that same offer: SchemeChoosing.scheme_names is now each
  frontend's, abstract on the shared parent (the TUI's is its colours' schemes).
- apply_setting_effect reports one setting's failing effect through show_error (shown, and
  saved to logs/errors, titled by the setting) and the other settings still apply, at start
  (SavedSettings.apply_all) and on a live change.
- shipped_run starts the shipped app with ansi-dark saved, and its scenario applies every
  scheme Qt offers in turn. Tests: Qt's offer excludes the terminal schemes and every scheme
  it offers resolves; Textual's offer includes them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant