diff --git a/e2e/terminal-ui.spec.ts b/e2e/terminal-ui.spec.ts index 88ca6488c..c52cdbd63 100644 --- a/e2e/terminal-ui.spec.ts +++ b/e2e/terminal-ui.spec.ts @@ -71,7 +71,15 @@ for (const { width, split } of [{ width: 220 }, { width: 280 }, { width: 520 }, const search = terminal.getByRole("search", { name: "Find in terminal" }); const input = search.getByRole("textbox", { name: "Find in terminal" }); await input.fill("alpha"); - await expect(search.locator("[aria-live=polite]")).toHaveText(/\d+\/3/); + const count = search.locator("[aria-live=polite]"); + await expect(count).toHaveText(/\d+\/3/); + await expect(count).toHaveCSS("font-size", "13px"); + const match = await count.textContent(); + // The incremental search can report after the first Enter; retry until Enter moves on. + await expect(async () => { + await input.press("Enter"); + await expect(count).not.toHaveText(match!, { timeout: 1000 }); + }).toPass(); if (process.env.OPENIDEA_TERMINAL_SHOTS) await terminal.screenshot({ path: `${process.env.OPENIDEA_TERMINAL_SHOTS}/terminal-${width}${split ? "-split" : ""}.png`, @@ -83,9 +91,19 @@ for (const { width, split } of [{ width: 220 }, { width: 280 }, { width: 520 }, expect(rect.x).toBeGreaterThanOrEqual(bounds.x); expect(rect.x + rect.width).toBeLessThanOrEqual(bounds.x + bounds.width + 1); } - expect((await input.boundingBox())!.width).toBeGreaterThan(40); - const matchCase = search.getByRole("button", { name: "Match Case", exact: true }); + const inputBox = (await input.boundingBox())!; + if (width <= 280 || split) { + expect(inputBox.width).toBeGreaterThan(bounds.width * 0.62); + expect((await matchCase.boundingBox())!.y).toBeGreaterThan(inputBox.y + inputBox.height); + } else { + expect(inputBox.width).toBeGreaterThan(80); + } + const countBox = (await count.boundingBox())!; + const previousBox = (await search.getByRole("button", { name: "Previous Occurrence", exact: true }).boundingBox())!; + expect(previousBox.x - countBox.x - countBox.width).toBeLessThanOrEqual(4); + expect(countBox.y + countBox.height / 2).toBeCloseTo(previousBox.y + previousBox.height / 2, 0); + await matchCase.focus(); await page.keyboard.press("Enter"); await expect(matchCase).toHaveAttribute("aria-pressed", "true"); @@ -130,7 +148,7 @@ test("wide terminal search leaves the grid in place and avoids covering the acti const top = (await search.boundingBox())!; expect(top.y).toBeCloseTo(before.y, 0); expect(top.x + top.width).toBeCloseTo(before.x + before.width, 0); - expect(top.width).toBeLessThan(before.width); + expect(top.width).toBeLessThan(420); await input.fill("right-edge"); await expect(search.locator("[aria-live=polite]")).toHaveText("1/1"); diff --git a/src/features/terminal/FindBar.tsx b/src/features/terminal/FindBar.tsx index 50155ba18..27769f017 100644 --- a/src/features/terminal/FindBar.tsx +++ b/src/features/terminal/FindBar.tsx @@ -166,53 +166,64 @@ export function TerminalFindBar({ sessionKey }: { sessionKey: string | null }) { placeholder="Find in terminal" aria-label="Find in terminal" invalid={none} - toggles={[ - { - id: "case", - icon: "case", - title: "Match Case", - shortcut: formatBinding("Alt+C"), - pressed: options.caseSensitive, - onToggle: () => toggle("caseSensitive"), - }, - { - id: "word", - icon: "word", - title: "Words", - shortcut: formatBinding("Alt+W"), - pressed: options.wholeWord, - onToggle: () => toggle("wholeWord"), - }, - { - id: "regex", - icon: "regex", - title: "Regex", - shortcut: formatBinding("Alt+X"), - pressed: options.regex, - onToggle: () => toggle("regex"), - }, - ]} /> - - {counter} - - find("previous")} - /> - find("next")} - /> - +
+
+ toggle("caseSensitive")} + /> + toggle("wholeWord")} + /> + toggle("regex")} + /> +
+
+ + {counter} + + find("previous")} + /> + find("next")} + /> +
+ +
); } diff --git a/src/features/terminal/Terminal.module.css b/src/features/terminal/Terminal.module.css index 2ebba0e29..808036f7d 100644 --- a/src/features/terminal/Terminal.module.css +++ b/src/features/terminal/Terminal.module.css @@ -163,21 +163,33 @@ display: flex; align-items: center; gap: var(--space-1); - padding: 4px 8px; + padding: var(--space-1) var(--space-2); background: var(--bg-elev); border-bottom: 1px solid var(--border); + font-size: var(--fs-ui); } .findField { - flex: 1; - min-width: 160px; + width: calc(14ch + 2 * var(--h-control-small) + var(--space-4)); + min-width: 0; +} +.findControls, +.findOptions, +.findActions { + display: flex; + align-items: center; + gap: var(--space-0-5); +} +.findControls { + gap: var(--space-1); } .findCount { - font-size: var(--fs-small); + font-size: var(--fs-ui); font-variant-numeric: tabular-nums; color: var(--fg-subtle); - padding: 0 6px; + min-inline-size: 7ch; + padding-inline: var(--space-1); + text-align: center; white-space: nowrap; - min-width: 56px; } .findCountNone { color: var(--danger); @@ -188,7 +200,8 @@ top: 0; right: 0; z-index: 6; - width: 500px; + width: max-content; + max-width: 100%; border-left: 1px solid var(--border); } .find[data-match-covered] { @@ -201,11 +214,16 @@ @container terminal-output (max-width: 360px) { .find { - display: grid; - grid-template-columns: minmax(0, 1fr) repeat(3, var(--h-control-small)); + flex-direction: column; + align-items: stretch; } .findField { - grid-column: 1 / -1; - min-width: 0; + width: 100%; + } + .findControls { + flex-wrap: wrap; + } + .findClose { + margin-inline-start: auto; } }