Skip to content

fix(tui): focus palette settings after layout - #39585

Merged
kitlangton merged 3 commits into
v2from
settings-search-v2
Jul 30, 2026
Merged

fix(tui): focus palette settings after layout#39585
kitlangton merged 3 commits into
v2from
settings-search-v2

Conversation

@kitlangton

@kitlangton kitlangton commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What

Make settings opened from command-palette search visible and active immediately, including off-screen results such as Sounds.

Before / After

Before: Type sounds in 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.tsx keeps selection updates synchronous and coalesces only the pending scroll onto CliRenderEvents.FRAME. It requests the layout frame, ignores stale selections, and removes the pending listener during cleanup.
  • packages/tui/test/cli/tui/command-palette.test.tsx first 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 typecheck
  • Repository pre-push typecheck: 33 packages passed
  • Full TUI suite: 562 passed, 5 skipped; one pre-existing timeout remains in restores queued compaction from durable pending input and reproduces unchanged on origin/v2

Demo

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

@kitlangton
kitlangton merged commit 8e3e94a into v2 Jul 30, 2026
9 checks passed
@kitlangton
kitlangton deleted the settings-search-v2 branch July 30, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant