The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 23:15 UTC
fix(web): avoid submitting PR titles during IME composition (#18087)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Amine Ilidrissi committed
Oct 20, 2026 at 13:22 UTC
50c5437add0c15b8068ef757716f2a0fb5ec9ffb
2 files changed
+38
-5
apps/web/src/components/pullRequest/PullRequestDetailPanel.browser.test.tsx
+37
-5
@@ -18,16 +18,16 @@ import { DraftId, useComposerDraftStore } from "~/composerDraftStore";
18
19
import "~/index.css";
20
21
-const { newThread, prepareThread, refresh, addToast, updateToast, checkoutState } = vi.hoisted(
22
- () => ({
21
+const { newThread, prepareThread, refresh, update, addToast, updateToast, checkoutState } =
22
+ vi.hoisted(() => ({
23
newThread: vi.fn(),
24
prepareThread: vi.fn(),
25
refresh: vi.fn(),
26
+ update: vi.fn(),
27
addToast: vi.fn(),
28
updateToast: vi.fn(),
29
checkoutState: { error: null as Error | null },
29
- }),
30
-);
30
+ }));
31
32
vi.mock(import("~/state/session"), async (original) => ({
33
...(await original()),
@@ -52,7 +52,7 @@ vi.mock(import("~/lib/sourceControlActions"), async (original) => ({
52
}));
53
vi.mock(import("~/state/use-atom-command"), async (original) => ({
54
...(await original()),
55
- useAtomCommand: (() => vi.fn()) as never,
55
+ useAtomCommand: ((command: unknown) => (command === "update" ? update : vi.fn())) as never,
56
}));
57
vi.mock(import("~/state/pullRequests"), async (original) => {
58
const actual = await original();
@@ -64,6 +64,7 @@ vi.mock(import("~/state/pullRequests"), async (original) => {
64
...actual.pullRequestEnvironment,
65
detail: (() => "detail") as never,
66
activity: (() => "activity") as never,
67
+ update: "update" as never,
68
reviewGuide: (() => "review-guide") as never,
69
generateReviewGuide: {
70
...actual.pullRequestEnvironment.generateReviewGuide,
@@ -267,6 +268,7 @@ beforeEach(() => {
268
_tag: "Success",
269
value: { branch: "feature", worktreePath: "/workspace/pr" },
270
});
271
+ update.mockReset().mockResolvedValue({ _tag: "Success", value: undefined });
272
});
273
afterEach(async () => {
274
for (const root of roots.splice(0)) await act(async () => root.unmount());
@@ -298,6 +300,36 @@ const unrelatedThread = {
300
301
const tab = (name: string) => page.getByRole("button", { name, exact: true });
302
303
+it.each([
304
+ { isComposing: true, keyCode: 13 },
305
+ { isComposing: false, keyCode: 229 },
306
+])("does not save the PR title during IME composition (%j)", async ({ isComposing, keyCode }) => {
307
+ await render();
308
+ await page.getByRole("button", { name: "Edit title" }).click();
309
+ const titleInput = page.getByRole("textbox", { name: "Pull request title" });
310
+ const title = "日本語のタイトル";
311
+ await titleInput.fill(title);
312
+ const pressEnter = (init: KeyboardEventInit) =>
313
+ act(async () => {
314
+ titleInput
315
+ .element()
316
+ .dispatchEvent(
317
+ new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true, ...init }),
318
+ );
319
+ });
320
+
321
+ await pressEnter({ isComposing, keyCode });
322
+ expect(update).not.toHaveBeenCalled();
323
+ await expect.element(titleInput).toHaveValue(title);
324
+
325
+ await pressEnter({ keyCode: 13 });
326
+ expect(update).toHaveBeenCalledExactlyOnceWith({
327
+ environmentId: threadRef.environmentId,
328
+ input: { ...surface, title },
329
+ });
330
+ await expect.element(titleInput).not.toBeInTheDocument();
331
+});
332
+
333
async function runAction(action: string) {
334
if (action === "Add to agent") {
335
await tab("Code").click();
apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
+1
@@ -2480,6 +2480,7 @@ export function PullRequestDetailPanel({
2480
setTitleScope({ pullRequestKey, text: event.target.value })
2481
}
2482
onKeyDown={(event) => {
2483
+ if (event.nativeEvent.isComposing || event.keyCode === 229) return;
2484
if (event.key === "Enter") {
2485
event.preventDefault();
2486
void saveTitle(titleDraft);