From 7594a98e8c4162af65af77fa7a4cfe3d63dce2aa Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Tue, 10 Nov 2026 23:41:29 +0800 Subject: [PATCH] fix(search): use 16px file icons and spinners in Find and Usages (#2493) Find results and Show Usages use the native 16px file/folder icons, and the four search indicators share the 16px eight-spoke animation, replacing 12/14px overrides; the preview and rerun controls get their proper icons. --- e2e/findUsages-ui.spec.ts | 163 ++++++++++++++++++ src/features/code-insight/UsagesPopup.tsx | 6 +- src/features/code-insight/UsagesView.tsx | 4 +- src/features/search/find/FindInFiles.tsx | 4 +- src/features/search/find/FindToolWindow.tsx | 6 +- src/ui/expui/general/previewHorizontally.svg | 6 + .../general/previewHorizontally_dark.svg | 6 + src/ui/icons.tsx | 1 + 8 files changed, 187 insertions(+), 9 deletions(-) create mode 100644 e2e/findUsages-ui.spec.ts create mode 100644 src/ui/expui/general/previewHorizontally.svg create mode 100644 src/ui/expui/general/previewHorizontally_dark.svg diff --git a/e2e/findUsages-ui.spec.ts b/e2e/findUsages-ui.spec.ts new file mode 100644 index 000000000..577542077 --- /dev/null +++ b/e2e/findUsages-ui.spec.ts @@ -0,0 +1,163 @@ +import type { Locator } from "@playwright/test"; +import { expect, stubDesktop, test } from "./fixtures"; + +async function checkSize(icon: Locator, size = 16) { + const dimensions = await icon.evaluate((node) => { + const style = getComputedStyle(node); + return [Number.parseFloat(style.width), Number.parseFloat(style.height)]; + }); + expect.soft(dimensions).toEqual([size, size]); +} + +for (const theme of ["light", "dark"] as const) { + for (const width of [160, 320]) { + test(`Find and Usages icons align in ${theme} at ${width}px`, async ({ workbench: page }) => { + await page.evaluate(async (theme) => { + const themePath = "/src/workbench/theme.ts"; + const findPath = "/src/features/search/find/windowStore.ts"; + const { previewTheme } = await import(themePath); + const { openInFindWindow, useFindViewOptions } = await import(findPath); + previewTheme(theme); + useFindViewOptions.setState({ groupByDirectory: true }); + let finish: (() => void) | undefined; + let request = 0; + openInFindWindow( + { pattern: "build", caseSensitive: false, wholeWord: false, isRegex: false, context: "any" }, + "build", + { + deps: { + validate: async () => {}, + nextRequestId: () => ++request, + cancel: () => finish?.(), + start: async (_id: number, _query: unknown, onFile: (file: object) => void) => { + onFile({ + path: "/dev/acme-api/build.gradle.kts", + relPath: "build.gradle.kts", + matches: [{ line: 0, text: "build", textOffset: 0, ranges: [[0, 5]] }], + }); + await new Promise((resolve) => (finish = resolve)); + return { files: 1, matches: 1, limitHit: false, cancelled: true, elapsedMs: 1 }; + }, + }, + }, + ); + }, theme); + + const find = page.getByRole("region", { name: "Find", exact: true }); + const tree = find.getByRole("tree", { name: "Find results" }); + await expect(tree.getByText("build.gradle.kts", { exact: true })).toBeVisible(); + const panel = tree.locator(".."); + const bounds = (await panel.boundingBox())!; + const handle = (await find.getByRole("separator").boundingBox())!; + const y = handle.y + handle.height / 2; + await page.mouse.move(handle.x + handle.width / 2, y); + await page.mouse.down(); + await page.mouse.move(bounds.x + width, y, { steps: 4 }); + await page.mouse.up(); + await expect.poll(async () => Math.abs((await panel.boundingBox())!.width - width)).toBeLessThan(2); + + const fileIcon = tree + .getByRole("treeitem") + .filter({ has: page.getByText("build.gradle.kts", { exact: true }) }) + .locator("svg") + .last(); + const directoryIcon = tree + .getByRole("treeitem") + .filter({ has: page.getByText("/", { exact: true }) }) + .locator("svg") + .last(); + await checkSize(fileIcon); + await checkSize(directoryIcon); + await checkSize(find.getByRole("status", { name: "Loading", exact: true })); + for (const title of ["Stop", "Expand All", "Collapse All", "Close Tab"]) + await checkSize(find.getByRole("button", { name: title, exact: true }).last().locator("svg")); + + await page.evaluate(async () => { + const path = "/src/ui/iconAppearance.ts"; + (await import(path)).setIconAppearance({ iconSize: 20, rowHeight: 28 }); + }); + await checkSize(fileIcon, 20); + await checkSize(directoryIcon, 20); + await checkSize(find.getByRole("status", { name: "Loading", exact: true })); + await find.getByRole("button", { name: "Stop", exact: true }).click(); + await expect(find.getByRole("status", { name: "Loading", exact: true })).toHaveCount(0); + await checkSize(find.getByRole("button", { name: "Rerun", exact: true }).locator("svg")); + await find.getByRole("button", { name: "Rerun", exact: true }).click(); + await expect(find.getByRole("status", { name: "Loading", exact: true })).toBeVisible(); + await find.getByRole("button", { name: "Stop", exact: true }).click(); + + await page.evaluate(async () => { + const path = "/src/features/code-insight/usages.ts"; + const { useUsagesPopup } = await import(path); + useUsagesPopup.setState({ + open: true, + anchor: { x: 100, y: 150 }, + symbol: "build", + loading: true, + groups: [ + { + path: "/dev/acme-api/build.gradle.kts", + usages: [{ path: "/dev/acme-api/build.gradle.kts", line: 0, col: 0, endCol: 5, text: "build" }], + }, + ], + }); + }); + const popup = page.getByRole("dialog", { name: "Usages", exact: true }); + await checkSize(popup.getByRole("option").locator("svg")); + await checkSize(popup.getByRole("status", { name: "Loading", exact: true })); + const preview = popup.getByRole("button", { name: "Show Preview", exact: true }); + await checkSize(preview.locator("svg")); + await preview.focus(); + await page.keyboard.press("Enter"); + await expect(popup.getByRole("region", { name: "Preview", exact: true })).toBeVisible(); + await preview.click(); + await expect(popup.getByRole("region", { name: "Preview", exact: true })).toHaveCount(0); + await popup.getByRole("button", { name: /Open in Find Window/ }).click(); + + const usages = page.getByRole("region", { name: "Find Usages", exact: true }); + const usageTree = usages.getByRole("tree", { name: "Usages", exact: true }); + await expect(usageTree.getByText("build.gradle.kts", { exact: true })).toBeVisible(); + const usageIcon = usageTree + .getByRole("treeitem") + .filter({ has: page.getByText("build.gradle.kts", { exact: true }) }) + .locator("svg") + .last(); + await checkSize(usageIcon, 20); + await page.evaluate(async () => { + const path = "/src/features/code-insight/usages.ts"; + const { useUsages } = await import(path); + useUsages.setState((s: { tabs: object[] }) => ({ tabs: s.tabs.map((t) => ({ ...t, loading: true })) })); + }); + await checkSize(usages.getByRole("status", { name: "Loading", exact: true })); + await page.evaluate(async () => { + const path = "/src/ui/iconAppearance.ts"; + (await import(path)).setIconAppearance(null); + }); + await checkSize(usageIcon); + }); + } + + test(`Find in Files keeps its loading icon at native size in ${theme}`, async ({ workbench: page }) => { + await stubDesktop(page); + await page.evaluate(async (theme) => { + const path = "/src/workbench/theme.ts"; + (await import(path)).previewTheme(theme); + window.__ipc.handlers.search_validate = () => null; + window.__ipc.handlers.search_start = () => null; + }, theme); + await page.keyboard.press("Meta+Shift+f"); + const popup = page.getByRole("dialog", { name: "Find in Files", exact: true }); + await popup.getByRole("textbox", { name: "Text to find" }).fill("build"); + const spinner = popup.getByRole("status", { name: "Loading", exact: true }); + await expect(spinner).toBeVisible(); + await checkSize(spinner); + const center = await spinner.evaluate((node) => { + const icon = node.getBoundingClientRect(); + const row = node.parentElement!.getBoundingClientRect(); + return Math.abs(icon.y + icon.height / 2 - (row.y + row.height / 2)); + }); + expect(center).toBeLessThan(1); + await page.keyboard.press("Escape"); + await expect(popup).toBeHidden(); + }); +} diff --git a/src/features/code-insight/UsagesPopup.tsx b/src/features/code-insight/UsagesPopup.tsx index cac51f3b6..3657b0217 100644 --- a/src/features/code-insight/UsagesPopup.tsx +++ b/src/features/code-insight/UsagesPopup.tsx @@ -169,7 +169,7 @@ function UsagesPopupInner() { )} {loading && ( - + )} {filter && ( @@ -178,7 +178,7 @@ function UsagesPopupInner() { )} (
- + diff --git a/src/features/code-insight/UsagesView.tsx b/src/features/code-insight/UsagesView.tsx index 033f48dca..e509ec0f3 100644 --- a/src/features/code-insight/UsagesView.tsx +++ b/src/features/code-insight/UsagesView.tsx @@ -259,7 +259,7 @@ export function UsagesView() {
{search.loading ? ( <> - {" "} + {" "} {search.symbol ? formatMessage(tx("Searching for usages of '{symbol}'"), { symbol: search.symbol }) : tx("Searching for usages")} diff --git a/src/features/search/find/FindInFiles.tsx b/src/features/search/find/FindInFiles.tsx index 572dae762..be76fae4b 100644 --- a/src/features/search/find/FindInFiles.tsx +++ b/src/features/search/find/FindInFiles.tsx @@ -621,7 +621,9 @@ function FindInFilesDialog() {
{s.replace ? tx("Replace in Files") : tx("Find in Files")} - {stale || state.status === "searching" || state.status === "validating" ? : null} + {stale || state.status === "searching" || state.status === "validating" ? ( + + ) : null} {summary} diff --git a/src/features/search/find/FindToolWindow.tsx b/src/features/search/find/FindToolWindow.tsx index cfd11a405..6b83cab93 100644 --- a/src/features/search/find/FindToolWindow.tsx +++ b/src/features/search/find/FindToolWindow.tsx @@ -370,7 +370,7 @@ function FindTabView({ tab }: { tab: FindTab }) { return (
- {(st.status === "searching" || busy) && } + {(st.status === "searching" || busy) && } {tab.title} {st.status === "invalid" || st.status === "error" @@ -524,7 +524,7 @@ function FindNodeContent({ node, state, tab }: { node: Node; state: TreeRowState case "dir": return ( - + {node.label} {node.count} {node.count === 1 ? "match" : "matches"} @@ -534,7 +534,7 @@ function FindNodeContent({ node, state, tab }: { node: Node; state: TreeRowState case "file": return ( - + {node.name} {node.count} {!state.depth && node.dir && {node.dir}} diff --git a/src/ui/expui/general/previewHorizontally.svg b/src/ui/expui/general/previewHorizontally.svg new file mode 100644 index 000000000..b7e88de78 --- /dev/null +++ b/src/ui/expui/general/previewHorizontally.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/ui/expui/general/previewHorizontally_dark.svg b/src/ui/expui/general/previewHorizontally_dark.svg new file mode 100644 index 000000000..45ae289a1 --- /dev/null +++ b/src/ui/expui/general/previewHorizontally_dark.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/ui/icons.tsx b/src/ui/icons.tsx index c12d29d09..6ecf9f618 100644 --- a/src/ui/icons.tsx +++ b/src/ui/icons.tsx @@ -259,6 +259,7 @@ const ICONS = { "split-horizontal": "general/splitHorizontally", "editor-only": "general/editorOnly", "editor-preview": "general/editorPreview", + "preview-details": "general/previewHorizontally", "preview-only": "general/previewOnly", maximize: "image/fitContent", "zoom-in": "openidea/general/zoomIn",