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 fixes for non-US layouts, Esc and Cmd-K, plus clearer settings (#14597)

Michael Han8bcbf837bdf3
diff --git a/studio/frontend/scripts/check-bundle-budget.ts b/studio/frontend/scripts/check-bundle-budget.ts
index cedcad4f39d..109a718ba16 100644
--- a/studio/frontend/scripts/check-bundle-budget.ts
+++ b/studio/frontend/scripts/check-bundle-budget.ts
@@ -362,8 +362,11 @@ export const BUDGET = {
// The shared custom folder store and its Undo / already-added toasts in the eager model picker: +557 B raw /
// +627 B transfer against 2749eeedaa (6_879_345 -> 6_879_902 raw, 2_071_823 -> 2_072_450 transfer, 97
// chunks); the folders dialog itself stays lazy. Raised by that, on top of the above.
- transferBytes: 2_073_309,
- rawBytes: 6_882_111,
+ // Shortcut fixes (#14597): stop action, isModEnter, zoom guard and strings in the eager locales:
+ // +3,339 B raw / +1,727 B transfer (6,881,936 -> 6,885,275 B raw,
+ // 2,073,188 -> 2,074,915 B transfer against b2ba86a514, Node 26, 98 chunks). Raised by that.
+ transferBytes: 2_075_036,
+ rawBytes: 6_885_450,
};
// The chunk count is reported but not budgeted. Splitting a page out of the entry raises it while lowering the
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsx
index 5c487458745..87bb1eef411 100644
--- a/studio/frontend/src/components/app-sidebar.tsx
+++ b/studio/frontend/src/components/app-sidebar.tsx
@@ -4109,66 +4109,81 @@ export function AppSidebar() {
isSurfaceBackgrounded("#root")
);
};
- useShortcut("archiveChat", () => {
- if (sidebarCovered()) return;
- if (projectsOnlySelected()) return;
- if (selectionCount > 0) {
- actOnSelection("archiveChat", () => void archiveSelected());
- return;
- }
- if (followsSelectionAction("archiveChat")) return;
- withActiveChat((item) => void handleArchiveThread(item));
- });
- useShortcut("markChatUnread", () => {
- if (sidebarCovered()) return;
- if (projectsOnlySelected()) return;
- if (selectionCount > 0) {
- actOnSelection("markChatUnread", markSelectedUnread);
- return;
- }
- if (followsSelectionAction("markChatUnread")) return;
- withActiveChat((item) =>
- markThreadsUnread(getSidebarItemThreadIds(item), rowIdByThreadId),
- );
- });
- useShortcut("togglePinChat", () => {
- if (sidebarCovered()) return;
- if (projectsOnlySelected()) return;
- if (selectionCount > 0) {
- actOnSelection("togglePinChat", () => pinSelected(!allSelectedPinned));
- return;
- }
- if (followsSelectionAction("togglePinChat")) return;
- withActiveChat((item) => togglePinnedChat(item.id));
- });
+ const sidebarUncovered = () => !sidebarCovered();
+ useShortcut(
+ "archiveChat",
+ () => {
+ if (projectsOnlySelected()) return;
+ if (selectionCount > 0) {
+ actOnSelection("archiveChat", () => void archiveSelected());
+ return;
+ }
+ if (followsSelectionAction("archiveChat")) return;
+ withActiveChat((item) => void handleArchiveThread(item));
+ },
+ { claims: sidebarUncovered },
+ );
+ useShortcut(
+ "markChatUnread",
+ () => {
+ if (projectsOnlySelected()) return;
+ if (selectionCount > 0) {
+ actOnSelection("markChatUnread", markSelectedUnread);
+ return;
+ }
+ if (followsSelectionAction("markChatUnread")) return;
+ withActiveChat((item) =>
+ markThreadsUnread(getSidebarItemThreadIds(item), rowIdByThreadId),
+ );
+ },
+ { claims: sidebarUncovered },
+ );
+ useShortcut(
+ "togglePinChat",
+ () => {
+ if (projectsOnlySelected()) return;
+ if (selectionCount > 0) {
+ actOnSelection("togglePinChat", () => pinSelected(!allSelectedPinned));
+ return;
+ }
+ if (followsSelectionAction("togglePinChat")) return;
+ withActiveChat((item) => togglePinnedChat(item.id));
+ },
+ { claims: sidebarUncovered },
+ );
// A selection made behind a dialog is invisible and still what the mutating chords hit once the
// dialog closes, which is the thing those chords being guarded was meant to prevent.
- useShortcut("selectAllChats", () => {
- if (sidebarCovered()) return;
- selectAllChats();
+ useShortcut("selectAllChats", () => selectAllChats(), {
+ claims: sidebarUncovered,
});
useShortcut("clearChatSelection", clearSelection);
- useShortcut("deleteSelectedChats", () => {
- if (sidebarCovered()) return;
- if (selectionCount > 0) deleteSelected();
- });
+ useShortcut(
+ "deleteSelectedChats",
+ () => {
+ if (selectionCount > 0) deleteSelected();
+ },
+ { claims: sidebarUncovered },
+ );
// Through the dialog: the row's inline pill is rendered by the row, and the open chat may be behind
// a collapsed section, past a folder's "show more", or on a route with no chat list at all, where
// the chord would look dead and leave a rename waiting to appear when the row came back.
- useShortcut("renameChat", () => {
- if (sidebarCovered()) return;
- withActiveChat((item) => openRenameChat(item));
- });
+ useShortcut(
+ "renameChat",
+ () => withActiveChat((item) => openRenameChat(item)),
+ { claims: sidebarUncovered },
+ );
// The clipboard is outside the app, so writing a hidden chat's contents into it from behind a
// dialog is not something the user can take back by closing the dialog.
- useShortcut("copyChatAsMarkdown", () => {
- if (sidebarCovered()) return;
- withActiveChat((item) => void copyChatItemAsMarkdown(item));
- });
- useShortcut("copySessionId", () => {
- if (sidebarCovered()) return;
- withActiveChat((item) => void copyChatSessionId(item));
- });
+ useShortcut(
+ "copyChatAsMarkdown",
+ () => withActiveChat((item) => void copyChatItemAsMarkdown(item)),
+ { claims: sidebarUncovered },
+ );
+ useShortcut(
+ "copySessionId",
+ () => withActiveChat((item) => void copyChatSessionId(item)),
+ { claims: sidebarUncovered },
+ );
// The chat header's menu acts on the open chat through the same handlers as its row's menu and
// the chords above. Every render, so the handlers it calls are never stale.
@@ -4254,18 +4269,33 @@ export function AppSidebar() {
useShortcut("nextChatNeedingAttention", () =>
goToChat(nextAttentionChatItem),
);
- // No undo and no menu item anywhere, so it says what it did.
- useShortcut("clearAllUnreads", () => {
- if (sidebarCovered()) return;
- const state = useChatNavigationStore.getState();
- const cleared = countUnreadRows(state);
- if (state.unreadThreadIds.size === 0) {
- toast.info("No unread chats");
- return;
- }
- state.clearAllUnreads();
- toast.success(`Cleared ${cleared} unread ${cleared === 1 ? "chat" : "chats"}`);
- });
+ useShortcut(
+ "clearAllUnreads",
+ () => {
+ const state = useChatNavigationStore.getState();
+ const cleared = countUnreadRows(state);
+ if (state.unreadThreadIds.size === 0) {
+ toast.info("No unread chats");
+ return;
+ }
+ const threadIds = [...state.unreadThreadIds];
+ const rowIds = { ...state.unreadRowIds };
+ state.clearAllUnreads();
+ toast.success(
+ `Cleared ${cleared} unread ${cleared === 1 ? "chat" : "chats"}`,
+ {
+ action: {
+ label: t("shell.sections.undo"),
+ onClick: () =>
+ useChatNavigationStore
+ .getState()
+ .markThreadsUnread(threadIds, rowIds),
+ },
+ },
+ );
+ },
+ { claims: sidebarUncovered },
+ );
// The six slots register as <Shortcut> elements: a loop of hooks would break the rules of hooks.
const slotShortcuts = (
diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsx
index 21d36583bd7..b899473b467 100644
--- a/studio/frontend/src/components/assistant-ui/thread.tsx
+++ b/studio/frontend/src/components/assistant-ui/thread.tsx
@@ -247,12 +247,14 @@ import {
import { pickerAcceptForTextBasenames } from "@/features/chat/text-attachment-accept";
import {
COMPOSER_INPUT_SELECTOR,
+ isModEnter,
isSurfaceInForeground,
shortcutMatchingEvent,
useKeyboardShortcutsStore,
useShortcut,
useSettingsDialogStore,
isMacPlatform,
+ resolveBindings,
} from "@/features/settings";
import { FIND_SKIP_ATTRIBUTE } from "@/features/find-in-page";
import { translate, useT } from "@/i18n";
@@ -3900,6 +3902,16 @@ const Composer: FC<{
const composerIdentity = threadListItemId ?? "";
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;
+ });
+ const declineOwnsEscape = useKeyboardShortcutsStore((s) => {
+ const bindings = resolveBindings(s.overrides, "declineToolRequest");
+ return bindings.primary === "Escape" || bindings.alternate === "Escape";
+ });
const composerFocusable = useContext(ChatComposerFocusableContext);
// While a Run handoff owns the model picker the input ignores focus(), so its autofocus cannot
// dismiss the picker. Gating autoFocus would focus it when the gate lifts; inert would also block
@@ -5880,6 +5892,7 @@ const Composer: FC<{
// no effect on Latin / CJK / Devanagari.
dir="auto"
{...inputProps}
+ cancelOnEscape={!(soleToolRequest && declineOwnsEscape)}
// Capture, so inputProps keeps the handlers it already owns.
onKeyDownCapture={notePlainPasteChord}
onKeyUpCapture={endPlainPasteChord}
@@ -7629,8 +7642,32 @@ const ComposerRightControls: FC<{
// A reply replayed after a reload has no adapter run for Cancel to abort.
stopRecoveredRun(threadRemoteId);
};
+ const aui = useAui();
+ const chatActive = useChatActive();
+ const threadRunning = useAuiState(({ thread }) => thread.isRunning);
+ const controlsRef = useRef<HTMLDivElement>(null);
+ // Claimed only while foreground: Compare keeps this composer mounted and inert behind its own.
+ useShortcut(
+ "stopGeneration",
+ () => {
+ const research = isResearchActive;
+ stop();
+ if (research) return;
+ const composer = aui.composer();
+ if (composer.getState().canCancel) composer.cancel();
+ },
+ {
+ enabled: chatActive && (threadRunning || isResearchActive),
+ claims: () =>
+ controlsRef.current !== null &&
+ !controlsRef.current.closest('[aria-hidden="true"], [inert]'),
+ },
+ );
return (
- <div className="aui-composer-action-wrapper flex shrink-0 items-center gap-1.5">
+ <div
+ ref={controlsRef}
+ className="aui-composer-action-wrapper flex shrink-0 items-center gap-1.5"
+ >
<ReasoningToggle side={menuSide} />
{/* Starts dictation; the recording bar then covers the input row and owns
the stop and send actions. */}
@@ -8443,7 +8480,7 @@ const AssistantMessage: FC = () => {
onInput={adjustHeight}
onKeyDown={(e) => {
e.stopPropagation();
- if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
+ if (isModEnter(e)) {
handleSave();
}
if (e.key === 'Escape') {
diff --git a/studio/frontend/src/components/assistant-ui/tool-confirmation-controls.tsx b/studio/frontend/src/components/assistant-ui/tool-confirmation-controls.tsx
index 4c1fe3fdecd..e39eeba6f61 100644
--- a/studio/frontend/src/components/assistant-ui/tool-confirmation-controls.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-confirmation-controls.tsx
@@ -149,36 +149,20 @@ export function ToolConfirmationControls({
!(autoAllowed && !failed);
// The Chat route stays mounted under a dialog, so `keyboardReady` still says
// yes while the request is hidden behind one. Answering a tool call the user
- // cannot see must not be reachable by accident, so both chords ask here.
- const chatCovered = () => isSurfaceBackgrounded(COMPOSER_INPUT_SELECTOR);
- useShortcut(
- "approveToolRequest",
- () => {
- if (chatCovered()) return;
- void resolve("allow");
- },
- {
- enabled: keyboardReady,
- // Enter belongs to the composer while it has focus.
- skipInTextFields: true,
- },
- );
- useShortcut(
- "declineToolRequest",
- () => {
- if (chatCovered()) return;
- void resolve("deny");
- },
- {
- enabled: keyboardReady,
- skipInTextFields: true,
- // A request usually arrives with the composer still focused from the prompt that caused it,
- // and Escape types nothing there, so the gate would hold the decline back at the one moment
- // it is most wanted. Enter above gets no such pass: that key sends. Every other field keeps
- // its Escape, the queued-prompt editor and the settings search included.
- textFieldException: COMPOSER_INPUT_SELECTOR,
- },
- );
+ // cannot see must not be reachable by accident, so both chords ask here, before the key is taken.
+ const chatUncovered = () => !isSurfaceBackgrounded(COMPOSER_INPUT_SELECTOR);
+ useShortcut("approveToolRequest", () => void resolve("allow"), {
+ enabled: keyboardReady,
+ claims: chatUncovered,
+ skipInTextFields: true,
+ });
+ useShortcut("declineToolRequest", () => void resolve("deny"), {
+ enabled: keyboardReady,
+ claims: chatUncovered,
+ skipInTextFields: true,
+ // Escape passes the gate from the composer (it types nothing there); Enter does not: it sends.
+ textFieldException: COMPOSER_INPUT_SELECTOR,
+ });
if (!showControls) return null;
// Auto-approved tools resolve silently unless the post fails.
diff --git a/studio/frontend/src/components/ui/sidebar.tsx b/studio/frontend/src/components/ui/sidebar.tsx
index 6c8fbd3c0c4..9135ea78202 100644
--- a/studio/frontend/src/components/ui/sidebar.tsx
+++ b/studio/frontend/src/components/ui/sidebar.tsx
@@ -73,6 +73,9 @@ function useSidebar() {
return context
}
+const OPEN_DIALOG_SELECTOR =
+ '[data-slot="dialog-content"][data-state="open"], [data-slot="alert-dialog-content"][data-state="open"]'
+
function SidebarProvider({
defaultOpen = true,
open: openProp,
@@ -146,8 +149,11 @@ function SidebarProvider({
return setOpen((open) => !open)
}, [isMobile, setOpen, setOpenMobile, hasPinMode, togglePinnedProp])
- // Chord comes from the shortcuts store, so Settings -> Shortcuts can rebind or clear it.
- useShortcut("toggleSidebar", toggleSidebar)
+ // Not behind an open dialog (Settings leaves the app un-hidden); the mobile drawer is itself one.
+ useShortcut("toggleSidebar", toggleSidebar, {
+ claims: () =>
+ (isMobile && openMobile) || document.querySelector(OPEN_DIALOG_SELECTOR) === null,
+ })
const pinned = pinnedProp ?? false
const setPinned = setPinnedProp ?? noop
diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsx
index 2b06dd20187..820964f20be 100644
--- a/studio/frontend/src/features/chat/chat-page.tsx
+++ b/studio/frontend/src/features/chat/chat-page.tsx
@@ -4230,26 +4230,18 @@ export function ChatPage({
const headerPickersShown = active && view.mode !== "compare";
// This page stays mounted under a dialog, so `enabled` still says yes while the header is inert; without a
// press-time check the chord opens a popover on the covered surface. Backgrounded, not "not in the foreground":
- // an unrendered layout is not a covered one.
- const chatCovered = () => isSurfaceBackgrounded(COMPOSER_INPUT_SELECTOR);
- useShortcut(
- "openModelPicker",
- () => {
- if (chatCovered()) return;
- toggleModelSelector();
- },
- { enabled: headerPickersShown },
- );
+ // an unrendered layout is not a covered one. A claim, so a covered press still reaches the dialog.
+ const chatUncovered = () => !isSurfaceBackgrounded(COMPOSER_INPUT_SELECTOR);
+ useShortcut("openModelPicker", toggleModelSelector, {
+ enabled: headerPickersShown,
+ claims: chatUncovered,
+ });
// The same condition the switcher renders by, so the chord cannot open a control that is not there.
const projectSwitcherShown = headerPickersShown && Boolean(currentProjectId);
- useShortcut(
- "openProjectPicker",
- () => {
- if (chatCovered()) return;
- setProjectPickerOpen(true);
- },
- { enabled: projectSwitcherShown },
- );
+ useShortcut("openProjectPicker", () => setProjectPickerOpen(true), {
+ enabled: projectSwitcherShown,
+ claims: chatUncovered,
+ });
// A picker left open would come back on the next visit as a ghost. Off-route is one way to leave it (this page
// stays mounted), and so is entering Compare or a standalone chat taking the project away. Adjusted during
// render, as React prescribes for derived state.
@@ -4287,29 +4279,18 @@ export function ChatPage({
},
[],
);
- useShortcut(
- "cycleReasoningEffort",
- () => {
- if (chatCovered()) return;
- shiftReasoningEffort(1, true);
- },
- { enabled: active },
- );
- useShortcut(
- "increaseReasoningEffort",
- () => {
- if (chatCovered()) return;
- shiftReasoningEffort(1, false);
- },
- { enabled: active },
- );
+ useShortcut("cycleReasoningEffort", () => shiftReasoningEffort(1, true), {
+ enabled: active,
+ claims: chatUncovered,
+ });
+ useShortcut("increaseReasoningEffort", () => shiftReasoningEffort(1, false), {
+ enabled: active,
+ claims: chatUncovered,
+ });
useShortcut(
"decreaseReasoningEffort",
- () => {
- if (chatCovered()) return;
- shiftReasoningEffort(-1, false);
- },
- { enabled: active },
+ () => shiftReasoningEffort(-1, false),
+ { enabled: active, claims: chatUncovered },
);
const fastModeSupported = providerSupportsFastMode(
@@ -4319,13 +4300,12 @@ export function ChatPage({
useShortcut(
"toggleFastMode",
() => {
- if (chatCovered()) return;
const state = useChatRuntimeStore.getState();
const next = !state.params.fastMode;
state.setParams({ ...state.params, fastMode: next });
toast.success(next ? "Fast mode on" : "Fast mode off");
},
- { enabled: active && fastModeSupported },
+ { enabled: active && fastModeSupported, claims: chatUncovered },
);
const { isMobile, pinned } = useSidebar();
// The tour's orientation step spotlights the nav, so hold it open for that step. The hold is
diff --git a/studio/frontend/src/features/chat/components/chat-search-dialog.tsx b/studio/frontend/src/features/chat/components/chat-search-dialog.tsx
index 851c7bc4d05..834f689d366 100644
--- a/studio/frontend/src/features/chat/components/chat-search-dialog.tsx
+++ b/studio/frontend/src/features/chat/components/chat-search-dialog.tsx
@@ -9,6 +9,7 @@ import {
CommandList,
} from "@/components/ui/command";
import {
+ COMPOSER_INPUT_SELECTOR,
type ShortcutId,
isImeComposing,
triggerShortcut,
@@ -252,10 +253,10 @@ export function ChatSearchDialog() {
return () => clearTimeout(timer);
}, [isOpen]);
- // skipInTextFields keeps the composer's own Cmd-K and any browser find intact while the user is
- // typing, as the hand-rolled handler did.
+ // Only the composer passes: an editor in other fields may chord on Cmd-K.
useShortcut("searchChats", () => useChatSearchStore.getState().open(), {
skipInTextFields: true,
+ textFieldException: COMPOSER_INPUT_SELECTOR,
});
const go = (to: () => void) => () => {
diff --git a/studio/frontend/src/features/chat/components/chat-skills-dialog.tsx b/studio/frontend/src/features/chat/components/chat-skills-dialog.tsx
index 9006d074392..6a137c4b7f0 100644
--- a/studio/frontend/src/features/chat/components/chat-skills-dialog.tsx
+++ b/studio/frontend/src/features/chat/components/chat-skills-dialog.tsx
@@ -31,6 +31,7 @@ import { Input } from "@/components/ui/input";
import { Spinner } from "@/components/ui/spinner";
import { Switch } from "@/components/ui/switch";
import { Textarea } from "@/components/ui/textarea";
+import { isModEnter } from "@/features/settings/lib/keyboard-shortcuts";
import { useT } from "@/i18n";
import {
ChevronLeftStandardIcon,
@@ -47,7 +48,6 @@ import {
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import {
- type KeyboardEvent,
type ReactElement,
type ReactNode,
useEffect,
@@ -87,10 +87,6 @@ function describe(cause: unknown): string | undefined {
return cause instanceof Error ? cause.message : undefined;
}
-function isChord(event: KeyboardEvent): boolean {
- return event.key === "Enter" && (event.metaKey || event.ctrlKey);
-}
-
function isEditable(skill: SkillRecord): boolean {
return skill.valid && skill.source === "agents" && !skill.linked;
}
@@ -942,7 +938,7 @@ function Editor({
if (!readOnly) onSubmit();
}}
onKeyDown={(event) => {
- if (isChord(event) && !readOnly) {
+ if (isModEnter(event) && !readOnly) {
event.preventDefault();
onSubmit();
}
diff --git a/studio/frontend/src/features/chat/components/edit-project-dialog.tsx b/studio/frontend/src/features/chat/components/edit-project-dialog.tsx
index b4c37a2082c..6cd04de395e 100644
--- a/studio/frontend/src/features/chat/components/edit-project-dialog.tsx
+++ b/studio/frontend/src/features/chat/components/edit-project-dialog.tsx
@@ -16,6 +16,7 @@ import { Textarea } from "@/components/ui/textarea";
import type { NativeDocumentFolderSelection } from "@/features/native-intents";
import { WorkingFolderPicker } from "./working-folder-picker";
import { LinkedFoldersManager } from "@/features/rag";
+import { isModEnter } from "@/features/settings/lib/keyboard-shortcuts";
import { toast } from "@/lib/toast";
import { Folder02Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
@@ -163,7 +164,7 @@ export function EditProjectDialog({
})
)
return;
- if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
+ if (isModEnter(e)) {
e.preventDefault();
void save();
}
diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsx
index 0195793318d..7a6e320f1d9 100644
--- a/studio/frontend/src/features/chat/shared-composer.tsx
+++ b/studio/frontend/src/features/chat/shared-composer.tsx
@@ -2554,6 +2554,10 @@ export function SharedComposer({
},
{ enabled: chatActive },
);
+ useShortcut("stopGeneration", stop, {
+ enabled: chatActive && busy,
+ claims: () => isSurfaceInForeground(COMPOSER_INPUT_SELECTOR),
+ });
const runPromptList = useCallback(
(items: string[]) => {
diff --git a/studio/frontend/src/features/images/paste-parameters-dialog.tsx b/studio/frontend/src/features/images/paste-parameters-dialog.tsx
index a14349d5ea2..3a95741be13 100644
--- a/studio/frontend/src/features/images/paste-parameters-dialog.tsx
+++ b/studio/frontend/src/features/images/paste-parameters-dialog.tsx
@@ -11,6 +11,7 @@ import {
DialogTitle,
} from "@/components/ui/dialog";
import { Textarea } from "@/components/ui/textarea";
+import { isModEnter } from "@/features/settings/lib/keyboard-shortcuts";
const EXAMPLE =
"a sloth hiking, <lora:sloth-style:0.8>\nNegative prompt: blurry\nSteps: 28, Sampler: DPM++ 2M, Schedule type: Karras, CFG scale: 6, Seed: 12345, Size: 832x1216";
@@ -65,7 +66,7 @@ export function PasteParametersDialog({
value={text}
onChange={(e) => onTextChange(e.target.value)}
onKeyDown={(e) => {
- if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
+ if (isModEnter(e)) {
e.preventDefault();
void apply();
}
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 af397f0b028..951c00c4748 100644
--- a/studio/frontend/src/features/interface-zoom/lib/zoom-chords.ts
+++ b/studio/frontend/src/features/interface-zoom/lib/zoom-chords.ts
@@ -41,9 +41,27 @@ export function zoomDirectionForKey(
return null;
}
+const ZOOM_CODES = new Set([
+ "Equal",
+ "Minus",
+ "Digit0",
+ "NumpadAdd",
+ "NumpadSubtract",
+ "Numpad0",
+]);
+
+export function zoomTypedOffZoomKey(
+ event: ZoomKeyEvent,
+ code: string,
+ mac: boolean,
+): boolean {
+ return !ZOOM_CODES.has(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).
+ * exact keys pressed (Mod+Shift+Equal, a keypad key). Only on a zoom key: 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(
event: ZoomKeyEvent,
@@ -53,5 +71,9 @@ export function zoomChordTaken(
): boolean {
if (owned(ZOOM_CHORDS[direction])) return true;
const pressed = bindingFromEvent(event, mac);
- return pressed !== null && owned(formatBindingValue(pressed));
+ return (
+ pressed !== null &&
+ ZOOM_CODES.has(pressed.code) &&
+ owned(formatBindingValue(pressed))
+ );
}
diff --git a/studio/frontend/src/features/settings/components/decision-try-dialog.tsx b/studio/frontend/src/features/settings/components/decision-try-dialog.tsx
index 9128d554b7b..be1ce4271c3 100644
--- a/studio/frontend/src/features/settings/components/decision-try-dialog.tsx
+++ b/studio/frontend/src/features/settings/components/decision-try-dialog.tsx
@@ -80,9 +80,9 @@ import {
DECISION_MODEL_LABELS,
isClefDecisionModel,
} from "../lib/decision-model-labels";
-import { isMacPlatform } from "../lib/keyboard-shortcuts";
+import { isModEnter, modEnterLabel } from "../lib/keyboard-shortcuts";
-const SHORTCUT = isMacPlatform() ? "⌘↵" : "Ctrl ↵";
+const SHORTCUT = modEnterLabel();
const TYPE_LABELS: Record<DecisionType, TranslationKey> = {
noul: "decisions.typeNoul",
@@ -988,9 +988,7 @@ export function DecisionTryDialog({
const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
if (
- event.key !== "Enter" ||
- !(event.metaKey || event.ctrlKey) ||
- event.nativeEvent.isComposing ||
+ !isModEnter(event) ||
event.repeat ||
(event.target instanceof Element &&
event.target.closest('[role="menu"], [role="listbox"]'))
diff --git a/studio/frontend/src/features/settings/hooks/use-shortcut.ts b/studio/frontend/src/features/settings/hooks/use-shortcut.ts
index c035dfbbbd9..658dcca5d13 100644
--- a/studio/frontend/src/features/settings/hooks/use-shortcut.ts
+++ b/studio/frontend/src/features/settings/hooks/use-shortcut.ts
@@ -2,12 +2,14 @@
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
import { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from "react";
+import { zoomTypedOffZoomKey } from "../../interface-zoom/lib/zoom-chords";
import {
SHORTCUT_SLOTS,
type ShortcutBinding,
type ShortcutId,
activationBelongsToFocus,
formatBindingLabel,
+ isMacPlatform,
matchesBinding,
parseBinding,
} from "../lib/keyboard-shortcuts";
@@ -250,6 +252,7 @@ export function useShortcut(
if (isImeComposing(event)) return;
const hit = bindings.find((binding) => matchesBinding(binding, event));
if (!hit) return;
+ if (zoomTypedOffZoomKey(event, hit.code, isMacPlatform())) return;
// The exception is for a chord that types nothing there. Decline ships on Escape; rebound to
// Enter or a letter, the same pass would deny the request as the user edits the prompt.
const exception = typesInTextField(hit) ? undefined : textFieldException;
diff --git a/studio/frontend/src/features/settings/index.ts b/studio/frontend/src/features/settings/index.ts
index 695526b0360..d92dfa64ef6 100644
--- a/studio/frontend/src/features/settings/index.ts
+++ b/studio/frontend/src/features/settings/index.ts
@@ -117,6 +117,7 @@ export {
currentBinding,
shortcutMatchingEvent,
useKeyboardShortcutsStore,
+ resolveBindings,
} from "./stores/keyboard-shortcuts-store";
export type { ShortcutId } from "./lib/keyboard-shortcuts";
export { SETTINGS_TABS, useSettingsDialogStore } from "./stores/settings-dialog-store";
@@ -134,4 +135,8 @@ export {
} from "./stores/voice-settings-store";
export type { Palette, ResolvedTheme, Theme } from "./stores/theme-store";
-export { isMacPlatform } from "./lib/keyboard-shortcuts";
+export {
+ isMacPlatform,
+ isModEnter,
+ modEnterLabel,
+} from "./lib/keyboard-shortcuts";
diff --git a/studio/frontend/src/features/settings/lib/keyboard-shortcuts.ts b/studio/frontend/src/features/settings/lib/keyboard-shortcuts.ts
index e1f7d1a8246..49aeb5d7df1 100644
--- a/studio/frontend/src/features/settings/lib/keyboard-shortcuts.ts
+++ b/studio/frontend/src/features/settings/lib/keyboard-shortcuts.ts
@@ -60,6 +60,7 @@ export type ShortcutId =
| "sendMessage"
| "queueMessage"
| "steerMessage"
+ | "stopGeneration"
| "toggleFastMode"
| "copyChatAsMarkdown"
| "copySessionId"
@@ -236,6 +237,8 @@ export const SHORTCUT_DEFS: ShortcutDef[] = [
// name the behaviour instead of flipping it. Chat settings picks the default.
def("queueMessage", null),
def("steerMessage", null),
+ // ⌘. is the macOS cancel chord. Safari's Stop loading shares it, but only while a page loads.
+ def("stopGeneration", "Mod+Period"),
def("toggleFastMode", null),
def("copyChatAsMarkdown", null),
@@ -319,6 +322,8 @@ const BROWSER_RESERVED_VALUES = new Set<string>([
"Mod+Shift+KeyP",
// Chrome's tab search, and Firefox's add-ons manager.
"Mod+Shift+KeyA",
+ // Firefox's Reader View, ⌥⌘R and Ctrl+Alt+R. renameChat ships on it anyway; this warns a web user.
+ "Mod+Alt+KeyR",
"Mod+Tab",
"Mod+Shift+Tab",
"Ctrl+Tab",
@@ -375,6 +380,31 @@ export function isBrowserReservedBinding(
: NON_MAC_RESERVED_VALUES.has(value);
}
+/** Tab and window chords a page never sees; only the desktop app can run them. */
+const BROWSER_UNREACHABLE_VALUES = new Set<string>([
+ "Mod+KeyN",
+ "Mod+Shift+KeyN",
+ "Mod+KeyT",
+ "Mod+Shift+KeyT",
+ "Mod+KeyW",
+ "Mod+Shift+KeyW",
+ "Mod+Tab",
+ "Mod+Shift+Tab",
+ "Ctrl+Tab",
+ "Ctrl+Shift+Tab",
+]);
+
+export function isBrowserUnreachableBinding(
+ value: string | null,
+ mac = isMacPlatform(),
+): boolean {
+ if (value === null) return false;
+ if (BROWSER_UNREACHABLE_VALUES.has(value)) return true;
+ return mac
+ ? value === "Mod+Shift+BracketLeft" || value === "Mod+Shift+BracketRight"
+ : value === "Mod+PageUp" || value === "Mod+PageDown";
+}
+
/**
* Keys the browser turns into a click on whatever control has focus. A chord built from one of
* these with no modifier has to leave that click alone, or pressing Enter on a focused Deny
@@ -428,6 +458,28 @@ export function isMacPlatform(): boolean {
return macPlatform;
}
+/** Not while an IME composes (isComposing, on nativeEvent for React); keyCode 229 alone is idle macOS Pinyin. */
+export function isModEnter(
+ event: {
+ key: string;
+ metaKey: boolean;
+ ctrlKey: boolean;
+ isComposing?: boolean;
+ nativeEvent?: { isComposing?: boolean };
+ },
+ mac = isMacPlatform(),
+): boolean {
+ if (event.key !== "Enter") return false;
+ if (event.isComposing || event.nativeEvent?.isComposing) return false;
+ return mac
+ ? event.metaKey && !event.ctrlKey
+ : event.ctrlKey && !event.metaKey;
+}
+
+export function modEnterLabel(mac = isMacPlatform()): string {
+ return mac ? "⌘↵" : "Ctrl+Enter";
+}
+
/** Serialize to the stored form, e.g. "Mod+Shift+KeyO". */
export function formatBindingValue(binding: ShortcutBinding): string {
const parts: string[] = [];
@@ -476,6 +528,18 @@ export function parseBinding(
return binding;
}
+/** Off macOS, Super or AltGr: bindingFromEvent returns null for both, which otherwise reads as "still assembling". */
+export function unrecordableModifier(
+ event: Parameters<typeof bindingFromEvent>[0],
+ mac = isMacPlatform(),
+): "meta" | "altGraph" | null {
+ if (mac) return null;
+ const code = eventCode(event, mac);
+ if (!code || isModifierCode(code)) return null;
+ if (event.metaKey) return "meta";
+ return isAltGraphEvent(event) ? "altGraph" : null;
+}
+
/** Build a binding from a keydown. Returns null while only modifiers are held. */
export function bindingFromEvent(
event: {
@@ -622,10 +686,25 @@ export function keystrokeMatchesBinding(
return true;
}
+const NUMPAD_NAMES: Record<string, string> = {
+ Add: "+",
+ Subtract: "-",
+ Multiply: "*",
+ Divide: "/",
+ Decimal: ".",
+ Comma: ",",
+ Equal: "=",
+ Enter: "Enter",
+};
+
/** Human label for a code: "KeyO" -> "O", "Comma" -> ",", "ArrowUp" -> "↑". */
-export function formatCode(code: string): string {
+export function formatCode(code: string, mac = isMacPlatform()): string {
if (code.startsWith("Key") && code.length === 4) return code.slice(3);
if (code.startsWith("Digit") && code.length === 6) return code.slice(5);
+ if (code.startsWith("Numpad")) {
+ const rest = code.slice(6);
+ return `Num ${NUMPAD_NAMES[rest] ?? rest}`;
+ }
const named: Record<string, string> = {
Comma: ",",
Period: ".",
@@ -635,14 +714,23 @@ export function formatCode(code: string): string {
BracketLeft: "[",
BracketRight: "]",
Backslash: "\\",
+ // The ISO key beside left Shift types < on most of Europe and \ in the UK, so no glyph fits all.
+ IntlBackslash: "ISO \\",
+ IntlRo: "Ro",
+ IntlYen: "¥",
Minus: "-",
Equal: "=",
Backquote: "`",
Space: "Space",
Enter: "Enter",
Escape: "Esc",
- Backspace: "⌫",
+ Backspace: mac ? "⌫" : "Backspace",
Delete: "Del",
+ Insert: "Ins",
+ Home: "Home",
+ End: "End",
+ PageUp: "Page Up",
+ PageDown: "Page Down",
Tab: "Tab",
ArrowUp: "↑",
ArrowDown: "↓",
@@ -658,7 +746,7 @@ export function formatBindingLabel(
binding: ShortcutBinding,
mac = isMacPlatform(),
): string {
- const key = formatCode(binding.code);
+ const key = formatCode(binding.code, mac);
if (mac) {
let out = "";
if (binding.ctrl) out += "⌃";
@@ -675,6 +763,42 @@ export function formatBindingLabel(
return parts.join("+");
}
+function bindingSearchText(binding: ShortcutBinding, mac: boolean): string {
+ const words = [formatBindingLabel(binding, mac)];
+ if (binding.mod) words.push(mac ? "⌘ cmd command" : "ctrl control");
+ if (binding.ctrl) words.push("⌃ ctrl control");
+ if (binding.alt) words.push(mac ? "⌥ opt option alt" : "alt opt option");
+ if (binding.shift) words.push("⇧ shift");
+ return words.join(" ").toLowerCase();
+}
+
+const MODIFIER_GLYPHS = new Set(["⌘", "⌃", "⌥", "⇧"]);
+
+/** Every word must match; a one-letter word is the key, so "k" finds ⌘K, not every chord with a k. */
+export function bindingMatchesQuery(
+ binding: ShortcutBinding,
+ query: string,
+ mac = isMacPlatform(),
+): boolean {
+ const q = query.trim().toLowerCase();
+ if (!q) return false;
+ if (formatBindingLabel(binding, mac).toLowerCase().includes(q)) return true;
+ const text = bindingSearchText(binding, mac);
+ const key = formatCode(binding.code, mac).toLowerCase();
+ const words = q
+ .replace(/[⌘⌃⌥⇧]/g, (glyph) => ` ${glyph} `)
+ .split(/[\s+]+/)
+ .filter(Boolean);
+ return (
+ words.length > 0 &&
+ words.every((word) =>
+ word.length === 1 && !MODIFIER_GLYPHS.has(word)
+ ? word === key
+ : text.includes(word),
+ )
+ );
+}
+
export function formatBindingValueLabel(
value: string | null,
mac = isMacPlatform(),
diff --git a/studio/frontend/src/features/settings/settings-search.ts b/studio/frontend/src/features/settings/settings-search.ts
index a03fed4a35f..1d06b2a4cdc 100644
--- a/studio/frontend/src/features/settings/settings-search.ts
+++ b/studio/frontend/src/features/settings/settings-search.ts
@@ -324,6 +324,7 @@ export const SETTINGS_SEARCH_INDEX: Record<SettingsTab, TranslationKey[]> = {
"settings.keyboardShortcuts.actions.sendMessage.label",
"settings.keyboardShortcuts.actions.queueMessage.label",
"settings.keyboardShortcuts.actions.steerMessage.label",
+ "settings.keyboardShortcuts.actions.stopGeneration.label",
"settings.keyboardShortcuts.actions.toggleFastMode.label",
"settings.keyboardShortcuts.actions.copyChatAsMarkdown.label",
"settings.keyboardShortcuts.actions.copySessionId.label",
diff --git a/studio/frontend/src/features/settings/stores/keyboard-shortcuts-store.ts b/studio/frontend/src/features/settings/stores/keyboard-shortcuts-store.ts
index c7053d4f48f..f9a884966bb 100644
--- a/studio/frontend/src/features/settings/stores/keyboard-shortcuts-store.ts
+++ b/studio/frontend/src/features/settings/stores/keyboard-shortcuts-store.ts
@@ -269,6 +269,15 @@ export const useKeyboardShortcutsStore = create<KeyboardShortcutsState>(
}),
);
+// Else this tab's next edit writes its stale copy over another tab's. A null key is localStorage.clear().
+if (typeof window !== "undefined") {
+ window.addEventListener("storage", (event) => {
+ if (event.key === STORAGE_KEY || event.key === null) {
+ useKeyboardShortcutsStore.setState({ overrides: loadOverrides() });
+ }
+ });
+}
+
/** Binding in force right now, for non-React callers (keydown handlers). */
export function currentBinding(
id: ShortcutId,
diff --git a/studio/frontend/src/features/settings/tabs/keyboard-shortcuts-tab.tsx b/studio/frontend/src/features/settings/tabs/keyboard-shortcuts-tab.tsx
index 8659a3b50ff..b85e69e956e 100644
--- a/studio/frontend/src/features/settings/tabs/keyboard-shortcuts-tab.tsx
+++ b/studio/frontend/src/features/settings/tabs/keyboard-shortcuts-tab.tsx
@@ -8,6 +8,8 @@ import {
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip";
+import { useChatPreferencesStore } from "@/features/chat/stores/chat-preferences-store";
+import { composerShortcutLabels } from "@/features/chat/utils/composer-preferences";
import { useT } from "@/i18n";
import { isTauri } from "@/lib/api-base";
import { cn } from "@/lib/utils";
@@ -35,14 +37,17 @@ import {
type ShortcutId,
type ShortcutSlot,
bindingFromEvent,
+ bindingMatchesQuery,
defaultBindingFor,
formatBindingLabel,
formatBindingValue,
isAcceptableBinding,
isBrowserReservedBinding,
+ isBrowserUnreachableBinding,
isMacPlatform,
keystrokeMatchesBinding,
parseBinding,
+ unrecordableModifier,
} from "../lib/keyboard-shortcuts";
import {
findConflicts,
@@ -139,6 +144,10 @@ export function KeyboardShortcutsTab() {
const [recording, setRecording] = useState<RecordingTarget | null>(null);
// Shown under the row being recorded when the pressed chord is rejected.
const [recordingError, setRecordingError] = useState<string | null>(null);
+ const [justRecorded, setJustRecorded] = useState<RecordingTarget | null>(
+ null,
+ );
+ const sendShortcut = useChatPreferencesStore((s) => s.sendShortcut);
// Search the list by pressing a chord instead of typing its name.
const [byKeystroke, setByKeystroke] = useState(false);
const [keystroke, setKeystroke] = useState<ShortcutBinding | null>(null);
@@ -185,13 +194,26 @@ export function KeyboardShortcutsTab() {
return;
}
const binding = bindingFromEvent(event);
- // Modifier held on its own: the user is still assembling the chord.
- if (!binding) return;
+ if (!binding) {
+ // A real key with the Windows key or AltGr, which cannot be bound; else still assembling.
+ const refused = unrecordableModifier(event);
+ if (refused) {
+ setRecordingError(
+ t(
+ refused === "meta"
+ ? "settings.keyboardShortcuts.metaUnsupported"
+ : "settings.keyboardShortcuts.altGraphUnsupported",
+ ),
+ );
+ }
+ return;
+ }
if (!isAcceptableBinding(binding, def?.allowBareKey)) {
setRecordingError(t("settings.keyboardShortcuts.needsModifier"));
return;
}
setBinding(recording.id, recording.slot, formatBindingValue(binding));
+ setJustRecorded(recording);
setRecording(null);
setRecordingError(null);
};
@@ -265,9 +287,7 @@ export function KeyboardShortcutsTab() {
if (haystack.toLowerCase().includes(q)) return true;
return SHORTCUT_SLOTS.some((slot) => {
const parsed = parseBinding(resolveBinding(overrides, def.id, slot));
- return parsed
- ? formatBindingLabel(parsed, mac).toLowerCase().includes(q)
- : false;
+ return parsed ? bindingMatchesQuery(parsed, q, mac) : false;
});
}).map((def) => def.id),
);
@@ -282,6 +302,7 @@ export function KeyboardShortcutsTab() {
const startRecording = (def: ShortcutDef, slot: ShortcutSlot) => {
setRecordingError(null);
+ setJustRecorded(null);
setRecording(
recording?.id === def.id && recording.slot === slot
? null
@@ -289,6 +310,33 @@ export function KeyboardShortcutsTab() {
);
};
+ const builtInKey = (id: ShortcutId): string | null => {
+ if (id === "clearChatSelection") return "Esc";
+ if (id !== "sendMessage") return null;
+ const send = composerShortcutLabels(sendShortcut, mac, "").send;
+ return sendShortcut === "mod-enter-multiline"
+ ? `${send} / ${composerShortcutLabels(sendShortcut, mac, "\n").send}`
+ : send;
+ };
+
+ const conflictingLabels = (id: ShortcutId): string => {
+ const values = new Set(
+ SHORTCUT_SLOTS.map((slot) => resolveBinding(overrides, id, slot)).filter(
+ (value): value is string => value !== null,
+ ),
+ );
+ return SHORTCUT_DEFS.filter(
+ (other) =>
+ other.id !== id &&
+ SHORTCUT_SLOTS.some((slot) => {
+ const value = resolveBinding(overrides, other.id, slot);
+ return value !== null && values.has(value);
+ }),
+ )
+ .map((other) => t(other.labelKey))
+ .join(", ");
+ };
+
/** One chord line: cap and pencil left, trash right. A row with an
* alternate stacks two. */
const renderSlot = (def: ShortcutDef, slot: ShortcutSlot): ReactNode => {
@@ -300,9 +348,11 @@ export function KeyboardShortcutsTab() {
? "settings.keyboardShortcuts.primarySlot"
: "settings.keyboardShortcuts.alternateSlot",
);
- // The warning rides the cap's tooltip, not a third line of description.
const reserved =
!isTauri && !isRecording && isBrowserReservedBinding(value);
+ const desktopOnly =
+ !isTauri && !isRecording && isBrowserUnreachableBinding(value, mac);
+ const builtIn = slot === "primary" ? builtInKey(def.id) : null;
return (
<div key={slot} className="flex items-center justify-between gap-3">
@@ -313,7 +363,11 @@ export function KeyboardShortcutsTab() {
? t("settings.keyboardShortcuts.recording")
: parsed
? formatBindingLabel(parsed, mac)
- : t("settings.keyboardShortcuts.unassigned")
+ : builtIn
+ ? t("settings.keyboardShortcuts.builtInKey", {
+ key: builtIn,
+ })
+ : t("settings.keyboardShortcuts.unassigned")
}
tone={
isRecording ? "recording" : parsed ? "assigned" : "unassigned"
@@ -324,6 +378,11 @@ export function KeyboardShortcutsTab() {
: undefined
}
/>
+ {desktopOnly ? (
+ <span className="text-xs text-muted-foreground">
+ {t("settings.keyboardShortcuts.desktopOnly")}
+ </span>
+ ) : null}
<RowIconButton
icon={PencilEdit02Icon}
label={`${t("settings.keyboardShortcuts.edit")} (${slotName})`}
@@ -358,6 +417,15 @@ export function KeyboardShortcutsTab() {
const value = resolveBinding(overrides, def.id, slot);
return !value || shortcutOwningBinding(overrides, value) !== def.id;
});
+ const clashesWith = conflicted ? conflictingLabels(def.id) : "";
+ const recordedValue =
+ justRecorded?.id === def.id && !isRecording
+ ? resolveBinding(overrides, def.id, justRecorded.slot)
+ : null;
+ const recordedReserved =
+ !isTauri &&
+ isBrowserReservedBinding(recordedValue, mac) &&
+ !isBrowserUnreachableBinding(recordedValue, mac);
// Anything this action ships an alternate for keeps its line, cleared or not: hiding a cleared
// slot would take its restore control with it, and Reset all is not a way back from one edit.
const hasAlternate =
@@ -391,11 +459,17 @@ export function KeyboardShortcutsTab() {
{shadowed
? t("settings.keyboardShortcuts.conflictShadowed")
: t("settings.keyboardShortcuts.conflict")}
+ {clashesWith ? `: ${clashesWith}` : null}
</span>
) : (
t(def.descriptionKey)
)}
</span>
+ {recordedReserved ? (
+ <span className="text-xs leading-snug text-amber-500">
+ {t("settings.keyboardShortcuts.browserReserved")}
+ </span>
+ ) : null}
</div>
{/* pl-10 nudges the caps off the descriptions: the labels run long
enough that a bare half-and-half split left them crowding. */}
@@ -506,6 +580,7 @@ export function KeyboardShortcutsTab() {
onClick={() => {
setRecording(null);
setRecordingError(null);
+ setJustRecorded(null);
resetAll();
}}
>
diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.ts
index a304b7d2d8b..027aa62cbf9 100644
--- a/studio/frontend/src/i18n/locales/ar.ts
+++ b/studio/frontend/src/i18n/locales/ar.ts
@@ -1085,6 +1085,10 @@ export const ar = {
alternateSlot: "اختصار بديل",
browserReserved:
"قد يحتفظ متصفحك بهذه التركيبة لنفسه. تعمل في تطبيق سطح المكتب.",
+ metaUnsupported: "لا يمكن استخدام مفتاح Windows في الاختصارات.",
+ altGraphUnsupported: "لا يمكن استخدام تركيبات AltGr كاختصارات.",
+ desktopOnly: "تطبيق سطح المكتب فقط",
+ builtInKey: "مدمج: {key}",
actions: {
findInPage: {
label: "البحث في الصفحة",
@@ -1286,6 +1290,10 @@ export const ar = {
label: "توجيه الرد",
description: "إيقاف الرد الحالي وإرسال المسودة بعده",
},
+ stopGeneration: {
+ label: "إيقاف التوليد",
+ description: "إيقاف الرد الجاري",
+ },
cycleReasoningEffort: {
label: "تدوير مستوى التفكير",
description: "التنقل بين مستويات جهد التفكير",
diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.ts
index ddfbe50e875..860cd811e40 100644
--- a/studio/frontend/src/i18n/locales/de.ts
+++ b/studio/frontend/src/i18n/locales/de.ts
@@ -1090,6 +1090,10 @@ export const de = {
alternateSlot: "Alternatives Kürzel",
browserReserved:
"Dein Browser behält diese Tastenkombination unter Umständen für sich. In der Desktop-App funktioniert sie.",
+ metaUnsupported: "Die Windows-Taste kann nicht in Tastenkürzeln verwendet werden.",
+ altGraphUnsupported: "AltGr-Kombinationen können nicht als Tastenkürzel verwendet werden.",
+ desktopOnly: "Nur in der Desktop-App",
+ builtInKey: "Integriert: {key}",
actions: {
findInPage: {
label: "Auf der Seite suchen",
@@ -1291,6 +1295,10 @@ export const de = {
label: "Antwort steuern",
description: "Die laufende Antwort stoppen und den Entwurf als Nächstes senden",
},
+ stopGeneration: {
+ label: "Generierung stoppen",
+ description: "Die laufende Antwort anhalten",
+ },
cycleReasoningEffort: {
label: "Denkaufwand durchschalten",
description: "Durch die Stufen des Denkaufwands blättern",
diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.ts
index 21f9bb4593c..9911a84031e 100644
--- a/studio/frontend/src/i18n/locales/en.ts
+++ b/studio/frontend/src/i18n/locales/en.ts
@@ -1143,6 +1143,10 @@ export const en = {
alternateSlot: "Alternate shortcut",
browserReserved:
"Your browser may keep this chord for itself. It works in the desktop app.",
+ metaUnsupported: "The Windows key can't be used in shortcuts.",
+ altGraphUnsupported: "AltGr chords can't be used as shortcuts.",
+ desktopOnly: "Desktop app only",
+ builtInKey: "Built in: {key}",
actions: {
findInPage: {
label: "Find in page",
@@ -1344,6 +1348,10 @@ export const en = {
label: "Steer response",
description: "Stop the current response and send the draft next",
},
+ stopGeneration: {
+ label: "Stop generating",
+ description: "Stop the response being written",
+ },
cycleReasoningEffort: {
label: "Cycle reasoning effort",
description: "Step through the reasoning effort levels",
diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.ts
index 1fa5f5812f9..02d1546a9f8 100644
--- a/studio/frontend/src/i18n/locales/es.ts
+++ b/studio/frontend/src/i18n/locales/es.ts
@@ -1089,6 +1089,10 @@ export const es = {
alternateSlot: "Atajo alternativo",
browserReserved:
"Puede que tu navegador se reserve esta combinación. En la app de escritorio funciona.",
+ metaUnsupported: "La tecla Windows no se puede usar en atajos.",
+ altGraphUnsupported: "Las combinaciones con AltGr no se pueden usar como atajos.",
+ desktopOnly: "Solo en la app de escritorio",
+ builtInKey: "Integrado: {key}",
actions: {
findInPage: {
label: "Buscar en la página",
@@ -1290,6 +1294,10 @@ export const es = {
label: "Dirigir la respuesta",
description: "Detener la respuesta actual y enviar el borrador a continuación",
},
+ stopGeneration: {
+ label: "Detener generación",
+ description: "Detener la respuesta en curso",
+ },
cycleReasoningEffort: {
label: "Alternar esfuerzo de razonamiento",
description: "Recorrer los niveles de esfuerzo de razonamiento",
diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.ts
index 41bf4d7d3da..bd5ba36558e 100644
--- a/studio/frontend/src/i18n/locales/fr.ts
+++ b/studio/frontend/src/i18n/locales/fr.ts
@@ -1090,6 +1090,10 @@ export const fr = {
alternateSlot: "Raccourci alternatif",
browserReserved:
"Votre navigateur peut réserver cette combinaison. Elle fonctionne dans l’application de bureau.",
+ metaUnsupported: "La touche Windows ne peut pas être utilisée dans les raccourcis.",
+ altGraphUnsupported: "Les combinaisons AltGr ne peuvent pas servir de raccourcis.",
+ desktopOnly: "Application de bureau uniquement",
+ builtInKey: "Intégré : {key}",
actions: {
findInPage: {
label: "Rechercher dans la page",
@@ -1291,6 +1295,10 @@ export const fr = {
label: "Réorienter la réponse",
description: "Arrêter la réponse en cours et envoyer le brouillon ensuite",
},
+ stopGeneration: {
+ label: "Arrêter la génération",
+ description: "Arrêter la réponse en cours",
+ },
cycleReasoningEffort: {
label: "Faire défiler l’effort de raisonnement",
description: "Parcourir les niveaux d’effort de raisonnement",
diff --git a/studio/frontend/src/i18n/locales/he.ts b/studio/frontend/src/i18n/locales/he.ts
index ffa016cc1cd..a7c475c3dea 100644
--- a/studio/frontend/src/i18n/locales/he.ts
+++ b/studio/frontend/src/i18n/locales/he.ts
@@ -1174,6 +1174,10 @@ export const he = {
alternateSlot: "קיצור דרך חלופי",
browserReserved:
"הדפדפן שלך עשוי לשמור צירוף זה לעצמו. הוא יעבוד באפליקציית שולחן העבודה.",
+ metaUnsupported: "לא ניתן להשתמש במקש Windows בקיצורי מקשים.",
+ altGraphUnsupported: "לא ניתן להשתמש בצירופי AltGr כקיצורי מקשים.",
+ desktopOnly: "באפליקציית שולחן העבודה בלבד",
+ builtInKey: "מובנה: {key}",
actions: {
findInPage: {
label: "חיפוש בדף",
@@ -1376,6 +1380,10 @@ export const he = {
label: "הכוונת התשובה",
description: "עצור את התשובה הנוכחית ושלח את הטיוטה מיד אחריה",
},
+ stopGeneration: {
+ label: "עצירת היצירה",
+ description: "עצירת התשובה שנכתבת",
+ },
cycleReasoningEffort: {
label: "החלף רמת מאמץ חשיבה",
description: "עבור בין רמות מאמץ החשיבה השונות",
diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.ts
index abdea3175d6..aa22cc9e19d 100644
--- a/studio/frontend/src/i18n/locales/hi.ts
+++ b/studio/frontend/src/i18n/locales/hi.ts
@@ -1089,6 +1089,10 @@ export const hi = {
alternateSlot: "वैकल्पिक शॉर्टकट",
browserReserved:
"आपका ब्राउज़र यह कुंजी संयोजन अपने पास रख सकता है। डेस्कटॉप ऐप में यह काम करता है।",
+ metaUnsupported: "Windows कुंजी का उपयोग शॉर्टकट में नहीं किया जा सकता।",
+ altGraphUnsupported: "AltGr संयोजनों को शॉर्टकट के रूप में उपयोग नहीं किया जा सकता।",
+ desktopOnly: "केवल डेस्कटॉप ऐप में",
+ builtInKey: "अंतर्निहित: {key}",
actions: {
findInPage: {
label: "पेज में खोजें",
@@ -1290,6 +1294,10 @@ export const hi = {
label: "उत्तर बदलें",
description: "मौजूदा उत्तर रोककर ड्राफ़्ट अगला भेजें",
},
+ stopGeneration: {
+ label: "जनरेशन रोकें",
+ description: "लिखा जा रहा जवाब रोकें",
+ },
cycleReasoningEffort: {
label: "तर्क प्रयास बदलें",
description: "तर्क प्रयास के स्तरों में क्रमशः बदलें",
diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.ts
index 85f141f4047..87c0f580341 100644
--- a/studio/frontend/src/i18n/locales/it.ts
+++ b/studio/frontend/src/i18n/locales/it.ts
@@ -993,6 +993,10 @@ export const it = {
alternateSlot: "Scorciatoia alternativa",
browserReserved:
"Il browser potrebbe riservare questa combinazione per sé. Nell’app desktop funziona.",
+ metaUnsupported: "Il tasto Windows non può essere usato nelle scorciatoie.",
+ altGraphUnsupported: "Le combinazioni con AltGr non possono essere usate come scorciatoie.",
+ desktopOnly: "Solo nell'app desktop",
+ builtInKey: "Integrato: {key}",
actions: {
findInPage: {
label: "Trova nella pagina",
@@ -1194,6 +1198,10 @@ export const it = {
label: "Reindirizza la risposta",
description: "Interrompi la risposta in corso e invia subito la bozza",
},
+ stopGeneration: {
+ label: "Interrompi generazione",
+ description: "Interrompi la risposta in corso",
+ },
cycleReasoningEffort: {
label: "Scorri lo sforzo di ragionamento",
description: "Passa in rassegna i livelli di sforzo di ragionamento",
diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.ts
index e9c7cf182c0..7b1ad78ba8c 100644
--- a/studio/frontend/src/i18n/locales/ja.ts
+++ b/studio/frontend/src/i18n/locales/ja.ts
@@ -1087,6 +1087,10 @@ export const ja = {
alternateSlot: "代替ショートカット",
browserReserved:
"ブラウザがこのキーを使う場合があります。デスクトップアプリでは動作します。",
+ metaUnsupported: "Windows キーはショートカットに使用できません。",
+ altGraphUnsupported: "AltGr の組み合わせはショートカットに使用できません。",
+ desktopOnly: "デスクトップアプリのみ",
+ builtInKey: "組み込み: {key}",
actions: {
findInPage: {
label: "ページ内検索",
@@ -1288,6 +1292,10 @@ export const ja = {
label: "応答を修正",
description: "現在の応答を停止して下書きを次に送信します",
},
+ stopGeneration: {
+ label: "生成を停止",
+ description: "生成中の応答を停止します",
+ },
cycleReasoningEffort: {
label: "思考の深さを順に切り替え",
description: "思考の深さのレベルを順に切り替えます",
diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.ts
index 588384c7cce..357d17efcf8 100644
--- a/studio/frontend/src/i18n/locales/ko.ts
+++ b/studio/frontend/src/i18n/locales/ko.ts
@@ -1085,6 +1085,10 @@ export const ko = {
alternateSlot: "대체 단축키",
browserReserved:
"브라우저가 이 조합을 가져갈 수 있습니다. 데스크톱 앱에서는 동작합니다.",
+ metaUnsupported: "Windows 키는 단축키에 사용할 수 없습니다.",
+ altGraphUnsupported: "AltGr 조합은 단축키로 사용할 수 없습니다.",
+ desktopOnly: "데스크톱 앱 전용",
+ builtInKey: "기본 제공: {key}",
actions: {
findInPage: {
label: "페이지에서 찾기",
@@ -1286,6 +1290,10 @@ export const ko = {
label: "응답 조정",
description: "현재 응답을 중단하고 초안을 다음으로 보냅니다",
},
+ stopGeneration: {
+ label: "생성 중지",
+ description: "작성 중인 응답을 중지합니다",
+ },
cycleReasoningEffort: {
label: "추론 강도 순환",
description: "추론 강도 단계를 차례로 바꿉니다",
diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.ts
index 40fa434ba54..f8332782bfd 100644
--- a/studio/frontend/src/i18n/locales/pt-br.ts
+++ b/studio/frontend/src/i18n/locales/pt-br.ts
@@ -1088,6 +1088,10 @@ export const ptBR = {
alternateSlot: "Atalho alternativo",
browserReserved:
"Seu navegador pode reservar essa combinação. No app para desktop ela funciona.",
+ metaUnsupported: "A tecla Windows não pode ser usada em atalhos.",
+ altGraphUnsupported: "Combinações com AltGr não podem ser usadas como atalhos.",
+ desktopOnly: "Somente no app para desktop",
+ builtInKey: "Integrado: {key}",
actions: {
findInPage: {
label: "Localizar na página",
@@ -1289,6 +1293,10 @@ export const ptBR = {
label: "Direcionar a resposta",
description: "Parar a resposta atual e enviar o rascunho em seguida",
},
+ stopGeneration: {
+ label: "Parar geração",
+ description: "Parar a resposta em andamento",
+ },
cycleReasoningEffort: {
label: "Alternar esforço de raciocínio",
description: "Percorrer os níveis de esforço de raciocínio",
diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.ts
index 7f440bb3bf5..ad869eba794 100644
--- a/studio/frontend/src/i18n/locales/ru.ts
+++ b/studio/frontend/src/i18n/locales/ru.ts
@@ -1088,6 +1088,10 @@ export const ru = {
alternateSlot: "Альтернативное сочетание",
browserReserved:
"Браузер может оставить это сочетание себе. В настольном приложении оно работает.",
+ metaUnsupported: "Клавишу Windows нельзя использовать в сочетаниях клавиш.",
+ altGraphUnsupported: "Сочетания с AltGr нельзя использовать как сочетания клавиш.",
+ desktopOnly: "Только в настольном приложении",
+ builtInKey: "Встроено: {key}",
actions: {
findInPage: {
label: "Поиск на странице",
@@ -1289,6 +1293,10 @@ export const ru = {
label: "Скорректировать ответ",
description: "Остановить текущий ответ и отправить черновик следующим",
},
+ stopGeneration: {
+ label: "Остановить генерацию",
+ description: "Остановить текущий ответ",
+ },
cycleReasoningEffort: {
label: "Переключать усилие рассуждения",
description: "Перебрать уровни усилия рассуждения",
diff --git a/studio/frontend/src/i18n/locales/sv.ts b/studio/frontend/src/i18n/locales/sv.ts
index 7056a086c65..b17cbf54a10 100644
--- a/studio/frontend/src/i18n/locales/sv.ts
+++ b/studio/frontend/src/i18n/locales/sv.ts
@@ -1204,6 +1204,10 @@ export const sv = {
alternateSlot: "Alternativ genväg",
browserReserved:
"Din webbläsare kan reservera denna tangentkombination. Den fungerar i skrivbordsappen.",
+ metaUnsupported: "Windows-tangenten kan inte användas i kortkommandon.",
+ altGraphUnsupported: "AltGr-kombinationer kan inte användas som kortkommandon.",
+ desktopOnly: "Endast i skrivbordsappen",
+ builtInKey: "Inbyggt: {key}",
actions: {
findInPage: {
label: "Sök på sidan",
@@ -1405,6 +1409,10 @@ export const sv = {
label: "Styr svaret",
description: "Stoppa det aktuella svaret och skicka utkastet härnäst",
},
+ stopGeneration: {
+ label: "Stoppa genereringen",
+ description: "Stoppa svaret som skrivs",
+ },
cycleReasoningEffort: {
label: "Växla resonemangsnivå",
description: "Stega genom nivåerna för resonemang",
diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.ts
index c2135027e9b..a1d2964e637 100644
--- a/studio/frontend/src/i18n/locales/zh-CN.ts
+++ b/studio/frontend/src/i18n/locales/zh-CN.ts
@@ -1083,6 +1083,10 @@ export const zhCN = {
alternateSlot: "备用快捷键",
browserReserved:
"浏览器可能会占用该组合键。桌面应用中可正常使用。",
+ metaUnsupported: "Windows 键不能用于快捷键。",
+ altGraphUnsupported: "AltGr 组合不能用作快捷键。",
+ desktopOnly: "仅限桌面应用",
+ builtInKey: "内置:{key}",
actions: {
findInPage: {
label: "在页面中查找",
@@ -1284,6 +1288,10 @@ export const zhCN = {
label: "引导回复",
description: "停止当前回复并接着发送草稿",
},
+ stopGeneration: {
+ label: "停止生成",
+ description: "停止正在生成的回复",
+ },
cycleReasoningEffort: {
label: "循环切换推理强度",
description: "在各推理强度等级之间循环",
diff --git a/studio/frontend/tests/edit-project-dialog.test.ts b/studio/frontend/tests/edit-project-dialog.test.ts
index 11bdf175a57..d95980568c0 100644
--- a/studio/frontend/tests/edit-project-dialog.test.ts
+++ b/studio/frontend/tests/edit-project-dialog.test.ts
@@ -112,7 +112,7 @@ test("the draft follows whichever project is open", () => {
test("the dialog commits on Enter and on the chord", () => {
assert.match(
DIALOG,
- /if \(e\.key === "Enter" && \(e\.metaKey \|\| e\.ctrlKey\)\) \{\n\s*e\.preventDefault\(\);\n\s*void save\(\);/,
+ /if \(isModEnter\(e\)\) \{\n\s*e\.preventDefault\(\);\n\s*void save\(\);/,
);
const nameInput = DIALOG.slice(
DIALOG.indexOf("<input"),
diff --git a/studio/frontend/tests/keyboard-shortcuts-storage-sync.test.ts b/studio/frontend/tests/keyboard-shortcuts-storage-sync.test.ts
new file mode 100644
index 00000000000..5cf391cbf02
--- /dev/null
+++ b/studio/frontend/tests/keyboard-shortcuts-storage-sync.test.ts
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+const stored = new Map<string, string>();
+const listeners: Array<(event: { key: string | null }) => void> = [];
+(globalThis as { window?: unknown }).window = {
+ localStorage: {
+ getItem: (key: string) => stored.get(key) ?? null,
+ setItem: (key: string, value: string) => stored.set(key, value),
+ removeItem: (key: string) => stored.delete(key),
+ },
+ addEventListener: (
+ type: string,
+ listener: (event: { key: string | null }) => void,
+ ) => {
+ if (type === "storage") listeners.push(listener);
+ },
+};
+
+const { KEYBOARD_SHORTCUTS_STORAGE_KEY, useKeyboardShortcutsStore } =
+ await import("../src/features/settings/stores/keyboard-shortcuts-store.ts");
+
+const fire = (key: string | null) => {
+ for (const listener of listeners) listener({ key });
+};
+
+test("an edit in another tab reaches this one before it writes again", () => {
+ assert.equal(listeners.length, 1);
+ useKeyboardShortcutsStore
+ .getState()
+ .setBinding("searchChats", "primary", "Mod+KeyJ");
+ stored.set(
+ KEYBOARD_SHORTCUTS_STORAGE_KEY,
+ JSON.stringify({ openSettings: { primary: "Mod+Alt+Comma" } }),
+ );
+ fire(KEYBOARD_SHORTCUTS_STORAGE_KEY);
+ assert.deepEqual(useKeyboardShortcutsStore.getState().overrides, {
+ openSettings: { primary: "Mod+Alt+Comma" },
+ });
+ useKeyboardShortcutsStore
+ .getState()
+ .setBinding("renameChat", "primary", "Mod+Alt+KeyT");
+ assert.deepEqual(
+ JSON.parse(stored.get(KEYBOARD_SHORTCUTS_STORAGE_KEY) ?? "{}"),
+ {
+ openSettings: { primary: "Mod+Alt+Comma" },
+ renameChat: { primary: "Mod+Alt+KeyT" },
+ },
+ );
+});
+
+test("other keys are ignored, and a cleared storage resets", () => {
+ const before = useKeyboardShortcutsStore.getState().overrides;
+ stored.set(KEYBOARD_SHORTCUTS_STORAGE_KEY, "{}");
+ fire("unsloth_theme");
+ assert.equal(useKeyboardShortcutsStore.getState().overrides, before);
+ stored.clear();
+ fire(null);
+ assert.deepEqual(useKeyboardShortcutsStore.getState().overrides, {});
+});
diff --git a/studio/frontend/tests/keyboard-shortcuts.test.ts b/studio/frontend/tests/keyboard-shortcuts.test.ts
index 36babe20d96..3e2b0817953 100644
--- a/studio/frontend/tests/keyboard-shortcuts.test.ts
+++ b/studio/frontend/tests/keyboard-shortcuts.test.ts
@@ -41,6 +41,13 @@ const CHAT_PAGE = readSrc("features/chat/chat-page.tsx");
const KEYBOARD_SHORTCUTS_TAB = readSrc("features/settings/tabs/keyboard-shortcuts-tab.tsx");
const EN = readSrc("i18n/locales/en.ts");
+function sidebarShortcut(id: string): string {
+ const at = APP_SIDEBAR.indexOf(`useShortcut(\n "${id}",`);
+ return at === -1
+ ? ""
+ : APP_SIDEBAR.slice(at, APP_SIDEBAR.indexOf("\n );", at));
+}
+
function keyEvent(
code: string,
mods: Partial<{
@@ -392,11 +399,11 @@ test("the workspace chords land where the guard lets them", async () => {
});
// A chord behind a hidden developer menu is not one the browser took from the
-// user, and these sets drive a warning the user reads. Safari has both of
-// these, but only once the Develop menu is switched on, so reserving them
-// would tell every macOS user something untrue about their own keyboard.
+// user, and these sets drive a warning the user reads. Safari has ⌥⌘E (and
+// ⌥⌘R, which Firefox's Reader View flags anyway) only once the Develop menu is
+// switched on, so reserving it would tell every macOS user something untrue.
test("an opt-in developer chord is not treated as taken", () => {
- for (const value of ["Mod+Alt+KeyE", "Mod+Alt+KeyR"]) {
+ for (const value of ["Mod+Alt+KeyE"]) {
for (const mac of [true, false]) {
assert.equal(
isBrowserReservedBinding(value, mac),
@@ -453,7 +460,6 @@ test("the browsers' own run on macOS is reserved there and only there", () => {
"Mod+Alt+KeyO",
"Mod+Alt+KeyS",
"Mod+Alt+KeyA",
- "Mod+Alt+KeyR",
"Mod+Alt+Digit1",
]) {
assert.equal(isBrowserReservedBinding(value, true), false, value);
@@ -528,6 +534,7 @@ test("no default takes a chord the browser owns without a reason", () => {
"Mod+KeyF",
// The command palette takes Print the same way.
"Mod+KeyP",
+ "Mod+Alt+KeyR",
]);
for (const def of SHORTCUT_DEFS) {
for (const slot of SHORTCUT_SLOTS) {
@@ -1097,7 +1104,10 @@ test("the chords that need one target do not fire where there are two", async ()
chatPage,
/const headerPickersShown = active && view\.mode !== "compare";/,
);
- assert.match(chatPage, /enabled: headerPickersShown[,\s]*\}/);
+ assert.match(
+ chatPage,
+ /enabled: headerPickersShown,\n\s*claims: chatUncovered,\n\s*\}/,
+ );
// Both panes mount the last message, and the chord would go to whichever
// registered its listener first. `If last` carries the other half.
assert.match(thread, /enabled: chatActive && !inComparePane && !forkDisabled/);
@@ -1123,7 +1133,10 @@ test("a chord's surface does not come back open on the next visit", async () =>
chatPage,
/const projectSwitcherShown = headerPickersShown && Boolean\(currentProjectId\);/,
);
- assert.match(chatPage, /useShortcut\(\n\s*"openProjectPicker",[\s\S]*?enabled: projectSwitcherShown/);
+ assert.match(
+ chatPage,
+ /useShortcut\("openProjectPicker",[\s\S]*?enabled: projectSwitcherShown/,
+ );
assert.match(
chatPage,
/if \(!projectSwitcherShown && projectPickerOpen\) \{\n\s*setProjectPickerOpen\(false\);/,
@@ -1270,7 +1283,10 @@ test("the model picker chord opens without the tour's pin", async () => {
CHAT_PAGE,
/const toggleModelSelector = useCallback\(\(\) => \{\n(?:\s*\/\/[^\n]*\n)*\s*if \(modelSelectorLocked\) return;\n\s*setModelSelectorOpen\(\(open\) => !open\);/,
);
- assert.match(CHAT_PAGE, /useShortcut\(\n\s*"openModelPicker",[\s\S]*?toggleModelSelector\(\);/);
+ assert.match(
+ CHAT_PAGE,
+ /useShortcut\("openModelPicker", toggleModelSelector, \{/,
+ );
// Three mentions left, all the tour's: the declaration, the step builder's
// argument, and that memo's dependency. Nothing else may pin it open.
@@ -1281,7 +1297,7 @@ test("the model picker chord opens without the tour's pin", async () => {
test("every sidebar chat rename opens the dialog", () => {
assert.match(
APP_SIDEBAR,
- /useShortcut\("renameChat", \(\) => \{[\s\S]*?withActiveChat\(\(item\) => openRenameChat\(item\)\);/,
+ /useShortcut\(\n\s*"renameChat",\n\s*\(\) => withActiveChat\(\(item\) => openRenameChat\(item\)\),/,
);
assert.match(APP_SIDEBAR, /onSelect=\{\(\) => openRenameChat\(item\)\}/);
assert.match(
@@ -1838,10 +1854,10 @@ test("a selection does not outlive the rows it was made on", async () => {
"togglePinChat",
"deleteSelectedChats",
]) {
- const at = APP_SIDEBAR.indexOf(`useShortcut("${id}"`);
- assert.ok(at !== -1, `${id} lost its call site`);
+ const body = sidebarShortcut(id);
+ assert.ok(body, `${id} lost its call site`);
assert.match(
- APP_SIDEBAR.slice(at, APP_SIDEBAR.indexOf("\n });", at)),
+ body,
/selectionCount > 0/,
`${id} no longer prefers the selection`,
);
@@ -1860,10 +1876,7 @@ test("a selection does not outlive the rows it was made on", async () => {
test("a selection chord does not fall through to the open chat", async () => {
assert.match(APP_SIDEBAR, /const SELECTION_ACTION_GRACE_MS = \d+;/);
for (const id of ["archiveChat", "markChatUnread", "togglePinChat"]) {
- const body = APP_SIDEBAR.slice(
- APP_SIDEBAR.indexOf(`useShortcut("${id}"`),
- APP_SIDEBAR.indexOf("\n });", APP_SIDEBAR.indexOf(`useShortcut("${id}"`)),
- );
+ const body = sidebarShortcut(id);
// Both halves name the action. A shared latch would hold back Archive
// after Pin took the selection, and that is a different command the user
// chose, not the repeat this guard exists for.
@@ -1881,25 +1894,26 @@ test("a selection chord does not fall through to the open chat", async () => {
);
}
// deleteSelectedChats needs none of this: it has no open-chat branch.
- const del = APP_SIDEBAR.slice(
- APP_SIDEBAR.indexOf('useShortcut("deleteSelectedChats"'),
- APP_SIDEBAR.indexOf("\n });", APP_SIDEBAR.indexOf('useShortcut("deleteSelectedChats"')),
- );
+ const del = sidebarShortcut("deleteSelectedChats");
+ assert.ok(del);
assert.doesNotMatch(del, /withActiveChat\(/);
});
-// The only action with no menu item anywhere and no undo, so a silent wipe
-// leaves the user nothing to tell it apart from a dead key.
test("clearing every unread says what it cleared", async () => {
- const body = APP_SIDEBAR.slice(
- APP_SIDEBAR.indexOf('useShortcut("clearAllUnreads"'),
- APP_SIDEBAR.indexOf("\n });", APP_SIDEBAR.indexOf('useShortcut("clearAllUnreads"')),
- );
+ const body = sidebarShortcut("clearAllUnreads");
// Counted before the wipe, or the toast reports zero every time. Rows, not
// threads: a Compare row is backed by two and would be cleared as two chats.
assert.match(body, /const cleared = countUnreadRows\(state\);[\s\S]*state\.clearAllUnreads\(\)/);
assert.match(body, /if \(state\.unreadThreadIds\.size === 0\) \{\n\s*toast\.info\(/);
assert.match(body, /toast\.success\(/);
+ assert.match(
+ body,
+ /const threadIds = \[\.\.\.state\.unreadThreadIds\];\n\s*const rowIds = \{ \.\.\.state\.unreadRowIds \};\n\s*state\.clearAllUnreads\(\);/,
+ );
+ assert.match(
+ body,
+ /label: t\("shell\.sections\.undo"\),\n\s*onClick: \(\) =>\n\s*useChatNavigationStore\n\s*\.getState\(\)\n\s*\.markThreadsUnread\(threadIds, rowIds\),/,
+ );
});
// Two parked requests must count as two, or both cards claim Enter and mount
@@ -1993,9 +2007,8 @@ test("the sidebar item lists are built once per change, not per render", async (
// chat, so Archive archived a chat the user had not pointed at.
test("the chat-only chords stand aside for a project selection", async () => {
for (const id of ["archiveChat", "markChatUnread", "togglePinChat"]) {
- const at = APP_SIDEBAR.indexOf(`useShortcut("${id}", () => {`);
- assert.notEqual(at, -1, `${id} is gone`);
- const body = APP_SIDEBAR.slice(at, APP_SIDEBAR.indexOf("\n });", at));
+ const body = sidebarShortcut(id);
+ assert.ok(body, `${id} is gone`);
const stand = body.indexOf("projectsOnlySelected()");
assert.notEqual(stand, -1, `${id} acts on the open chat under a project selection`);
assert.ok(
diff --git a/studio/frontend/tests/project-name-ime.test.ts b/studio/frontend/tests/project-name-ime.test.ts
index f5468550139..59bae536b47 100644
--- a/studio/frontend/tests/project-name-ime.test.ts
+++ b/studio/frontend/tests/project-name-ime.test.ts
@@ -9,6 +9,7 @@ import {
inputImeHandlers,
newInputImeState,
} from "../src/features/chat/utils/composer-preferences.ts";
+import { isModEnter } from "../src/features/settings/lib/keyboard-shortcuts.ts";
import { readSrc } from "./helpers/kit.ts";
type Target = "input" | "dialog";
@@ -136,12 +137,15 @@ function fixture(
file: string,
action: "commitCreate" | "save",
target: Target = "input",
+ mac = true,
) {
const effects: string[] = [];
const nameImeRef = { current: newInputImeState() };
const ime = compositionHandlers(file, { inputImeHandlers, nameImeRef });
const onKey = keyHandler(file, target, action, {
imeOwnsInputKeydown,
+ isModEnter: (event: Parameters<typeof isModEnter>[0]) =>
+ isModEnter(event, mac),
nameImeRef,
commitCreate: () => effects.push("submit"),
save: () => effects.push("submit"),
@@ -278,6 +282,7 @@ for (const modifier of ["metaKey", "ctrlKey"] as const) {
"features/chat/components/edit-project-dialog.tsx",
"save",
"dialog",
+ modifier === "metaKey",
);
f.key({ keyCode: 229, [modifier]: true });
assert.equal(f.effects.filter((effect) => effect === "submit").length, 1);
diff --git a/studio/frontend/tests/shortcut-dispatch-guards.test.ts b/studio/frontend/tests/shortcut-dispatch-guards.test.ts
index ca6a811b0b0..c3df327c55e 100644
--- a/studio/frontend/tests/shortcut-dispatch-guards.test.ts
+++ b/studio/frontend/tests/shortcut-dispatch-guards.test.ts
@@ -356,12 +356,12 @@ test("the sidebar's mutating chords refuse to fire under a dialog", async () =>
"renameChat",
"clearAllUnreads",
]) {
- const at = APP_SIDEBAR.indexOf(`useShortcut("${id}", () => {`);
+ const at = APP_SIDEBAR.indexOf(`useShortcut(\n "${id}",`);
assert.notEqual(at, -1, `${id} is gone`);
- const body = APP_SIDEBAR.slice(at, APP_SIDEBAR.indexOf("\n });", at));
+ const body = APP_SIDEBAR.slice(at, APP_SIDEBAR.indexOf("\n );", at));
assert.match(
body,
- /if \(sidebarCovered\(\)\) return;/,
+ /\{ claims: sidebarUncovered \}/,
`${id} acts on the chat behind an open dialog`,
);
}
@@ -456,13 +456,13 @@ test("the header pickers do not open behind a dialog", async () => {
assert.notEqual(at, -1, `${id} is gone`);
assert.match(
CHAT_PAGE.slice(at, at + 260),
- /if \(chatCovered\(\)\) return;/,
+ /claims: chatUncovered/,
`${id} opens a control on the covered surface`,
);
}
assert.match(
CHAT_PAGE,
- /isSurfaceBackgrounded\(COMPOSER_INPUT_SELECTOR\)/,
+ /const chatUncovered = \(\) => !isSurfaceBackgrounded\(COMPOSER_INPUT_SELECTOR\);/,
);
});
@@ -492,25 +492,27 @@ test("a tool call cannot be answered from behind a dialog", async () => {
for (const id of ["approveToolRequest", "declineToolRequest"]) {
const at = source.indexOf(`"${id}",`);
assert.notEqual(at, -1, `${id} is gone`);
- const body = source.slice(at, at + 200);
- const guard = body.indexOf("if (chatCovered()) return;");
- const call = body.indexOf("resolve(");
- assert.notEqual(guard, -1, `${id} answers from behind a dialog`);
- assert.ok(guard < call, `${id} resolves before it checks`);
+ assert.match(
+ source.slice(at, source.indexOf("\n });", at)),
+ /claims: chatUncovered,/,
+ `${id} answers from behind a dialog`,
+ );
}
- assert.match(source, /isSurfaceBackgrounded\(COMPOSER_INPUT_SELECTOR\)/);
+ assert.match(
+ source,
+ /const chatUncovered = \(\) => !isSurfaceBackgrounded\(COMPOSER_INPUT_SELECTOR\);/,
+ );
});
// A selection made behind a dialog is invisible and still what the mutating
// chords act on afterwards, and the clipboard is outside the app entirely.
test("selection and clipboard chords stop at a covered sidebar", async () => {
for (const id of ["selectAllChats", "copyChatAsMarkdown", "copySessionId"]) {
- const at = APP_SIDEBAR.indexOf(`useShortcut("${id}", () => {`);
+ const at = APP_SIDEBAR.search(new RegExp(`useShortcut\\(\\n?\\s*"${id}",`));
assert.notEqual(at, -1, `${id} is gone`);
- const body = APP_SIDEBAR.slice(at, APP_SIDEBAR.indexOf("\n });", at));
assert.match(
- body,
- /if \(sidebarCovered\(\)\) return;/,
+ APP_SIDEBAR.slice(at, at + 260),
+ /claims: sidebarUncovered/,
`${id} acts behind an open dialog`,
);
}
@@ -543,8 +545,8 @@ test("the remaining chat-page chords stop at a covered surface", async () => {
const at = CHAT_PAGE.indexOf(`"${id}",`);
assert.notEqual(at, -1, `${id} is gone`);
assert.match(
- CHAT_PAGE.slice(at, at + 220),
- /if \(chatCovered\(\)\) return;/,
+ CHAT_PAGE.slice(at, at + 400),
+ /claims: chatUncovered/,
`${id} acts on the covered surface`,
);
}
diff --git a/studio/frontend/tests/shortcut-layout-and-recorder.test.ts b/studio/frontend/tests/shortcut-layout-and-recorder.test.ts
new file mode 100644
index 00000000000..6f6d1dea8b7
--- /dev/null
+++ b/studio/frontend/tests/shortcut-layout-and-recorder.test.ts
@@ -0,0 +1,327 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import {
+ zoomChordTaken,
+ zoomDirectionForKey,
+ zoomTypedOffZoomKey,
+} from "../src/features/interface-zoom/lib/zoom-chords.ts";
+import {
+ SHORTCUT_DEFS,
+ SHORTCUT_SLOTS,
+ bindingFromEvent,
+ bindingMatchesQuery,
+ defaultBindingFor,
+ formatBindingValueLabel,
+ formatCode,
+ isAcceptableBinding,
+ isBrowserReservedBinding,
+ isBrowserUnreachableBinding,
+ isModEnter,
+ modEnterLabel,
+ parseBinding,
+ unrecordableModifier,
+} from "../src/features/settings/lib/keyboard-shortcuts.ts";
+import { readSrc } from "./helpers/kit.ts";
+
+function press(
+ code: string,
+ key: string,
+ mods: Partial<{
+ metaKey: boolean;
+ ctrlKey: boolean;
+ shiftKey: boolean;
+ altKey: boolean;
+ altGraph: boolean;
+ }> = {},
+) {
+ const { altGraph = false, ...rest } = mods;
+ return {
+ code,
+ key,
+ metaKey: false,
+ ctrlKey: false,
+ shiftKey: false,
+ altKey: false,
+ ...rest,
+ getModifierState: (name: string) => name === "AltGraph" && altGraph,
+ };
+}
+
+const defOf = (id: string) => {
+ const def = SHORTCUT_DEFS.find((d) => d.id === id);
+ assert.ok(def, `${id} is not registered`);
+ return def;
+};
+
+// Much of Europe types "-" on the US Slash key, so Mod+"-" reads as Mod+Slash.
+test('Mod and "-" on the Slash key zooms out, not the shortcuts list', () => {
+ const ownsSlash = (value: string) => value === "Mod+Slash";
+ for (const [mac, mods] of [
+ [false, { ctrlKey: true }],
+ [true, { metaKey: true }],
+ ] as const) {
+ const event = press("Slash", "-", mods);
+ assert.equal(zoomDirectionForKey(event, mac), -1);
+ assert.equal(zoomChordTaken(event, -1, mac, ownsSlash), false);
+ assert.equal(zoomTypedOffZoomKey(event, "Slash", mac), true);
+ assert.equal(
+ zoomTypedOffZoomKey(press("Slash", "/", mods), "Slash", mac),
+ false,
+ );
+ assert.equal(
+ zoomTypedOffZoomKey(press("Minus", "-", mods), "Minus", mac),
+ false,
+ );
+ assert.equal(
+ zoomChordTaken(
+ press("Minus", "-", mods),
+ -1,
+ mac,
+ (v) => v === "Mod+Minus",
+ ),
+ true,
+ );
+ }
+ assert.match(
+ readSrc("features/settings/hooks/use-shortcut.ts"),
+ /if \(zoomTypedOffZoomKey\(event, hit\.code, isMacPlatform\(\)\)\) return;/,
+ );
+});
+
+test("stopGeneration ships on Mod+. and clashes with nothing", () => {
+ const stop = defOf("stopGeneration");
+ for (const mac of [true, false]) {
+ const value = defaultBindingFor(stop, "primary", mac);
+ assert.equal(value, "Mod+Period");
+ assert.equal(isBrowserReservedBinding(value, mac), false);
+ const parsed = parseBinding(value);
+ assert.ok(parsed && isAcceptableBinding(parsed));
+ for (const other of SHORTCUT_DEFS) {
+ if (other.id === "stopGeneration") continue;
+ for (const slot of SHORTCUT_SLOTS) {
+ assert.notEqual(
+ defaultBindingFor(other, slot, mac),
+ value,
+ `${other.id}.${slot} also ships on ${value} (mac=${mac})`,
+ );
+ }
+ }
+ }
+ assert.equal(formatBindingValueLabel("Mod+Period", true), "⌘.");
+ assert.equal(formatBindingValueLabel("Mod+Period", false), "Ctrl+.");
+ const thread = readSrc("components/assistant-ui/thread.tsx");
+ const at = thread.indexOf('useShortcut(\n "stopGeneration",');
+ assert.notEqual(at, -1, "stopGeneration has no handler");
+ const body = thread.slice(at, thread.indexOf("\n );", at));
+ assert.match(body, /stop\(\);/);
+ assert.match(body, /composer\.cancel\(\)/);
+ assert.doesNotMatch(body, /skipInTextFields/);
+ assert.match(
+ readSrc("features/chat/shared-composer.tsx"),
+ /useShortcut\("stopGeneration", stop, \{\n\s*enabled: chatActive && busy,/,
+ );
+});
+
+test("Firefox's Reader View warns on both platforms, and renameChat keeps it", () => {
+ for (const mac of [true, false]) {
+ assert.ok(isBrowserReservedBinding("Mod+Alt+KeyR", mac));
+ assert.equal(
+ defaultBindingFor(defOf("renameChat"), "primary", mac),
+ "Mod+Alt+KeyR",
+ );
+ }
+});
+
+test("tab and window chords are flagged desktop-only, per platform", () => {
+ for (const mac of [true, false]) {
+ for (const id of [
+ "newTemporaryChat",
+ "nextRecentlyViewedChat",
+ "previousRecentlyViewedChat",
+ ]) {
+ assert.ok(
+ isBrowserUnreachableBinding(
+ defaultBindingFor(defOf(id), "primary", mac),
+ mac,
+ ),
+ `${id} (mac=${mac})`,
+ );
+ }
+ assert.equal(isBrowserUnreachableBinding("Mod+Shift+KeyO", mac), false);
+ assert.ok(isBrowserUnreachableBinding("Mod+KeyN", mac));
+ }
+ for (const id of ["nextChat", "previousChat"]) {
+ const value = defaultBindingFor(defOf(id), "primary", true);
+ assert.ok(isBrowserUnreachableBinding(value, true), id);
+ assert.equal(isBrowserUnreachableBinding(value, false), false, id);
+ }
+});
+
+test("the recorder names the AltGr or Windows key it cannot bind", () => {
+ const winK = press("KeyK", "k", { metaKey: true });
+ assert.equal(bindingFromEvent(winK, false), null);
+ assert.equal(unrecordableModifier(winK, false), "meta");
+ const altGrQ = press("KeyQ", "@", {
+ ctrlKey: true,
+ altKey: true,
+ altGraph: true,
+ });
+ assert.equal(bindingFromEvent(altGrQ, false), null);
+ assert.equal(unrecordableModifier(altGrQ, false), "altGraph");
+ assert.equal(
+ unrecordableModifier(press("MetaLeft", "Meta", { metaKey: true }), false),
+ null,
+ );
+ assert.equal(
+ unrecordableModifier(
+ press("AltRight", "AltGraph", { altGraph: true }),
+ false,
+ ),
+ null,
+ );
+ assert.equal(unrecordableModifier(winK, true), null);
+ assert.equal(
+ unrecordableModifier(press("KeyK", "k", { ctrlKey: true }), false),
+ null,
+ );
+ const tab = readSrc("features/settings/tabs/keyboard-shortcuts-tab.tsx");
+ assert.match(tab, /"settings\.keyboardShortcuts\.metaUnsupported"/);
+ assert.match(tab, /"settings\.keyboardShortcuts\.altGraphUnsupported"/);
+});
+
+test("formatCode names the ISO, JIS, keypad and navigation keys", () => {
+ assert.equal(formatCode("IntlBackslash", false), "ISO \\");
+ assert.equal(formatCode("IntlRo", false), "Ro");
+ assert.equal(formatCode("IntlYen", false), "¥");
+ assert.equal(formatCode("Numpad1", false), "Num 1");
+ assert.equal(formatCode("NumpadAdd", false), "Num +");
+ assert.equal(formatCode("NumpadSubtract", true), "Num -");
+ assert.equal(formatCode("NumpadEnter", false), "Num Enter");
+ assert.equal(formatCode("PageUp", false), "Page Up");
+ assert.equal(formatCode("PageDown", false), "Page Down");
+ assert.equal(formatCode("Home", false), "Home");
+ assert.equal(formatCode("End", false), "End");
+ assert.equal(formatCode("Insert", false), "Ins");
+ assert.equal(formatCode("Delete", false), "Del");
+ assert.equal(formatCode("Backspace", true), "⌫");
+ assert.equal(formatCode("Backspace", false), "Backspace");
+ assert.equal(
+ formatBindingValueLabel("Mod+Backspace", false),
+ "Ctrl+Backspace",
+ );
+ assert.equal(formatBindingValueLabel("Mod+Backspace", true), "⌘⌫");
+});
+
+test("searching by modifier words finds the chord", () => {
+ const cmdShiftO = parseBinding("Mod+Shift+KeyO");
+ const optCmdR = parseBinding("Mod+Alt+KeyR");
+ const ctrlShiftP = parseBinding("Ctrl+Shift+KeyP");
+ assert.ok(cmdShiftO && optCmdR && ctrlShiftP);
+ for (const q of [
+ "cmd",
+ "command",
+ "⌘",
+ "shift o",
+ "⇧",
+ "cmd+shift+o",
+ "⇧⌘o",
+ ]) {
+ assert.ok(bindingMatchesQuery(cmdShiftO, q, true), q);
+ }
+ for (const q of ["opt", "option", "alt", "⌥", "⌥⌘r", "opt cmd r"]) {
+ assert.ok(bindingMatchesQuery(optCmdR, q, true), q);
+ }
+ for (const q of ["ctrl", "control", "⌃", "ctrl shift p"]) {
+ assert.ok(bindingMatchesQuery(ctrlShiftP, q, true), q);
+ }
+ assert.ok(bindingMatchesQuery(cmdShiftO, "ctrl shift o", false));
+ assert.ok(bindingMatchesQuery(cmdShiftO, "control", false));
+ assert.equal(bindingMatchesQuery(cmdShiftO, "cmd", false), false);
+ assert.equal(bindingMatchesQuery(cmdShiftO, "alt", true), false);
+ assert.equal(bindingMatchesQuery(optCmdR, "cmd o", true), false);
+ assert.equal(bindingMatchesQuery(cmdShiftO, "c", true), false);
+ assert.match(
+ readSrc("features/settings/tabs/keyboard-shortcuts-tab.tsx"),
+ /return parsed \? bindingMatchesQuery\(parsed, q, mac\) : false;/,
+ );
+});
+
+test("Mod+Enter is the platform's own modifier, and never mid-composition", () => {
+ const enter = (
+ mods: Partial<{ metaKey: boolean; ctrlKey: boolean }>,
+ extra = {},
+ ) => ({
+ key: "Enter",
+ metaKey: false,
+ ctrlKey: false,
+ ...mods,
+ ...extra,
+ });
+ assert.ok(isModEnter(enter({ metaKey: true }), true));
+ assert.equal(isModEnter(enter({ ctrlKey: true }), true), false);
+ assert.ok(isModEnter(enter({ ctrlKey: true }), false));
+ assert.equal(isModEnter(enter({ metaKey: true }), false), false);
+ assert.equal(
+ isModEnter(enter({ metaKey: true, ctrlKey: true }), true),
+ false,
+ );
+ assert.equal(isModEnter(enter({}), false), false);
+ assert.equal(
+ isModEnter({ ...enter({ ctrlKey: true }), key: "a" }, false),
+ false,
+ );
+ assert.equal(
+ isModEnter(enter({ ctrlKey: true }, { isComposing: true }), false),
+ false,
+ );
+ assert.equal(
+ isModEnter(
+ enter({ ctrlKey: true }, { nativeEvent: { isComposing: true } }),
+ false,
+ ),
+ false,
+ );
+ assert.ok(isModEnter(enter({ metaKey: true }, { keyCode: 229 }), true));
+ assert.equal(modEnterLabel(true), "⌘↵");
+ assert.equal(modEnterLabel(false), "Ctrl+Enter");
+ for (const path of [
+ "features/chat/components/edit-project-dialog.tsx",
+ "features/images/paste-parameters-dialog.tsx",
+ "features/chat/components/chat-skills-dialog.tsx",
+ "features/settings/components/decision-try-dialog.tsx",
+ ]) {
+ const source = readSrc(path);
+ assert.match(source, /isModEnter\(/, path);
+ assert.doesNotMatch(source, /\.metaKey \|\| [a-z]+\.ctrlKey/, path);
+ }
+ assert.doesNotMatch(
+ readSrc("components/assistant-ui/thread.tsx"),
+ /e\.key === 'Enter' && \(e\.ctrlKey \|\| e\.metaKey\)/,
+ );
+});
+
+test("Escape in the composer is left to a sole pending tool request", () => {
+ const thread = readSrc("components/assistant-ui/thread.tsx");
+ assert.match(
+ thread,
+ /const soleToolRequest = useChatRuntimeStore\(\(s\) => \{/,
+ );
+ 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", () => {
+ const search = readSrc("features/chat/components/chat-search-dialog.tsx");
+ assert.match(
+ search,
+ /useShortcut\("searchChats", [^\n]+\n\s*skipInTextFields: true,\n\s*textFieldException: COMPOSER_INPUT_SELECTOR,/,
+ );
+ assert.match(
+ readSrc("components/ui/sidebar.tsx"),
+ /useShortcut\("toggleSidebar", toggleSidebar, \{\n\s*claims: \(\) =>\n\s*\(isMobile && openMobile\) \|\| document\.querySelector\(OPEN_DIALOG_SELECTOR\) === null,/,
+ );
+});
diff --git a/studio/frontend/tests/shortcut-text-field-gate.test.ts b/studio/frontend/tests/shortcut-text-field-gate.test.ts
index a6e60aaff65..48c6a7c3ab8 100644
--- a/studio/frontend/tests/shortcut-text-field-gate.test.ts
+++ b/studio/frontend/tests/shortcut-text-field-gate.test.ts
@@ -68,7 +68,7 @@ test("the decline chord takes the exception and the approve chord does not", asy
// Escape leaves the text alone. Enter sends, so it stays behind the gate.
assert.match(
controls,
- /useShortcut\(\n\s*"declineToolRequest",[\s\S]{0,800}?textFieldException: COMPOSER_INPUT_SELECTOR,/,
+ /useShortcut\(\n?\s*"declineToolRequest",[\s\S]{0,800}?textFieldException: COMPOSER_INPUT_SELECTOR,/,
);
const approve = controls.slice(
controls.indexOf('"approveToolRequest",'),