@devries-cameron20 / t3code-1 / commits / 40c0b0efe4
Fork 0

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

fix(web): warn when ctrl shortcuts collide with mod on Windows and Linux (#22496)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Victor Vogel committed Oct 30, 2026 at 15:41 UTC 40c0b0efe41ad3b3f6828e2b40e36a66191f86a4
2 files changed +52 -7
apps/web/src/components/settings/KeybindingsSettings.logic.test.ts
+34
@@ -266,4 +266,38 @@ describe("KeybindingsSettings.logic", () => {
266 }),
267 ).toEqual(["Chat: New Local"]);
268 });
269 +
270 + it.each([
271 + { platform: "Linux x86_64", ctrl: ["Chat: New"], meta: [] },
272 + { platform: "Win32", ctrl: ["Chat: New"], meta: [] },
273 + { platform: "MacIntel", ctrl: [], meta: ["Chat: New"] },
274 + ])("resolves mod to the $platform modifier when reporting conflicts", (expected) => {
275 + const rows = buildKeybindingRows(
276 + compileResolvedKeybindingsConfig([
277 + { command: "chat.new", key: "mod+k" },
278 + { command: "chat.newLocal", key: "ctrl+k" },
279 + { command: "thread.copyReference", key: "meta+k" },
280 + ]),
281 + expected.platform,
282 + );
283 + const conflictsFor = (key: string) => rows.find((row) => row.key === key)?.conflicts;
284 +
285 + expect(conflictsFor("ctrl+k")).toEqual(expected.ctrl);
286 + expect(conflictsFor("meta+k")).toEqual(expected.meta);
287 + expect(
288 + keybindingConflictLabels(rows, { rowId: "new", key: "ctrl+k", when: "" }, expected.platform),
289 + ).toEqual(["Chat: New Local", ...expected.ctrl].toSorted());
290 + });
291 +
292 + it("keeps mod and ctrl shortcuts apart when their when contexts differ", () => {
293 + const rows = buildKeybindingRows(
294 + compileResolvedKeybindingsConfig([
295 + { command: "chat.new", key: "mod+k", when: "!terminalFocus" },
296 + { command: "chat.newLocal", key: "ctrl+k", when: "terminalFocus" },
297 + ]),
298 + "Linux x86_64",
299 + );
300 +
301 + expect(rows.map((row) => row.conflicts)).toEqual([[], []]);
302 + });
303 });
apps/web/src/components/settings/KeybindingsSettings.logic.ts
+18 -7
@@ -8,11 +8,12 @@ import {
8 } from "@t3tools/contracts";
9 import {
10 DEFAULT_RESOLVED_KEYBINDINGS,
11 + parseKeybindingShortcut,
12 parseKeybindingWhenExpression,
13 US_SHIFTED_TO_UNSHIFTED_KEYS,
14 } from "@t3tools/shared/keybindings";
15
15 -import { shortcutKeyFromEvent } from "../../keybindings";
16 +import { shortcutConflictKey, shortcutKeyFromEvent } from "../../keybindings";
17 import { isMacPlatform } from "../../lib/utils";
18 import { METRIC_OPTIONS, WINDOW_OPTIONS } from "../usage/usageShortcuts";
19
@@ -180,13 +181,18 @@ function conflictsWithWhen(leftWhen: string, rightWhen: string): boolean {
181 export function keybindingConflictLabels(
182 rows: ReadonlyArray<KeybindingRow>,
183 input: { readonly rowId: string; readonly key: string; readonly when: string },
184 + platform = navigator.platform,
185 ): ReadonlyArray<string> {
186 if (input.key.trim().length === 0) return [];
187 + const shortcut = parseKeybindingShortcut(input.key);
188 + if (!shortcut) return [];
189 + // Compare resolved chords so mod+k and ctrl+k collide where mod is Ctrl.
190 + const conflictKey = shortcutConflictKey(shortcut, platform);
191 const conflicts: Array<string> = [];
192 for (const candidate of rows) {
193 if (
194 candidate.id !== input.rowId &&
189 - candidate.key === input.key &&
195 + shortcutConflictKey(candidate.binding.shortcut, platform) === conflictKey &&
196 conflictsWithWhen(candidate.when, input.when)
197 ) {
198 conflicts.push(commandLabel(candidate.command));
@@ -242,6 +248,7 @@ export function groupKeybindingRows(
248
249 export function buildKeybindingRows(
250 keybindings: ResolvedKeybindingsConfig,
251 + platform = navigator.platform,
252 ): ReadonlyArray<KeybindingRow> {
253 const rowsById = new Map<string, KeybindingRow>();
254 for (const binding of keybindings) {
@@ -264,11 +271,15 @@ export function buildKeybindingRows(
271 const rows = [...rowsById.values()];
272
273 const rowsWithConflicts = rows.map((row) => {
267 - const conflicts = keybindingConflictLabels(rows, {
268 - rowId: row.id,
269 - key: row.key,
270 - when: row.when,
271 - });
274 + const conflicts = keybindingConflictLabels(
275 + rows,
276 + {
277 + rowId: row.id,
278 + key: row.key,
279 + when: row.when,
280 + },
281 + platform,
282 + );
283 return conflicts.length > 0
284 ? Object.assign({}, row, { conflicts: [...new Set(conflicts)].toSorted() })
285 : row;