Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

keybindings.test.ts

1,360 lines40.8 KB

1import { assert, describe, it } from "vite-plus/test";
2import {
3 compileResolvedKeybindingsConfig,
4 DEFAULT_RESOLVED_KEYBINDINGS,
5 mergeWithDefaultKeybindings,
6} from "@t3tools/shared/keybindings";
7​
8import {
9 type KeybindingCommand,
10 type KeybindingShortcut,
11 type KeybindingWhenNode,
12 type ResolvedKeybindingsConfig,
13} from "@t3tools/contracts";
14import {
15 formatShortcutLabel,
16 isDiffToggleShortcut,
17 isRichTextBoldShortcut,
18 modelPickerJumpCommandForIndex,
19 modelPickerJumpIndexFromCommand,
20 isOpenFavoriteEditorShortcut,
21 isTerminalClearShortcut,
22 isTerminalCloseShortcut,
23 isTerminalNewShortcut,
24 isTerminalSplitShortcut,
25 isTerminalSplitVerticalShortcut,
26 isTerminalToggleShortcut,
27 resolveShortcutCommand,
28 shouldShowThreadJumpHintsForModifiers,
29 shortcutLabelForCommand,
30 terminalDeleteShortcutData,
31 terminalNavigationShortcutData,
32 threadJumpCommandForIndex,
33 threadJumpIndexFromCommand,
34 threadTraversalDirectionFromCommand,
35 type ShortcutEventLike,
36} from "./keybindings";
37​
38function event(overrides: Partial<ShortcutEventLike> = {}): ShortcutEventLike {
39 return {
40 key: "j",
41 metaKey: false,
42 ctrlKey: false,
43 shiftKey: false,
44 altKey: false,
45 ...overrides,
46 };
48​
49function modShortcut(
50 key: string,
51 overrides: Partial<Omit<KeybindingShortcut, "key">> = {},
52): KeybindingShortcut {
53 return {
54 key,
55 metaKey: false,
56 ctrlKey: false,
57 shiftKey: false,
58 altKey: false,
59 modKey: true,
60 ...overrides,
61 };
63​
64function whenIdentifier(name: string): KeybindingWhenNode {
65 return { type: "identifier", name };
67​
68function whenNot(node: KeybindingWhenNode): KeybindingWhenNode {
69 return { type: "not", node };
71​
72function whenAnd(left: KeybindingWhenNode, right: KeybindingWhenNode): KeybindingWhenNode {
73 return { type: "and", left, right };
75​
76interface TestBinding {
77 shortcut: KeybindingShortcut;
78 command: KeybindingCommand;
79 whenAst?: KeybindingWhenNode;
81​
82function compile(bindings: TestBinding[]): ResolvedKeybindingsConfig {
83 return bindings.map((binding) => ({
84 command: binding.command,
85 shortcut: binding.shortcut,
86 ...(binding.whenAst ? { whenAst: binding.whenAst } : {}),
87 }));
89​
90const DEFAULT_BINDINGS = compile([
91 { shortcut: modShortcut("b"), command: "sidebar.toggle" },
92 { shortcut: modShortcut("j"), command: "terminal.toggle" },
93 { shortcut: modShortcut("b", { altKey: true }), command: "rightPanel.toggle" },
94 {
95 shortcut: modShortcut("d"),
96 command: "terminal.split",
97 whenAst: whenIdentifier("terminalFocus"),
98 },
99 {
100 shortcut: modShortcut("d", { shiftKey: true }),
101 command: "terminal.splitVertical",
102 whenAst: whenIdentifier("terminalFocus"),
103 },
104 {
105 shortcut: modShortcut("n"),
106 command: "terminal.new",
107 whenAst: whenIdentifier("terminalFocus"),
108 },
109 {
110 shortcut: modShortcut("w"),
111 command: "terminal.close",
112 whenAst: whenIdentifier("terminalFocus"),
113 },
114 {
115 shortcut: modShortcut("w"),
116 command: "rightPanel.close",
117 whenAst: whenNot(whenIdentifier("terminalFocus")),
118 },
119 {
120 shortcut: modShortcut("d"),
121 command: "diff.toggle",
122 whenAst: whenNot(whenIdentifier("terminalFocus")),
123 },
124 {
125 shortcut: modShortcut("k"),
126 command: "commandPalette.toggle",
127 whenAst: whenNot(whenIdentifier("terminalFocus")),
128 },
129 {
130 shortcut: modShortcut("p"),
131 command: "filePicker.toggle",
132 whenAst: whenNot(whenIdentifier("terminalFocus")),
133 },
134 {
135 shortcut: modShortcut("f", { shiftKey: true }),
136 command: "projectSearch.toggle",
137 whenAst: whenNot(whenIdentifier("terminalFocus")),
138 },
139 {
140 shortcut: modShortcut("t", { altKey: true, shiftKey: true }),
141 command: "themeEditor.toggle",
142 },
143 {
144 shortcut: modShortcut("m", { shiftKey: true }),
145 command: "modelPicker.toggle",
146 whenAst: whenNot(whenIdentifier("terminalFocus")),
147 },
148 { shortcut: modShortcut("o", { shiftKey: true }), command: "chat.new" },
149 { shortcut: modShortcut("n", { shiftKey: true }), command: "chat.newLocal" },
150 { shortcut: modShortcut("o"), command: "editor.openFavorite" },
151 { shortcut: modShortcut("[", { shiftKey: true }), command: "thread.previous" },
152 { shortcut: modShortcut("]", { shiftKey: true }), command: "thread.next" },
153 {
154 shortcut: modShortcut("c", { shiftKey: true }),
155 command: "thread.copyReference",
156 whenAst: whenNot(whenIdentifier("terminalFocus")),
157 },
158 {
159 shortcut: modShortcut("s", { shiftKey: true }),
160 command: "thread.settle",
161 whenAst: whenNot(whenIdentifier("terminalFocus")),
162 },
163 { shortcut: modShortcut("1"), command: "thread.jump.1" },
164 { shortcut: modShortcut("2"), command: "thread.jump.2" },
165 { shortcut: modShortcut("3"), command: "thread.jump.3" },
166 {
167 shortcut: modShortcut("1"),
168 command: "modelPicker.jump.1",
169 whenAst: whenIdentifier("modelPickerOpen"),
170 },
171 {
172 shortcut: modShortcut("2"),
173 command: "modelPicker.jump.2",
174 whenAst: whenIdentifier("modelPickerOpen"),
175 },
176 {
177 shortcut: modShortcut("3"),
178 command: "modelPicker.jump.3",
179 whenAst: whenIdentifier("modelPickerOpen"),
180 },
181]);
182​
183describe("isTerminalToggleShortcut", () => {
184 it("matches Cmd+J on macOS", () => {
185 assert.isTrue(
186 isTerminalToggleShortcut(event({ metaKey: true }), DEFAULT_BINDINGS, {
187 platform: "MacIntel",
188 }),
189 );
190 });
191​
192 it("matches Ctrl+J on non-macOS", () => {
193 assert.isTrue(
194 isTerminalToggleShortcut(event({ ctrlKey: true }), DEFAULT_BINDINGS, { platform: "Win32" }),
195 );
196 });
197​
198 it("matches Ctrl+J on non-macOS while terminalFocus is true", () => {
199 assert.isTrue(
200 isTerminalToggleShortcut(event({ ctrlKey: true }), DEFAULT_BINDINGS, {
201 platform: "Win32",
202 context: { terminalFocus: true },
203 }),
204 );
205 });
206});
207​
208describe("settle thread shortcut", () => {
209 it("resolves outside the terminal", () => {
210 assert.equal(
211 resolveShortcutCommand(event({ key: "s", metaKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
212 platform: "MacIntel",
213 context: { terminalFocus: false },
214 }),
215 "thread.settle",
216 );
217 });
218​
219 it("does not intercept the terminal", () => {
220 assert.isNull(
221 resolveShortcutCommand(event({ key: "s", ctrlKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
222 platform: "Win32",
223 context: { terminalFocus: true },
224 }),
225 );
226 });
227});
228​
229describe("thread undo shortcut", () => {
230 it("resolves mod+z with nothing editable focused", () => {
231 assert.equal(
232 resolveShortcutCommand(event({ key: "z", metaKey: true }), DEFAULT_RESOLVED_KEYBINDINGS, {
233 platform: "MacIntel",
234 context: { terminalFocus: false, editableFocus: false },
235 }),
236 "thread.undo",
237 );
238 });
239​
240 it("leaves native undo alone inside text fields and terminals", () => {
241 assert.isNull(
242 resolveShortcutCommand(event({ key: "z", ctrlKey: true }), DEFAULT_RESOLVED_KEYBINDINGS, {
243 platform: "Win32",
244 context: { editableFocus: true },
245 }),
246 );
247 assert.isNull(
248 resolveShortcutCommand(event({ key: "z", ctrlKey: true }), DEFAULT_RESOLVED_KEYBINDINGS, {
249 platform: "Win32",
250 context: { terminalFocus: true },
251 }),
252 );
253 });
254});
255​
256describe("copy thread reference shortcut", () => {
257 it("resolves Cmd+Shift+C on macOS and Ctrl+Shift+C elsewhere", () => {
258 assert.equal(
259 resolveShortcutCommand(event({ key: "c", metaKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
260 platform: "MacIntel",
261 }),
262 "thread.copyReference",
263 );
264 assert.equal(
265 resolveShortcutCommand(event({ key: "c", ctrlKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
266 platform: "Linux",
267 }),
268 "thread.copyReference",
269 );
270 });
271​
272 it("leaves terminal copy untouched", () => {
273 assert.isNull(
274 resolveShortcutCommand(event({ key: "c", ctrlKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
275 platform: "Linux",
276 context: { terminalFocus: true },
277 }),
278 );
279 });
280});
281​
282describe("split/new/close terminal shortcuts", () => {
283 it("requires terminalFocus for default split/new/close bindings", () => {
284 assert.isFalse(
285 isTerminalSplitShortcut(event({ key: "d", metaKey: true }), DEFAULT_BINDINGS, {
286 platform: "MacIntel",
287 context: { terminalFocus: false },
288 }),
289 );
290 assert.isFalse(
291 isTerminalSplitVerticalShortcut(
292 event({ key: "d", metaKey: true, shiftKey: true }),
293 DEFAULT_BINDINGS,
294 {
295 platform: "MacIntel",
296 context: { terminalFocus: false },
297 },
298 ),
299 );
300 assert.isFalse(
301 isTerminalNewShortcut(event({ key: "n", ctrlKey: true }), DEFAULT_BINDINGS, {
302 platform: "Linux",
303 context: { terminalFocus: false },
304 }),
305 );
306 assert.isFalse(
307 isTerminalCloseShortcut(event({ key: "w", ctrlKey: true }), DEFAULT_BINDINGS, {
308 platform: "Linux",
309 context: { terminalFocus: false },
310 }),
311 );
312 });
313​
314 it("matches split/new when terminalFocus is true", () => {
315 assert.isTrue(
316 isTerminalSplitShortcut(event({ key: "d", metaKey: true }), DEFAULT_BINDINGS, {
317 platform: "MacIntel",
318 context: { terminalFocus: true },
319 }),
320 );
321 assert.isTrue(
322 isTerminalSplitVerticalShortcut(
323 event({ key: "d", metaKey: true, shiftKey: true }),
324 DEFAULT_BINDINGS,
325 {
326 platform: "MacIntel",
327 context: { terminalFocus: true },
328 },
329 ),
330 );
331 assert.isTrue(
332 isTerminalNewShortcut(event({ key: "n", ctrlKey: true }), DEFAULT_BINDINGS, {
333 platform: "Linux",
334 context: { terminalFocus: true },
335 }),
336 );
337 assert.isTrue(
338 isTerminalCloseShortcut(event({ key: "w", ctrlKey: true }), DEFAULT_BINDINGS, {
339 platform: "Linux",
340 context: { terminalFocus: true },
341 }),
342 );
343 });
344​
345 it("supports when expressions", () => {
346 const keybindings = compile([
347 {
348 shortcut: modShortcut("\\"),
349 command: "terminal.split",
350 whenAst: whenAnd(whenIdentifier("terminalOpen"), whenNot(whenIdentifier("terminalFocus"))),
351 },
352 {
353 shortcut: modShortcut("n", { shiftKey: true }),
354 command: "terminal.new",
355 whenAst: whenAnd(whenIdentifier("terminalOpen"), whenNot(whenIdentifier("terminalFocus"))),
356 },
357 { shortcut: modShortcut("j"), command: "terminal.toggle" },
358 ]);
359 assert.isTrue(
360 isTerminalSplitShortcut(event({ key: "\\", ctrlKey: true }), keybindings, {
361 platform: "Win32",
362 context: { terminalOpen: true, terminalFocus: false },
363 }),
364 );
365 assert.isFalse(
366 isTerminalSplitShortcut(event({ key: "\\", ctrlKey: true }), keybindings, {
367 platform: "Win32",
368 context: { terminalOpen: false, terminalFocus: false },
369 }),
370 );
371 assert.isTrue(
372 isTerminalNewShortcut(event({ key: "n", ctrlKey: true, shiftKey: true }), keybindings, {
373 platform: "Win32",
374 context: { terminalOpen: true, terminalFocus: false },
375 }),
376 );
377 });
378​
379 it("supports when boolean literals", () => {
380 const keybindings = compile([
381 { shortcut: modShortcut("n"), command: "terminal.new", whenAst: whenIdentifier("true") },
382 { shortcut: modShortcut("m"), command: "terminal.new", whenAst: whenIdentifier("false") },
383 ]);
384​
385 assert.isTrue(
386 isTerminalNewShortcut(event({ key: "n", ctrlKey: true }), keybindings, {
387 platform: "Linux",
388 }),
389 );
390 assert.isFalse(
391 isTerminalNewShortcut(event({ key: "m", ctrlKey: true }), keybindings, {
392 platform: "Linux",
393 }),
394 );
395 });
396});
397​
398describe("shortcutLabelForCommand", () => {
399 it("returns the effective binding label", () => {
400 const bindings = compile([
401 {
402 shortcut: modShortcut("\\"),
403 command: "terminal.split",
404 whenAst: whenIdentifier("terminalFocus"),
405 },
406 {
407 shortcut: modShortcut("\\", { shiftKey: true }),
408 command: "terminal.split",
409 whenAst: whenNot(whenIdentifier("terminalFocus")),
410 },
411 ]);
412 assert.strictEqual(
413 shortcutLabelForCommand(bindings, "terminal.split", {
414 platform: "Linux",
415 context: { terminalFocus: false },
416 }),
417 "Ctrl+Shift+\\",
418 );
419 });
420​
421 it("returns effective labels for non-terminal commands", () => {
422 assert.strictEqual(
423 shortcutLabelForCommand(DEFAULT_BINDINGS, "sidebar.toggle", "MacIntel"),
424 "⌘B",
425 );
426 assert.strictEqual(shortcutLabelForCommand(DEFAULT_BINDINGS, "chat.new", "MacIntel"), "⇧⌘O");
427 assert.strictEqual(shortcutLabelForCommand(DEFAULT_BINDINGS, "diff.toggle", "Linux"), "Ctrl+D");
428 assert.strictEqual(
429 shortcutLabelForCommand(DEFAULT_BINDINGS, "rightPanel.toggle", "MacIntel"),
430 "⌥⌘B",
431 );
432 assert.strictEqual(
433 shortcutLabelForCommand(DEFAULT_BINDINGS, "commandPalette.toggle", "MacIntel"),
434 "⌘K",
435 );
436 assert.strictEqual(
437 shortcutLabelForCommand(DEFAULT_BINDINGS, "filePicker.toggle", "MacIntel"),
438 "⌘P",
439 );
440 assert.strictEqual(
441 shortcutLabelForCommand(DEFAULT_BINDINGS, "projectSearch.toggle", "MacIntel"),
442 "⇧⌘F",
443 );
444 assert.strictEqual(
445 shortcutLabelForCommand(DEFAULT_BINDINGS, "modelPicker.toggle", "Linux"),
446 "Ctrl+Shift+M",
447 );
448 assert.strictEqual(
449 shortcutLabelForCommand(DEFAULT_BINDINGS, "editor.openFavorite", "Linux"),
450 "Ctrl+O",
451 );
452 assert.strictEqual(
453 shortcutLabelForCommand(DEFAULT_BINDINGS, "thread.jump.3", "MacIntel"),
454 "⌘3",
455 );
456 assert.strictEqual(
457 shortcutLabelForCommand(DEFAULT_BINDINGS, "thread.previous", "Linux"),
458 "Ctrl+Shift+[",
459 );
460 assert.strictEqual(
461 shortcutLabelForCommand(DEFAULT_BINDINGS, "modelPicker.jump.3", {
462 platform: "MacIntel",
463 context: { modelPickerOpen: true },
464 }),
465 "⌘3",
466 );
467 });
468​
469 it("returns null for commands shadowed by a later conflicting shortcut", () => {
470 const bindings = compile([
471 { shortcut: modShortcut("1", { shiftKey: true }), command: "thread.jump.1" },
472 { shortcut: modShortcut("1", { shiftKey: true }), command: "thread.jump.7" },
473 ]);
474​
475 assert.isNull(shortcutLabelForCommand(bindings, "thread.jump.1", "MacIntel"));
476 assert.strictEqual(shortcutLabelForCommand(bindings, "thread.jump.7", "MacIntel"), "⇧⌘1");
477 });
478​
479 it("respects when-context while resolving labels", () => {
480 const bindings = compile([
481 { shortcut: modShortcut("d"), command: "diff.toggle" },
482 {
483 shortcut: modShortcut("d"),
484 command: "terminal.split",
485 whenAst: whenIdentifier("terminalFocus"),
486 },
487 ]);
488​
489 assert.strictEqual(
490 shortcutLabelForCommand(bindings, "diff.toggle", {
491 platform: "Linux",
492 context: { terminalFocus: false },
493 }),
494 "Ctrl+D",
495 );
496 assert.isNull(
497 shortcutLabelForCommand(bindings, "diff.toggle", {
498 platform: "Linux",
499 context: { terminalFocus: true },
500 }),
501 );
502 assert.strictEqual(
503 shortcutLabelForCommand(bindings, "terminal.split", {
504 platform: "Linux",
505 context: { terminalFocus: true },
506 }),
507 "Ctrl+D",
508 );
509 });
510});
511​
512describe("thread navigation helpers", () => {
513 it("maps jump commands to visible thread indices", () => {
514 assert.strictEqual(threadJumpCommandForIndex(0), "thread.jump.1");
515 assert.strictEqual(threadJumpCommandForIndex(2), "thread.jump.3");
516 assert.isNull(threadJumpCommandForIndex(9));
517 assert.strictEqual(threadJumpIndexFromCommand("thread.jump.1"), 0);
518 assert.strictEqual(threadJumpIndexFromCommand("thread.jump.3"), 2);
519 assert.isNull(threadJumpIndexFromCommand("thread.next"));
520 });
521​
522 it("maps traversal commands to directions", () => {
523 assert.strictEqual(threadTraversalDirectionFromCommand("thread.previous"), "previous");
524 assert.strictEqual(threadTraversalDirectionFromCommand("thread.next"), "next");
525 assert.isNull(threadTraversalDirectionFromCommand("thread.jump.1"));
526 assert.isNull(threadTraversalDirectionFromCommand(null));
527 });
528​
529 it("shows jump hints only when configured modifiers match", () => {
530 assert.isTrue(
531 shouldShowThreadJumpHintsForModifiers(event({ metaKey: true }), DEFAULT_BINDINGS, {
532 platform: "MacIntel",
533 }),
534 );
535 assert.isFalse(
536 shouldShowThreadJumpHintsForModifiers(
537 event({ metaKey: true, shiftKey: true }),
538 DEFAULT_BINDINGS,
539 {
540 platform: "MacIntel",
541 },
542 ),
543 );
544 assert.isTrue(
545 shouldShowThreadJumpHintsForModifiers(event({ ctrlKey: true }), DEFAULT_BINDINGS, {
546 platform: "Linux",
547 }),
548 );
549 });
550​
551 it("never shows jump hints while the terminal is focused, even with an unrestricted binding", () => {
552 assert.isFalse(
553 shouldShowThreadJumpHintsForModifiers(event({ metaKey: true }), DEFAULT_BINDINGS, {
554 platform: "MacIntel",
555 context: { terminalFocus: true },
556 }),
557 );
558 assert.isTrue(
559 shouldShowThreadJumpHintsForModifiers(event({ metaKey: true }), DEFAULT_BINDINGS, {
560 platform: "MacIntel",
561 context: { terminalFocus: false },
562 }),
563 );
564 });
565​
566 it("keeps default thread jumps off the web so the browser can switch tabs", () => {
567 const input = event({ key: "1", metaKey: true });
568 assert.isNull(
569 resolveShortcutCommand(input, DEFAULT_RESOLVED_KEYBINDINGS, {
570 platform: "MacIntel",
571 context: { isDesktop: false },
572 }),
573 );
574 assert.strictEqual(
575 resolveShortcutCommand(input, DEFAULT_RESOLVED_KEYBINDINGS, {
576 platform: "MacIntel",
577 context: { isDesktop: true },
578 }),
579 "thread.jump.1",
580 );
581 assert.isFalse(
582 shouldShowThreadJumpHintsForModifiers(
583 event({ metaKey: true }),
584 DEFAULT_RESOLVED_KEYBINDINGS,
585 {
586 platform: "MacIntel",
587 context: { isDesktop: false },
588 },
589 ),
590 );
591 assert.isTrue(
592 shouldShowThreadJumpHintsForModifiers(
593 event({ metaKey: true }),
594 DEFAULT_RESOLVED_KEYBINDINGS,
595 {
596 platform: "MacIntel",
597 context: { isDesktop: true },
598 },
599 ),
600 );
601 });
602});
603​
604describe("model picker navigation helpers", () => {
605 it("maps jump commands to visible model indices", () => {
606 assert.strictEqual(modelPickerJumpCommandForIndex(0), "modelPicker.jump.1");
607 assert.strictEqual(modelPickerJumpCommandForIndex(2), "modelPicker.jump.3");
608 assert.isNull(modelPickerJumpCommandForIndex(9));
609 assert.strictEqual(modelPickerJumpIndexFromCommand("modelPicker.jump.1"), 0);
610 assert.strictEqual(modelPickerJumpIndexFromCommand("modelPicker.jump.3"), 2);
611 assert.isNull(modelPickerJumpIndexFromCommand("thread.jump.1"));
612 });
613​
614 it("keeps default model jumps off the web even while the picker is open", () => {
615 const input = event({ key: "3", metaKey: true });
616 assert.isNull(
617 resolveShortcutCommand(input, DEFAULT_RESOLVED_KEYBINDINGS, {
618 platform: "MacIntel",
619 context: { isDesktop: false, modelPickerOpen: true },
620 }),
621 );
622 assert.strictEqual(
623 resolveShortcutCommand(input, DEFAULT_RESOLVED_KEYBINDINGS, {
624 platform: "MacIntel",
625 context: { isDesktop: true, modelPickerOpen: true },
626 }),
627 "modelPicker.jump.3",
628 );
629 assert.strictEqual(
630 resolveShortcutCommand(input, DEFAULT_RESOLVED_KEYBINDINGS, {
631 platform: "MacIntel",
632 context: { isDesktop: true, modelPickerOpen: false },
633 }),
634 "thread.jump.3",
635 );
636 });
637});
638​
639describe("chat/editor shortcuts", () => {
640 it("matches chat.new shortcut", () => {
641 assert.strictEqual(
642 resolveShortcutCommand(event({ key: "o", metaKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
643 platform: "MacIntel",
644 }),
645 "chat.new",
646 );
647 assert.strictEqual(
648 resolveShortcutCommand(event({ key: "o", ctrlKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
649 platform: "Linux",
650 }),
651 "chat.new",
652 );
653 });
654​
655 it("matches chat.newLocal shortcut", () => {
656 assert.strictEqual(
657 resolveShortcutCommand(event({ key: "n", metaKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
658 platform: "MacIntel",
659 }),
660 "chat.newLocal",
661 );
662 assert.strictEqual(
663 resolveShortcutCommand(event({ key: "n", ctrlKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
664 platform: "Linux",
665 }),
666 "chat.newLocal",
667 );
668 });
669​
670 it("matches editor.openFavorite shortcut", () => {
671 assert.isTrue(
672 isOpenFavoriteEditorShortcut(event({ key: "o", metaKey: true }), DEFAULT_BINDINGS, {
673 platform: "MacIntel",
674 }),
675 );
676 assert.isTrue(
677 isOpenFavoriteEditorShortcut(event({ key: "o", ctrlKey: true }), DEFAULT_BINDINGS, {
678 platform: "Linux",
679 }),
680 );
681 });
682​
683 it("matches commandPalette.toggle shortcut outside terminal focus", () => {
684 assert.strictEqual(
685 resolveShortcutCommand(event({ key: "k", metaKey: true }), DEFAULT_BINDINGS, {
686 platform: "MacIntel",
687 context: { terminalFocus: false },
688 }),
689 "commandPalette.toggle",
690 );
691 assert.notStrictEqual(
692 resolveShortcutCommand(event({ key: "k", metaKey: true }), DEFAULT_BINDINGS, {
693 platform: "MacIntel",
694 context: { terminalFocus: true },
695 }),
696 "commandPalette.toggle",
697 );
698 });
699​
700 it("matches filePicker.toggle shortcut outside terminal focus", () => {
701 assert.strictEqual(
702 resolveShortcutCommand(event({ key: "p", metaKey: true }), DEFAULT_BINDINGS, {
703 platform: "MacIntel",
704 context: { terminalFocus: false },
705 }),
706 "filePicker.toggle",
707 );
708 assert.notStrictEqual(
709 resolveShortcutCommand(event({ key: "p", metaKey: true }), DEFAULT_BINDINGS, {
710 platform: "MacIntel",
711 context: { terminalFocus: true },
712 }),
713 "filePicker.toggle",
714 );
715 });
716​
717 it("matches projectSearch.toggle shortcut outside terminal focus", () => {
718 assert.strictEqual(
719 resolveShortcutCommand(event({ key: "f", metaKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
720 platform: "MacIntel",
721 context: { terminalFocus: false },
722 }),
723 "projectSearch.toggle",
724 );
725 assert.notStrictEqual(
726 resolveShortcutCommand(event({ key: "f", metaKey: true, shiftKey: true }), DEFAULT_BINDINGS, {
727 platform: "MacIntel",
728 context: { terminalFocus: true },
729 }),
730 "projectSearch.toggle",
731 );
732 });
733​
734 it("matches themeEditor.toggle on macOS and Windows", () => {
735 assert.strictEqual(
736 resolveShortcutCommand(
737 event({ key: "t", metaKey: true, altKey: true, shiftKey: true }),
738 DEFAULT_BINDINGS,
739 { platform: "MacIntel" },
740 ),
741 "themeEditor.toggle",
742 );
743 assert.strictEqual(
744 resolveShortcutCommand(
745 event({ key: "t", ctrlKey: true, altKey: true, shiftKey: true }),
746 DEFAULT_BINDINGS,
747 { platform: "Win32" },
748 ),
749 "themeEditor.toggle",
750 );
751 });
752​
753 it("matches diff.toggle shortcut outside terminal focus", () => {
754 assert.isTrue(
755 isDiffToggleShortcut(event({ key: "d", metaKey: true }), DEFAULT_BINDINGS, {
756 platform: "MacIntel",
757 context: { terminalFocus: false },
758 }),
759 );
760 assert.isFalse(
761 isDiffToggleShortcut(event({ key: "d", metaKey: true }), DEFAULT_BINDINGS, {
762 platform: "MacIntel",
763 context: { terminalFocus: true },
764 }),
765 );
766 });
767});
768​
769describe("cross-command precedence", () => {
770 it("uses when + order so a later focused rule overrides a global rule", () => {
771 const keybindings = compile([
772 { shortcut: modShortcut("n"), command: "chat.new" },
773 {
774 shortcut: modShortcut("n"),
775 command: "terminal.new",
776 whenAst: whenIdentifier("terminalFocus"),
777 },
778 ]);
779​
780 assert.isTrue(
781 isTerminalNewShortcut(event({ key: "n", metaKey: true }), keybindings, {
782 platform: "MacIntel",
783 context: { terminalFocus: true },
784 }),
785 );
786 assert.strictEqual(
787 resolveShortcutCommand(event({ key: "n", metaKey: true }), keybindings, {
788 platform: "MacIntel",
789 context: { terminalFocus: true },
790 }),
791 "terminal.new",
792 );
793 assert.isFalse(
794 isTerminalNewShortcut(event({ key: "n", metaKey: true }), keybindings, {
795 platform: "MacIntel",
796 context: { terminalFocus: false },
797 }),
798 );
799 assert.strictEqual(
800 resolveShortcutCommand(event({ key: "n", metaKey: true }), keybindings, {
801 platform: "MacIntel",
802 context: { terminalFocus: false },
803 }),
804 "chat.new",
805 );
806 });
807​
808 it("still lets a later global rule win when both rules match", () => {
809 const keybindings = compile([
810 {
811 shortcut: modShortcut("n"),
812 command: "terminal.new",
813 whenAst: whenIdentifier("terminalFocus"),
814 },
815 { shortcut: modShortcut("n"), command: "chat.new" },
816 ]);
817​
818 assert.isFalse(
819 isTerminalNewShortcut(event({ key: "n", ctrlKey: true }), keybindings, {
820 platform: "Linux",
821 context: { terminalFocus: true },
822 }),
823 );
824 assert.strictEqual(
825 resolveShortcutCommand(event({ key: "n", ctrlKey: true }), keybindings, {
826 platform: "Linux",
827 context: { terminalFocus: true },
828 }),
829 "chat.new",
830 );
831 });
832});
833​
834describe("resolveShortcutCommand", () => {
835 it("resolves a custom stop-thread shortcut", () => {
836 const keybindings = compile([{ shortcut: modShortcut("escape"), command: "thread.stop" }]);
837​
838 assert.strictEqual(
839 resolveShortcutCommand(event({ key: "Escape", metaKey: true }), keybindings, {
840 platform: "MacIntel",
841 }),
842 "thread.stop",
843 );
844 });
845​
846 it("honors preview conditions for a stop-thread shortcut", () => {
847 const keybindings = compile([
848 {
849 shortcut: modShortcut("escape"),
850 command: "thread.stop",
851 whenAst: whenIdentifier("previewFocus"),
852 },
853 ]);
854 const input = event({ key: "Escape", metaKey: true });
855​
856 assert.isNull(
857 resolveShortcutCommand(input, keybindings, {
858 platform: "MacIntel",
859 context: { previewFocus: false },
860 }),
861 );
862 assert.strictEqual(
863 resolveShortcutCommand(input, keybindings, {
864 platform: "MacIntel",
865 context: { previewFocus: true },
866 }),
867 "thread.stop",
868 );
869 });
870​
871 it("returns dynamic script commands", () => {
872 const keybindings = compile([{ shortcut: modShortcut("r"), command: "script.setup.run" }]);
873​
874 assert.strictEqual(
875 resolveShortcutCommand(event({ key: "r", ctrlKey: true }), keybindings, {
876 platform: "Linux",
877 }),
878 "script.setup.run",
879 );
880 });
881​
882 it("routes mod+w to the terminal while focused and to the right panel otherwise", () => {
883 const closeEvent = event({ key: "w", metaKey: true });
884 assert.strictEqual(
885 resolveShortcutCommand(closeEvent, DEFAULT_BINDINGS, {
886 platform: "MacIntel",
887 context: { terminalFocus: true },
888 }),
889 "terminal.close",
890 );
891 assert.strictEqual(
892 resolveShortcutCommand(closeEvent, DEFAULT_BINDINGS, {
893 platform: "MacIntel",
894 context: { terminalFocus: false },
895 }),
896 "rightPanel.close",
897 );
898 });
899​
900 it("resolves a custom right panel maximize binding", () => {
901 const keybindings = compile([
902 {
903 shortcut: modShortcut("m", { shiftKey: true }),
904 command: "rightPanel.toggleMaximized",
905 },
906 ]);
907​
908 assert.strictEqual(
909 resolveShortcutCommand(event({ key: "m", metaKey: true, shiftKey: true }), keybindings, {
910 platform: "MacIntel",
911 }),
912 "rightPanel.toggleMaximized",
913 );
914 });
915​
916 it("matches bracket shortcuts using the physical key code", () => {
917 assert.strictEqual(
918 resolveShortcutCommand(
919 event({ key: "{", code: "BracketLeft", metaKey: true, shiftKey: true }),
920 DEFAULT_BINDINGS,
921 {
922 platform: "MacIntel",
923 },
924 ),
925 "thread.previous",
926 );
927 assert.strictEqual(
928 resolveShortcutCommand(
929 event({ key: "}", code: "BracketRight", ctrlKey: true, shiftKey: true }),
930 DEFAULT_BINDINGS,
931 {
932 platform: "Linux",
933 },
934 ),
935 "thread.next",
936 );
937 });
938​
939 it("matches punctuation shortcuts by physical key across keyboard layouts", () => {
940 const keybindings = compile([
941 { shortcut: modShortcut("'", { shiftKey: true }), command: "diff.toggle" },
942 ]);
943​
944 assert.strictEqual(
945 resolveShortcutCommand(
946 event({ key: "@", code: "Quote", metaKey: true, shiftKey: true }),
947 keybindings,
948 { platform: "MacIntel" },
949 ),
950 "diff.toggle",
951 );
952 assert.isNull(
953 resolveShortcutCommand(
954 event({ key: '"', code: "Digit2", metaKey: true, shiftKey: true }),
955 keybindings,
956 { platform: "MacIntel" },
957 ),
958 );
959 });
960​
961 it("does not let a punctuation position shadow a Latin layout key", () => {
962 const keybindings = compile([
963 { shortcut: modShortcut("m"), command: "diff.toggle" },
964 { shortcut: modShortcut(";"), command: "sidebar.toggle" },
965 ]);
966​
967 assert.strictEqual(
968 resolveShortcutCommand(event({ key: "m", code: "Semicolon", metaKey: true }), keybindings, {
969 platform: "MacIntel",
970 }),
971 "diff.toggle",
972 );
973 });
974​
975 it("matches Option-modified letters using the physical key code on macOS", () => {
976 assert.strictEqual(
977 resolveShortcutCommand(
978 event({ key: "∫", code: "KeyB", metaKey: true, altKey: true }),
979 DEFAULT_BINDINGS,
980 { platform: "MacIntel" },
981 ),
982 "rightPanel.toggle",
983 );
984 });
985​
986 it("matches non-Latin layout letters using the physical key code", () => {
987 const keybindings = compile([{ shortcut: modShortcut("d"), command: "diff.toggle" }]);
988​
989 assert.strictEqual(
990 resolveShortcutCommand(event({ key: "в", code: "KeyD", metaKey: true }), keybindings, {
991 platform: "MacIntel",
992 }),
993 "diff.toggle",
994 );
995 });
996​
997 it("ignores the physical key code when the layout types a different Latin letter", () => {
998 const keybindings = compile([{ shortcut: modShortcut("d"), command: "diff.toggle" }]);
999​
1000 // On a remapped layout the physical D key types "a"; only the physical
1001 // key whose layout output is "d" may trigger the shortcut.
1002 assert.isNull(
1003 resolveShortcutCommand(event({ key: "a", code: "KeyD", metaKey: true }), keybindings, {
1004 platform: "MacIntel",
1005 }),
1006 );
1007 assert.strictEqual(
1008 resolveShortcutCommand(event({ key: "d", code: "KeyL", metaKey: true }), keybindings, {
1009 platform: "MacIntel",
1010 }),
1011 "diff.toggle",
1012 );
1013 });
1014});
1015​
1016describe("formatShortcutLabel", () => {
1017 it("formats labels for macOS", () => {
1018 assert.strictEqual(
1019 formatShortcutLabel(modShortcut("d", { shiftKey: true }), "MacIntel"),
1020 "⇧⌘D",
1021 );
1022 });
1023​
1024 it("formats labels for non-macOS", () => {
1025 assert.strictEqual(
1026 formatShortcutLabel(modShortcut("d", { shiftKey: true }), "Linux"),
1027 "Ctrl+Shift+D",
1028 );
1029 });
1030​
1031 it("formats labels for plus key", () => {
1032 assert.strictEqual(formatShortcutLabel(modShortcut("+"), "MacIntel"), "⌘+");
1033 assert.strictEqual(formatShortcutLabel(modShortcut("+"), "Linux"), "Ctrl++");
1034 });
1035});
1036​
1037describe("isTerminalClearShortcut", () => {
1038 it("matches Ctrl+L on all platforms", () => {
1039 assert.isTrue(isTerminalClearShortcut(event({ key: "l", ctrlKey: true }), "Linux"));
1040 assert.isTrue(isTerminalClearShortcut(event({ key: "l", ctrlKey: true }), "MacIntel"));
1041 });
1042​
1043 it("matches Cmd+K on macOS", () => {
1044 assert.isTrue(isTerminalClearShortcut(event({ key: "k", metaKey: true }), "MacIntel"));
1045 });
1046​
1047 it("ignores non-keydown events", () => {
1048 assert.isFalse(
1049 isTerminalClearShortcut(event({ type: "keyup", key: "l", ctrlKey: true }), "Linux"),
1050 );
1051 });
1052});
1053​
1054describe("isRichTextBoldShortcut", () => {
1055 it("matches Mod+B without extra modifiers", () => {
1056 assert.isTrue(isRichTextBoldShortcut(event({ key: "b", metaKey: true })));
1057 assert.isTrue(isRichTextBoldShortcut(event({ key: "B", ctrlKey: true })));
1058 });
1059​
1060 it("ignores shifted, alted, bare, and non-keydown presses", () => {
1061 assert.isFalse(isRichTextBoldShortcut(event({ key: "b", metaKey: true, shiftKey: true })));
1062 assert.isFalse(isRichTextBoldShortcut(event({ key: "b", metaKey: true, altKey: true })));
1063 assert.isFalse(isRichTextBoldShortcut(event({ key: "b" })));
1064 assert.isFalse(isRichTextBoldShortcut(event({ key: "i", metaKey: true })));
1065 assert.isFalse(isRichTextBoldShortcut(event({ type: "keyup", key: "b", metaKey: true })));
1066 });
1067});
1068​
1069describe("terminalDeleteShortcutData", () => {
1070 it("maps Cmd+Backspace on macOS to delete-to-line-start", () => {
1071 assert.strictEqual(
1072 terminalDeleteShortcutData(event({ key: "Backspace", metaKey: true }), "MacIntel"),
1073 "\u0015",
1074 );
1075 });
1076​
1077 it("ignores non-macOS platforms and modified variants", () => {
1078 assert.isNull(terminalDeleteShortcutData(event({ key: "Backspace", metaKey: true }), "Linux"));
1079 assert.isNull(
1080 terminalDeleteShortcutData(
1081 event({ key: "Backspace", metaKey: true, altKey: true }),
1082 "MacIntel",
1083 ),
1084 );
1085 });
1086​
1087 it("ignores non-keydown events", () => {
1088 assert.isNull(
1089 terminalDeleteShortcutData(
1090 event({ type: "keyup", key: "Backspace", metaKey: true }),
1091 "MacIntel",
1092 ),
1093 );
1094 });
1095});
1096​
1097describe("terminalNavigationShortcutData", () => {
1098 it("maps Option+Arrow on macOS to word movement", () => {
1099 assert.strictEqual(
1100 terminalNavigationShortcutData(event({ key: "ArrowLeft", altKey: true }), "MacIntel"),
1101 "\u001bb",
1102 );
1103 assert.strictEqual(
1104 terminalNavigationShortcutData(event({ key: "ArrowRight", altKey: true }), "MacIntel"),
1105 "\u001bf",
1106 );
1107 });
1108​
1109 it("maps Cmd+Arrow on macOS to line movement", () => {
1110 assert.strictEqual(
1111 terminalNavigationShortcutData(event({ key: "ArrowLeft", metaKey: true }), "MacIntel"),
1112 "\u0001",
1113 );
1114 assert.strictEqual(
1115 terminalNavigationShortcutData(event({ key: "ArrowRight", metaKey: true }), "MacIntel"),
1116 "\u0005",
1117 );
1118 });
1119​
1120 it("maps Ctrl+Arrow on non-macOS to word movement", () => {
1121 assert.strictEqual(
1122 terminalNavigationShortcutData(event({ key: "ArrowLeft", ctrlKey: true }), "Win32"),
1123 "\u001bb",
1124 );
1125 assert.strictEqual(
1126 terminalNavigationShortcutData(event({ key: "ArrowRight", ctrlKey: true }), "Linux"),
1127 "\u001bf",
1128 );
1129 });
1130​
1131 it("rejects unsupported combinations", () => {
1132 assert.isNull(
1133 terminalNavigationShortcutData(
1134 event({ key: "ArrowLeft", shiftKey: true, altKey: true }),
1135 "MacIntel",
1136 ),
1137 );
1138 assert.isNull(
1139 terminalNavigationShortcutData(event({ key: "ArrowLeft", metaKey: true }), "Linux"),
1140 );
1141 assert.isNull(terminalNavigationShortcutData(event({ key: "a", altKey: true }), "MacIntel"));
1142 });
1143​
1144 it("ignores non-keydown events", () => {
1145 assert.isNull(
1146 terminalNavigationShortcutData(
1147 event({ type: "keyup", key: "ArrowLeft", altKey: true }),
1148 "MacIntel",
1149 ),
1150 );
1151 });
1152});
1153​
1154describe("plus key parsing", () => {
1155 it("matches the plus key shortcut", () => {
1156 const plusBindings = compile([{ shortcut: modShortcut("+"), command: "terminal.toggle" }]);
1157 assert.isTrue(
1158 isTerminalToggleShortcut(event({ key: "+", metaKey: true }), plusBindings, {
1159 platform: "MacIntel",
1160 }),
1161 );
1162 assert.isTrue(
1163 isTerminalToggleShortcut(event({ key: "+", ctrlKey: true }), plusBindings, {
1164 platform: "Linux",
1165 }),
1166 );
1167 });
1168});
1169​
1170describe("composer and pull request shortcuts", () => {
1171 it("fills missing number shortcuts without replacing the saved URL binding", () => {
1172 const olderServerBindings = DEFAULT_RESOLVED_KEYBINDINGS.filter(
1173 (binding) =>
1174 binding.command !== "pullRequest.copyNumber" && binding.command !== "thread.copyReference",
1175 );
1176 const bindings = mergeWithDefaultKeybindings([
1177 ...olderServerBindings,
1178 ...compileResolvedKeybindingsConfig([
1179 { key: "mod+shift+8", command: "thread.copyReference", when: "!terminalFocus" },
1180 ]),
1181 ]);
1182 for (const [key, command] of [
1183 ["k", "pullRequest.copyNumber"],
1184 ["8", "thread.copyReference"],
1185 ["c", null],
1186 ["y", null],
1187 ] as const) {
1188 assert.strictEqual(
1189 resolveShortcutCommand(event({ key, metaKey: true, shiftKey: true }), bindings, {
1190 platform: "MacIntel",
1191 }),
1192 command,
1193 );
1195 });
1196​
1197 it.each(["terminalOpen", "previewFocus", "previewOpen", "modelPickerOpen", "isWeb", "isDesktop"])(
1198 "honors custom PR shortcut conditions for %s",
1199 (condition) => {
1200 const bindings = compileResolvedKeybindingsConfig([
1201 { key: "mod+shift+k", command: "thread.copyReference", when: condition },
1202 { key: "mod+shift+k", command: "pullRequest.copyNumber", when: `!${condition}` },
1203 ]);
1204 const input = event({ key: "k", ctrlKey: true, shiftKey: true });
1205 for (const enabled of [false, true]) {
1206 assert.strictEqual(
1207 resolveShortcutCommand(input, bindings, {
1208 platform: "Linux",
1209 context: { [condition]: enabled },
1210 }),
1211 enabled ? "thread.copyReference" : "pullRequest.copyNumber",
1212 );
1214 },
1215 );
1216​
1217 const shortcuts = [
1218 ["h", "composer.host"],
1219 ["e", "composer.effort"],
1220 ["a", "composer.mode"],
1221 ["x", "composer.workspace"],
1222 ["g", "composer.branch"],
1223 ["l", "composer.previousWorktree"],
1224 ["c", "thread.copyReference"],
1225 ["k", "pullRequest.copyNumber"],
1226 ["Enter", "thread.steerQueuedMessage"],
1227 ] as const;
1228​
1229 for (const platform of ["MacIntel", "Win32", "Linux"]) {
1230 it.each(shortcuts)(
1231 `resolves %s on ${platform} and leaves terminal input alone`,
1232 (key, command) => {
1233 const input = event({
1234 key,
1235 shiftKey: true,
1236 metaKey: platform === "MacIntel",
1237 ctrlKey: platform !== "MacIntel",
1238 });
1239 assert.strictEqual(
1240 resolveShortcutCommand(input, DEFAULT_RESOLVED_KEYBINDINGS, {
1241 platform,
1242 context: { terminalFocus: false },
1243 }),
1244 command,
1245 );
1246 assert.isNull(
1247 resolveShortcutCommand(input, DEFAULT_RESOLVED_KEYBINDINGS, {
1248 platform,
1249 context: { terminalFocus: true },
1250 }),
1251 );
1252 },
1253 );
1255​
1256 for (const platform of ["MacIntel", "Win32", "Linux"]) {
1257 it.each([
1258 ["s", "thread.settle"],
1259 ["p", "thread.pin"],
1260 ])(`preserves the existing %s shortcut on ${platform}`, (key, command) => {
1261 assert.strictEqual(
1262 resolveShortcutCommand(
1263 event({
1264 key,
1265 shiftKey: true,
1266 metaKey: platform === "MacIntel",
1267 ctrlKey: platform !== "MacIntel",
1268 }),
1269 DEFAULT_RESOLVED_KEYBINDINGS,
1270 { platform },
1271 ),
1272 command,
1273 );
1274 });
1276​
1277 const altEffortBindings = compileResolvedKeybindingsConfig([
1278 { key: "mod+alt+e", command: "composer.effort", when: "!terminalFocus" },
1279 ]);
1280​
1281 it("leaves AltGr text entry alone with a custom Alt binding", () => {
1282 for (const platform of ["Win32", "Linux"]) {
1283 const input = event({
1284 key: "€",
1285 code: "KeyE",
1286 ctrlKey: true,
1287 altKey: true,
1288 getModifierState: (key) => key === "AltGraph",
1289 });
1290 assert.isNull(resolveShortcutCommand(input, altEffortBindings, { platform }));
1291 assert.strictEqual(
1292 resolveShortcutCommand({ ...input, getModifierState: () => false }, altEffortBindings, {
1293 platform,
1294 }),
1295 "composer.effort",
1296 );
1298 });
1299​
1300 it("keeps Firefox modifier reporting usable on Windows and macOS", () => {
1301 const getModifierState = (key: string) => key === "AltGraph";
1302 assert.strictEqual(
1303 resolveShortcutCommand(
1304 event({ key: "e", ctrlKey: true, altKey: true, getModifierState }),
1305 altEffortBindings,
1306 { platform: "Win32" },
1307 ),
1308 "composer.effort",
1309 );
1310 assert.strictEqual(
1311 resolveShortcutCommand(
1312 event({ key: "´", code: "KeyE", metaKey: true, altKey: true, getModifierState }),
1313 altEffortBindings,
1314 { platform: "MacIntel" },
1315 ),
1316 "composer.effort",
1317 );
1318 });
1319​
1320 it.each(shortcuts)("uses a custom binding for %s", (_key, command) => {
1321 const bindings = compileResolvedKeybindingsConfig([
1322 { key: "mod+shift+y", command, when: "!terminalFocus" },
1323 ]);
1324 assert.strictEqual(
1325 resolveShortcutCommand(
1326 event({ key: "Y", code: "KeyY", ctrlKey: true, shiftKey: true }),
1327 bindings,
1328 { platform: "Linux" },
1329 ),
1330 command,
1331 );
1332 });
1333​
1334 for (const platform of ["MacIntel", "Win32", "Linux"]) {
1335 it.each([
1336 ["ArrowUp", "modelPicker.previousProvider"],
1337 ["ArrowDown", "modelPicker.nextProvider"],
1338 ] as const)(`limits %s to the model picker on ${platform}`, (key, command) => {
1339 const input = event({
1340 key,
1341 shiftKey: true,
1342 metaKey: platform === "MacIntel",
1343 ctrlKey: platform !== "MacIntel",
1344 });
1345 assert.strictEqual(
1346 resolveShortcutCommand(input, DEFAULT_RESOLVED_KEYBINDINGS, {
1347 platform,
1348 context: { modelPickerOpen: true },
1349 }),
1350 command,
1351 );
1352 assert.isNull(
1353 resolveShortcutCommand(input, DEFAULT_RESOLVED_KEYBINDINGS, {
1354 platform,
1355 context: { modelPickerOpen: false },
1356 }),
1357 );
1358 });
1360});