fix(tui): focus palette settings after layout - #39585
Merged
Merged
Conversation
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.
What
Make settings opened from command-palette search visible and active immediately, including off-screen results such as Sounds.
Before / After
Before: Type
soundsin the command palette and press Enter immediately. The Settings dialog selects Sounds internally, but its scrollbox remains at Appearance because the scroll runs before OpenTUI has completed layout.After: Selection updates synchronously, so immediate input targets Sounds. The layout-dependent scroll runs after OpenTUI completes the frame, centering Sounds in the viewport.
How
packages/tui/src/ui/dialog-select.tsxkeeps selection updates synchronous and coalesces only the pending scroll ontoCliRenderEvents.FRAME. It requests the layout frame, ignores stale selections, and removes the pending listener during cleanup.packages/tui/test/cli/tui/command-palette.test.tsxfirst moves away from index zero, then searches for the off-screen Sounds setting and submits immediately. This covers both synchronous selection reset and post-layout scrolling.Scope
This only changes selection-visibility scheduling in
DialogSelect. Filtering, selection reconciliation, and setting mutation behavior are unchanged.Testing
cd packages/tui && bun run test test/cli/tui/dialog-select.test.tsx test/cli/tui/command-palette.test.tsx test/ui/select-controller.test.ts(11 passed)cd packages/tui && bun typecheckrestores queued compaction from durable pending inputand reproduces unchanged onorigin/v2Demo
This six-second crop uses the OpenTUI regression harness to preserve the immediate type-and-submit timing. The first half shows the baseline dialog at Appearance; the second shows the fixed dialog centered on Sounds.
opencode-sounds-clean-before-after.mp4