Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: shortcut follow-up to #14597 for Swiss/Turkish digit chords and Esc-to-stop (#14633)

Michael Hand8d2281befc3
diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsx
index b899473b467..04fe15fcefe 100644
--- a/studio/frontend/src/components/assistant-ui/thread.tsx
+++ b/studio/frontend/src/components/assistant-ui/thread.tsx
@@ -252,6 +252,7 @@ import {
shortcutMatchingEvent,
useKeyboardShortcutsStore,
useShortcut,
+ useShortcutAvailable,
useSettingsDialogStore,
isMacPlatform,
resolveBindings,
@@ -3903,11 +3904,9 @@ const Composer: FC<{
composerIdentityRef.current = composerIdentity;
const chatActive = useChatActive();
// assistant-ui's Escape cancels the run and prevents the key, which would block declining a tool request.
- // Only when decline would take that Escape: not for an image disclosure (no keyboard), nor once rebound.
- const soleToolRequest = useChatRuntimeStore((s) => {
- const pending = Object.values(s.toolConfirmations);
- return pending.length === 1 && !pending[0].imageDisclosure;
- });
+ // Only when decline would take that Escape: its card is keyboard-ready on this screen (not parked in a
+ // background chat, where Escape would then stop nothing), and not once rebound.
+ const declineMounted = useShortcutAvailable("declineToolRequest", true);
const declineOwnsEscape = useKeyboardShortcutsStore((s) => {
const bindings = resolveBindings(s.overrides, "declineToolRequest");
return bindings.primary === "Escape" || bindings.alternate === "Escape";
@@ -5892,7 +5891,7 @@ const Composer: FC<{
// no effect on Latin / CJK / Devanagari.
dir="auto"
{...inputProps}
- cancelOnEscape={!(soleToolRequest && declineOwnsEscape)}
+ cancelOnEscape={!(declineMounted && declineOwnsEscape)}
// Capture, so inputProps keeps the handlers it already owns.
onKeyDownCapture={notePlainPasteChord}
onKeyUpCapture={endPlainPasteChord}
diff --git a/studio/frontend/src/features/interface-zoom/lib/zoom-chords.ts b/studio/frontend/src/features/interface-zoom/lib/zoom-chords.ts
index 951c00c4748..898376af644 100644
--- a/studio/frontend/src/features/interface-zoom/lib/zoom-chords.ts
+++ b/studio/frontend/src/features/interface-zoom/lib/zoom-chords.ts
@@ -50,17 +50,23 @@ const ZOOM_CODES = new Set([
"Numpad0",
]);
+// Digits keep their shortcut: Swiss and Turkish type "+" with Shift on 1 and 4, where Windows and
+// Linux put Ctrl+Shift+1-9 (the workspace chords).
+function keepsShortcut(code: string): boolean {
+ return ZOOM_CODES.has(code) || code.startsWith("Digit");
+}
+
export function zoomTypedOffZoomKey(
event: ZoomKeyEvent,
code: string,
mac: boolean,
): boolean {
- return !ZOOM_CODES.has(code) && zoomDirectionForKey(event, mac) !== null;
+ return !keepsShortcut(code) && zoomDirectionForKey(event, mac) !== null;
}
/**
* Whether a user shortcut takes this press instead: one bound to the canonical chord, or to the
- * exact keys pressed (Mod+Shift+Equal, a keypad key). Only on a zoom key: German and most of Europe
+ * exact keys pressed (Mod+Shift+Equal, a keypad key). Not on punctuation: German and most of Europe
* type "-" on the Slash key, and Mod+Slash there is a shortcut, not the zoom the user typed.
*/
export function zoomChordTaken(
@@ -73,7 +79,7 @@ export function zoomChordTaken(
const pressed = bindingFromEvent(event, mac);
return (
pressed !== null &&
- ZOOM_CODES.has(pressed.code) &&
+ keepsShortcut(pressed.code) &&
owned(formatBindingValue(pressed))
);
}
diff --git a/studio/frontend/tests/shortcut-layout-and-recorder.test.ts b/studio/frontend/tests/shortcut-layout-and-recorder.test.ts
index 6f6d1dea8b7..89936c843b3 100644
--- a/studio/frontend/tests/shortcut-layout-and-recorder.test.ts
+++ b/studio/frontend/tests/shortcut-layout-and-recorder.test.ts
@@ -92,6 +92,28 @@ test('Mod and "-" on the Slash key zooms out, not the shortcuts list', () => {
);
});
+// Swiss Ctrl+Shift+1 and Turkish Ctrl+Shift+4 type "+" and are workspace chords off macOS.
+test("a digit chord that types + keeps its shortcut", () => {
+ for (const [code, key] of [
+ ["Digit1", "+"],
+ ["Digit4", "+"],
+ ] as const) {
+ const event = press(code, key, { ctrlKey: true, shiftKey: true });
+ assert.notEqual(zoomDirectionForKey(event, false), null);
+ assert.equal(zoomTypedOffZoomKey(event, code, false), false, code);
+ const value = `Mod+Shift+${code}`;
+ assert.equal(
+ zoomChordTaken(event, 1, false, (v) => v === value),
+ true,
+ code,
+ );
+ }
+ assert.equal(
+ defaultBindingFor(defOf("switchToChat"), "primary", false),
+ "Mod+Shift+Digit1",
+ );
+});
+
test("stopGeneration ships on Mod+. and clashes with nothing", () => {
const stop = defOf("stopGeneration");
for (const mac of [true, false]) {
@@ -304,14 +326,29 @@ test("Mod+Enter is the platform's own modifier, and never mid-composition", () =
);
});
-test("Escape in the composer is left to a sole pending tool request", () => {
+// A request parked in a background chat has no card here; gating on the store left Escape dead.
+test("Escape in the composer is left to a mounted, keyboard-ready decline", () => {
const thread = readSrc("components/assistant-ui/thread.tsx");
assert.match(
thread,
- /const soleToolRequest = useChatRuntimeStore\(\(s\) => \{/,
+ /const declineMounted = useShortcutAvailable\("declineToolRequest", true\);/,
+ );
+ assert.match(
+ thread,
+ /cancelOnEscape=\{!\(declineMounted && declineOwnsEscape\)\}/,
+ );
+ assert.doesNotMatch(thread, /Object\.values\(s\.toolConfirmations\)/);
+ const controls = readSrc(
+ "components/assistant-ui/tool-confirmation-controls.tsx",
+ );
+ assert.match(
+ controls,
+ /useShortcut\("declineToolRequest", [^\n]+\n\s*enabled: keyboardReady,/,
+ );
+ assert.match(
+ controls,
+ /const keyboardReady =\n\s*!disclosure &&\n\s*chatActive &&\n\s*soleRequest &&/,
);
- assert.match(thread, /cancelOnEscape=\{!\(soleToolRequest && declineOwnsEscape\)\}/);
- assert.match(thread, /pending.length === 1 && !pending\[0\].imageDisclosure/);
});
test("search chats fires from the composer, and toggleSidebar not behind a modal", () => {