From 08d719e03d3339d017e494651738f498fceddfea Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Sun, 22 Nov 2026 21:07:00 +0800 Subject: [PATCH] fix(search): keep action names and shortcuts readable (#5203) Search Everywhere reserves room for action names alongside shortcuts and categories. Shortcut text is smaller and semibold. Very long key sequences and categories can shorten with an ellipsis, and hovering shows their full text. --- e2e/searchEverywhereLayout.spec.ts | 54 +++++++++++++++++++ .../everywhere/SearchEverywhere.module.css | 9 ++++ .../search/everywhere/SearchEverywhere.tsx | 13 ++++- 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/e2e/searchEverywhereLayout.spec.ts b/e2e/searchEverywhereLayout.spec.ts index 3f33ae714..abc760a18 100644 --- a/e2e/searchEverywhereLayout.spec.ts +++ b/e2e/searchEverywhereLayout.spec.ts @@ -1,6 +1,60 @@ import { doubleShift, expect, stubDesktop, test } from "./fixtures"; import type { Page } from "@playwright/test"; +test("action names stay readable beside shortcuts and categories", async ({ workbench: page }) => { + const titles = ["Reconcile warehouse totals", "Reconcile settlement exports"]; + const shortcuts = await page.evaluate(async (titles) => { + const actionsModule = "/src/platform/actions.ts"; + const keymapModule = "/src/platform/keymap.ts"; + const { registerActions, executeAction } = await import(/* @vite-ignore */ actionsModule); + const platformModule = "/src/platform/platformInfo.ts"; + const { registerExtensionBindings, shortcutLabel } = await import(/* @vite-ignore */ keymapModule); + const { usePlatform } = await import(/* @vite-ignore */ platformModule); + usePlatform.setState({ os: "windows" }); + const ids = ["review.reconcileWarehouse", "review.reconcileSettlement"]; + const bindings = ["Ctrl+K Ctrl+R", "Ctrl+Alt+Shift+PageDown Ctrl+Alt+Shift+PageUp"]; + registerActions( + titles.map((title, index) => ({ + id: ids[index]!, + title, + category: "Warehouse reconciliation and settlement reports", + icon: "check", + run: () => document.body.setAttribute("data-review-action", title), + })), + ); + ids.forEach((id, index) => registerExtensionBindings(id, [bindings[index]!])); + await executeAction("navigate.findAction"); + return ids.map((id) => shortcutLabel(id) as string); + }, titles); + const dialog = page.locator('[role="dialog"]:has(#se-query)'); + await dialog.getByRole("combobox", { name: "Search query" }).fill("Reconcile"); + + for (const width of [400, 1120]) { + await page.setViewportSize({ width, height: 630 }); + for (const [index, title] of titles.entries()) { + const row = dialog.getByRole("option").filter({ hasText: title }); + const keys = row.getByText(shortcuts[index]!, { exact: true }); + await expect(keys).toBeAttached(); + const geometry = await keys.evaluate((el) => { + const name = el.previousElementSibling!.getBoundingClientRect(); + const main = el.parentElement!.getBoundingClientRect(); + const key = el.getBoundingClientRect(); + return { name: name.width, inside: key.left >= name.right && key.right <= main.right + 1 }; + }); + expect(geometry.name).toBeGreaterThanOrEqual(80); + expect(geometry.inside).toBe(true); + await expect(keys).toHaveCSS("font-size", "12px"); + await expect(keys).toHaveCSS("font-weight", "600"); + await expect(keys).toHaveAttribute("title", shortcuts[index]!); + if (index === 0) expect(await keys.evaluate((el) => el.scrollWidth <= el.clientWidth)).toBe(true); + } + } + + await dialog.getByRole("option").filter({ hasText: titles[1]! }).click(); + await expect(dialog).toBeHidden(); + await expect(page.locator("body")).toHaveAttribute("data-review-action", titles[1]!); +}); + async function searchFiles(page: Page) { await stubDesktop(page); await page.evaluate(() => { diff --git a/src/features/search/everywhere/SearchEverywhere.module.css b/src/features/search/everywhere/SearchEverywhere.module.css index dcb48684e..ede8a364e 100644 --- a/src/features/search/everywhere/SearchEverywhere.module.css +++ b/src/features/search/everywhere/SearchEverywhere.module.css @@ -227,8 +227,14 @@ } .shortcut { flex: none; + max-width: 55%; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; color: var(--fg-subtle); font-family: var(--font-keys); + font-size: var(--fs-small); + font-weight: 600; } .right { flex: none; @@ -249,6 +255,9 @@ align-items: center; gap: var(--space-1-5); } +.actionRow > .right { + max-width: 30%; +} .disabled .name, .disabled .location, .disabled .shortcut, diff --git a/src/features/search/everywhere/SearchEverywhere.tsx b/src/features/search/everywhere/SearchEverywhere.tsx index 6e8cb987e..64142066f 100644 --- a/src/features/search/everywhere/SearchEverywhere.tsx +++ b/src/features/search/everywhere/SearchEverywhere.tsx @@ -872,11 +872,16 @@ function ResultRow({ {row.icon ? : null} - {shortcut && {shortcut}} + {shortcut && ( + + {shortcut} + + )} {toggled !== undefined ? ( ) : ( - row.category && {row.category} + row.category && ( + + {row.category} + + ) )} );