@devries-cameron20 / t3code-1 / commits / 645df4541b
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): keep add-project inputs open during IME composition (#24016)

Co-authored-by: GPT-6.1 Sol <noreply@openai.com> Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>

Victor Vogel committed Oct 30, 2026 at 16:01 UTC 645df4541bd4e0ba9e93b471aa0582b71115a6c6
2 files changed +136
apps/web/src/components/CommandPalette.composition.browser.test.tsx new
+130
@@ -0,0 +1,130 @@
1 +import { describe, expect, it, vi } from "vite-plus/test";
2 +import { page, userEvent } from "vite-plus/test/browser";
3 +import { DEFAULT_RESOLVED_KEYBINDINGS } from "@t3tools/shared/keybindings";
4 +import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings";
5 +import { act, render } from "../../test/render";
6 +import { CommandPalette } from "./CommandPalette";
7 +import { openCommandPalette } from "../commandPaletteBus";
8 +import { primaryServerKeybindingsAtom } from "../state/server";
9 +
10 +vi.mock("@effect/atom-react", async (original) => ({
11 + ...(await original<typeof import("@effect/atom-react")>()),
12 + useAtomValue: (atom: unknown) =>
13 + atom === primaryServerKeybindingsAtom ? DEFAULT_RESOLVED_KEYBINDINGS : [],
14 +}));
15 +vi.mock("../hooks/useTheme", () => ({
16 + useRenderedAppearance: () => "light",
17 + useTheme: () => ({ theme: "t3-chat", resolvedTheme: "light", appearanceMode: "light" }),
18 +}));
19 +vi.mock("../hooks/useCustomThemes", () => ({ useCustomThemes: () => [] }));
20 +vi.mock("../hooks/useEnvironmentTheme", () => ({ useEnvironmentThemeDefinitions: () => [] }));
21 +vi.mock("../hooks/useSettings", async (original) => ({
22 + ...(await original<typeof import("../hooks/useSettings")>()),
23 + useClientSettings: () => DEFAULT_CLIENT_SETTINGS,
24 +}));
25 +vi.mock("../hooks/useScratchProject", () => ({
26 + useScratchProject: () => ({ scratchEnvironmentId: () => null }),
27 +}));
28 +vi.mock("../hooks/useNewProject", () => ({ useNewProject: () => async () => undefined }));
29 +vi.mock("../hooks/useHandleNewThread", () => ({
30 + useHandleNewThread: () => ({
31 + activeDraftThread: null,
32 + activeThread: null,
33 + defaultProjectRef: null,
34 + handleNewThread: async () => undefined,
35 + }),
36 + useNewThreadHandler: () => async () => undefined,
37 +}));
38 +vi.mock("../hooks/useOpenPanelPullRequestUrl", () => ({ useOpenPanelPullRequestUrl: () => null }));
39 +vi.mock("../connection/useDesktopLocalBootstraps", () => ({ useDesktopLocalBootstraps: () => [] }));
40 +vi.mock("../state/use-atom-command", () => ({
41 + useAtomCommand: () => async () => ({ _tag: "Success", value: undefined }),
42 +}));
43 +vi.mock("../state/use-atom-query-runner", () => ({
44 + useAtomQueryRunner: () => async () => ({ _tag: "Success", value: undefined }),
45 +}));
46 +vi.mock("../state/environments", async (original) => ({
47 + ...(await original<typeof import("../state/environments")>()),
48 + useEnvironments: () => ({
49 + environments: [
50 + {
51 + environmentId: "local",
52 + label: "Local",
53 + connection: { phase: "connected" },
54 + entry: { target: { _tag: "PrimaryConnectionTarget" } },
55 + serverConfig: {
56 + environment: { platform: { os: "linux" }, capabilities: { projectCloneTracking: true } },
57 + settings: { addProjectBaseDirectory: "/workspace/" },
58 + },
59 + },
60 + ],
61 + }),
62 + usePrimaryEnvironmentId: () => "local",
63 + useEnvironmentProviders: () => new Map(),
64 +}));
65 +vi.mock("../state/entities", async (original) => ({
66 + ...(await original<typeof import("../state/entities")>()),
67 + useProjects: () => [],
68 + useThreadShells: () => [],
69 + useServerConfigs: () => new Map(),
70 + waitForProject: async () => undefined,
71 +}));
72 +vi.mock("../state/queries", async (original) => ({
73 + ...(await original<typeof import("../state/queries")>()),
74 + useThreadSearch: (_environmentIds: unknown, query: string) => ({
75 + matches: [],
76 + query,
77 + isPending: false,
78 + }),
79 +}));
80 +vi.mock("../state/session", async (original) => ({
81 + ...(await original<typeof import("../state/session")>()),
82 + useEnvironmentScope: () => true,
83 + readEnvironmentScope: () => true,
84 +}));
85 +vi.mock("../state/filesystem", async (original) => ({
86 + ...(await original<typeof import("../state/filesystem")>()),
87 + useFilesystemReadAccess: () => ({ canReadFiles: true, isPending: false, error: null }),
88 +}));
89 +vi.mock("../state/query", async (original) => ({
90 + ...(await original<typeof import("../state/query")>()),
91 + useEnvironmentQuery: () => ({ data: undefined, isLoading: false }),
92 +}));
93 +vi.mock("./settings/useAvailableSettingsSearchItems", () => ({
94 + useAvailableSettingsSearchItems: () => [],
95 +}));
96 +
97 +// The real palette and Base UI input must agree that confirming composition is typing.
98 +describe.each(["repository", "folder", "destination"] as const)("add-project %s", (step) => {
99 + it.each([
100 + { isComposing: true, keyCode: 13 },
101 + { isComposing: false, keyCode: 229 },
102 + ])("keeps Enter in the input during composition: %j", async (composition) => {
103 + await using _screen = await render(<CommandPalette>{null}</CommandPalette>);
104 + await act(() => openCommandPalette({ open: "add-project" }));
105 + await page.getByText(step === "folder" ? "Local folder" : "Git URL", { exact: true }).click();
106 + const input = () => page.getByRole("combobox");
107 + if (step === "destination") {
108 + await input().fill("https://example.com/team/project.git");
109 + await userEvent.keyboard("{Enter}");
110 + }
111 + const value = step === "repository" ? "https://example.com/team/計画.git" : "/workspace/計画";
112 + await input().fill(value);
113 + const event = new KeyboardEvent("keydown", {
114 + key: "Enter",
115 + bubbles: true,
116 + cancelable: true,
117 + ...composition,
118 + });
119 + await act(() => input().element().dispatchEvent(event));
120 + expect(event.defaultPrevented).toBe(false);
121 + await expect.element(input()).toHaveValue(value);
122 + if (step === "repository") {
123 + await userEvent.keyboard("{Enter}");
124 + await expect.element(input()).toHaveValue("/workspace/計画");
125 + } else {
126 + await userEvent.keyboard("{Enter}");
127 + await expect.element(page.getByRole("combobox")).not.toBeInTheDocument();
128 + }
129 + });
130 +});
apps/web/src/components/CommandPalette.tsx
+6
@@ -2287,6 +2287,12 @@ function OpenCommandPaletteDialog(props: {
2287 }
2288
2289 function handleKeyDown(event: KeyboardEvent<HTMLInputElement>): void {
2290 + if (event.key === "Enter" && (event.nativeEvent.isComposing || event.keyCode === 229)) {
2291 + // Confirming an IME candidate must not submit a path or select a row.
2292 + (event as typeof event & { preventBaseUIHandler?: () => void }).preventBaseUIHandler?.();
2293 + return;
2294 + }
2295 +
2296 const command = resolveShortcutCommand(event, keybindings, {
2297 platform: navigator.platform,
2298 context: { modelPickerOpen: false, editableFocus: true },