Repository navigation
fix(tui): apply theme only on confirm in theme list - #62498
Open
ColonelToad wants to merge 1 commit into
Open
ColonelToad wants to merge 1 commit into
ColonelToad wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
This works as described. I drove /themes in the TUI from source on both branches: on the base, pressing the down arrow applies each highlighted theme to the whole UI right away; with this PR only the highlight moves and the palette stays the same until you press Enter. The new test fails on the base and passes here. In the TUI package, tsc shows the same errors on the base and on this PR, none of them in the changed files. The public API is unchanged.
The change is sound. DialogSelect already starts the highlight on current and handles filtering by itself, and both callers keep working (app.tsx, and Settings through onClose). No concerns.
Related: #61598
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Issue for this PR
Closes #56147
Type of change
What does this PR do?
The theme dialog called
themes.set()fromonMoveandonFilter, and restored the original theme fromonCleanupwhen the dialog closed without confirmation. Browsing the list therefore applied the theme on every arrow key and every filter keystroke, so the whole TUI changed appearance while the user was only looking. The reporter's thread describes the same behavior and asks for the model, agent and variant dialog behavior instead: highlight while navigating, apply on confirmation.This drops the live preview.
DialogSelectalready tracks its own highlighted row and acceptscurrent, so the dialog now starts on the active theme, moves the highlight without callingthemes.set(), and applies the theme only inonSelect. Esc closes without writing; Enter applies the highlighted theme. TheonCleanuprestore is removed because there is no longer a live change to roll back.The dialog keeps
onClose, so the settings entry point still returns to the settings list instead of closing every dialog.What this does not change
DialogSelect, the theme provider and palette handling, and the external-config hot reload in #37423. It also does not add an optional preview switch: the preview is removed rather than made configurable, which is what the reporter asked for and what the maintainer restated in the thread.How did you verify your code works?
New
packages/tui/test/component/dialog-theme-list.test.tsxrenders the dialog and asserts four things: arrow-down leavesthemes.selectedunchanged, typing a filter leaves it unchanged, Esc closes the dialog and leaves it unchanged, and moving to another row then pressing Enter applies that theme.On
dev's component the test fails at the first assertion: the selected theme changes fromopencodetoorngas soon as the arrow key is pressed. With this branch's component the same test passes.On Debian 13/WSL2 with Bun 1.4.4:
cd packages/tui && bun test test/component/dialog-theme-list.test.tsx→ 1 pass, 0 fail (4 expects)bun run check→ 32/32 tasks successfulLimitations
The test drives the dialog through the TUI test renderer and the fixture theme source, not a real terminal session, so it checks the dialog's state calls rather than the rendered palette. The settings entry point that passes
onCloseis not exercised by the test; it uses the sameonSelectpath.Visual
AI assistance
I used AI assistance to investigate this issue and draft the change. I reviewed the diff, ran the test and checks above, and am accountable for the code in this PR.
Checklist
Added by the opencode bot (AI-generated).
Related: #61598