@@ -12,6 +12,8 @@ import { |
12 | 12 | type DialogSelectProps, |
13 | 13 | } from "../../../src/ui/dialog-select" |
14 | 14 | import { truncateFilePath } from "../../../src/ui/file-path" |
| 15 | +import { getOpenCodeTheme } from "../../../src/theme" |
| 16 | +import { resolveThemeDocument } from "@opencode/theme/tui" |
15 | 17 | import { stringWidth } from "../../../src/util/string-width" |
16 | 18 | import { emptyThemeSource, tmpdir } from "../../fixture/fixture" |
17 | 19 | import { TestTuiContexts } from "../../fixture/tui-environment" |
@@ -23,10 +25,11 @@ async function renderSelect( |
23 | 25 | onGlobal: () => void, |
24 | 26 | onRow: (option: DialogSelectOption<string>) => void, |
25 | 27 | current?: string, |
| 28 | + settings: Parameters<typeof createTuiResolvedConfig>[0] = {}, |
26 | 29 | ) { |
27 | 30 | const state = path.join(root, "state") |
28 | 31 | await mkdir(state, { recursive: true }) |
29 | | - const config = createTuiResolvedConfig() |
| 32 | + const config = createTuiResolvedConfig(settings) |
30 | 33 | const [{ ConfigProvider }, { ThemeProvider }, { Keymap }, { DialogProvider }, { DialogSelect }, { ToastProvider }] = |
31 | 34 | await Promise.all([ |
32 | 35 | import("../../../src/config"), |
@@ -375,6 +378,30 @@ test("dialog actions run without options while row actions still require a selec |
375 | 378 | } |
376 | 379 | }) |
377 | 380 |
|
| 381 | +test("matches the search cursor to the highlighted row until text is typed under new designs", async () => { |
| 382 | + await using tmp = await tmpdir() |
| 383 | + const theme = resolveThemeDocument(getOpenCodeTheme(), "dark") |
| 384 | + const app = await renderSelect( |
| 385 | + tmp.path, |
| 386 | + [{ title: "First", value: "first" }], |
| 387 | + () => {}, |
| 388 | + () => {}, |
| 389 | + undefined, |
| 390 | + { experimental: { "new-designs": true } }, |
| 391 | + ) |
| 392 | + |
| 393 | + try { |
| 394 | + await app.waitFor(() => app.renderer.getCursorState().visible) |
| 395 | + expect(app.renderer.getCursorState().color.toInts()).toEqual(theme.background.action.primary.focused.toInts()) |
| 396 | + |
| 397 | + await app.mockInput.typeText("f") |
| 398 | + await app.waitFor(() => app.renderer.getCursorState().color.equals(theme.text.base)) |
| 399 | + expect(app.renderer.getCursorState().color.toInts()).toEqual(theme.text.base.toInts()) |
| 400 | + } finally { |
| 401 | + app.renderer.destroy() |
| 402 | + } |
| 403 | +}) |
| 404 | + |
378 | 405 | test("renders one gap before an empty state", async () => { |
379 | 406 | await using tmp = await tmpdir() |
380 | 407 | const app = await renderSelect( |
@@ -638,7 +665,9 @@ test("dialog rows do not add renderer resize listeners", async () => { |
638 | 665 | const before = count() |
639 | 666 | // Mounting 30 rows must not add one resize listener per row (Node warns |
640 | 667 | // past 10 listeners on one emitter). |
641 | | - select.replaceOptions(Array.from({ length: 30 }, (_, index) => ({ title: `Item ${index}`, value: `item-${index}` }))) |
| 668 | + select.replaceOptions( |
| 669 | + Array.from({ length: 30 }, (_, index) => ({ title: `Item ${index}`, value: `item-${index}` })), |
| 670 | + ) |
642 | 671 | await select.app.waitForVisualIdle() |
643 | 672 | expect(count()).toBe(before) |
644 | 673 | } finally { |
|