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: shared pill selector in settings toggles, plus queue and steer shortcuts (#11250)

Michael Han45002962c925
diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsx
index a685f1c6489..ca2860bf41c 100644
--- a/studio/frontend/src/components/assistant-ui/thread.tsx
+++ b/studio/frontend/src/components/assistant-ui/thread.tsx
@@ -58,6 +58,7 @@ import {
composerSubmitIntent,
composerFollowUpBehavior,
composerShortcutLabels,
+ followUpSubmitIntent,
steeringInsertionIndex,
cancelPreStreamRunForThreadIds,
type ComposerSendShortcut,
@@ -168,6 +169,8 @@ import { pickerAcceptForTextBasenames } from "@/features/chat/text-attachment-ac
import {
COMPOSER_INPUT_SELECTOR,
isSurfaceInForeground,
+ shortcutMatchingEvent,
+ useKeyboardShortcutsStore,
useShortcut,
useSettingsDialogStore,
isMacPlatform,
@@ -367,6 +370,33 @@ import { useIsMobile } from "@/hooks/use-mobile";
// can show its "Drop files here" affordance.
const PageDragContext = createContext(false);
+/** The follow-up each of the two chords names. */
+const FOLLOW_UP_SHORTCUTS = {
+ queueMessage: "queue",
+ steerMessage: "steer",
+} as const satisfies Record<string, ComposerFollowUpBehavior>;
+
+const FOLLOW_UP_SHORTCUT_IDS = Object.keys(
+ FOLLOW_UP_SHORTCUTS,
+) as (keyof typeof FOLLOW_UP_SHORTCUTS)[];
+
+/** The behaviour a bound queue or steer chord names, if this event fires one. */
+function followUpShortcutBehavior(event: {
+ code: string;
+ key?: string;
+ metaKey: boolean;
+ ctrlKey: boolean;
+ shiftKey: boolean;
+ altKey: boolean;
+}): ComposerFollowUpBehavior | null {
+ const id = shortcutMatchingEvent(
+ useKeyboardShortcutsStore.getState().overrides,
+ FOLLOW_UP_SHORTCUT_IDS,
+ event,
+ );
+ return id ? FOLLOW_UP_SHORTCUTS[id] : null;
+}
+
// Prompt queues live at module level so they survive Composer remounts,
// including the first queued message that creates a new thread. Each chat gets
// its own queue run; completion detection subscribes to runningByThreadId
@@ -2561,7 +2591,16 @@ const Composer: FC<{
(event: KeyboardEvent<HTMLTextAreaElement>, intent: ComposerSubmitIntent) => {
const form = event.currentTarget.form;
if (typeof form?.requestSubmit !== "function") return;
- submitIntentRef.current = intent;
+ // A queue or steer chord bound onto an Enter combination lands here
+ // first, and preventDefault keeps it from ever reaching useShortcut. Run
+ // the behaviour it names, rather than the one the send chord implies.
+ const named = followUpShortcutBehavior(event);
+ submitIntentRef.current = named
+ ? followUpSubmitIntent(
+ useChatPreferencesStore.getState().followUpBehavior,
+ named,
+ )
+ : intent;
try {
form.requestSubmit();
} finally {
@@ -4732,6 +4771,41 @@ const Composer: FC<{
textFieldException: COMPOSER_INPUT_SELECTOR,
},
);
+ // Same send as above, with the follow-up named rather than left to the
+ // preference. handleSubmit reads the intent ref, so ask it for the opposite
+ // whenever the preference is not already the behaviour wanted here.
+ const submitWithFollowUp = useCallback(
+ (behavior: ComposerFollowUpBehavior) => {
+ // No dictation branch: the recording bar replaces the composer, so the
+ // foreground gate below already turns these into a no-op there.
+ if (!isSurfaceInForeground(COMPOSER_INPUT_SELECTOR)) return;
+ submitIntentRef.current = followUpSubmitIntent(
+ useChatPreferencesStore.getState().followUpBehavior,
+ behavior,
+ );
+ try {
+ formRef.current?.requestSubmit();
+ } finally {
+ submitIntentRef.current = "default";
+ }
+ },
+ [],
+ );
+ const followUpShortcutOptions = {
+ enabled: chatActive && !disabled,
+ skipInTextFields: true,
+ textFieldException: COMPOSER_INPUT_SELECTOR,
+ };
+ useShortcut(
+ "queueMessage",
+ () => submitWithFollowUp("queue"),
+ followUpShortcutOptions,
+ );
+ useShortcut(
+ "steerMessage",
+ () => submitWithFollowUp("steer"),
+ followUpShortcutOptions,
+ );
const wasDictatingRef = useRef(false);
useEffect(() => {
if (isDictating) {
diff --git a/studio/frontend/src/features/chat/index.ts b/studio/frontend/src/features/chat/index.ts
index 20ed71d22b8..96f198162bb 100644
--- a/studio/frontend/src/features/chat/index.ts
+++ b/studio/frontend/src/features/chat/index.ts
@@ -394,6 +394,7 @@ export {
composerSubmitIntent,
composerFollowUpBehavior,
composerShortcutLabels,
+ followUpSubmitIntent,
steeringInsertionIndex,
type ComposerSendShortcut,
type ComposerFollowUpBehavior,
diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsx
index c4be86ab066..a6fa2542849 100644
--- a/studio/frontend/src/features/chat/shared-composer.tsx
+++ b/studio/frontend/src/features/chat/shared-composer.tsx
@@ -2014,6 +2014,20 @@ export function SharedComposer({
textFieldException: COMPOSER_INPUT_SELECTOR,
},
);
+ // Compare has no follow-up behaviour of its own: a send waits for the run to
+ // finish, so there is nothing to queue behind or steer. Both chords still
+ // register here, or they would be dead on the only composer on screen.
+ const sendFollowUp = () => {
+ if (!isSurfaceInForeground(COMPOSER_INPUT_SELECTOR)) return;
+ sendRef.current?.();
+ };
+ const followUpOptions = {
+ enabled: chatActive && canSend,
+ skipInTextFields: true,
+ textFieldException: COMPOSER_INPUT_SELECTOR,
+ };
+ useShortcut("queueMessage", sendFollowUp, followUpOptions);
+ useShortcut("steerMessage", sendFollowUp, followUpOptions);
useShortcut(
"attachFiles",
() => {
diff --git a/studio/frontend/src/features/chat/utils/composer-preferences.ts b/studio/frontend/src/features/chat/utils/composer-preferences.ts
index 34b419f5e75..e9165079685 100644
--- a/studio/frontend/src/features/chat/utils/composer-preferences.ts
+++ b/studio/frontend/src/features/chat/utils/composer-preferences.ts
@@ -46,6 +46,14 @@ export function composerFollowUpBehavior(
return preference === "queue" ? "steer" : "queue";
}
+/** Intent that lands a submit on `behavior` from either preference. */
+export function followUpSubmitIntent(
+ preference: ComposerFollowUpBehavior,
+ behavior: ComposerFollowUpBehavior,
+): ComposerSubmitIntent {
+ return preference === behavior ? "default" : "opposite";
+}
+
export function composerShortcutLabels(
shortcut: ComposerSendShortcut,
mac: boolean,
diff --git a/studio/frontend/src/features/settings/components/composer-settings.tsx b/studio/frontend/src/features/settings/components/composer-settings.tsx
index 952699cf6f6..588d395d104 100644
--- a/studio/frontend/src/features/settings/components/composer-settings.tsx
+++ b/studio/frontend/src/features/settings/components/composer-settings.tsx
@@ -10,6 +10,7 @@ import {
SelectValue,
} from "@/components/ui/select";
import { Switch } from "@/components/ui/switch";
+import { cn } from "@/lib/utils";
import {
useChatPreferencesStore,
composerShortcutLabels,
@@ -81,8 +82,9 @@ export function ComposerSettings({ embedded = false }: { embedded?: boolean }) {
})}
hint={t("composerSettings.steerDescription")}
>
+ {/* Shared track + pill selector, as on the API key expiry row. */}
<div
- className="inline-flex gap-1 rounded-full bg-muted p-1"
+ className="hub-tab-toggle inline-flex h-8 items-center rounded-full"
role="group"
aria-label={t("composerSettings.followUp")}
>
@@ -92,7 +94,12 @@ export function ComposerSettings({ embedded = false }: { embedded?: boolean }) {
type="button"
aria-pressed={prefs.followUpBehavior === behavior}
onClick={() => prefs.setFollowUpBehavior(behavior)}
- className="cursor-pointer rounded-full px-3 py-1.5 text-sm text-muted-foreground transition-colors aria-pressed:bg-background aria-pressed:text-foreground aria-pressed:shadow-sm"
+ className={cn(
+ "inline-flex h-8 cursor-pointer items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ prefs.followUpBehavior === behavior
+ ? "hub-tab-toggle-pill text-foreground"
+ : "text-muted-foreground hover:text-foreground",
+ )}
>
{t(
behavior === "queue"
diff --git a/studio/frontend/src/features/settings/index.ts b/studio/frontend/src/features/settings/index.ts
index ddab0329ae6..80f9b38db74 100644
--- a/studio/frontend/src/features/settings/index.ts
+++ b/studio/frontend/src/features/settings/index.ts
@@ -84,6 +84,7 @@ export {
export { Shortcut } from "./components/shortcut";
export {
currentBinding,
+ shortcutMatchingEvent,
useKeyboardShortcutsStore,
} from "./stores/keyboard-shortcuts-store";
export type { ShortcutId } 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 91a2fc1587c..43fb3e5c852 100644
--- a/studio/frontend/src/features/settings/lib/keyboard-shortcuts.ts
+++ b/studio/frontend/src/features/settings/lib/keyboard-shortcuts.ts
@@ -56,6 +56,8 @@ export type ShortcutId =
| "openProjectPicker"
| "startDictation"
| "sendMessage"
+ | "queueMessage"
+ | "steerMessage"
| "toggleFastMode"
| "copyChatAsMarkdown"
| "copySessionId"
@@ -223,6 +225,10 @@ export const SHORTCUT_DEFS: ShortcutDef[] = [
nonMacDefaultBinding: "Mod+Alt+KeyV",
}),
def("sendMessage", null),
+ // Unassigned: ⌘⏎ already sends with the opposite follow-up, and these two
+ // name the behaviour instead of flipping it. Chat settings picks the default.
+ def("queueMessage", null),
+ def("steerMessage", null),
def("toggleFastMode", null),
def("copyChatAsMarkdown", null),
diff --git a/studio/frontend/src/features/settings/settings-search.ts b/studio/frontend/src/features/settings/settings-search.ts
index 85461317028..53b191cbc31 100644
--- a/studio/frontend/src/features/settings/settings-search.ts
+++ b/studio/frontend/src/features/settings/settings-search.ts
@@ -228,6 +228,8 @@ export const SETTINGS_SEARCH_INDEX: Record<SettingsTab, TranslationKey[]> = {
"settings.keyboardShortcuts.actions.openProjectPicker.label",
"settings.keyboardShortcuts.actions.startDictation.label",
"settings.keyboardShortcuts.actions.sendMessage.label",
+ "settings.keyboardShortcuts.actions.queueMessage.label",
+ "settings.keyboardShortcuts.actions.steerMessage.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 0c1cd6ec131..c7053d4f48f 100644
--- a/studio/frontend/src/features/settings/stores/keyboard-shortcuts-store.ts
+++ b/studio/frontend/src/features/settings/stores/keyboard-shortcuts-store.ts
@@ -9,7 +9,10 @@ import {
type ShortcutId,
type ShortcutSlot,
defaultBindingFor,
+ isMacPlatform,
isShortcutId,
+ matchesBinding,
+ parseBinding,
// Explicit extension: this module is imported directly by the node test
// runner, which does not do bundler-style resolution.
} from "../lib/keyboard-shortcuts.ts";
@@ -191,6 +194,30 @@ export function findConflicts(overrides: ShortcutOverrides): Set<ShortcutId> {
return out;
}
+/**
+ * The first of `ids` this event fires, or null. For a handler that runs before
+ * the window listener and would otherwise consume the chord: an Enter chord
+ * reaches the composer's own keydown first, and preventDefault there stops
+ * useShortcut. Ownership is checked the same way useShortcut checks it, so a
+ * slot another action owns does not count.
+ */
+export function shortcutMatchingEvent<Id extends ShortcutId>(
+ overrides: ShortcutOverrides,
+ ids: readonly Id[],
+ event: Parameters<typeof matchesBinding>[1],
+ mac = isMacPlatform(),
+): Id | null {
+ for (const id of ids) {
+ for (const slot of SHORTCUT_SLOTS) {
+ const value = resolveBinding(overrides, id, slot);
+ if (!value || shortcutOwningBinding(overrides, value) !== id) continue;
+ const binding = parseBinding(value);
+ if (binding && matchesBinding(binding, event, mac)) return id;
+ }
+ }
+ return null;
+}
+
interface KeyboardShortcutsState {
overrides: ShortcutOverrides;
/** Assign a serialized binding, e.g. "Mod+Shift+KeyO". */
diff --git a/studio/frontend/src/features/settings/tabs/agents-tab.tsx b/studio/frontend/src/features/settings/tabs/agents-tab.tsx
index 14a25a07f6e..1ff74d8a221 100644
--- a/studio/frontend/src/features/settings/tabs/agents-tab.tsx
+++ b/studio/frontend/src/features/settings/tabs/agents-tab.tsx
@@ -1295,44 +1295,48 @@ export function AgentsTab() {
{t("settings.agents.intro")}
</p>
- <fieldset className="flex min-w-0 items-center gap-0.5">
- <legend className="mb-2 text-xs font-medium text-foreground">
+ {/* Shared track + pill selector. The legend is sr-only: the two shell
+ names already say what the control picks. */}
+ <fieldset className="flex min-w-0">
+ <legend className="sr-only">
{t("settings.agents.commandShell")}
</legend>
- <button
- type="button"
- onClick={() => {
- setCommandOsOverride("unix");
- setStoredOs("unix");
- resetCopied();
- }}
- aria-pressed={commandOs === "unix"}
- className={cn(
- "rounded-full px-2.5 py-1 text-ui-11 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
- commandOs === "unix"
- ? "hub-tab-toggle-pill text-foreground"
- : "text-muted-foreground hover:text-foreground",
- )}
- >
- {t("settings.apiKeys.osUnix")}
- </button>
- <button
- type="button"
- onClick={() => {
- setCommandOsOverride("windows");
- setStoredOs("windows");
- resetCopied();
- }}
- aria-pressed={commandOs === "windows"}
- className={cn(
- "rounded-full px-2.5 py-1 text-ui-11 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
- commandOs === "windows"
- ? "hub-tab-toggle-pill text-foreground"
- : "text-muted-foreground hover:text-foreground",
- )}
- >
- {t("settings.apiKeys.osWindows")}
- </button>
+ <div className="hub-tab-toggle inline-flex h-8 items-center rounded-full">
+ <button
+ type="button"
+ onClick={() => {
+ setCommandOsOverride("unix");
+ setStoredOs("unix");
+ resetCopied();
+ }}
+ aria-pressed={commandOs === "unix"}
+ className={cn(
+ "inline-flex h-8 items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ commandOs === "unix"
+ ? "hub-tab-toggle-pill text-foreground"
+ : "text-muted-foreground hover:text-foreground",
+ )}
+ >
+ {t("settings.apiKeys.osUnix")}
+ </button>
+ <button
+ type="button"
+ onClick={() => {
+ setCommandOsOverride("windows");
+ setStoredOs("windows");
+ resetCopied();
+ }}
+ aria-pressed={commandOs === "windows"}
+ className={cn(
+ "inline-flex h-8 items-center rounded-full px-3.5 text-ui-12 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ commandOs === "windows"
+ ? "hub-tab-toggle-pill text-foreground"
+ : "text-muted-foreground hover:text-foreground",
+ )}
+ >
+ {t("settings.apiKeys.osWindows")}
+ </button>
+ </div>
</fieldset>
<section
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 029b8aefd0b..ebb98a9e6f6 100644
--- a/studio/frontend/src/features/settings/tabs/keyboard-shortcuts-tab.tsx
+++ b/studio/frontend/src/features/settings/tabs/keyboard-shortcuts-tab.tsx
@@ -374,12 +374,9 @@ export function KeyboardShortcutsTab() {
{t("settings.keyboardShortcuts.noResults")}
</p>
) : (
- // Rows carry the padding, so the dividers sit inset from the edge.
- <div className="rounded-xl border border-border/70 px-5">
- <div className="divide-y divide-border/60">
- {visible.map(renderRow)}
- </div>
- </div>
+ // No frame: the dividers alone separate the rows, and they line up
+ // with the heading and the search box above.
+ <div className="divide-y divide-border/60">{visible.map(renderRow)}</div>
)}
<div className="flex justify-start pt-1">
diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.ts
index 6b2739835f4..aa0b1fe69e3 100644
--- a/studio/frontend/src/i18n/locales/ar.ts
+++ b/studio/frontend/src/i18n/locales/ar.ts
@@ -499,6 +499,14 @@ export const ar = {
label: "إرسال الرسالة",
description: "إرسال ما في مربع الكتابة",
},
+ queueMessage: {
+ label: "إضافة الرسالة إلى الطابور",
+ description: "إرسال المسودة إلى نهاية الطابور",
+ },
+ steerMessage: {
+ label: "توجيه الرد",
+ description: "إيقاف الرد الحالي وإرسال المسودة بعده",
+ },
cycleReasoningEffort: {
label: "تدوير مستوى التفكير",
description: "التنقل بين مستويات جهد التفكير",
diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.ts
index 8922905672e..ee73a178e54 100644
--- a/studio/frontend/src/i18n/locales/de.ts
+++ b/studio/frontend/src/i18n/locales/de.ts
@@ -503,6 +503,14 @@ export const de = {
label: "Nachricht senden",
description: "Den Inhalt des Eingabefelds senden",
},
+ queueMessage: {
+ label: "Nachricht einreihen",
+ description: "Den Entwurf ans Ende der Warteschlange senden",
+ },
+ steerMessage: {
+ label: "Antwort steuern",
+ description: "Die laufende Antwort stoppen und den Entwurf als Nächstes senden",
+ },
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 0b166b525be..b11730db61c 100644
--- a/studio/frontend/src/i18n/locales/en.ts
+++ b/studio/frontend/src/i18n/locales/en.ts
@@ -10,7 +10,7 @@ export const en = {
sendShortcut: "Send shortcut",
sendDescription: "Choose when Enter sends a prompt or inserts a new line.",
followUp: "Follow-up behavior",
- followUpDescription: "Choose what happens when you send during a response. Press {shortcut} to do the opposite for one message.",
+ followUpDescription: "What happens when you send during a response. Press {shortcut} to do the opposite once.",
queue: "Queue",
steer: "Steer",
steerDescription: "Steer stops the current response and sends your follow-up next.",
@@ -504,6 +504,14 @@ export const en = {
label: "Send message",
description: "Send what is in the composer",
},
+ queueMessage: {
+ label: "Queue message",
+ description: "Send the draft to the end of the prompt queue",
+ },
+ steerMessage: {
+ label: "Steer response",
+ description: "Stop the current response and send the draft next",
+ },
cycleReasoningEffort: {
label: "Cycle reasoning effort",
description: "Step through the reasoning effort levels",
@@ -1485,9 +1493,8 @@ export const en = {
"When off, use the same settings for every model.",
autoCompactHint: "Uses the context length you set, not available VRAM.",
pastedTextShortDescription:
- "Pastes of {count} characters or more become .txt attachments. Shorter pastes stay in the message box.",
- pastedTextOffDescription:
- "All pasted text stays in the message box, regardless of length.",
+ "Pastes of {count} characters or more become .txt attachments.",
+ pastedTextOffDescription: "Pasted text always stays in the message box.",
compactionDescriptionInherit: "Follow the server's context policy.",
compactionDescriptionCheckpoint:
"Keep the latest turn and standing instructions.",
diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.ts
index cd91995a4d4..f1120aebfbf 100644
--- a/studio/frontend/src/i18n/locales/es.ts
+++ b/studio/frontend/src/i18n/locales/es.ts
@@ -502,6 +502,14 @@ export const es = {
label: "Enviar mensaje",
description: "Enviar lo que hay en el redactor",
},
+ queueMessage: {
+ label: "Poner el mensaje en cola",
+ description: "Enviar el borrador al final de la cola",
+ },
+ steerMessage: {
+ label: "Dirigir la respuesta",
+ description: "Detener la respuesta actual y enviar el borrador a continuación",
+ },
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 25d0eab8dd9..8d27067d3c1 100644
--- a/studio/frontend/src/i18n/locales/fr.ts
+++ b/studio/frontend/src/i18n/locales/fr.ts
@@ -503,6 +503,14 @@ export const fr = {
label: "Envoyer le message",
description: "Envoyer le contenu de la zone de saisie",
},
+ queueMessage: {
+ label: "Mettre le message en file",
+ description: "Envoyer le brouillon à la fin de la file",
+ },
+ steerMessage: {
+ label: "Réorienter la réponse",
+ description: "Arrêter la réponse en cours et envoyer le brouillon ensuite",
+ },
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/hi.ts b/studio/frontend/src/i18n/locales/hi.ts
index b47bd46473f..0630aee086a 100644
--- a/studio/frontend/src/i18n/locales/hi.ts
+++ b/studio/frontend/src/i18n/locales/hi.ts
@@ -502,6 +502,14 @@ export const hi = {
label: "संदेश भेजें",
description: "लिखने के बॉक्स की सामग्री भेजें",
},
+ queueMessage: {
+ label: "संदेश कतार में डालें",
+ description: "ड्राफ़्ट को कतार के अंत में भेजें",
+ },
+ steerMessage: {
+ label: "उत्तर बदलें",
+ description: "मौजूदा उत्तर रोककर ड्राफ़्ट अगला भेजें",
+ },
cycleReasoningEffort: {
label: "तर्क प्रयास बदलें",
description: "तर्क प्रयास के स्तरों में क्रमशः बदलें",
diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.ts
index 42bd4957fc5..5a80152bc1a 100644
--- a/studio/frontend/src/i18n/locales/it.ts
+++ b/studio/frontend/src/i18n/locales/it.ts
@@ -467,6 +467,14 @@ export const it = {
label: "Invia messaggio",
description: "Invia il contenuto dell’editor",
},
+ queueMessage: {
+ label: "Accoda messaggio",
+ description: "Invia la bozza in fondo alla coda",
+ },
+ steerMessage: {
+ label: "Reindirizza la risposta",
+ description: "Interrompi la risposta in corso e invia subito la bozza",
+ },
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 ea8a63d7eea..af68a7ff05c 100644
--- a/studio/frontend/src/i18n/locales/ja.ts
+++ b/studio/frontend/src/i18n/locales/ja.ts
@@ -501,6 +501,14 @@ export const ja = {
label: "メッセージを送信",
description: "入力欄の内容を送信します",
},
+ queueMessage: {
+ label: "メッセージをキューに追加",
+ description: "下書きをキューの最後に送信します",
+ },
+ steerMessage: {
+ label: "応答を修正",
+ description: "現在の応答を停止して下書きを次に送信します",
+ },
cycleReasoningEffort: {
label: "思考の深さを順に切り替え",
description: "思考の深さのレベルを順に切り替えます",
diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.ts
index 37a3cc1d96b..82af561a0d4 100644
--- a/studio/frontend/src/i18n/locales/ko.ts
+++ b/studio/frontend/src/i18n/locales/ko.ts
@@ -499,6 +499,14 @@ export const ko = {
label: "메시지 보내기",
description: "입력창의 내용을 보냅니다",
},
+ queueMessage: {
+ label: "메시지 대기열에 추가",
+ description: "초안을 대기열 끝으로 보냅니다",
+ },
+ steerMessage: {
+ 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 78a8418e2ce..09472930265 100644
--- a/studio/frontend/src/i18n/locales/pt-br.ts
+++ b/studio/frontend/src/i18n/locales/pt-br.ts
@@ -501,6 +501,14 @@ export const ptBR = {
label: "Enviar mensagem",
description: "Enviar o que está no compositor",
},
+ queueMessage: {
+ label: "Enfileirar mensagem",
+ description: "Enviar o rascunho para o fim da fila",
+ },
+ steerMessage: {
+ label: "Direcionar a resposta",
+ description: "Parar a resposta atual e enviar o rascunho em seguida",
+ },
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 90035839c80..18f71b46d9b 100644
--- a/studio/frontend/src/i18n/locales/ru.ts
+++ b/studio/frontend/src/i18n/locales/ru.ts
@@ -501,6 +501,14 @@ export const ru = {
label: "Отправить сообщение",
description: "Отправить содержимое поля ввода",
},
+ queueMessage: {
+ label: "Поставить сообщение в очередь",
+ description: "Отправить черновик в конец очереди",
+ },
+ steerMessage: {
+ label: "Скорректировать ответ",
+ description: "Остановить текущий ответ и отправить черновик следующим",
+ },
cycleReasoningEffort: {
label: "Переключать усилие рассуждения",
description: "Перебрать уровни усилия рассуждения",
diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.ts
index 1be10f88099..1895c8239b3 100644
--- a/studio/frontend/src/i18n/locales/zh-CN.ts
+++ b/studio/frontend/src/i18n/locales/zh-CN.ts
@@ -497,6 +497,14 @@ export const zhCN = {
label: "发送消息",
description: "发送输入框中的内容",
},
+ queueMessage: {
+ label: "将消息排队",
+ description: "把草稿发送到队列末尾",
+ },
+ steerMessage: {
+ label: "引导回复",
+ description: "停止当前回复并接着发送草稿",
+ },
cycleReasoningEffort: {
label: "循环切换推理强度",
description: "在各推理强度等级之间循环",
diff --git a/studio/frontend/tests/composer-preferences.test.ts b/studio/frontend/tests/composer-preferences.test.ts
index 10434450177..7454c376fd1 100644
--- a/studio/frontend/tests/composer-preferences.test.ts
+++ b/studio/frontend/tests/composer-preferences.test.ts
@@ -1,9 +1,11 @@
import assert from "node:assert/strict";
import test from "node:test";
+import { readFile } from "node:fs/promises";
import {
composerSubmitIntent,
composerFollowUpBehavior,
composerShortcutLabels,
+ followUpSubmitIntent,
normalizeComposerPreferences,
type ComposerKeyEvent,
} from "../src/features/chat/utils/composer-preferences.ts";
@@ -84,6 +86,42 @@ test("one-message override flips both preferences without changing the default",
opposite: "Ctrl+Shift+Enter",
});
});
+// The queue and steer chords name a behavior, where ⌘⏎ only flips the one in
+// settings. Both preferences have to reach both behaviors, or a user set to
+// steer would find the queue chord steering.
+test("the queue and steer chords land on their behavior from either preference", () => {
+ for (const preference of ["queue", "steer"] as const) {
+ for (const behavior of ["queue", "steer"] as const) {
+ assert.equal(
+ composerFollowUpBehavior(
+ preference,
+ followUpSubmitIntent(preference, behavior),
+ ),
+ behavior,
+ `${preference} preference, ${behavior} chord`,
+ );
+ }
+ }
+});
+// The chords submit the form, and handleSubmit is what reads the intent, so
+// the ref has to be set before requestSubmit and cleared after it returns.
+test("the queue and steer chords set the intent around the submit", async () => {
+ const source = await readFile(
+ new URL("../src/components/assistant-ui/thread.tsx", import.meta.url),
+ "utf8",
+ );
+ const body = source.slice(
+ source.indexOf("const submitWithFollowUp = useCallback("),
+ );
+ const call = body.slice(0, body.indexOf("\n );"));
+ assert.match(call, /submitIntentRef\.current = followUpSubmitIntent\(/);
+ assert.ok(
+ call.indexOf("followUpSubmitIntent(") <
+ call.indexOf("formRef.current?.requestSubmit()"),
+ "the intent is set after the submit it belongs to",
+ );
+ assert.match(call, /finally \{\n\s*submitIntentRef\.current = "default";/);
+});
test("legacy and malformed saved settings retain usable defaults", () => {
const defaults = {
plainTextComposer: true,
diff --git a/studio/frontend/tests/keyboard-shortcuts.test.ts b/studio/frontend/tests/keyboard-shortcuts.test.ts
index 2f7ea0bffb4..0a4eccbcc5b 100644
--- a/studio/frontend/tests/keyboard-shortcuts.test.ts
+++ b/studio/frontend/tests/keyboard-shortcuts.test.ts
@@ -26,6 +26,7 @@ import {
resolveAllBindings,
resolveBinding,
resolveBindings,
+ shortcutMatchingEvent,
shortcutOwningBinding,
} from "../src/features/settings/stores/keyboard-shortcuts-store.ts";
import { SETTINGS_TABS } from "../src/features/settings/stores/settings-dialog-store.ts";
@@ -1865,3 +1866,116 @@ test("the logout row is not offered on the desktop build", async () => {
);
assert.match(KEYBOARD_SHORTCUTS_TAB, /!\(isTauri && def\.webOnly\)/);
});
+
+// The composer's own keydown runs before the window listener and calls
+// preventDefault, which useShortcut treats as "already handled". A queue or
+// steer chord bound onto an Enter combination would therefore submit with the
+// send preference's intent instead of the behaviour it names, so the composer
+// looks the chord up itself.
+const FOLLOW_UP_IDS = ["queueMessage", "steerMessage"] as const;
+
+/** Mod+Enter as it arrives on each platform: Cmd on macOS, Ctrl elsewhere. */
+const modEnterOn = (mac: boolean) => ({
+ code: "Enter",
+ metaKey: mac,
+ ctrlKey: !mac,
+ shiftKey: false,
+ altKey: false,
+});
+
+test("an Enter chord bound to queue or steer is recognised in the composer", () => {
+ for (const mac of [true, false]) {
+ const modEnter = modEnterOn(mac);
+ assert.equal(shortcutMatchingEvent({}, FOLLOW_UP_IDS, modEnter, mac), null);
+ assert.equal(
+ shortcutMatchingEvent(
+ { queueMessage: { primary: "Mod+Enter" } },
+ FOLLOW_UP_IDS,
+ modEnter,
+ mac,
+ ),
+ "queueMessage",
+ );
+ // A different chord is not this one: the composer keeps its own intent.
+ assert.equal(
+ shortcutMatchingEvent(
+ { queueMessage: { primary: "Mod+Enter" } },
+ FOLLOW_UP_IDS,
+ { ...modEnter, shiftKey: true },
+ mac,
+ ),
+ null,
+ );
+ // Shared with an action the registry ranks higher, so that one runs and
+ // this row is shadowed, the same rule useShortcut applies.
+ assert.equal(
+ shortcutMatchingEvent(
+ {
+ newChat: { primary: "Mod+Enter" },
+ queueMessage: { primary: "Mod+Enter" },
+ },
+ FOLLOW_UP_IDS,
+ modEnter,
+ mac,
+ ),
+ null,
+ );
+ }
+});
+
+test("the composer submits an Enter-bound chord with the named behavior", async () => {
+ const { composerFollowUpBehavior, followUpSubmitIntent } = await import(
+ "../src/features/chat/utils/composer-preferences.ts"
+ );
+ // ⌘⏎ with the send preference on Enter is the "opposite" chord, so a steer
+ // user pressing it would queue. Bound to Queue message it has to queue for
+ // both, and bound to Steer response it has to steer for both.
+ for (const preference of ["queue", "steer"] as const) {
+ for (const [id, behavior] of [
+ ["queueMessage", "queue"],
+ ["steerMessage", "steer"],
+ ] as const) {
+ const named = shortcutMatchingEvent(
+ { [id]: { primary: "Mod+Enter" } },
+ FOLLOW_UP_IDS,
+ modEnterOn(true),
+ true,
+ );
+ assert.equal(named, id);
+ assert.equal(
+ composerFollowUpBehavior(
+ preference,
+ followUpSubmitIntent(preference, behavior),
+ ),
+ behavior,
+ `${preference} preference, ${id} chord`,
+ );
+ }
+ }
+ // The composer path has to consult the chord before it uses the intent the
+ // send preference produced.
+ const submitOnKey = THREAD.slice(THREAD.indexOf("const submitOnKey = useCallback("));
+ const body = submitOnKey.slice(0, submitOnKey.indexOf("\n );"));
+ assert.match(body, /const named = followUpShortcutBehavior\(event\);/);
+ assert.match(body, /submitIntentRef\.current = named\n?\s*\?/);
+});
+
+// Compare hides the thread composer and puts SharedComposer on screen, so a
+// composer chord registered in only one of them is dead in the other mode.
+test("the follow-up chords are registered in both composers", async () => {
+ const shared = await readSrcAsync("features/chat/shared-composer.tsx");
+ for (const id of FOLLOW_UP_IDS) {
+ assert.match(
+ THREAD,
+ new RegExp(`useShortcut\\(\\s*\n?\\s*"${id}"`),
+ `thread.tsx does not register ${id}`,
+ );
+ assert.match(
+ shared,
+ new RegExp(`useShortcut\\(\\s*\n?\\s*"${id}"`),
+ `shared-composer.tsx does not register ${id}`,
+ );
+ }
+ // The reason the second registration is needed rather than optional.
+ assert.match(CHAT_PAGE, /<Thread hideComposer=\{true\}/);
+});