diff --git a/packages/tui/src/ui/dialog-select.tsx b/packages/tui/src/ui/dialog-select.tsx index c10e44ad2f..dd83396c66 100644 --- a/packages/tui/src/ui/dialog-select.tsx +++ b/packages/tui/src/ui/dialog-select.tsx @@ -290,16 +290,18 @@ export function DialogSelect(props: DialogSelectProps) { createEffect( on([() => store.filter, () => props.current], ([filter, current]) => { if (filter.length > 0) resetSelection = true - setTimeout(() => { - if (filter.length > 0) { - moveTo(0, true, false) - } else if (current && props.focusCurrent !== false) { - const currentIndex = flat().findIndex((opt) => isDeepEqual(opt.value, current)) - if (currentIndex >= 0) { - moveTo(currentIndex, true) + requestAnimationFrame(() => { + requestAnimationFrame(() => { + if (filter.length > 0) { + moveTo(0, true, false) + return } - } - }, 0) + if (current && props.focusCurrent !== false) { + const currentIndex = flat().findIndex((opt) => isDeepEqual(opt.value, current)) + if (currentIndex >= 0) moveTo(currentIndex, true) + } + }) + }) }), ) diff --git a/packages/tui/test/cli/tui/command-palette.test.tsx b/packages/tui/test/cli/tui/command-palette.test.tsx index b4f93e02af..a431a7a335 100644 --- a/packages/tui/test/cli/tui/command-palette.test.tsx +++ b/packages/tui/test/cli/tui/command-palette.test.tsx @@ -73,16 +73,11 @@ test("searches settings globally and opens the matching setting", async () => { expect(app.captureCharFrame()).not.toContain("Animations") await app.waitFor(() => app.renderer.currentFocusedEditor instanceof InputRenderable) - for (const key of "side") app.mockInput.pressKey(key) - await app.waitForFrame((frame) => frame.includes("Sidebar")) - expect(app.captureCharFrame()).not.toContain("New session") - expect(app.captureCharFrame()).not.toContain("Switch model") - expect(app.captureCharFrame()).not.toContain("Markdown") - + for (const key of "sounds") app.mockInput.pressKey(key) app.mockInput.pressEnter() - await app.waitForFrame((frame) => frame.includes("Settings") && frame.includes("Color mode")) + await app.waitForFrame((frame) => frame.includes("Settings") && frame.includes("Sounds")) app.mockInput.pressEnter() - await app.waitFor(() => current.session?.sidebar === "hide") + await app.waitFor(() => current.attention?.sound === false) } finally { app.renderer.destroy() }