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 21, 19:45 UTC
fix(web): terminal Ctrl+Shift+C copies on non-Latin keyboard layouts (#35210)
Julius Marminge committed
Nov 12, 2026 at 04:03 UTC
64959eb9690aacd08e73848fcf9ad0357fca95e5
2 files changed
+27
-9
apps/web/src/terminal/ghostty/surface.test.ts
+17
@@ -286,6 +286,21 @@ describe("GhosttyTerminalSurface visibility", () => {
286
expect(surface.hasSelection()).toBe(false);
287
});
288
289
+ it("copies on Ctrl+Shift+C when a non-Latin layout reports another letter on KeyC", async () => {
290
+ vi.stubGlobal("navigator", { platform: "Linux x86_64" });
291
+ const harness = createHarness();
292
+ const surface = await harness.create({ beforeKey: () => true });
293
+ Object.assign(surface.input, { select() {} });
294
+ const execCommand = vi.fn(() => true);
295
+ Object.assign(document, { execCommand });
296
+ surface.write("SELECTED_OUTPUT");
297
+ surface.selectAll();
298
+ // Russian layout: Cyrillic Es (U+0421) on the physical C key.
299
+ key(surface, "С", "KeyC", { ctrlKey: true, shiftKey: true });
300
+ expect(execCommand).toHaveBeenCalledWith("copy");
301
+ expect(harness.onData).not.toHaveBeenCalled();
302
+ });
303
+
304
it("skips middle-click selection paste when the desktop turned primary paste off", async () => {
305
vi.stubGlobal("navigator", { platform: "Linux x86_64" });
306
const harness = createHarness();
@@ -918,6 +933,8 @@ describe("terminalLinkAtPositionWithRange", () => {
933
934
describe("isTerminalCopyShortcut", () => {
935
const event = (overrides: Partial<Parameters<typeof isTerminalCopyShortcut>[0]> = {}) => ({
936
+ altKey: false,
937
+ code: "KeyC",
938
ctrlKey: false,
939
key: "c",
940
metaKey: false,
apps/web/src/terminal/ghostty/surface.ts
+10
-9
@@ -1,3 +1,4 @@
1
+import { resolveEventKeys } from "@t3tools/shared/keybindingMatching";
2
import { isMacPlatform } from "../../lib/utils";
3
import { SELECTION_MULTI_CLICK_INTERVAL_MS } from "../../lib/selectionActions";
4
import { collectWrappedTerminalLinkLine, extractTerminalLinks } from "../../terminal-links";
@@ -313,14 +314,14 @@ export function terminalLinkAtPositionWithRange(
314
}
315
316
export function isTerminalCopyShortcut(
316
- event: Pick<KeyboardEvent, "ctrlKey" | "key" | "metaKey" | "shiftKey">,
317
+ event: Pick<KeyboardEvent, "altKey" | "code" | "ctrlKey" | "key" | "metaKey" | "shiftKey">,
318
platform = navigator.platform,
319
) {
319
- const key = event.key.toLowerCase();
320
- if (key === "insert" && !isMacPlatform(platform)) {
320
+ const keys = resolveEventKeys(event);
321
+ if (keys.has("insert") && !isMacPlatform(platform)) {
322
return event.ctrlKey && !event.shiftKey && !event.metaKey;
323
}
323
- if (key !== "c") return false;
324
+ if (!keys.has("c")) return false;
325
return isMacPlatform(platform) ? event.metaKey : event.ctrlKey;
326
}
327
@@ -355,14 +356,14 @@ export function applyTerminalCopyEvent(
356
}
357
358
function isTerminalPasteShortcut(
358
- event: Pick<KeyboardEvent, "ctrlKey" | "key" | "metaKey" | "shiftKey">,
359
+ event: Pick<KeyboardEvent, "altKey" | "code" | "ctrlKey" | "key" | "metaKey" | "shiftKey">,
360
platform = navigator.platform,
361
) {
361
- const key = event.key.toLowerCase();
362
- if (key === "insert" && !isMacPlatform(platform)) {
362
+ const keys = resolveEventKeys(event);
363
+ if (keys.has("insert") && !isMacPlatform(platform)) {
364
return event.shiftKey && !event.ctrlKey && !event.metaKey;
365
}
365
- if (key !== "v") return false;
366
+ if (!keys.has("v")) return false;
367
return isMacPlatform(platform) ? event.metaKey : event.ctrlKey && event.shiftKey;
368
}
369
@@ -1119,7 +1120,7 @@ export class GhosttyTerminalSurface {
1120
const mac = isMacPlatform(navigator.platform);
1121
const primaryModifier = mac ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey;
1122
const selectAllShortcut =
1122
- event.key.toLowerCase() === "a" &&
1123
+ resolveEventKeys(event).has("a") &&
1124
primaryModifier &&
1125
!event.altKey &&
1126
(mac ? !event.shiftKey : event.shiftKey);