From 7b1e54a74f6201e725a50cba5d7fb383aa64e407 Mon Sep 17 00:00:00 2001 From: usrnk1 <7547651+usrnk1@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:21:02 +0100 Subject: [PATCH] feat(app): align search and command palettes (#59604) --- .../e2e/regression/command-palette.spec.ts | 65 +++++++-- packages/app/src/new-session/view.tsx | 2 +- packages/app/src/shell/commands/dialog.css | 125 ++++++++++++++++++ packages/app/src/shell/commands/dialog.tsx | 19 ++- 4 files changed, 192 insertions(+), 19 deletions(-) diff --git a/packages/app/e2e/regression/command-palette.spec.ts b/packages/app/e2e/regression/command-palette.spec.ts index 68533559af9..bfadd05f571 100644 --- a/packages/app/e2e/regression/command-palette.spec.ts +++ b/packages/app/e2e/regression/command-palette.spec.ts @@ -619,18 +619,61 @@ test("keeps matching session and file results steady across keystrokes while sea }) }) -test("keeps the same height as the number of results changes", async ({ page }) => { - const { dialog, input } = await openCommandPalette(page) +test("titlebar session search shrinks with results while its field stays anchored through scrolling", async ({ + page, +}) => { + await openPaletteWorkspace(page, true, [ + { ...paletteSession, time: { ...paletteSession.time } }, + ...Array.from({ length: 23 }, (_, index) => ({ + ...paletteSession, + id: `ses_compact_palette_${index}`, + title: index === 0 ? "Compact keeper needle" : `Compact keeper result ${index}`, + time: { created: 1700000000000 - index - 1, updated: 1700000000000 - index - 1 }, + })), + ]) + await page.getByRole("banner").getByRole("button", { name: "Search sessions", exact: true }).click() + const dialog = page.getByRole("dialog") + const input = dialog.getByRole("combobox") + const options = dialog.getByRole("option") const container = page.locator('[data-component="dialog-v2"] [data-slot="dialog-container"]') - const height = async () => (await container.boundingBox())?.height - const initial = await height() - expect(initial).toBe(480) - await input.fill("copy session") - await expect(dialog.getByRole("option")).toHaveCount(1) - expect(await height()).toBe(initial) + const geometry = () => + container.evaluate((element) => ({ + height: element.getBoundingClientRect().height, + inputTop: element.querySelector('[role="combobox"]')!.getBoundingClientRect().top, + })) - await input.fill("zzzz no palette match") - await expect(dialog.getByText("No results found")).toBeVisible() - expect(await height()).toBe(initial) + await expect(input).toBeFocused() + await expect(options).toHaveCount(10) + // Hover waits for the field's opening animation to settle before taking the reference position. + await input.hover() + const initial = await geometry() + expect(initial.height).toBeGreaterThan(200) + + await input.fill("Compact keeper needle") + await expect(options).toHaveText([/Compact keeper needle/]) + await expect.poll(async () => (await geometry()).height).toBeLessThan(initial.height - 100) + await expect.poll(async () => (await geometry()).inputTop).toBeCloseTo(initial.inputTop, 0) + + await input.clear() + await expect(options).toHaveCount(10) + await expect.poll(geometry).toEqual({ + height: expect.closeTo(initial.height, 0), + inputTop: expect.closeTo(initial.inputTop, 0), + }) + + // A broader query exposes more than the recent-session limit and must scroll below the field. + await input.fill("Compact keeper") + await expect(options).toHaveCount(23) + const scroll = dialog.locator('[data-slot="search-list-scroll"]') + await expect.poll(() => scroll.evaluate((element) => element.scrollHeight - element.clientHeight)).toBeGreaterThan(0) + await expect.poll(async () => (await geometry()).height).toBeLessThanOrEqual(480) + const last = dialog.getByRole("option", { name: /Compact keeper result 22/ }) + await expect(last).not.toBeInViewport() + await scroll.hover() + await page.mouse.wheel(0, 2000) + await expect(last).toBeInViewport() + await expect.poll(() => scroll.evaluate((element) => element.scrollTop)).toBeGreaterThan(0) + await expect.poll(async () => (await geometry()).inputTop).toBeCloseTo(initial.inputTop, 0) + await expect(input).toBeFocused() }) diff --git a/packages/app/src/new-session/view.tsx b/packages/app/src/new-session/view.tsx index c2ad7b2f8bf..bfdd3b04000 100644 --- a/packages/app/src/new-session/view.tsx +++ b/packages/app/src/new-session/view.tsx @@ -365,7 +365,7 @@ function NewSessionLocation(props: { {(directory) => (