@devries-cameron20 / t3code Mirror · read-only / commits / 009c13fade
Fork 0

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 24, 09:00 UTC

refactor(web): test live keybinding resolvers directly (#10069)

Julius Marminge committed Sep 5, 2026 at 01:54 UTC 009c13fade9dde2fe7eed068c72c579172f12e60
2 files changed +33 -48
apps/web/src/keybindings.test.ts
+33 -24
@@ -8,8 +8,6 @@ import {
8 } from "@t3tools/contracts";
9 import {
10 formatShortcutLabel,
11 - isChatNewShortcut,
12 - isChatNewLocalShortcut,
11 isDiffToggleShortcut,
12 modelPickerJumpCommandForIndex,
13 modelPickerJumpIndexFromCommand,
@@ -22,7 +20,7 @@ import {
20 isTerminalToggleShortcut,
21 resolveShortcutCommand,
22 shouldShowModelPickerJumpHints,
25 - shouldShowThreadJumpHints,
23 + shouldShowThreadJumpHintsForModifiers,
24 shortcutLabelForCommand,
25 terminalDeleteShortcutData,
26 terminalNavigationShortcutData,
@@ -498,17 +496,21 @@ describe("thread navigation helpers", () => {
496
497 it("shows jump hints only when configured modifiers match", () => {
498 assert.isTrue(
501 - shouldShowThreadJumpHints(event({ metaKey: true }), DEFAULT_BINDINGS, {
499 + shouldShowThreadJumpHintsForModifiers(event({ metaKey: true }), DEFAULT_BINDINGS, {
500 platform: "MacIntel",
501 }),
502 );
503 assert.isFalse(
506 - shouldShowThreadJumpHints(event({ metaKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
507 - platform: "MacIntel",
508 - }),
504 + shouldShowThreadJumpHintsForModifiers(
505 + event({ metaKey: true, shiftKey: true }),
506 + DEFAULT_BINDINGS,
507 + {
508 + platform: "MacIntel",
509 + },
510 + ),
511 );
512 assert.isTrue(
511 - shouldShowThreadJumpHints(event({ ctrlKey: true }), DEFAULT_BINDINGS, {
513 + shouldShowThreadJumpHintsForModifiers(event({ ctrlKey: true }), DEFAULT_BINDINGS, {
514 platform: "Linux",
515 }),
516 );
@@ -516,13 +518,13 @@ describe("thread navigation helpers", () => {
518
519 it("never shows jump hints while the terminal is focused, even with an unrestricted binding", () => {
520 assert.isFalse(
519 - shouldShowThreadJumpHints(event({ metaKey: true }), DEFAULT_BINDINGS, {
521 + shouldShowThreadJumpHintsForModifiers(event({ metaKey: true }), DEFAULT_BINDINGS, {
522 platform: "MacIntel",
523 context: { terminalFocus: true },
524 }),
525 );
526 assert.isTrue(
525 - shouldShowThreadJumpHints(event({ metaKey: true }), DEFAULT_BINDINGS, {
527 + shouldShowThreadJumpHintsForModifiers(event({ metaKey: true }), DEFAULT_BINDINGS, {
528 platform: "MacIntel",
529 context: { terminalFocus: false },
530 }),
@@ -558,28 +560,32 @@ describe("model picker navigation helpers", () => {
560
561 describe("chat/editor shortcuts", () => {
562 it("matches chat.new shortcut", () => {
561 - assert.isTrue(
562 - isChatNewShortcut(event({ key: "o", metaKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
563 + assert.strictEqual(
564 + resolveShortcutCommand(event({ key: "o", metaKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
565 platform: "MacIntel",
566 }),
567 + "chat.new",
568 );
566 - assert.isTrue(
567 - isChatNewShortcut(event({ key: "o", ctrlKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
569 + assert.strictEqual(
570 + resolveShortcutCommand(event({ key: "o", ctrlKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
571 platform: "Linux",
572 }),
573 + "chat.new",
574 );
575 });
576
577 it("matches chat.newLocal shortcut", () => {
574 - assert.isTrue(
575 - isChatNewLocalShortcut(event({ key: "n", metaKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
578 + assert.strictEqual(
579 + resolveShortcutCommand(event({ key: "n", metaKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
580 platform: "MacIntel",
581 }),
582 + "chat.newLocal",
583 );
579 - assert.isTrue(
580 - isChatNewLocalShortcut(event({ key: "n", ctrlKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
584 + assert.strictEqual(
585 + resolveShortcutCommand(event({ key: "n", ctrlKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
586 platform: "Linux",
587 }),
588 + "chat.newLocal",
589 );
590 });
591
@@ -699,11 +705,12 @@ describe("cross-command precedence", () => {
705 context: { terminalFocus: true },
706 }),
707 );
702 - assert.isFalse(
703 - isChatNewShortcut(event({ key: "n", metaKey: true }), keybindings, {
708 + assert.strictEqual(
709 + resolveShortcutCommand(event({ key: "n", metaKey: true }), keybindings, {
710 platform: "MacIntel",
711 context: { terminalFocus: true },
712 }),
713 + "terminal.new",
714 );
715 assert.isFalse(
716 isTerminalNewShortcut(event({ key: "n", metaKey: true }), keybindings, {
@@ -711,11 +718,12 @@ describe("cross-command precedence", () => {
718 context: { terminalFocus: false },
719 }),
720 );
714 - assert.isTrue(
715 - isChatNewShortcut(event({ key: "n", metaKey: true }), keybindings, {
721 + assert.strictEqual(
722 + resolveShortcutCommand(event({ key: "n", metaKey: true }), keybindings, {
723 platform: "MacIntel",
724 context: { terminalFocus: false },
725 }),
726 + "chat.new",
727 );
728 });
729
@@ -735,11 +743,12 @@ describe("cross-command precedence", () => {
743 context: { terminalFocus: true },
744 }),
745 );
738 - assert.isTrue(
739 - isChatNewShortcut(event({ key: "n", ctrlKey: true }), keybindings, {
746 + assert.strictEqual(
747 + resolveShortcutCommand(event({ key: "n", ctrlKey: true }), keybindings, {
748 platform: "Linux",
749 context: { terminalFocus: true },
750 }),
751 + "chat.new",
752 );
753 });
754 });
apps/web/src/keybindings.ts
-24
@@ -288,14 +288,6 @@ export function threadTraversalDirectionFromCommand(
288 return null;
289 }
290
291 -export function shouldShowThreadJumpHints(
292 - event: ShortcutEventLike,
293 - keybindings: ResolvedKeybindingsConfig,
294 - options?: ShortcutMatchOptions,
295 -): boolean {
296 - return shouldShowThreadJumpHintsForModifiers(event, keybindings, options);
297 -}
298 -
291 export function shouldShowThreadJumpHintsForModifiers(
292 modifiers: ShortcutModifierStateLike,
293 keybindings: ResolvedKeybindingsConfig,
@@ -419,22 +411,6 @@ export function isPreviewRefreshShortcut(
411 return matchesCommandShortcut(event, keybindings, "preview.refresh", options);
412 }
413
422 -export function isChatNewShortcut(
423 - event: ShortcutEventLike,
424 - keybindings: ResolvedKeybindingsConfig,
425 - options?: ShortcutMatchOptions,
426 -): boolean {
427 - return matchesCommandShortcut(event, keybindings, "chat.new", options);
428 -}
429 -
430 -export function isChatNewLocalShortcut(
431 - event: ShortcutEventLike,
432 - keybindings: ResolvedKeybindingsConfig,
433 - options?: ShortcutMatchOptions,
434 -): boolean {
435 - return matchesCommandShortcut(event, keybindings, "chat.newLocal", options);
436 -}
437 -
414 export function isOpenFavoriteEditorShortcut(
415 event: ShortcutEventLike,
416 keybindings: ResolvedKeybindingsConfig,