From 7db4d9969aaa88448471eb5321775846bfc7e8f0 Mon Sep 17 00:00:00 2001 From: spoukyii <61633921+spoukyii@users.noreply.github.com> Date: Tue, 3 Nov 2026 14:29:35 -0800 Subject: [PATCH 1/2] test(web): project content search during IME composition Types into the project content search with three results, then sends the keys an IME sends while the user browses and confirms a candidate: ArrowDown and Enter, flagged either by isComposing or by keyCode 229. None of them should open a file, close the dialog or move the highlighted result, so the next real Enter opens the first one. On main the composing Enters each open a file and close the dialog, and the composing ArrowDowns move the highlight off the first result, so this fails. --- ...tSearchDialog.composition.browser.test.tsx | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 apps/web/src/components/search/ProjectContentSearchDialog.composition.browser.test.tsx diff --git a/apps/web/src/components/search/ProjectContentSearchDialog.composition.browser.test.tsx b/apps/web/src/components/search/ProjectContentSearchDialog.composition.browser.test.tsx new file mode 100644 index 0000000000000..ced1ea47c6fdb --- /dev/null +++ b/apps/web/src/components/search/ProjectContentSearchDialog.composition.browser.test.tsx @@ -0,0 +1,74 @@ +import { EnvironmentId, ThreadId } from "@t3tools/contracts"; +import { expect, it, vi } from "vite-plus/test"; +import { page, userEvent } from "vite-plus/test/browser"; + +import { act, render } from "../../../test/render"; +import { useRightPanelStore } from "../../rightPanelStore"; +import { ProjectContentSearchDialog } from "./ProjectContentSearchDialog"; + +const threadRef = { + environmentId: EnvironmentId.make("local"), + threadId: ThreadId.make("thread"), +}; + +const { search } = vi.hoisted(() => ({ + search: { + canReadFiles: true, + isCheckingAccess: false, + hasQuery: true, + isPending: false, + error: null, + invalidRegex: false, + truncated: false, + matches: [ + { path: "a.ts", lineNumber: 1, lineContent: "計画", matchRanges: [] }, + { path: "b.ts", lineNumber: 2, lineContent: "計画", matchRanges: [] }, + { path: "c.ts", lineNumber: 3, lineContent: "計画", matchRanges: [] }, + ], + }, +})); + +vi.mock("~/hooks/useActiveProjectTarget", () => ({ + useActiveProjectTarget: () => ({ + environmentId: threadRef.environmentId, + cwd: "/workspace", + projectName: "workspace", + threadRef, + }), +})); +vi.mock("~/hooks/useTheme", () => ({ + useRenderedAppearance: () => "light", + useTheme: () => ({ theme: "t3-chat", resolvedTheme: "light", appearanceMode: "light" }), +})); +vi.mock("~/state/session", async (original) => ({ + ...(await original()), + readEnvironmentScope: () => true, +})); +vi.mock("~/state/queries", async (original) => ({ + ...(await original()), + useProjectContentSearch: () => search, +})); + +it("ignores composing keys in the search", async () => { + using openFile = vi.spyOn(useRightPanelStore.getState(), "openFile").mockImplementation(() => {}); + const onOpenChange = vi.fn(); + await using _screen = await render(); + const input = page.getByRole("combobox"); + await input.fill("計画"); + + for (const composition of [ + { key: "ArrowDown", isComposing: true, keyCode: 40 }, + { key: "ArrowDown", isComposing: false, keyCode: 229 }, + { key: "Enter", isComposing: true, keyCode: 13 }, + { key: "Enter", isComposing: false, keyCode: 229 }, + ]) { + const event = new KeyboardEvent("keydown", { ...composition, bubbles: true, cancelable: true }); + await act(() => input.element().dispatchEvent(event)); + } + expect(onOpenChange).not.toHaveBeenCalled(); + expect(openFile).not.toHaveBeenCalled(); + + await userEvent.keyboard("{Enter}"); + expect(onOpenChange).toHaveBeenCalledExactlyOnceWith(false); + expect(openFile).toHaveBeenCalledExactlyOnceWith(threadRef, "a.ts", 1); +}); From fda3065781e20a57d4e4d5a4d0688268df740229 Mon Sep 17 00:00:00 2001 From: spoukyii <61633921+spoukyii@users.noreply.github.com> Date: Tue, 3 Nov 2026 14:29:36 -0800 Subject: [PATCH 2/2] fix(web): project content search no longer opens a result on an IME Enter The search input's key handler acted on Enter and the arrow keys without checking for IME composition. Typing Japanese or Chinese and pressing Enter to confirm a candidate opened the highlighted file and closed the dialog, and the arrow keys that browse candidates moved the highlighted result. The handler now returns early while composing, the guard #10262 gave the settings inputs and #28298 gave the settings search. The thread find bar and the command palette already had it. Bug: project content search opens a file and closes when Enter confirms an IME candidate --- apps/web/src/components/search/ProjectContentSearchDialog.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/web/src/components/search/ProjectContentSearchDialog.tsx b/apps/web/src/components/search/ProjectContentSearchDialog.tsx index fd6d26017d0a8..6406af73e8115 100644 --- a/apps/web/src/components/search/ProjectContentSearchDialog.tsx +++ b/apps/web/src/components/search/ProjectContentSearchDialog.tsx @@ -199,6 +199,7 @@ function OpenContentSearchDialog(props: { disabled: !search.canReadFiles, placeholder: `Search in ${target.projectName}`, onKeyDown: (event) => { + if (event.nativeEvent.isComposing || event.keyCode === 229) return; if (event.key === "ArrowDown" && matches.length > 0) { event.preventDefault(); setSelectedIndex((current) => (current + 1) % matches.length);