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.

feat(studio): type-to-activate search, composer and prompt inputs (#10303)

Fahad Iftikhar2fd457b8bac2
diff --git a/studio/frontend/src/app/routes/__root.tsx b/studio/frontend/src/app/routes/__root.tsx
index 3707a805592..9bdae8be8d8 100644
--- a/studio/frontend/src/app/routes/__root.tsx
+++ b/studio/frontend/src/app/routes/__root.tsx
@@ -57,6 +57,7 @@ import { useNativePathLeasesSupported } from "@/features/native-intents";
import { useRagAvailabilityStore } from "@/features/rag";
import { useIsMobileShell } from "@/hooks/use-mobile";
import { useSidebarPin } from "@/hooks/use-sidebar-pin";
+import { useTypeToActivate } from "@/hooks/use-type-to-activate";
import { type TranslationKey, useT } from "@/i18n";
import { isTauri } from "@/lib/api-base";
import { createNavigationNonce } from "@/lib/navigation-nonce";
@@ -444,6 +445,7 @@ function RootLayout() {
: "pt-[calc(var(--studio-non-chat-content-top-inset,var(--studio-content-top-inset,0px))-var(--studio-non-chat-scroller-top,0px))] [--studio-titlebar-height:var(--studio-non-chat-content-top-inset,var(--studio-content-top-inset,0px))]";
useTrainingUnloadGuard();
+ useTypeToActivate();
// Global export driver: streams worker logs and tracks status from any route
// so an export keeps running and stays visible while training / chatting.
useExportRuntimeLifecycle();
diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsx
index 466e962ae10..e641469a637 100644
--- a/studio/frontend/src/components/assistant-ui/thread.tsx
+++ b/studio/frontend/src/components/assistant-ui/thread.tsx
@@ -5448,6 +5448,7 @@ const Composer: FC<{
overlay ? "Type your edits for your image" : "Ask anything"
}
ref={inputRef}
+ data-type-to-activate="composer"
className="aui-composer-input unsloth-composer-input"
minRows={1}
maxRows={12}
diff --git a/studio/frontend/src/features/audio/pages/clone-page.tsx b/studio/frontend/src/features/audio/pages/clone-page.tsx
index 502078fd612..2a7fe95e159 100644
--- a/studio/frontend/src/features/audio/pages/clone-page.tsx
+++ b/studio/frontend/src/features/audio/pages/clone-page.tsx
@@ -175,6 +175,7 @@ function CloneInputs({
Text to speak
</label>
<Textarea
+ data-type-to-activate="prompt"
id={CLONE_TEXT_FIELD_ID}
value={clone.text}
onChange={(event) => setText(event.target.value)}
diff --git a/studio/frontend/src/features/audio/pages/music-page.tsx b/studio/frontend/src/features/audio/pages/music-page.tsx
index adbba6edc46..0b578ea469e 100644
--- a/studio/frontend/src/features/audio/pages/music-page.tsx
+++ b/studio/frontend/src/features/audio/pages/music-page.tsx
@@ -195,6 +195,7 @@ function SongInputs({
htmlFor={MUSIC_DESCRIPTION_FIELD_ID}
>
<Textarea
+ data-type-to-activate="prompt"
id={MUSIC_DESCRIPTION_FIELD_ID}
value={description}
disabled={disabled}
diff --git a/studio/frontend/src/features/audio/pages/tts-workspace.tsx b/studio/frontend/src/features/audio/pages/tts-workspace.tsx
index f212356fc33..3cc240bdbbf 100644
--- a/studio/frontend/src/features/audio/pages/tts-workspace.tsx
+++ b/studio/frontend/src/features/audio/pages/tts-workspace.tsx
@@ -205,6 +205,7 @@ export function TtsRailFields({
}
>
<Textarea
+ data-type-to-activate="prompt"
id="audio-prompt"
value={prompt}
onChange={(event) => setPrompt(event.target.value)}
diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsx
index e2f094df907..85109d4ee53 100644
--- a/studio/frontend/src/features/chat/shared-composer.tsx
+++ b/studio/frontend/src/features/chat/shared-composer.tsx
@@ -2694,6 +2694,7 @@ export function SharedComposer({
<textarea
{...skillMentions.inputProps}
ref={textareaRef}
+ data-type-to-activate="composer"
value={text}
onChange={(e) => {
// ALWAYS mirror the DOM value into React state, even during IME composition: the controlled `value`
diff --git a/studio/frontend/src/features/images/images-page.tsx b/studio/frontend/src/features/images/images-page.tsx
index de0eeb5304b..8d3ecf7fbfd 100644
--- a/studio/frontend/src/features/images/images-page.tsx
+++ b/studio/frontend/src/features/images/images-page.tsx
@@ -5266,6 +5266,7 @@ export function ImagesPage({
<Field label={workflow === "edit" ? "Instruction" : "Prompt"}>
<Textarea
+ data-type-to-activate="prompt"
rows={4}
className={cn(IMAGE_PROMPT_BOX, "min-h-32")}
placeholder={
diff --git a/studio/frontend/src/features/settings/settings-dialog.tsx b/studio/frontend/src/features/settings/settings-dialog.tsx
index c0ddf44af48..a54cd6398a2 100644
--- a/studio/frontend/src/features/settings/settings-dialog.tsx
+++ b/studio/frontend/src/features/settings/settings-dialog.tsx
@@ -463,6 +463,7 @@ export function SettingsDialog() {
<>
<Dialog open={open} onOpenChange={(o) => !o && closeDialog()}>
<DialogContent
+ data-settings-dialog
showCloseButton={false}
overlayClassName="bg-black/30 supports-backdrop-filter:backdrop-blur-[2px]"
onCloseAutoFocus={(e) => {
@@ -527,6 +528,7 @@ export function SettingsDialog() {
setQuery("");
}
}}
+ data-type-to-activate="settings-search"
placeholder={t("settings.dialog.searchPlaceholder")}
aria-label={t("settings.dialog.searchPlaceholder")}
className="h-8 w-full rounded-full border border-border bg-background pr-8 pl-8 text-sm text-foreground outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-ring dark:focus-visible:border-transparent dark:focus-visible:bg-[rgb(255_255_255_/_calc(0.12*var(--contrast-wash-gain,1)))] dark:border-transparent dark:bg-[rgb(255_255_255_/_calc(0.06*var(--contrast-wash-gain,1)))]"
diff --git a/studio/frontend/src/features/video/video-page.tsx b/studio/frontend/src/features/video/video-page.tsx
index de9e81a8a44..735ce95c147 100644
--- a/studio/frontend/src/features/video/video-page.tsx
+++ b/studio/frontend/src/features/video/video-page.tsx
@@ -3846,6 +3846,7 @@ function VideoGenerator({
<Field label="Prompt">
<Textarea
+ data-type-to-activate="prompt"
rows={4}
placeholder={exampleDismissed ? undefined : VIDEO_EXAMPLE_PROMPT}
value={prompt}
diff --git a/studio/frontend/src/hooks/use-type-to-activate.ts b/studio/frontend/src/hooks/use-type-to-activate.ts
new file mode 100644
index 00000000000..f09f8ff5092
--- /dev/null
+++ b/studio/frontend/src/hooks/use-type-to-activate.ts
@@ -0,0 +1,119 @@
+// 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 { useEffect } from "react";
+import { useSettingsDialogStore } from "@/features/settings";
+
+/**
+ * A printable keystroke with nothing editable focused moves focus to the
+ * screen's primary input (settings search, composer, or media prompt). Focusing
+ * during keydown lets the browser's default action insert the character there.
+ */
+export function useTypeToActivate(): void {
+ const settingsOpen = useSettingsDialogStore((s) => s.open);
+
+ useEffect(() => {
+ const handler = (e: KeyboardEvent) => {
+ if (e.defaultPrevented) return;
+ // AltGr (Ctrl+Alt) and macOS Option type characters, so they are not shortcuts.
+ const altGraph =
+ typeof e.getModifierState === "function" &&
+ e.getModifierState("AltGraph");
+ if (e.metaKey) return;
+ if (e.ctrlKey && !altGraph) return;
+ if (
+ e.altKey &&
+ !altGraph &&
+ !(IS_MAC && (codePointCount(e.key) === 1 || e.key === "Dead"))
+ ) {
+ return;
+ }
+ // IME start and dead keys must reach the target so composition begins there.
+ const compositionStart =
+ e.keyCode === 229 || e.isComposing || e.key === "Dead";
+ if (
+ !compositionStart &&
+ (codePointCount(e.key) !== 1 || e.key === " ")
+ ) {
+ return;
+ }
+
+ if (isEditable(document.activeElement)) return;
+ if (hasOpenOverlay(settingsOpen)) return;
+
+ // Radix keeps the settings dialog mounted while it animates closed, so its
+ // search is excluded then or it would win and swallow the keystroke.
+ const target = firstVisible(
+ settingsOpen
+ ? '[data-type-to-activate="settings-search"]'
+ : '[data-type-to-activate]:not([data-type-to-activate="settings-search"])',
+ );
+ target?.focus();
+ };
+ window.addEventListener("keydown", handler);
+ return () => window.removeEventListener("keydown", handler);
+ }, [settingsOpen]);
+}
+
+// From the browser, not the server's device_type: remote sessions can differ.
+const IS_MAC =
+ typeof navigator !== "undefined" &&
+ (navigator.platform?.toLowerCase().includes("mac") ||
+ navigator.userAgent.toLowerCase().includes("mac"));
+
+const TEXT_INPUT_TYPES = new Set([
+ "date",
+ "datetime-local",
+ "email",
+ "month",
+ "number",
+ "password",
+ "search",
+ "tel",
+ "text",
+ "time",
+ "url",
+ "week",
+]);
+
+/** Surrogate pairs count as one character. */
+function codePointCount(value: string): number {
+ return Array.from(value).length;
+}
+
+function isEditable(el: Element | null): boolean {
+ if (!(el instanceof HTMLElement)) return false;
+ if (el instanceof HTMLTextAreaElement) return !el.readOnly;
+ if (el instanceof HTMLSelectElement) return true;
+ if (el.isContentEditable) return true;
+ if (el instanceof HTMLInputElement) {
+ return TEXT_INPUT_TYPES.has(el.type) && !el.readOnly;
+ }
+ return false;
+}
+
+/** Popovers, menus, the lightbox, blocking screens, and any dialog but settings own the keystroke. */
+function hasOpenOverlay(settingsOpen: boolean): boolean {
+ const notSettings = settingsOpen ? ":not([data-settings-dialog])" : "";
+ const overlaySelector = [
+ '[data-slot="popover-content"][data-state="open"]',
+ '[data-slot="combobox-content"][data-open]',
+ '[data-slot="image-zoom-overlay"]',
+ "[data-blocking-screen]",
+ '[role="menu"][data-state="open"]',
+ '[role="listbox"][data-state="open"]',
+ `[role="dialog"][data-state="open"]${notSettings}`,
+ `[role="dialog"][aria-modal="true"]:not([data-state="closed"])${notSettings}`,
+ `[role="alertdialog"][data-state="open"]${notSettings}`,
+ `[role="alertdialog"][aria-modal="true"]:not([data-state="closed"])${notSettings}`,
+ ].join(", ");
+ return document.querySelector(overlaySelector) !== null;
+}
+
+function firstVisible(selector: string): HTMLElement | null {
+ for (const el of document.querySelectorAll<HTMLElement>(selector)) {
+ if (el.matches(":disabled") || el.closest("[inert]")) continue;
+ if (el.getClientRects().length > 0) return el;
+ }
+ return null;
+}