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: three-state Thinking and Tool calls visibility in Display (#11433)

Michael Han49b484341f04
diff --git a/studio/frontend/smoke-tool-activity-main.tsx b/studio/frontend/smoke-tool-activity-main.tsx
index 1515b185898..18008bcca5d 100644
--- a/studio/frontend/smoke-tool-activity-main.tsx
+++ b/studio/frontend/smoke-tool-activity-main.tsx
@@ -196,14 +196,17 @@ function App() {
w.__setHasText = (v: boolean) => setHasText(v);
w.__setAwaitingApproval = (v: boolean) => setAwaitingApproval(v);
w.__remount = () => setGeneration((g) => g + 1);
+ // The scenes drive the old boolean, which maps exactly onto the two settings they
+ // exercise: true is "collapsed", false is "auto". Always expanded has no scene here;
+ // tests/tool-activity-preference.ts covers it.
w.__setPreference = (v: boolean) =>
- useChatPreferencesStore.getState().setCollapseToolActivityByDefault(v);
+ useChatPreferencesStore.getState().setToolVisibility(v ? "collapsed" : "auto");
w.__getPreference = () =>
- useChatPreferencesStore.getState().collapseToolActivityByDefault;
+ useChatPreferencesStore.getState().toolVisibility === "collapsed";
// The declared default, so a scene can check "landed on the default"
// without hard-coding which default that currently is.
w.__getDefaultPreference = () =>
- useChatPreferencesStore.getInitialState().collapseToolActivityByDefault;
+ useChatPreferencesStore.getInitialState().toolVisibility === "collapsed";
}, []);
useEffect(() => {
@@ -215,7 +218,7 @@ function App() {
strict,
rtl,
preference:
- useChatPreferencesStore.getState().collapseToolActivityByDefault,
+ useChatPreferencesStore.getState().toolVisibility === "collapsed",
};
});
});
diff --git a/studio/frontend/src/components/assistant-ui/reasoning.tsx b/studio/frontend/src/components/assistant-ui/reasoning.tsx
index 89ffed42be5..d7fab9782a9 100644
--- a/studio/frontend/src/components/assistant-ui/reasoning.tsx
+++ b/studio/frontend/src/components/assistant-ui/reasoning.tsx
@@ -31,6 +31,7 @@ import {
} from "@/components/ui/unmeasured-collapsible";
import {
clearReasoningRound,
+ foldIsActive,
resolveReasoningGroupDuration,
resolveReasoningOpen,
resolveReasoningToggle,
@@ -748,8 +749,8 @@ function ReasoningBody({
// answer. Later reasoning groups in that span render as plain rounds inside it, following its
// open state, and the tool groups between them do the same (see tool-group.tsx).
const ReasoningGroupImpl: ReasoningGroupComponent = (props) => {
- const foldToolActivity = useChatPreferencesStore(
- (state) => state.foldToolActivityIntoThinking,
+ const foldToolActivity = useChatPreferencesStore((state) =>
+ foldIsActive(state.foldToolActivityIntoThinking, state.toolVisibility),
);
const folded = useAuiState(
({ message }) =>
@@ -918,12 +919,12 @@ const ReasoningGroupBlock = ({
return resolveReasoningGroupDuration(message.parts, startIndex, custom);
});
- const collapseByDefault = useChatPreferencesStore(
- (state) => state.collapseThinkingByDefault,
+ const visibility = useChatPreferencesStore(
+ (state) => state.thinkingVisibility,
);
- const [manualOpen, setManualOpen] = useState(false);
- const [dismissedWhileStreaming, setDismissedWhileStreaming] = useState(false);
+ // null until toggled by hand, then it outranks the setting for the round.
+ const [override, setOverride] = useState<boolean | null>(null);
const [retainStreamingHeight, setRetainStreamingHeight] = useState(false);
const [duration, setDuration] = useState<number>(0);
const startTimeRef = useRef<number | null>(null);
@@ -940,18 +941,30 @@ const ReasoningGroupBlock = ({
}
}, [isReasoningStreaming]);
- // Reset per-round open state. manualOpen is sticky and regenerate reuses this instance, so a
- // hand-opened block would stay pinned open and never collapse. Adjusted during render, not in an
- // effect: React re-runs this component before committing, so a stale open never reaches the DOM.
+ // Reset per-round open state. Regenerate reuses this instance, so a hand-opened block would
+ // stay pinned open. Adjusted during render, not in an effect, so no stale open reaches the DOM.
const [wasStreaming, setWasStreaming] = useState(isReasoningStreaming);
if (wasStreaming !== isReasoningStreaming) {
setWasStreaming(isReasoningStreaming);
if (startsNewReasoningRound(isReasoningStreaming, wasStreaming)) {
- setDismissedWhileStreaming(false);
- setManualOpen(false);
+ setOverride(null);
}
}
+ // Changing the setting hands every block back to it, including those already on screen.
+ const [lastVisibility, setLastVisibility] = useState(visibility);
+ if (lastVisibility !== visibility) {
+ setLastVisibility(visibility);
+ setOverride(null);
+ }
+
+ // Whatever the setting says, until this block is toggled by hand.
+ const isOpen = resolveReasoningOpen({
+ isStreaming: isReasoningStreaming,
+ visibility,
+ override,
+ });
+
// Keep the streaming height cap until the automatic close finishes. Removing it on the completion
// frame expands long reasoning to its full height before the collapsible can close, which makes
// the entire chat jump. The grid path needs the same margin the collapsible's own backstop uses.
@@ -959,7 +972,10 @@ const ReasoningGroupBlock = ({
// mid-animation cannot change what they animate; `1fr` instead resolves against the live content
// every frame, so an early release grows the row in the middle of the collapse and produces
// exactly the jump this timer prevents. The transition also starts a render after this timer is
- // armed, so an exact ANIMATION_DURATION lands inside it.
+ // armed, so an exact ANIMATION_DURATION lands inside it. A block the setting keeps open past
+ // its stream has no collapse to wait out and grows into its full height when this fires. isOpen
+ // is deliberately not a dependency: re-running on a manual open would re-arm the cap that
+ // handleOpenChange just released.
useEffect(() => {
const closeDelay = GRID_COLLAPSE_REASONING_ENABLED
? ANIMATION_DURATION + CLOSE_FALLBACK_MARGIN_MS
@@ -970,15 +986,6 @@ const ReasoningGroupBlock = ({
);
return () => window.clearTimeout(timeout);
}, [isReasoningStreaming]);
-
- // Open while streaming (unless dismissed), or once manually opened. With
- // collapse by default on, only a manual open shows the block.
- const isOpen = resolveReasoningOpen({
- isStreaming: isReasoningStreaming,
- collapseByDefault,
- dismissedWhileStreaming,
- manualOpen,
- });
// Publish the lead's open state for everything folded under it, and count the tool calls for
// its header. A layout effect, so the folded parts settle before the frame the user sees.
const roundKey = reasoningRoundKey(messageId, endIndex);
@@ -1017,17 +1024,14 @@ const ReasoningGroupBlock = ({
}
const next = resolveReasoningToggle(open, {
isStreaming: isReasoningStreaming,
- collapseByDefault,
+ visibility,
});
if (next.releaseStreamingHeight) {
setRetainStreamingHeight(false);
}
- setManualOpen(next.manualOpen);
- if (next.dismissedWhileStreaming !== undefined) {
- setDismissedWhileStreaming(next.dismissedWhileStreaming);
- }
+ setOverride(next.override);
},
- [isReasoningStreaming, collapseByDefault, detachFromBottom],
+ [isReasoningStreaming, visibility, detachFromBottom],
);
return (
diff --git a/studio/frontend/src/components/assistant-ui/tool-activity-open-state.ts b/studio/frontend/src/components/assistant-ui/tool-activity-open-state.ts
index 51853890f01..aaac6bbf6ea 100644
--- a/studio/frontend/src/components/assistant-ui/tool-activity-open-state.ts
+++ b/studio/frontend/src/components/assistant-ui/tool-activity-open-state.ts
@@ -1,23 +1,50 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+// eslint-disable-next-line no-restricted-imports -- this file is in the startup cycle; the chat barrel closes it.
+import {
+ type DisplayVisibility,
+ defaultOpenFor,
+} from "@/features/chat/utils/display-visibility";
+
interface ToolActivityTransition {
currentOpen: boolean;
- collapseByDefault: boolean;
- previousCollapseByDefault: boolean;
+ visibility: DisplayVisibility;
+ previousVisibility: DisplayVisibility;
isRunning: boolean;
+ /** The answer has started, so the call is finished and no longer worth watching. */
hasText: boolean;
+ /** null until the user clicks this card's trigger. */
+ override?: boolean | null;
+ /** True on the render where the call starts again. Regenerate reuses this card, so the
+ * previous round's hand-set state is already stale when the new round begins. */
+ startedNewRound?: boolean;
}
+/** Where a card sits after the setting, the run or the answer changed. Changing the setting
+ * re-applies it to every card, so Settings reaches messages already on screen. Between changes
+ * a hand-set card keeps its state, except that auto still closes it once the answer starts. */
export function resolveToolActivityOpen({
currentOpen,
- collapseByDefault,
- previousCollapseByDefault,
+ visibility,
+ previousVisibility,
isRunning,
hasText,
+ startedNewRound = false,
+ override = null,
}: ToolActivityTransition) {
- if (collapseByDefault) {
- return previousCollapseByDefault ? currentOpen : false;
+ if (visibility !== previousVisibility || startedNewRound) {
+ // A new round re-runs the call in this same card, so it starts where the setting puts it:
+ // Expand while running opens it to watch the fresh call, and the old round's hand-set
+ // state is dropped rather than carried into a round the user never set it for.
+ return defaultOpenFor(visibility, isRunning);
+ }
+ if (override !== null) {
+ return override;
+ }
+ // Only auto keeps moving on its own; the other two stay where the user last put them.
+ if (visibility !== "auto") {
+ return currentOpen;
}
if (isRunning) {
return true;
@@ -28,21 +55,46 @@ export function resolveToolActivityOpen({
return currentOpen;
}
+/** A new round starts when the call resumes. Regenerate reuses the card, so the previous
+ * round's hand-set state has to clear on the render the new one begins, like Thinking. */
+export function startsNewToolRound(
+ isRunning: boolean,
+ wasRunning: boolean,
+): boolean {
+ return isRunning && !wasRunning;
+}
+
export interface ToolActivityPreferenceState {
- collapseByDefault: boolean;
- open: boolean;
+ visibility: DisplayVisibility;
+ /** Still running. A live prop, so it falls to false when the call finishes. */
+ active: boolean;
+ /** null until the user clicks the trigger. */
+ override: boolean | null;
}
+/** The state uncontrolled cards and groups keep. A setting change hands the card back to the
+ * setting; activity changing on its own only moves cards the user has not touched, so auto can
+ * close a card when its call ends without discarding a manual open. */
export function syncToolActivityPreference(
current: ToolActivityPreferenceState,
- collapseByDefault: boolean,
- defaultOpen: boolean,
-) {
- if (current.collapseByDefault === collapseByDefault) {
+ visibility: DisplayVisibility,
+ active: boolean,
+): ToolActivityPreferenceState {
+ if (current.visibility === visibility && current.active === active) {
return current;
}
+ // A setting change or a new round hands the card back to the setting, matching the controlled
+ // cards: a regenerated run reuses this card, so the old round's hand-set state must not carry.
+ const kept =
+ current.visibility === visibility && !startsNewToolRound(active, current.active);
return {
- collapseByDefault,
- open: defaultOpen && !collapseByDefault,
+ visibility,
+ active,
+ override: kept ? current.override : null,
};
}
+
+/** Whether such a card is open right now. */
+export function toolActivityOpen(state: ToolActivityPreferenceState): boolean {
+ return state.override ?? defaultOpenFor(state.visibility, state.active);
+}
diff --git a/studio/frontend/src/components/assistant-ui/tool-fallback.tsx b/studio/frontend/src/components/assistant-ui/tool-fallback.tsx
index c9c04340501..5d8080c9424 100644
--- a/studio/frontend/src/components/assistant-ui/tool-fallback.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-fallback.tsx
@@ -48,7 +48,10 @@ import {
toolArgText,
toolFallbackLabel,
} from "./tool-arg-text";
-import { syncToolActivityPreference } from "./tool-activity-open-state";
+import {
+ syncToolActivityPreference,
+ toolActivityOpen,
+} from "./tool-activity-open-state";
const ANIMATION_DURATION = 200;
@@ -77,18 +80,15 @@ function ToolFallbackRoot({
...props
}: ToolFallbackRootProps) {
const collapsibleRef = useRef<HTMLDivElement>(null);
- const collapseByDefault = useChatPreferencesStore(
- (state) => state.collapseToolActivityByDefault,
- );
- const [uncontrolledState, setUncontrolledState] = useState(
- () => ({
- collapseByDefault,
- open: defaultOpen && !collapseByDefault,
- }),
- );
+ const visibility = useChatPreferencesStore((state) => state.toolVisibility);
+ const [uncontrolledState, setUncontrolledState] = useState(() => ({
+ visibility,
+ active: defaultOpen,
+ override: null as boolean | null,
+ }));
const syncedUncontrolledState = syncToolActivityPreference(
uncontrolledState,
- collapseByDefault,
+ visibility,
defaultOpen,
);
if (syncedUncontrolledState !== uncontrolledState) {
@@ -99,7 +99,7 @@ function ToolFallbackRoot({
const isControlled = controlledOpen !== undefined;
const isOpen =
awaitingApproval ||
- (isControlled ? controlledOpen : syncedUncontrolledState.open);
+ (isControlled ? controlledOpen : toolActivityOpen(syncedUncontrolledState));
// Opening by hand grows the card downward; see the same note in reasoning.tsx.
const detachFromBottom = useDetachThreadFromBottom();
@@ -114,15 +114,12 @@ function ToolFallbackRoot({
detachFromBottom();
}
if (!isControlled) {
- setUncontrolledState({
- collapseByDefault,
- open,
- });
+ setUncontrolledState({ ...syncedUncontrolledState, override: open });
}
controlledOnOpenChange?.(open);
},
[
- collapseByDefault,
+ syncedUncontrolledState,
lockScroll,
isControlled,
controlledOnOpenChange,
@@ -451,7 +448,10 @@ const ToolFallbackImpl: ToolCallMessagePartComponent = ({
const isCancelled = isToolCallCancelled(status);
return (
- <ToolFallbackRoot className={cn(isCancelled && "bg-muted/30")}>
+ <ToolFallbackRoot
+ className={cn(isCancelled && "bg-muted/30")}
+ defaultOpen={isToolCallRunning(status)}
+ >
<ToolFallbackTrigger
toolName={toolName}
mcpServer={mcpServerFromProvenance(provenance)}
diff --git a/studio/frontend/src/components/assistant-ui/tool-group.tsx b/studio/frontend/src/components/assistant-ui/tool-group.tsx
index 71c394e713b..6ad2e5fd494 100644
--- a/studio/frontend/src/components/assistant-ui/tool-group.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-group.tsx
@@ -37,7 +37,12 @@ import { useCollapseScrollLock } from "@/hooks/use-collapse-scroll-lock";
import { cn } from "@/lib/utils";
import { Spinner } from "@/components/ui/spinner";
import { awaitsConfirmation, holdsOwnOutput } from "./tool-fold-exemptions";
-import { syncToolActivityPreference } from "./tool-activity-open-state";
+import {
+ syncToolActivityPreference,
+ toolActivityOpen,
+} from "./tool-activity-open-state";
+// eslint-disable-next-line no-restricted-imports -- this file is in the startup cycle; the chat barrel closes it.
+import { foldIsActive } from "@/features/chat/utils/display-visibility";
const ANIMATION_DURATION = 200;
@@ -76,16 +81,15 @@ function ToolGroupRoot({
// Same treatment as ToolFallbackRoot. ToolGroupImpl passes `undefined` whenever it is not forcing
// the group open, so this uncontrolled state is what is on screen for most of a group's life --
// without the sync, a group expanded by hand stays open while every card inside it closes.
- const collapseByDefault = useChatPreferencesStore(
- (state) => state.collapseToolActivityByDefault,
- );
+ const visibility = useChatPreferencesStore((state) => state.toolVisibility);
const [uncontrolledState, setUncontrolledState] = useState(() => ({
- collapseByDefault,
- open: defaultOpen && !collapseByDefault,
+ visibility,
+ active: defaultOpen,
+ override: null as boolean | null,
}));
const syncedUncontrolledState = syncToolActivityPreference(
uncontrolledState,
- collapseByDefault,
+ visibility,
defaultOpen,
);
if (syncedUncontrolledState !== uncontrolledState) {
@@ -94,7 +98,9 @@ function ToolGroupRoot({
const lockScroll = useCollapseScrollLock(collapsibleRef, ANIMATION_DURATION);
const isControlled = controlledOpen !== undefined;
- const isOpen = isControlled ? controlledOpen : syncedUncontrolledState.open;
+ const isOpen = isControlled
+ ? controlledOpen
+ : toolActivityOpen(syncedUncontrolledState);
// Opening by hand grows the group downward; see the same note in reasoning.tsx.
const detachFromBottom = useDetachThreadFromBottom();
@@ -109,12 +115,12 @@ function ToolGroupRoot({
detachFromBottom();
}
if (!isControlled) {
- setUncontrolledState({ collapseByDefault, open });
+ setUncontrolledState({ ...syncedUncontrolledState, override: open });
}
controlledOnOpenChange?.(open);
},
[
- collapseByDefault,
+ syncedUncontrolledState,
lockScroll,
isControlled,
controlledOnOpenChange,
@@ -273,8 +279,22 @@ const ToolGroupImpl: FC<
const messageRunning = useAuiState(
({ message }) => message.status?.type === "running",
);
+ // Still working: a part inherits the message status until it has a result, so the group goes
+ // quiet once every call in it has one, without waiting for the rest of the turn.
+ const groupRunning = useAuiState(
+ ({ message }) =>
+ message.status?.type === "running" &&
+ message.parts
+ .slice(startIndex, endIndex + 1)
+ .some(
+ (part) =>
+ part.type === "tool-call" &&
+ (part as { result?: unknown }).result === undefined,
+ ),
+ );
+ // Only collapsed suppresses the forced opens below. Auto and expanded want it open anyway.
const collapseByDefault = useChatPreferencesStore(
- (state) => state.collapseToolActivityByDefault,
+ (state) => state.toolVisibility === "collapsed",
);
// Force the group open when any call is receiving tool_output events.
const toolLiveOutput = useChatRuntimeStore((s) => s.toolLiveOutput);
@@ -312,11 +332,11 @@ const ToolGroupImpl: FC<
((hasLiveOutput && messageRunning) ||
(forcedOpenRef.current && messageRunning)));
- // With the fold preference on, this run of calls belongs to the turn's first thinking block
- // and shows only while that block is open. Calls that hold their own output, and any awaiting
- // an allow or deny, are never folded away.
- const foldToolActivity = useChatPreferencesStore(
- (state) => state.foldToolActivityIntoThinking,
+ // With the fold preference on, this run belongs to the turn's first thinking block and shows
+ // only while it is open. Calls holding their own output, and any awaiting an allow or deny, are
+ // never folded away. Nor is anything while tool calls are always expanded (see foldIsActive).
+ const foldToolActivity = useChatPreferencesStore((state) =>
+ foldIsActive(state.foldToolActivityIntoThinking, state.toolVisibility),
);
const roundKey = useAuiState(({ message }) => {
const reasoningEnd = governingReasoningEnd(message.parts, startIndex);
@@ -340,7 +360,7 @@ const ToolGroupImpl: FC<
toolCount <= 1 || containsUngroupedTool ? (
<>{children}</>
) : (
- <ToolGroupRoot open={forceOpen ? true : undefined}>
+ <ToolGroupRoot open={forceOpen ? true : undefined} defaultOpen={groupRunning}>
<ToolGroupTrigger count={toolCount} />
<ToolGroupContent>{children}</ToolGroupContent>
</ToolGroupRoot>
diff --git a/studio/frontend/src/components/assistant-ui/tool-ui-python.tsx b/studio/frontend/src/components/assistant-ui/tool-ui-python.tsx
index 1daa553b93b..c5b3104f553 100644
--- a/studio/frontend/src/components/assistant-ui/tool-ui-python.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-ui-python.tsx
@@ -120,7 +120,7 @@ const PythonToolUIImpl: ToolCallMessagePartComponent = ({
const awaitingApproval = useToolAwaitingApproval(toolCallId);
const isWriting = isWritingCode && !awaitingApproval;
const collapseByDefault = useChatPreferencesStore(
- (state) => state.collapseToolActivityByDefault,
+ (state) => state.toolVisibility === "collapsed",
);
const scriptCell = code ? (
<div className="mt-1 pl-5">
@@ -137,7 +137,7 @@ const PythonToolUIImpl: ToolCallMessagePartComponent = ({
return (
// Status, output and images collapse from history; the executed script renders outside
// ToolFallbackContent so it stays visible on reopen (#7165) -- a script is an artifact, a
- // one-line command is not. That holds only while collapseToolActivity is off; with it on the
+ // one-line command is not. That holds unless tool calls are set to collapsed, where the
// script moves inside the collapsible, behind one click. awaitingApproval is the exception: a
// decision about a script needs the script on screen. Created files stay outside even when the
// card is collapsed (#10425).
diff --git a/studio/frontend/src/components/assistant-ui/use-tool-activity-open.ts b/studio/frontend/src/components/assistant-ui/use-tool-activity-open.ts
index d8dc4aab8d1..7aa20da51d6 100644
--- a/studio/frontend/src/components/assistant-ui/use-tool-activity-open.ts
+++ b/studio/frontend/src/components/assistant-ui/use-tool-activity-open.ts
@@ -3,29 +3,50 @@
// eslint-disable-next-line no-restricted-imports -- the feature barrel imports consumers of this hook
import { useChatPreferencesStore } from "@/features/chat/stores/chat-preferences-store";
+// eslint-disable-next-line no-restricted-imports -- this file is in the startup cycle; the chat barrel closes it.
+import { defaultOpenFor } from "@/features/chat/utils/display-visibility";
import { useEffect, useRef, useState } from "react";
-import { resolveToolActivityOpen } from "./tool-activity-open-state";
+import {
+ resolveToolActivityOpen,
+ startsNewToolRound,
+} from "./tool-activity-open-state";
export function useToolActivityOpen(isRunning: boolean, hasText: boolean) {
- const collapseByDefault = useChatPreferencesStore(
- (state) => state.collapseToolActivityByDefault,
- );
- const [open, setOpen] = useState(isRunning && !collapseByDefault);
- const previousCollapseByDefault = useRef(collapseByDefault);
+ const visibility = useChatPreferencesStore((state) => state.toolVisibility);
+ const [state, setState] = useState(() => ({
+ open: defaultOpenFor(visibility, isRunning),
+ override: null as boolean | null,
+ }));
+ const previousVisibility = useRef(visibility);
+ const previousRunning = useRef(isRunning);
useEffect(() => {
- const previousPreference = previousCollapseByDefault.current;
- previousCollapseByDefault.current = collapseByDefault;
- setOpen((currentOpen) =>
- resolveToolActivityOpen({
- currentOpen,
- collapseByDefault,
- previousCollapseByDefault: previousPreference,
- isRunning,
- hasText,
- }),
- );
- }, [isRunning, hasText, collapseByDefault]);
+ const previous = previousVisibility.current;
+ previousVisibility.current = visibility;
+ // Regenerate reuses this card, so a re-run of the same call would otherwise inherit the
+ // previous round's hand-set state. Same rule the reasoning block applies to its round.
+ const startedNewRound = startsNewToolRound(isRunning, previousRunning.current);
+ previousRunning.current = isRunning;
+ setState((current) => {
+ const override =
+ previous === visibility && !startedNewRound ? current.override : null;
+ return {
+ override,
+ open: resolveToolActivityOpen({
+ currentOpen: current.open,
+ visibility,
+ previousVisibility: previous,
+ isRunning,
+ hasText,
+ override,
+ startedNewRound,
+ }),
+ };
+ });
+ }, [isRunning, hasText, visibility]);
- return [open, setOpen] as const;
+ return [
+ state.open,
+ (open: boolean) => setState({ open, override: open }),
+ ] as const;
}
diff --git a/studio/frontend/src/features/chat/index.ts b/studio/frontend/src/features/chat/index.ts
index 215f66ed23e..2a2af87d98e 100644
--- a/studio/frontend/src/features/chat/index.ts
+++ b/studio/frontend/src/features/chat/index.ts
@@ -320,11 +320,22 @@ export {
} from "./utils/fork-count-store";
export { resolveReasoningGroupDuration } from "./utils/reasoning-duration";
export {
- reasoningAutoOpensWhileStreaming,
+ reasoningFollowsPreference,
resolveReasoningOpen,
resolveReasoningToggle,
startsNewReasoningRound,
} from "./utils/reasoning-visibility";
+export {
+ DEFAULT_THINKING_VISIBILITY,
+ DEFAULT_TOOL_VISIBILITY,
+ DISPLAY_VISIBILITIES,
+ type DisplayVisibility,
+ defaultOpenFor,
+ foldIsActive,
+ migrateVisibility,
+ normaliseDisplayVisibility,
+ resolveOpen,
+} from "./utils/display-visibility";
export { ArtifactCard } from "./artifacts/artifact-card";
export { ResearchMessage } from "./components/research-message";
export {
diff --git a/studio/frontend/src/features/chat/stores/chat-preferences-store.ts b/studio/frontend/src/features/chat/stores/chat-preferences-store.ts
index a13beee4e73..47d1ffa23c4 100644
--- a/studio/frontend/src/features/chat/stores/chat-preferences-store.ts
+++ b/studio/frontend/src/features/chat/stores/chat-preferences-store.ts
@@ -12,12 +12,19 @@ import {
PASTED_TEXT_DEFAULT_MIN_CHARS,
PASTED_TEXT_THRESHOLD_CHOICES,
} from "../utils/pasted-text.ts";
+import {
+ DEFAULT_THINKING_VISIBILITY,
+ DEFAULT_TOOL_VISIBILITY,
+ type DisplayVisibility,
+ migrateVisibility,
+} from "../utils/display-visibility.ts";
// Client-side chat UI prefs kept in localStorage, not the chat DB. confirmDeleteChats: off skips
// the delete confirm dialog. alwaysDeleteChatFiles: on also removes the sandbox folder.
// showModelDisclaimer: off hides the "LLMs can make mistakes" footer. showResponseModel: on shows
-// the producing model on responses. collapseThinkingByDefault: on keeps thinking collapsed.
-// foldToolActivityIntoThinking: on hides a round's tool calls until its thinking block is opened.
+// the producing model on responses. thinkingVisibility / toolVisibility: collapsed, auto or
+// expanded, see display-visibility.ts. foldToolActivityIntoThinking: on hides a round's tool calls
+// until its thinking block is opened, and has no effect while toolVisibility is "expanded".
// pastedTextMinChars: paste length that becomes a .txt attachment; 0 is off.
export interface ChatPreferencesState {
plainTextComposer: boolean;
@@ -36,10 +43,10 @@ export interface ChatPreferencesState {
setShowModelDisclaimer: (value: boolean) => void;
showResponseModel: boolean;
setShowResponseModel: (value: boolean) => void;
- collapseThinkingByDefault: boolean;
- setCollapseThinkingByDefault: (value: boolean) => void;
- collapseToolActivityByDefault: boolean;
- setCollapseToolActivityByDefault: (value: boolean) => void;
+ thinkingVisibility: DisplayVisibility;
+ setThinkingVisibility: (value: DisplayVisibility) => void;
+ toolVisibility: DisplayVisibility;
+ setToolVisibility: (value: DisplayVisibility) => void;
foldToolActivityIntoThinking: boolean;
setFoldToolActivityIntoThinking: (value: boolean) => void;
pastedTextMinChars: number;
@@ -76,12 +83,11 @@ export const useChatPreferencesStore = create<ChatPreferencesState>()(
set({ showModelDisclaimer }),
showResponseModel: false,
setShowResponseModel: (showResponseModel) => set({ showResponseModel }),
- collapseThinkingByDefault: false,
- setCollapseThinkingByDefault: (collapseThinkingByDefault) =>
- set({ collapseThinkingByDefault }),
- collapseToolActivityByDefault: true,
- setCollapseToolActivityByDefault: (collapseToolActivityByDefault) =>
- set({ collapseToolActivityByDefault }),
+ thinkingVisibility: DEFAULT_THINKING_VISIBILITY,
+ setThinkingVisibility: (thinkingVisibility) =>
+ set({ thinkingVisibility }),
+ toolVisibility: DEFAULT_TOOL_VISIBILITY,
+ setToolVisibility: (toolVisibility) => set({ toolVisibility }),
// Off by default: it hides rows the thread shows today, so it stays opt in.
foldToolActivityIntoThinking: false,
setFoldToolActivityIntoThinking: (foldToolActivityIntoThinking) =>
@@ -94,6 +100,13 @@ export const useChatPreferencesStore = create<ChatPreferencesState>()(
name: "unsloth_chat_preferences",
merge: (persisted, current) => {
const saved = persisted as Partial<ChatPreferencesState> | undefined;
+ // Records written before the three-state settings carry the two booleans instead.
+ const legacy = persisted as
+ | {
+ collapseThinkingByDefault?: unknown;
+ collapseToolActivityByDefault?: unknown;
+ }
+ | undefined;
return {
...current,
...normalizeComposerPreferences(saved),
@@ -101,9 +114,16 @@ export const useChatPreferencesStore = create<ChatPreferencesState>()(
alwaysDeleteChatFiles: saved?.alwaysDeleteChatFiles ?? false,
showModelDisclaimer: saved?.showModelDisclaimer ?? false,
showResponseModel: saved?.showResponseModel ?? false,
- collapseThinkingByDefault: saved?.collapseThinkingByDefault ?? false,
- collapseToolActivityByDefault:
- saved?.collapseToolActivityByDefault ?? true,
+ thinkingVisibility: migrateVisibility(
+ saved?.thinkingVisibility,
+ legacy?.collapseThinkingByDefault,
+ DEFAULT_THINKING_VISIBILITY,
+ ),
+ toolVisibility: migrateVisibility(
+ saved?.toolVisibility,
+ legacy?.collapseToolActivityByDefault,
+ DEFAULT_TOOL_VISIBILITY,
+ ),
foldToolActivityIntoThinking:
saved?.foldToolActivityIntoThinking ?? false,
pastedTextMinChars: normalisePastedTextMinChars(
diff --git a/studio/frontend/src/features/chat/utils/display-visibility.ts b/studio/frontend/src/features/chat/utils/display-visibility.ts
new file mode 100644
index 00000000000..40ae96c05b7
--- /dev/null
+++ b/studio/frontend/src/features/chat/utils/display-visibility.ts
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+// How Thinking blocks and tool activity open. Shared by Settings -> Display and every block.
+// collapsed: never opens on its own.
+// auto: opens while streaming or running, closes once the answer starts.
+// expanded: stays open in every phase, streaming included.
+// A block toggled by hand wins over the setting for the rest of its round.
+export const DISPLAY_VISIBILITIES = ["collapsed", "auto", "expanded"] as const;
+
+export type DisplayVisibility = (typeof DISPLAY_VISIBILITIES)[number];
+
+export const DEFAULT_THINKING_VISIBILITY: DisplayVisibility = "auto";
+// There is usually a lot more tool activity than reasoning, so it starts collapsed.
+export const DEFAULT_TOOL_VISIBILITY: DisplayVisibility = "collapsed";
+
+function isDisplayVisibility(value: unknown): value is DisplayVisibility {
+ return DISPLAY_VISIBILITIES.includes(value as DisplayVisibility);
+}
+
+/** A stored value from a newer build, or a hand-edited one, must not leave a select blank. */
+export function normaliseDisplayVisibility(
+ value: unknown,
+ fallback: DisplayVisibility,
+): DisplayVisibility {
+ return isDisplayVisibility(value) ? value : fallback;
+}
+
+/** Falls back to the boolean older builds wrote: `true` meant collapsed, `false` meant auto. */
+export function migrateVisibility(
+ stored: unknown,
+ legacyCollapseByDefault: unknown,
+ fallback: DisplayVisibility,
+): DisplayVisibility {
+ if (isDisplayVisibility(stored)) {
+ return stored;
+ }
+ if (typeof legacyCollapseByDefault === "boolean") {
+ return legacyCollapseByDefault ? "collapsed" : "auto";
+ }
+ return fallback;
+}
+
+/** Where a block sits before anyone touches it. `active` is streaming in, or still running. */
+export function defaultOpenFor(
+ visibility: DisplayVisibility,
+ active: boolean,
+): boolean {
+ switch (visibility) {
+ case "expanded":
+ return true;
+ case "collapsed":
+ return false;
+ default:
+ return active;
+ }
+}
+
+/** `override` is null until the user clicks the trigger, then holds for the rest of the round. */
+export function resolveOpen(
+ visibility: DisplayVisibility,
+ active: boolean,
+ override: boolean | null,
+): boolean {
+ return override ?? defaultOpenFor(visibility, active);
+}
+
+/** Whether the fold preference applies. Folding hides calls behind a Thinking block, so it
+ * cannot coexist with always expanded: the calls would be pinned open somewhere closed.
+ * Always expanded wins, and the fold preference stays stored so switching back restores it. */
+export function foldIsActive(
+ foldToolsIntoThinking: boolean,
+ toolVisibility: DisplayVisibility,
+): boolean {
+ return foldToolsIntoThinking && toolVisibility !== "expanded";
+}
diff --git a/studio/frontend/src/features/chat/utils/reasoning-visibility.ts b/studio/frontend/src/features/chat/utils/reasoning-visibility.ts
index 53d35e3e16b..33d0d3fbb3f 100644
--- a/studio/frontend/src/features/chat/utils/reasoning-visibility.ts
+++ b/studio/frontend/src/features/chat/utils/reasoning-visibility.ts
@@ -1,47 +1,43 @@
// 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 {
+ type DisplayVisibility,
+ defaultOpenFor,
+ resolveOpen,
+} from "./display-visibility";
+
// Open/closed rules for a reasoning group, kept out of the component so the streaming and
// preference interplay stays testable.
export interface ReasoningOpenStateInput {
/** Group is receiving reasoning deltas. */
isStreaming: boolean;
- /** Settings -> Chat: keep thinking collapsed instead of streaming it open. */
- collapseByDefault: boolean;
- /** User closed the auto-opened block mid stream. */
- dismissedWhileStreaming: boolean;
- /** User opened the block by hand. */
- manualOpen: boolean;
+ /** Settings -> Display: collapsed, auto (open while streaming) or expanded (always open). */
+ visibility: DisplayVisibility;
+ /** What the user did to this block by hand: null until they click its trigger. */
+ override: boolean | null;
}
-/** Thinking auto opens while it streams and collapses when it finishes, unless the preference is
- * on: then only an explicit open shows it, in either phase. */
+/** Thinking follows the setting until the user toggles this block. */
export function resolveReasoningOpen({
isStreaming,
- collapseByDefault,
- dismissedWhileStreaming,
- manualOpen,
+ visibility,
+ override,
}: ReasoningOpenStateInput): boolean {
- if (manualOpen) {
- return true;
- }
- if (collapseByDefault) {
- return false;
- }
- return isStreaming && !dismissedWhileStreaming;
+ return resolveOpen(visibility, isStreaming, override);
}
-/** Whether the block opens on its own for this round, so a toggle dismisses it. */
-export function reasoningAutoOpensWhileStreaming(
+/** Whether the block sits where the setting alone would put it. */
+export function reasoningFollowsPreference(
+ open: boolean,
isStreaming: boolean,
- collapseByDefault: boolean,
+ visibility: DisplayVisibility,
): boolean {
- return isStreaming && !collapseByDefault;
+ return open === defaultOpenFor(visibility, isStreaming);
}
-/** A new round starts when streaming resumes. Regenerate reuses the component, so last round's
- * open state has to clear in that same render, not in an effect, or the block paints open
- * before collapsing. */
+/** A new round starts when streaming resumes. Regenerate reuses the component, so the previous
+ * round's override has to clear in that same render, not in an effect. */
export function startsNewReasoningRound(
isStreaming: boolean,
wasStreaming: boolean,
@@ -50,29 +46,26 @@ export function startsNewReasoningRound(
}
export interface ReasoningToggleResult {
- /** Sticky user open. Cleared on close so a preference flip cannot pin it. */
- manualOpen: boolean;
- /** Set only when the block auto opens, since that is what gets dismissed. */
- dismissedWhileStreaming?: boolean;
+ /** The user's choice for this block, kept until the round restarts or the setting changes. */
+ override: boolean;
/** Drop the streaming height cap so a hand-opened block shows in full. */
releaseStreamingHeight: boolean;
}
-/** Resolves a trigger click into the next open state. */
+/** Resolves a trigger click into the next open state. Every click records an override, which is
+ * what keeps a hand-opened block open once its stream ends. */
export function resolveReasoningToggle(
open: boolean,
{
isStreaming,
- collapseByDefault,
- }: Pick<ReasoningOpenStateInput, "isStreaming" | "collapseByDefault">,
+ visibility,
+ }: Pick<ReasoningOpenStateInput, "isStreaming" | "visibility">,
): ReasoningToggleResult {
- const autoOpens = reasoningAutoOpensWhileStreaming(
- isStreaming,
- collapseByDefault,
- );
return {
- manualOpen: open && !autoOpens,
- ...(autoOpens ? { dismissedWhileStreaming: !open } : {}),
- releaseStreamingHeight: open && !autoOpens,
+ override: open,
+ // A block that opened on its own keeps the streaming cap. One opened against the setting
+ // is there to be read, so it gets its full height.
+ releaseStreamingHeight:
+ open && !defaultOpenFor(visibility, isStreaming),
};
}
diff --git a/studio/frontend/src/features/settings/settings-search.ts b/studio/frontend/src/features/settings/settings-search.ts
index c29a6911bf1..bc6db1bb46b 100644
--- a/studio/frontend/src/features/settings/settings-search.ts
+++ b/studio/frontend/src/features/settings/settings-search.ts
@@ -111,8 +111,8 @@ export const SETTINGS_SEARCH_INDEX: Record<SettingsTab, TranslationKey[]> = {
"settings.chat.rememberParamsPerModel",
"settings.chat.autoCompact",
"settings.profile.greetingSloth",
- "settings.chat.thinking.collapseByDefault",
- "settings.chat.tools.collapseByDefault",
+ "settings.chat.thinking.visibility",
+ "settings.chat.tools.visibility",
"settings.chat.tools.foldIntoThinking",
"settings.chat.artifacts.title",
"settings.chat.artifacts.collapseHtmlBlocks",
@@ -314,4 +314,8 @@ export const SETTINGS_SEARCH_KEYWORDS: Partial<
"settings.resources.modelMemory.noRamReserve":
"settings.resources.modelMemory.modelMemoryKeywords",
"settings.chat.autoCompact": "settings.chat.autoCompactKeywords",
+ // These rows are labelled with what they are, so the verbs people search for live here.
+ "settings.chat.thinking.visibility": "settings.chat.visibilityKeywords",
+ "settings.chat.tools.visibility": "settings.chat.visibilityKeywords",
+ "settings.chat.tools.foldIntoThinking": "settings.chat.visibilityKeywords",
};
diff --git a/studio/frontend/src/features/settings/tabs/chat-tab.tsx b/studio/frontend/src/features/settings/tabs/chat-tab.tsx
index 4af09cb05b5..84d4703708a 100644
--- a/studio/frontend/src/features/settings/tabs/chat-tab.tsx
+++ b/studio/frontend/src/features/settings/tabs/chat-tab.tsx
@@ -10,7 +10,10 @@ import {
} from "@/components/ui/select";
import { Switch } from "@/components/ui/switch";
import {
+ DEFAULT_THINKING_VISIBILITY,
+ DEFAULT_TOOL_VISIBILITY,
type PlusMenuItemId,
+ normaliseDisplayVisibility,
refreshModelDisclaimerPreference,
saveModelDisclaimerPreference,
useChatPreferencesStore,
@@ -233,11 +236,11 @@ export function ChatTab() {
const setShowResponseModel = useChatPreferencesStore(
(state) => state.setShowResponseModel,
);
- const collapseThinkingByDefault = useChatPreferencesStore(
- (state) => state.collapseThinkingByDefault,
+ const thinkingVisibility = useChatPreferencesStore(
+ (state) => state.thinkingVisibility,
);
- const setCollapseThinkingByDefault = useChatPreferencesStore(
- (state) => state.setCollapseThinkingByDefault,
+ const setThinkingVisibility = useChatPreferencesStore(
+ (state) => state.setThinkingVisibility,
);
const [currentDatePrompt, setCurrentDatePrompt] =
useState<CurrentDatePromptSettings | null>(null);
@@ -246,11 +249,11 @@ export function ChatTab() {
>(null);
const [isSavingCurrentDatePrompt, setIsSavingCurrentDatePrompt] =
useState(false);
- const collapseToolActivityByDefault = useChatPreferencesStore(
- (state) => state.collapseToolActivityByDefault,
+ const toolVisibility = useChatPreferencesStore(
+ (state) => state.toolVisibility,
);
- const setCollapseToolActivityByDefault = useChatPreferencesStore(
- (state) => state.setCollapseToolActivityByDefault,
+ const setToolVisibility = useChatPreferencesStore(
+ (state) => state.setToolVisibility,
);
const foldToolActivityIntoThinking = useChatPreferencesStore(
(state) => state.foldToolActivityIntoThinking,
@@ -258,6 +261,8 @@ export function ChatTab() {
const setFoldToolActivityIntoThinking = useChatPreferencesStore(
(state) => state.setFoldToolActivityIntoThinking,
);
+ // Cannot coexist with always expanded. The stored preference is left alone so it comes back.
+ const foldBlockedByAlwaysExpanded = toolVisibility === "expanded";
const pastedTextMinChars = useChatPreferencesStore(
(state) => state.pastedTextMinChars,
);
@@ -443,32 +448,80 @@ export function ChatTab() {
<Switch checked={searchImages} onCheckedChange={setSearchImages} />
</SettingsRow>
<SettingsRow
- label={t("settings.chat.thinking.collapseByDefault")}
- description={t("settings.chat.thinking.collapseByDefaultDescription")}
+ label={t("settings.chat.thinking.visibility")}
+ description={t("settings.chat.thinking.visibilityDescription")}
>
- <Switch
- aria-label={t("settings.chat.thinking.collapseByDefault")}
- checked={collapseThinkingByDefault}
- onCheckedChange={setCollapseThinkingByDefault}
- />
+ <Select
+ value={thinkingVisibility}
+ onValueChange={(value) =>
+ setThinkingVisibility(
+ normaliseDisplayVisibility(value, DEFAULT_THINKING_VISIBILITY),
+ )
+ }
+ >
+ <SelectTrigger
+ className="w-64"
+ aria-label={t("settings.chat.thinking.visibility")}
+ >
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="collapsed">
+ {t("settings.chat.visibility.collapsed")}
+ </SelectItem>
+ <SelectItem value="auto">
+ {t("settings.chat.visibility.auto")}
+ </SelectItem>
+ <SelectItem value="expanded">
+ {t("settings.chat.visibility.expanded")}
+ </SelectItem>
+ </SelectContent>
+ </Select>
</SettingsRow>
<SettingsRow
- label={t("settings.chat.tools.collapseByDefault")}
- description={t("settings.chat.tools.collapseByDefaultDescription")}
+ label={t("settings.chat.tools.visibility")}
+ description={t("settings.chat.tools.visibilityDescription")}
>
- <Switch
- aria-label={t("settings.chat.tools.collapseByDefault")}
- checked={collapseToolActivityByDefault}
- onCheckedChange={setCollapseToolActivityByDefault}
- />
+ <Select
+ value={toolVisibility}
+ onValueChange={(value) =>
+ setToolVisibility(
+ normaliseDisplayVisibility(value, DEFAULT_TOOL_VISIBILITY),
+ )
+ }
+ >
+ <SelectTrigger
+ className="w-64"
+ aria-label={t("settings.chat.tools.visibility")}
+ >
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="collapsed">
+ {t("settings.chat.visibility.collapsed")}
+ </SelectItem>
+ <SelectItem value="auto">
+ {t("settings.chat.visibility.auto")}
+ </SelectItem>
+ <SelectItem value="expanded">
+ {t("settings.chat.visibility.expanded")}
+ </SelectItem>
+ </SelectContent>
+ </Select>
</SettingsRow>
<SettingsRow
label={t("settings.chat.tools.foldIntoThinking")}
- description={t("settings.chat.tools.foldIntoThinkingDescription")}
+ // Says why the row is off rather than letting a checked switch do nothing.
+ description={t(
+ foldBlockedByAlwaysExpanded
+ ? "settings.chat.tools.foldIntoThinkingBlocked"
+ : "settings.chat.tools.foldIntoThinkingDescription",
+ )}
>
<Switch
aria-label={t("settings.chat.tools.foldIntoThinking")}
- checked={foldToolActivityIntoThinking}
+ checked={foldToolActivityIntoThinking && !foldBlockedByAlwaysExpanded}
+ disabled={foldBlockedByAlwaysExpanded}
onCheckedChange={setFoldToolActivityIntoThinking}
/>
</SettingsRow>
diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.ts
index 07d64f7bf66..b2d1894f5b7 100644
--- a/studio/frontend/src/i18n/locales/ar.ts
+++ b/studio/frontend/src/i18n/locales/ar.ts
@@ -1580,10 +1580,17 @@ export const ar = {
"تنتقل الأدوار الأقدم إلى أرشيف قابل للبحث عندما تمتلئ نافذة سياق المحادثة.",
autoCompactKeywords:
"ضغط تلقائي سياق نافذة اقتطاع منزلقة نقطة تحقق هامش أرشيف استرجاع بحث compaction rolling checkpoint headroom archive retrieval rag",
+ visibility: {
+ collapsed: "مطوي",
+ auto: "التوسيع أثناء التشغيل",
+ expanded: "موسّع دائمًا",
+ },
+ visibilityKeywords:
+ "طي مطوي توسيع موسّع فتح مغلق تفكير استدعاءات الأدوات نشاط الأدوات تجميع بث",
thinking: {
- collapseByDefault: "طيّ التفكير افتراضيًا",
- collapseByDefaultDescription:
- "إبقاء التفكير مطويًا أثناء تفكير النموذج بدلًا من فتحه تلقائيًا. وسّع أي كتلة لقراءتها.",
+ visibility: "التفكير",
+ visibilityDescription:
+ "كيفية فتح التفكير. لا يزال بإمكانك توسيع أو طي أي كتلة بنفسك.",
},
currentDate: {
label: "إخبار النموذج بتاريخ اليوم",
@@ -1593,12 +1600,14 @@ export const ar = {
saveError: "تعذّر تحديث إعدادات التاريخ الحالي",
},
tools: {
- collapseByDefault: "طيّ نشاط الأدوات افتراضيًا",
- collapseByDefaultDescription:
- "إبقاء مدخلات الأدوات ومخرجاتها مطوية أثناء التشغيل. وسّع أي صف أداة لفحصه.",
- foldIntoThinking: "طيّ استدعاءات الأدوات داخل التفكير",
+ visibility: "استدعاءات الأدوات",
+ visibilityDescription:
+ "كيفية فتح نشاط الأدوات. لا يزال بإمكانك توسيع أو طي أي استدعاء بنفسك.",
+ foldIntoThinking: "تجميع استدعاءات الأدوات ضمن التفكير",
foldIntoThinkingDescription:
- "إخفاء استدعاءات الأدوات في الدور حتى فتح كتلة التفكير.",
+ "عرض استدعاءات الأدوات في الدور داخل كتلة التفكير بدلًا من صفوف مستقلة.",
+ foldIntoThinkingBlocked:
+ "غير متاح بينما تكون استدعاءات الأدوات مضبوطة على «موسّع دائمًا»، وهو ما يبقيها في صفوف مستقلة.",
},
webSearch: {
title: "البحث على الويب",
diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.ts
index a112ccb72af..5bcb1cf97b3 100644
--- a/studio/frontend/src/i18n/locales/de.ts
+++ b/studio/frontend/src/i18n/locales/de.ts
@@ -1616,10 +1616,17 @@ export const de = {
"Ältere Runden wandern in ein durchsuchbares Archiv, wenn ein Chat voll läuft.",
autoCompactKeywords:
"Komprimierung automatisch Kontext Fenster kürzen gleitend Prüfpunkt Reserve Archiv Abruf Suche compaction rolling checkpoint headroom archive retrieval rag",
+ visibility: {
+ collapsed: "Eingeklappt",
+ auto: "Während der Ausführung ausklappen",
+ expanded: "Immer ausgeklappt",
+ },
+ visibilityKeywords:
+ "einklappen eingeklappt ausklappen ausgeklappt offen geschlossen Denken Reasoning Tool-Aufrufe Tool-Aktivität gruppieren Streaming",
thinking: {
- collapseByDefault: "Denken standardmäßig einklappen",
- collapseByDefaultDescription:
- "Das Denken bleibt eingeklappt, während das Modell denkt, statt automatisch aufzuklappen. Zum Lesen einen Block ausklappen.",
+ visibility: "Denken",
+ visibilityDescription:
+ "Wie das Denken geöffnet wird. Einzelne Blöcke lassen sich weiterhin selbst aus- und einklappen.",
},
currentDate: {
label: "Dem Modell das heutige Datum mitteilen",
@@ -1629,12 +1636,14 @@ export const de = {
saveError: "Einstellungen zum aktuellen Datum konnten nicht aktualisiert werden",
},
tools: {
- collapseByDefault: "Tool-Aktivität standardmäßig einklappen",
- collapseByDefaultDescription:
- "Tool-Eingaben und -Ausgaben bleiben während der Ausführung eingeklappt. Zum Prüfen eine Tool-Zeile ausklappen.",
- foldIntoThinking: "Tool-Aufrufe ins Denken einklappen",
+ visibility: "Tool-Aufrufe",
+ visibilityDescription:
+ "Wie die Tool-Aktivität geöffnet wird. Einzelne Aufrufe lassen sich weiterhin selbst aus- und einklappen.",
+ foldIntoThinking: "Tool-Aufrufe unter Denken gruppieren",
foldIntoThinkingDescription:
- "Tool-Aufrufe eines Zuges ausblenden, bis der Denken-Block geöffnet wird.",
+ "Die Tool-Aufrufe eines Zuges im Denken-Block statt in eigenen Zeilen anzeigen.",
+ foldIntoThinkingBlocked:
+ "Nicht verfügbar, solange Tool-Aufrufe auf „Immer ausgeklappt“ stehen, dann bleiben sie in eigenen Zeilen.",
},
webSearch: {
title: "Websuche",
diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.ts
index b8988c3e94c..916e8b9696a 100644
--- a/studio/frontend/src/i18n/locales/en.ts
+++ b/studio/frontend/src/i18n/locales/en.ts
@@ -1575,10 +1575,17 @@ export const en = {
"Older turns move to a searchable archive when a chat fills its context.",
autoCompactKeywords:
"compaction compact auto-compact context window truncate rolling checkpoint headroom archive retrieval recall rag search",
+ visibility: {
+ collapsed: "Collapsed",
+ auto: "Expand while running",
+ expanded: "Always expanded",
+ },
+ visibilityKeywords:
+ "collapse collapsed expand expanded open closed reasoning thinking tool calls tool activity fold group streaming",
thinking: {
- collapseByDefault: "Collapse Thinking by default",
- collapseByDefaultDescription:
- "Keep reasoning collapsed. Expand a block to read it.",
+ visibility: "Thinking",
+ visibilityDescription:
+ "How reasoning opens. You can still expand or collapse any block yourself.",
},
currentDate: {
label: "Tell the model today's date",
@@ -1588,12 +1595,14 @@ export const en = {
saveError: "Failed to update current date settings",
},
tools: {
- collapseByDefault: "Collapse tool activity by default",
- collapseByDefaultDescription:
- "Keep tool details collapsed. Expand a row to inspect it.",
- foldIntoThinking: "Fold tool calls into Thinking",
+ visibility: "Tool calls",
+ visibilityDescription:
+ "How tool activity opens. You can still expand or collapse any call yourself.",
+ foldIntoThinking: "Group tool calls under Thinking",
foldIntoThinkingDescription:
- "Hide a turn's tool calls until its Thinking block is opened.",
+ "Show a turn's tool calls inside its Thinking block instead of on their own rows.",
+ foldIntoThinkingBlocked:
+ "Unavailable while tool calls are set to Always expanded, which keeps them on their own rows.",
},
webSearch: {
title: "Web search",
diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.ts
index 29fb5925fb2..f175521641b 100644
--- a/studio/frontend/src/i18n/locales/es.ts
+++ b/studio/frontend/src/i18n/locales/es.ts
@@ -1607,10 +1607,17 @@ export const es = {
"Los turnos antiguos pasan a un archivo consultable al llenarse el contexto de un chat.",
autoCompactKeywords:
"compactación compactar automáticamente contexto ventana truncar deslizante checkpoint margen archivo recuperación búsqueda compaction rolling headroom archive retrieval rag",
+ visibility: {
+ collapsed: "Contraído",
+ auto: "Expandir mientras se ejecuta",
+ expanded: "Siempre expandido",
+ },
+ visibilityKeywords:
+ "contraer contraído expandir expandido abierto cerrado razonamiento pensamiento llamadas de herramientas actividad agrupar streaming",
thinking: {
- collapseByDefault: "Contraer el razonamiento de forma predeterminada",
- collapseByDefaultDescription:
- "Mantén el razonamiento contraído mientras el modelo piensa, en lugar de abrirlo automáticamente. Expande cualquier bloque para leerlo.",
+ visibility: "Razonamiento",
+ visibilityDescription:
+ "Cómo se abre el razonamiento. Puedes expandir o contraer cualquier bloque por tu cuenta.",
},
currentDate: {
label: "Indicar al modelo la fecha de hoy",
@@ -1620,12 +1627,14 @@ export const es = {
saveError: "No se pudieron actualizar los ajustes de fecha actual",
},
tools: {
- collapseByDefault: "Contraer la actividad de herramientas por defecto",
- collapseByDefaultDescription:
- "Mantén contraídas las entradas y salidas de las herramientas mientras se ejecutan. Expande cualquier fila para inspeccionarla.",
- foldIntoThinking: "Plegar las llamadas de herramientas en Pensamiento",
+ visibility: "Llamadas de herramientas",
+ visibilityDescription:
+ "Cómo se abre la actividad de herramientas. Puedes expandir o contraer cualquier llamada por tu cuenta.",
+ foldIntoThinking: "Agrupar las llamadas de herramientas en Razonamiento",
foldIntoThinkingDescription:
- "Oculta las llamadas de herramientas de un turno hasta abrir su bloque de Pensamiento.",
+ "Muestra las llamadas de herramientas de un turno dentro de su bloque de Razonamiento en lugar de en filas propias.",
+ foldIntoThinkingBlocked:
+ "No disponible mientras las llamadas de herramientas estén en «Siempre expandido», que las mantiene en filas propias.",
},
webSearch: {
title: "Búsqueda web",
diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.ts
index 12363ce8a96..dc208291d18 100644
--- a/studio/frontend/src/i18n/locales/fr.ts
+++ b/studio/frontend/src/i18n/locales/fr.ts
@@ -1613,10 +1613,17 @@ export const fr = {
"Les anciens échanges vont dans une archive consultable quand un chat sature son contexte.",
autoCompactKeywords:
"compaction automatique contexte fenêtre tronquer glissante point de contrôle marge archive récupération recherche rolling checkpoint headroom retrieval rag",
+ visibility: {
+ collapsed: "Replié",
+ auto: "Déplier pendant l’exécution",
+ expanded: "Toujours déplié",
+ },
+ visibilityKeywords:
+ "replier replié déplier déplié ouvert fermé réflexion raisonnement appels d'outils activité des outils regrouper streaming",
thinking: {
- collapseByDefault: "Replier la réflexion par défaut",
- collapseByDefaultDescription:
- "Garde la réflexion repliée pendant que le modèle réfléchit, au lieu de l’ouvrir automatiquement. Dépliez un bloc pour le lire.",
+ visibility: "Réflexion",
+ visibilityDescription:
+ "Comment la réflexion s’ouvre. Vous pouvez toujours déplier ou replier un bloc vous-même.",
},
currentDate: {
label: "Indiquer la date du jour au modèle",
@@ -1626,12 +1633,14 @@ export const fr = {
saveError: "Impossible de mettre à jour les paramètres de date actuelle",
},
tools: {
- collapseByDefault: "Replier l’activité des outils par défaut",
- collapseByDefaultDescription:
- "Garde les entrées et sorties des outils repliées pendant leur exécution. Dépliez une ligne d’outil pour l’examiner.",
- foldIntoThinking: "Replier les appels d'outils dans la Réflexion",
+ visibility: "Appels d’outils",
+ visibilityDescription:
+ "Comment l’activité des outils s’ouvre. Vous pouvez toujours déplier ou replier un appel vous-même.",
+ foldIntoThinking: "Regrouper les appels d’outils dans la Réflexion",
foldIntoThinkingDescription:
- "Masque les appels d'outils d'un tour jusqu'à l'ouverture de son bloc de Réflexion.",
+ "Affiche les appels d’outils d’un tour dans son bloc de Réflexion plutôt que sur leurs propres lignes.",
+ foldIntoThinkingBlocked:
+ "Indisponible tant que les appels d’outils sont sur « Toujours déplié », qui les garde sur leurs propres lignes.",
},
webSearch: {
title: "Recherche web",
diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.ts
index 16f29a4a50e..4576e869962 100644
--- a/studio/frontend/src/i18n/locales/hi.ts
+++ b/studio/frontend/src/i18n/locales/hi.ts
@@ -1586,10 +1586,17 @@ export const hi = {
"चैट का कॉन्टेक्स्ट भरने पर पुराने टर्न खोजे जा सकने वाले आर्काइव में चले जाते हैं।",
autoCompactKeywords:
"कॉम्पैक्शन कॉम्पैक्ट कॉन्टेक्स्ट विंडो ट्रंकेट स्लाइडिंग चेकपॉइंट हेडरूम आर्काइव पुनर्प्राप्ति खोज compaction rolling checkpoint headroom archive retrieval rag",
+ visibility: {
+ collapsed: "संक्षिप्त",
+ auto: "चलने के दौरान विस्तृत करें",
+ expanded: "हमेशा विस्तृत",
+ },
+ visibilityKeywords:
+ "संक्षिप्त समेटें विस्तृत खोलें बंद रीज़निंग थिंकिंग टूल कॉल टूल गतिविधि समूह स्ट्रीमिंग",
thinking: {
- collapseByDefault: "थिंकिंग को डिफ़ॉल्ट रूप से संक्षिप्त रखें",
- collapseByDefaultDescription:
- "मॉडल के सोचते समय रीज़निंग अपने आप खुलने के बजाय संक्षिप्त रहती है। पढ़ने के लिए किसी भी ब्लॉक को विस्तृत करें।",
+ visibility: "थिंकिंग",
+ visibilityDescription:
+ "रीज़निंग कैसे खुलती है। आप किसी भी ब्लॉक को खुद विस्तृत या संक्षिप्त कर सकते हैं।",
},
currentDate: {
label: "मॉडल को आज की तारीख बताएँ",
@@ -1599,12 +1606,14 @@ export const hi = {
saveError: "मौजूदा तारीख की सेटिंग्स अपडेट नहीं हो सकीं",
},
tools: {
- collapseByDefault: "टूल गतिविधि को डिफ़ॉल्ट रूप से संक्षिप्त रखें",
- collapseByDefaultDescription:
- "टूल चलते समय उनके इनपुट और आउटपुट संक्षिप्त रखें। जाँचने के लिए किसी भी टूल पंक्ति को विस्तृत करें।",
- foldIntoThinking: "टूल कॉल को थिंकिंग में समेटें",
+ visibility: "टूल कॉल",
+ visibilityDescription:
+ "टूल गतिविधि कैसे खुलती है। आप किसी भी कॉल को खुद विस्तृत या संक्षिप्त कर सकते हैं।",
+ foldIntoThinking: "टूल कॉल को थिंकिंग के अंतर्गत समूहित करें",
foldIntoThinkingDescription:
- "किसी टर्न के टूल कॉल तब तक छिपाएँ जब तक उसका थिंकिंग ब्लॉक न खोला जाए।",
+ "किसी टर्न के टूल कॉल अलग पंक्तियों के बजाय उसके थिंकिंग ब्लॉक के भीतर दिखाएँ।",
+ foldIntoThinkingBlocked:
+ "जब तक टूल कॉल «हमेशा विस्तृत» पर सेट हैं तब तक उपलब्ध नहीं, क्योंकि वे अलग पंक्तियों में ही रहते हैं।",
},
webSearch: {
title: "वेब खोज",
diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.ts
index 62650faee8b..78b1346b92f 100644
--- a/studio/frontend/src/i18n/locales/it.ts
+++ b/studio/frontend/src/i18n/locales/it.ts
@@ -1581,10 +1581,17 @@ export const it = {
"I turni più vecchi passano in un archivio consultabile quando una chat riempie il contesto.",
autoCompactKeywords:
"compattazione automatica contesto finestra troncare scorrevole checkpoint margine archivio recupero ricerca compaction rolling headroom archive retrieval rag",
+ visibility: {
+ collapsed: "Compresso",
+ auto: "Espandi durante l’esecuzione",
+ expanded: "Sempre espanso",
+ },
+ visibilityKeywords:
+ "comprimi compresso espandi espanso aperto chiuso ragionamento chiamate agli strumenti attività raggruppa streaming",
thinking: {
- collapseByDefault: "Comprimi il ragionamento per impostazione predefinita",
- collapseByDefaultDescription:
- "Mantieni il ragionamento compresso mentre il modello pensa, invece di aprirlo automaticamente. Espandi un blocco per leggerlo.",
+ visibility: "Ragionamento",
+ visibilityDescription:
+ "Come si apre il ragionamento. Puoi comunque espandere o comprimere ogni blocco a mano.",
},
currentDate: {
label: "Comunica al modello la data di oggi",
@@ -1594,12 +1601,14 @@ export const it = {
saveError: "Impossibile aggiornare le impostazioni della data corrente",
},
tools: {
- collapseByDefault: "Comprimi l’attività degli strumenti per impostazione predefinita",
- collapseByDefaultDescription:
- "Mantieni compressi input e output degli strumenti durante l’esecuzione. Espandi una riga per esaminarla.",
- foldIntoThinking: "Comprimi le chiamate agli strumenti nel Ragionamento",
+ visibility: "Chiamate agli strumenti",
+ visibilityDescription:
+ "Come si apre l’attività degli strumenti. Puoi comunque espandere o comprimere ogni chiamata a mano.",
+ foldIntoThinking: "Raggruppa le chiamate agli strumenti nel Ragionamento",
foldIntoThinkingDescription:
- "Nasconde le chiamate agli strumenti di un turno finché non si apre il blocco Ragionamento.",
+ "Mostra le chiamate agli strumenti di un turno nel blocco Ragionamento invece che su righe proprie.",
+ foldIntoThinkingBlocked:
+ "Non disponibile finché le chiamate agli strumenti sono su «Sempre espanso», che le tiene su righe proprie.",
},
webSearch: {
title: "Ricerca web",
diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.ts
index 8dc8277a4a6..acb45cd3d1b 100644
--- a/studio/frontend/src/i18n/locales/ja.ts
+++ b/studio/frontend/src/i18n/locales/ja.ts
@@ -1564,10 +1564,17 @@ export const ja = {
"チャットの文脈が満杯になると、古いターンは検索可能なアーカイブに移ります。",
autoCompactKeywords:
"圧縮 自動圧縮 コンテキスト ウィンドウ 切り詰め スライディング チェックポイント 余裕 アーカイブ 検索 取得 compaction rolling headroom archive retrieval rag",
+ visibility: {
+ collapsed: "折りたたむ",
+ auto: "実行中は展開",
+ expanded: "常に展開",
+ },
+ visibilityKeywords:
+ "折りたたむ 展開 開く 閉じる 思考 推論 ツール呼び出し ツールの動作 グループ ストリーミング",
thinking: {
- collapseByDefault: "思考をデフォルトで折りたたむ",
- collapseByDefaultDescription:
- "モデルの思考中も自動で展開せず、折りたたんだままにします。読みたいときはブロックを展開してください。",
+ visibility: "思考",
+ visibilityDescription:
+ "思考の開き方。個々のブロックは手動で展開・折りたたみできます。",
},
currentDate: {
label: "今日の日付をモデルに伝える",
@@ -1577,12 +1584,14 @@ export const ja = {
saveError: "現在の日付の設定を更新できませんでした",
},
tools: {
- collapseByDefault: "ツールの動作をデフォルトで折りたたむ",
- collapseByDefaultDescription:
- "ツールの実行中は入力と出力を折りたたんだままにします。確認するにはツール行を展開してください。",
- foldIntoThinking: "ツール呼び出しを思考に折りたたむ",
+ visibility: "ツール呼び出し",
+ visibilityDescription:
+ "ツールの動作の開き方。個々の呼び出しは手動で展開・折りたたみできます。",
+ foldIntoThinking: "ツール呼び出しを思考にまとめる",
foldIntoThinkingDescription:
- "思考ブロックを開くまで、そのターンのツール呼び出しを隠します。",
+ "そのターンのツール呼び出しを独立した行ではなく思考ブロック内に表示します。",
+ foldIntoThinkingBlocked:
+ "ツール呼び出しが「常に展開」の間は使えません。その設定では独立した行に表示されます。",
},
webSearch: {
title: "ウェブ検索",
diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.ts
index 2bf1374469f..f96cba318aa 100644
--- a/studio/frontend/src/i18n/locales/ko.ts
+++ b/studio/frontend/src/i18n/locales/ko.ts
@@ -1575,10 +1575,17 @@ export const ko = {
"채팅이 컨텍스트를 모두 채우면 오래된 턴은 검색 가능한 보관소로 옮겨집니다.",
autoCompactKeywords:
"압축 자동 컨텍스트 윈도우 자르기 슬라이딩 체크포인트 여유 보관 검색 회수 compaction rolling checkpoint headroom archive retrieval rag",
+ visibility: {
+ collapsed: "접힘",
+ auto: "실행 중 펼치기",
+ expanded: "항상 펼침",
+ },
+ visibilityKeywords:
+ "접기 접힘 펼치기 펼침 열기 닫기 사고 과정 추론 도구 호출 도구 활동 그룹 스트리밍",
thinking: {
- collapseByDefault: "기본적으로 사고 과정 접기",
- collapseByDefaultDescription:
- "모델이 생각하는 동안 사고 과정을 자동으로 펼치지 않고 접어 둡니다. 읽으려면 블록을 펼치세요.",
+ visibility: "사고 과정",
+ visibilityDescription:
+ "사고 과정이 열리는 방식. 각 블록은 직접 펼치거나 접을 수 있습니다.",
},
currentDate: {
label: "모델에 오늘 날짜 알려주기",
@@ -1588,12 +1595,14 @@ export const ko = {
saveError: "현재 날짜 설정을 업데이트하지 못했습니다",
},
tools: {
- collapseByDefault: "기본적으로 도구 활동 접기",
- collapseByDefaultDescription:
- "도구가 실행되는 동안 입력과 출력을 접어 둡니다. 확인하려면 도구 행을 펼치세요.",
- foldIntoThinking: "도구 호출을 생각 안으로 접기",
+ visibility: "도구 호출",
+ visibilityDescription:
+ "도구 활동이 열리는 방식. 각 호출은 직접 펼치거나 접을 수 있습니다.",
+ foldIntoThinking: "도구 호출을 사고 과정으로 묶기",
foldIntoThinkingDescription:
- "생각 블록을 열기 전까지 해당 턴의 도구 호출을 숨깁니다.",
+ "해당 턴의 도구 호출을 별도 행 대신 사고 과정 블록 안에 표시합니다.",
+ foldIntoThinkingBlocked:
+ "도구 호출이 ‘항상 펼침’으로 설정된 동안에는 사용할 수 없습니다. 그 설정은 호출을 별도 행에 유지합니다.",
},
webSearch: {
title: "웹 검색",
diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.ts
index 43ed40b2bc6..5798ee6caad 100644
--- a/studio/frontend/src/i18n/locales/pt-br.ts
+++ b/studio/frontend/src/i18n/locales/pt-br.ts
@@ -1594,10 +1594,17 @@ export const ptBR = {
"Os turnos antigos vão para um arquivo pesquisável quando um chat enche o contexto.",
autoCompactKeywords:
"compactação compactar automaticamente contexto janela truncar deslizante checkpoint margem arquivo recuperação busca compaction rolling headroom archive retrieval rag",
+ visibility: {
+ collapsed: "Recolhido",
+ auto: "Expandir durante a execução",
+ expanded: "Sempre expandido",
+ },
+ visibilityKeywords:
+ "recolher recolhido expandir expandido aberto fechado raciocínio pensamento chamadas de ferramentas atividade agrupar streaming",
thinking: {
- collapseByDefault: "Recolher o raciocínio por padrão",
- collapseByDefaultDescription:
- "Mantém o raciocínio recolhido enquanto o modelo pensa, em vez de abri-lo automaticamente. Expanda um bloco para lê-lo.",
+ visibility: "Raciocínio",
+ visibilityDescription:
+ "Como o raciocínio abre. Você ainda pode expandir ou recolher qualquer bloco.",
},
currentDate: {
label: "Informar a data de hoje ao modelo",
@@ -1607,12 +1614,14 @@ export const ptBR = {
saveError: "Não foi possível atualizar as configurações de data atual",
},
tools: {
- collapseByDefault: "Recolher atividade de ferramentas por padrão",
- collapseByDefaultDescription:
- "Mantém entradas e saídas das ferramentas recolhidas durante a execução. Expanda uma linha para inspecioná-la.",
- foldIntoThinking: "Recolher chamadas de ferramentas no Pensamento",
+ visibility: "Chamadas de ferramentas",
+ visibilityDescription:
+ "Como a atividade de ferramentas abre. Você ainda pode expandir ou recolher qualquer chamada.",
+ foldIntoThinking: "Agrupar chamadas de ferramentas no Raciocínio",
foldIntoThinkingDescription:
- "Oculta as chamadas de ferramentas de um turno até abrir o bloco de Pensamento.",
+ "Mostra as chamadas de ferramentas de um turno dentro do bloco de Raciocínio em vez de em linhas próprias.",
+ foldIntoThinkingBlocked:
+ "Indisponível enquanto as chamadas de ferramentas estiverem em «Sempre expandido», que as mantém em linhas próprias.",
},
webSearch: {
title: "Busca na web",
diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.ts
index 55776ed9322..df3c5ddd5e4 100644
--- a/studio/frontend/src/i18n/locales/ru.ts
+++ b/studio/frontend/src/i18n/locales/ru.ts
@@ -1591,10 +1591,17 @@ export const ru = {
"Старые ходы уходят в доступный для поиска архив, когда чат заполняет контекст.",
autoCompactKeywords:
"сжатие автоматически контекст окно обрезка скользящее контрольная точка запас архив поиск извлечение compaction rolling checkpoint headroom archive retrieval rag",
+ visibility: {
+ collapsed: "Свёрнуто",
+ auto: "Разворачивать во время работы",
+ expanded: "Всегда развёрнуто",
+ },
+ visibilityKeywords:
+ "свернуть свёрнуто развернуть развёрнуто открыть закрыть размышления рассуждения вызовы инструментов действия группировать потоковая передача",
thinking: {
- collapseByDefault: "Сворачивать размышления по умолчанию",
- collapseByDefaultDescription:
- "Размышления остаются свёрнутыми, пока модель думает, вместо автоматического раскрытия. Разверните блок, чтобы прочитать его.",
+ visibility: "Размышления",
+ visibilityDescription:
+ "Как открываются размышления. Любой блок по-прежнему можно развернуть или свернуть вручную.",
},
currentDate: {
label: "Сообщать модели сегодняшнюю дату",
@@ -1604,12 +1611,14 @@ export const ru = {
saveError: "Не удалось обновить настройки текущей даты",
},
tools: {
- collapseByDefault: "Сворачивать действия инструментов по умолчанию",
- collapseByDefaultDescription:
- "Входные и выходные данные инструментов остаются свёрнутыми во время работы. Разверните строку инструмента для просмотра.",
- foldIntoThinking: "Сворачивать вызовы инструментов в Размышление",
+ visibility: "Вызовы инструментов",
+ visibilityDescription:
+ "Как открываются действия инструментов. Любой вызов по-прежнему можно развернуть или свернуть вручную.",
+ foldIntoThinking: "Группировать вызовы инструментов в Размышлениях",
foldIntoThinkingDescription:
- "Скрывает вызовы инструментов хода, пока не открыт блок размышления.",
+ "Показывать вызовы инструментов хода внутри блока размышлений, а не отдельными строками.",
+ foldIntoThinkingBlocked:
+ "Недоступно, пока для вызовов инструментов выбрано «Всегда развёрнуто»: в этом режиме они остаются отдельными строками.",
},
webSearch: {
title: "Веб-поиск",
diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.ts
index 7a962a7b076..3d0cf4cd9f9 100644
--- a/studio/frontend/src/i18n/locales/zh-CN.ts
+++ b/studio/frontend/src/i18n/locales/zh-CN.ts
@@ -1545,10 +1545,17 @@ export const zhCN = {
"聊天填满上下文时,较早的轮次会转入可检索的归档。",
autoCompactKeywords:
"压缩 自动压缩 上下文 窗口 截断 滑动 检查点 余量 归档 检索 搜索 compaction rolling checkpoint headroom archive retrieval rag",
+ visibility: {
+ collapsed: "折叠",
+ auto: "运行时展开",
+ expanded: "始终展开",
+ },
+ visibilityKeywords:
+ "折叠 展开 打开 关闭 思考 推理 工具调用 工具活动 分组 流式",
thinking: {
- collapseByDefault: "默认折叠思考过程",
- collapseByDefaultDescription:
- "模型思考时保持折叠,而不是自动展开。需要阅读时展开对应区块。",
+ visibility: "思考过程",
+ visibilityDescription:
+ "思考过程如何展开。你仍可自行展开或折叠任意区块。",
},
currentDate: {
label: "告诉模型今天的日期",
@@ -1558,12 +1565,14 @@ export const zhCN = {
saveError: "无法更新当前日期设置",
},
tools: {
- collapseByDefault: "默认折叠工具活动",
- collapseByDefaultDescription:
- "工具运行时保持输入和输出折叠。需要检查时展开对应工具行。",
- foldIntoThinking: "将工具调用折叠进思考",
+ visibility: "工具调用",
+ visibilityDescription:
+ "工具活动如何展开。你仍可自行展开或折叠任意调用。",
+ foldIntoThinking: "将工具调用归入思考过程",
foldIntoThinkingDescription:
- "在展开思考块之前隐藏该轮的工具调用。",
+ "把该轮的工具调用显示在思考区块内,而不是各自独立成行。",
+ foldIntoThinkingBlocked:
+ "当工具调用设置为“始终展开”时不可用,该设置会让它们保持独立成行。",
},
webSearch: {
title: "网页搜索",
diff --git a/studio/frontend/tests/reasoning-collapse-preference.test.ts b/studio/frontend/tests/reasoning-collapse-preference.test.ts
index abfbda41df3..3e4e87f38d5 100644
--- a/studio/frontend/tests/reasoning-collapse-preference.test.ts
+++ b/studio/frontend/tests/reasoning-collapse-preference.test.ts
@@ -4,132 +4,143 @@
import assert from "node:assert/strict";
import test from "node:test";
-import {
- reasoningAutoOpensWhileStreaming,
+import { registerBundlerResolver } from "./helpers/kit.ts";
+
+// reasoning-visibility.ts imports a sibling extensionless, like the rest of src.
+registerBundlerResolver();
+
+import type { DisplayVisibility } from "../src/features/chat/utils/display-visibility.ts";
+const { DISPLAY_VISIBILITIES } = await import(
+ "../src/features/chat/utils/display-visibility.ts"
+);
+const {
+ reasoningFollowsPreference,
resolveReasoningOpen,
resolveReasoningToggle,
startsNewReasoningRound,
-} from "../src/features/chat/utils/reasoning-visibility.ts";
+} = await import("../src/features/chat/utils/reasoning-visibility.ts");
+
+interface BlockState {
+ isStreaming: boolean;
+ visibility: DisplayVisibility;
+ override: boolean | null;
+}
// Mirrors the component: toggle results feed straight back into the open state.
-function applyToggle(
- state: {
- isStreaming: boolean;
- collapseByDefault: boolean;
- dismissedWhileStreaming: boolean;
- manualOpen: boolean;
- },
- open: boolean,
-) {
- const next = resolveReasoningToggle(open, state);
- return {
- ...state,
- manualOpen: next.manualOpen,
- dismissedWhileStreaming:
- next.dismissedWhileStreaming ?? state.dismissedWhileStreaming,
- };
+function applyToggle(state: BlockState, open: boolean): BlockState {
+ return { ...state, override: resolveReasoningToggle(open, state).override };
+}
+
+// Mirrors the component's render-time reset when the setting moves.
+function applyPreferenceChange(
+ state: BlockState,
+ visibility: DisplayVisibility,
+): BlockState {
+ return { ...state, visibility, override: null };
}
-test("thinking streams open and auto-collapses when the preference is off", () => {
- const base = { collapseByDefault: false, manualOpen: false };
+test("auto streams the block open and collapses it when the stream ends", () => {
+ const base = { visibility: "auto" as const, override: null };
+ assert.equal(resolveReasoningOpen({ ...base, isStreaming: true }), true);
+ assert.equal(resolveReasoningOpen({ ...base, isStreaming: false }), false);
+});
+
+test("collapsed keeps the block shut in both phases", () => {
+ const base = { visibility: "collapsed" as const, override: null };
+ assert.equal(resolveReasoningOpen({ ...base, isStreaming: true }), false);
+ assert.equal(resolveReasoningOpen({ ...base, isStreaming: false }), false);
+ // A hand-opened block still wins, including while it is streaming.
assert.equal(
- resolveReasoningOpen({
- ...base,
- isStreaming: true,
- dismissedWhileStreaming: false,
- }),
+ resolveReasoningOpen({ ...base, isStreaming: true, override: true }),
true,
);
- // Closing mid-stream keeps it closed for the rest of the round.
- assert.equal(
- resolveReasoningOpen({
- ...base,
- isStreaming: true,
- dismissedWhileStreaming: true,
- }),
- false,
- );
assert.equal(
- resolveReasoningOpen({
- ...base,
- isStreaming: false,
- dismissedWhileStreaming: false,
- }),
- false,
+ resolveReasoningOpen({ ...base, isStreaming: false, override: true }),
+ true,
);
});
-test("thinking stays collapsed in both phases when the preference is on", () => {
- const base = { collapseByDefault: true, dismissedWhileStreaming: false };
- assert.equal(
- resolveReasoningOpen({ ...base, isStreaming: true, manualOpen: false }),
- false,
- );
+test("always expanded keeps the block open in both phases, streaming included", () => {
+ const base = { visibility: "expanded" as const, override: null };
+ assert.equal(resolveReasoningOpen({ ...base, isStreaming: true }), true);
+ // The case the old pair of switches could not express.
+ assert.equal(resolveReasoningOpen({ ...base, isStreaming: false }), true);
+ // And it is still closable by hand.
assert.equal(
- resolveReasoningOpen({ ...base, isStreaming: false, manualOpen: false }),
+ resolveReasoningOpen({ ...base, isStreaming: false, override: false }),
false,
);
- // A hand-opened block still wins, including while it is streaming.
- assert.equal(
- resolveReasoningOpen({ ...base, isStreaming: true, manualOpen: true }),
- true,
- );
- assert.equal(
- resolveReasoningOpen({ ...base, isStreaming: false, manualOpen: true }),
- true,
- );
});
-test("auto-open applies only while streaming with the preference off", () => {
- assert.equal(reasoningAutoOpensWhileStreaming(true, false), true);
- assert.equal(reasoningAutoOpensWhileStreaming(true, true), false);
- assert.equal(reasoningAutoOpensWhileStreaming(false, false), false);
- assert.equal(reasoningAutoOpensWhileStreaming(false, true), false);
+test("closing mid-stream keeps it closed for the rest of the round", () => {
+ let state: BlockState = {
+ isStreaming: true,
+ visibility: "auto",
+ override: null,
+ };
+ assert.equal(resolveReasoningOpen(state), true);
+ state = applyToggle(state, false);
+ assert.equal(resolveReasoningOpen(state), false);
+ // Still closed as the stream continues.
+ assert.equal(resolveReasoningOpen({ ...state, isStreaming: true }), false);
+});
+
+test("a block sits where the setting puts it until someone touches it", () => {
+ assert.equal(reasoningFollowsPreference(true, true, "auto"), true);
+ assert.equal(reasoningFollowsPreference(false, true, "auto"), false);
+ assert.equal(reasoningFollowsPreference(true, false, "expanded"), true);
+ assert.equal(reasoningFollowsPreference(false, false, "collapsed"), true);
+ assert.equal(reasoningFollowsPreference(true, false, "collapsed"), false);
});
-test("a hand-opened block closes again in every phase", () => {
+test("a hand-opened block closes again in every phase and every setting", () => {
for (const isStreaming of [true, false]) {
- for (const collapseByDefault of [true, false]) {
- let state = {
- isStreaming,
- collapseByDefault,
- dismissedWhileStreaming: false,
- manualOpen: false,
- };
+ for (const visibility of DISPLAY_VISIBILITIES) {
+ let state: BlockState = { isStreaming, visibility, override: null };
state = applyToggle(state, true);
assert.equal(
resolveReasoningOpen(state),
true,
- `open failed for streaming=${isStreaming} collapse=${collapseByDefault}`,
+ `open failed for streaming=${isStreaming} visibility=${visibility}`,
);
state = applyToggle(state, false);
assert.equal(
resolveReasoningOpen(state),
false,
- `close failed for streaming=${isStreaming} collapse=${collapseByDefault}`,
+ `close failed for streaming=${isStreaming} visibility=${visibility}`,
);
}
}
});
-test("closing still works after the preference flips mid stream", () => {
- // Collapsed by default, opened by hand while the model is thinking.
- let state = {
+test("changing the setting mid stream re-applies it to a block already on screen", () => {
+ // Collapsed, opened by hand while the model is thinking.
+ let state: BlockState = {
isStreaming: true,
- collapseByDefault: true,
- dismissedWhileStreaming: false,
- manualOpen: false,
+ visibility: "collapsed",
+ override: null,
};
state = applyToggle(state, true);
assert.equal(resolveReasoningOpen(state), true);
- // Preference turned off from settings without leaving the stream.
- state = { ...state, collapseByDefault: false };
+ // Switched to always expanded mid stream: the block follows the new setting.
+ state = applyPreferenceChange(state, "expanded");
+ assert.equal(state.override, null);
assert.equal(resolveReasoningOpen(state), true);
- // The sticky open has to clear here, or the block cannot be collapsed again.
+ // Still closable afterwards, which a pinned override would have blocked.
state = applyToggle(state, false);
- assert.equal(state.manualOpen, false);
+ assert.equal(resolveReasoningOpen(state), false);
+});
+
+test("switching to collapsed shuts a block the user had opened", () => {
+ let state: BlockState = {
+ isStreaming: false,
+ visibility: "expanded",
+ override: null,
+ };
+ state = applyToggle(state, true);
+ state = applyPreferenceChange(state, "collapsed");
assert.equal(resolveReasoningOpen(state), false);
});
@@ -141,13 +152,12 @@ test("a round starts only when streaming resumes", () => {
assert.equal(startsNewReasoningRound(false, false), false);
});
-test("regenerating drops the previous round's manual open", () => {
+test("regenerating drops the previous round's override", () => {
// Block opened by hand after the last round finished.
- let state = {
+ let state: BlockState = {
isStreaming: false,
- collapseByDefault: true,
- dismissedWhileStreaming: false,
- manualOpen: true,
+ visibility: "collapsed",
+ override: true,
};
assert.equal(resolveReasoningOpen(state), true);
@@ -155,29 +165,36 @@ test("regenerating drops the previous round's manual open", () => {
const wasStreaming = state.isStreaming;
state = { ...state, isStreaming: true };
assert.equal(startsNewReasoningRound(state.isStreaming, wasStreaming), true);
- state = { ...state, manualOpen: false, dismissedWhileStreaming: false };
+ state = { ...state, override: null };
assert.equal(resolveReasoningOpen(state), false);
});
-test("streaming height cap is released only for a hand-opened block", () => {
+test("streaming height cap is released only for a block opened against the setting", () => {
assert.equal(
- resolveReasoningToggle(true, { isStreaming: true, collapseByDefault: true })
+ resolveReasoningToggle(true, { isStreaming: true, visibility: "collapsed" })
.releaseStreamingHeight,
true,
);
- // Re-opening an auto-opened block keeps the cap, so live text stays scrolled.
+ // Re-opening a block that opened itself keeps the cap, so live text stays scrolled.
+ assert.equal(
+ resolveReasoningToggle(true, { isStreaming: true, visibility: "auto" })
+ .releaseStreamingHeight,
+ false,
+ );
assert.equal(
- resolveReasoningToggle(true, {
- isStreaming: true,
- collapseByDefault: false,
- }).releaseStreamingHeight,
+ resolveReasoningToggle(true, { isStreaming: true, visibility: "expanded" })
+ .releaseStreamingHeight,
false,
);
+ // Opening a finished block that auto would have left closed still needs its full height.
+ assert.equal(
+ resolveReasoningToggle(true, { isStreaming: false, visibility: "auto" })
+ .releaseStreamingHeight,
+ true,
+ );
assert.equal(
- resolveReasoningToggle(false, {
- isStreaming: false,
- collapseByDefault: false,
- }).releaseStreamingHeight,
+ resolveReasoningToggle(false, { isStreaming: false, visibility: "auto" })
+ .releaseStreamingHeight,
false,
);
});
diff --git a/studio/frontend/tests/thinking-fold.test.ts b/studio/frontend/tests/thinking-fold.test.ts
index cd48b85769a..0e035140f94 100644
--- a/studio/frontend/tests/thinking-fold.test.ts
+++ b/studio/frontend/tests/thinking-fold.test.ts
@@ -439,9 +439,15 @@ test("the preference ships off and survives a reload", () => {
test("the setting is in the Chat tab and findable", () => {
const chatTab = readSrc("features/settings/tabs/chat-tab.tsx");
assert.match(chatTab, /t\("settings\.chat\.tools\.foldIntoThinking"\)/);
+ // The switch reads as off, and refuses input, exactly when the fold cannot apply.
assert.match(
chatTab,
- /checked=\{foldToolActivityIntoThinking\}\n\s*onCheckedChange=\{setFoldToolActivityIntoThinking\}/,
+ /checked=\{foldToolActivityIntoThinking && !foldBlockedByAlwaysExpanded\}\n\s*disabled=\{foldBlockedByAlwaysExpanded\}\n\s*onCheckedChange=\{setFoldToolActivityIntoThinking\}/,
+ );
+ assert.match(
+ chatTab,
+ /const foldBlockedByAlwaysExpanded = toolVisibility === "expanded";/,
+ "the row no longer works out when the fold is unavailable",
);
assert.ok(
SETTINGS_SEARCH_INDEX.chat.includes("settings.chat.tools.foldIntoThinking"),
@@ -449,7 +455,37 @@ test("the setting is in the Chat tab and findable", () => {
);
assert.equal(
en.settings.chat.tools.foldIntoThinking,
- "Fold tool calls into Thinking",
+ "Group tool calls under Thinking",
);
assert.ok(en.settings.chat.tools.foldIntoThinkingDescription.length > 0);
+ assert.ok(en.settings.chat.tools.foldIntoThinkingBlocked.length > 0);
+});
+
+test("the two visibility rows replaced the pair of collapse switches", () => {
+ const chatTab = readSrc("features/settings/tabs/chat-tab.tsx");
+ for (const key of [
+ "settings.chat.thinking.visibility",
+ "settings.chat.tools.visibility",
+ ]) {
+ assert.ok(
+ SETTINGS_SEARCH_INDEX.chat.includes(key as never),
+ `${key} cannot be found by search`,
+ );
+ assert.ok(
+ chatTab.includes(`t("${key}")`),
+ `${key} is indexed but not rendered, so search scrolls to nothing`,
+ );
+ }
+ // All three states are offered, and no old switch is left claiming the same job.
+ for (const value of ["collapsed", "auto", "expanded"]) {
+ assert.ok(
+ chatTab.includes(`<SelectItem value="${value}">`),
+ `the ${value} option is missing from Display`,
+ );
+ }
+ assert.equal(
+ /collapseThinkingByDefault|collapseToolActivityByDefault/.test(chatTab),
+ false,
+ "an old collapse switch is still wired up alongside its replacement",
+ );
});
diff --git a/studio/frontend/tests/tool-activity-preference.test.ts b/studio/frontend/tests/tool-activity-preference.test.ts
index 3a9f0a1d464..d93482a22d2 100644
--- a/studio/frontend/tests/tool-activity-preference.test.ts
+++ b/studio/frontend/tests/tool-activity-preference.test.ts
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// The transition table for the collapse-tool-activity preference, the store's
+// The transition table for the tool-call visibility setting, the store's
// compatibility promise, and the JSX wiring that carries both.
//
// The reducers and the store are plain .ts, so those claims run the code. The
@@ -46,8 +46,15 @@ store.set(
const { useChatPreferencesStore } = await import(
"../src/features/chat/stores/chat-preferences-store.ts"
);
-const { resolveToolActivityOpen, syncToolActivityPreference } = await import(
- "../src/components/assistant-ui/tool-activity-open-state.ts"
+const {
+ resolveToolActivityOpen,
+ startsNewToolRound,
+ syncToolActivityPreference,
+ toolActivityOpen,
+} =
+ await import("../src/components/assistant-ui/tool-activity-open-state.ts");
+const { foldIsActive } = await import(
+ "../src/features/chat/utils/display-visibility.ts"
);
/** Write `state` as a persisted record and hydrate the live store from it. */
@@ -60,26 +67,58 @@ async function rehydrateFrom(state: unknown): Promise<void> {
// The store's compatibility promise, made against a real hydrate.
// ---------------------------------------------------------------------------
-test("tool activity is collapsed by default", () => {
- assert.equal(
- useChatPreferencesStore.getInitialState().collapseToolActivityByDefault,
- true,
- );
+test("tool calls are collapsed by default and thinking follows its stream", () => {
+ const initial = useChatPreferencesStore.getInitialState();
+ assert.equal(initial.toolVisibility, "collapsed");
+ assert.equal(initial.thinkingVisibility, "auto");
});
test("a record written before the setting existed inherits the collapsed default", () => {
- // This is not an opt-in: `?? true` in merge() means an install that never
- // saw this setting starts collapsing tool activity the moment it upgrades.
- // Asserted against a real hydrate of a real legacy record so that the day
- // someone reconsiders that call, the test says so out loud instead of
- // quietly agreeing.
- assert.equal(
- useChatPreferencesStore.getState().collapseToolActivityByDefault,
- true,
- );
+ // Not an opt-in: an install that never saw this setting starts collapsing tool activity the
+ // moment it upgrades. Asserted against a real hydrate so reconsidering that call is loud.
+ assert.equal(useChatPreferencesStore.getState().toolVisibility, "collapsed");
+});
+
+test("the old pair of switches carries over to the three-state settings", () => {
+ // LEGACY_STATE has collapseThinkingByDefault: true and no tool key, so this covers both
+ // halves: an explicit collapse survives the rename, an absent key lands on the new default.
+ const state = useChatPreferencesStore.getState();
+ assert.equal(state.thinkingVisibility, "collapsed");
+ assert.equal(state.toolVisibility, "collapsed");
+});
+
+test("a legacy `off` becomes auto rather than always expanded", async () => {
+ // The old `false` meant "open while running, close after", which is auto. Reading it as
+ // expanded would leave every upgrading user with permanently open tool cards.
+ await rehydrateFrom({
+ ...LEGACY_STATE,
+ collapseThinkingByDefault: false,
+ collapseToolActivityByDefault: false,
+ });
+ const state = useChatPreferencesStore.getState();
+ assert.equal(state.thinkingVisibility, "auto");
+ assert.equal(state.toolVisibility, "auto");
+ await rehydrateFrom(LEGACY_STATE);
+});
+
+test("a stored visibility wins over the legacy boolean beside it", async () => {
+ // Both keys can coexist for one upgrade, and the new one is the one the user last set.
+ await rehydrateFrom({
+ ...LEGACY_STATE,
+ collapseToolActivityByDefault: true,
+ toolVisibility: "expanded",
+ });
+ assert.equal(useChatPreferencesStore.getState().toolVisibility, "expanded");
+ await rehydrateFrom(LEGACY_STATE);
+});
+
+test("a value from a newer build falls back instead of blanking the row", async () => {
+ await rehydrateFrom({ ...LEGACY_STATE, toolVisibility: "peek" });
+ assert.equal(useChatPreferencesStore.getState().toolVisibility, "collapsed");
+ await rehydrateFrom(LEGACY_STATE);
});
-test("hydrating the new key leaves the older preferences alone", () => {
+test("hydrating the new keys leaves the older preferences alone", () => {
// merge() is a hand-maintained allowlist, so adding a field to it is exactly
// when one of the others goes missing.
const state = useChatPreferencesStore.getState();
@@ -87,32 +126,35 @@ test("hydrating the new key leaves the older preferences alone", () => {
assert.equal(state.alwaysDeleteChatFiles, true);
assert.equal(state.showModelDisclaimer, true);
assert.equal(state.showResponseModel, true);
- assert.equal(state.collapseThinkingByDefault, true);
assert.equal(state.pastedTextMinChars, 8000);
// The setters have to survive too: a merge returning only the saved fields
// would leave a store with no way to write to it.
- assert.equal(typeof state.setCollapseToolActivityByDefault, "function");
+ assert.equal(typeof state.setToolVisibility, "function");
+ assert.equal(typeof state.setThinkingVisibility, "function");
});
-test("turning the preference off round-trips through storage", async () => {
- // The direction that matters now that the default is on: a user who wants
- // their tool output back has to be able to keep it across a reload.
- await rehydrateFrom({
- ...LEGACY_STATE,
- collapseToolActivityByDefault: false,
- });
- assert.equal(
- useChatPreferencesStore.getState().collapseToolActivityByDefault,
- false,
- "an explicit off is being overridden by the new default",
- );
- useChatPreferencesStore.getState().setCollapseToolActivityByDefault(true);
- assert.equal(
- JSON.parse(store.get(PREFERENCES_KEY) ?? "{}").state
- .collapseToolActivityByDefault,
- true,
- "the preference is not persisted, so it would not survive a reload",
- );
+test("each visibility round-trips through storage", async () => {
+ for (const visibility of ["auto", "expanded", "collapsed"] as const) {
+ useChatPreferencesStore.getState().setToolVisibility(visibility);
+ useChatPreferencesStore.getState().setThinkingVisibility(visibility);
+ const saved = JSON.parse(store.get(PREFERENCES_KEY) ?? "{}").state;
+ assert.equal(
+ saved.toolVisibility,
+ visibility,
+ "the tool setting is not persisted, so it would not survive a reload",
+ );
+ assert.equal(
+ saved.thinkingVisibility,
+ visibility,
+ "the thinking setting is not persisted, so it would not survive a reload",
+ );
+ await useChatPreferencesStore.persist.rehydrate();
+ assert.equal(useChatPreferencesStore.getState().toolVisibility, visibility);
+ assert.equal(
+ useChatPreferencesStore.getState().thinkingVisibility,
+ visibility,
+ );
+ }
await rehydrateFrom(LEGACY_STATE);
});
@@ -122,8 +164,43 @@ test("an unreadable record leaves every default in place", async () => {
await useChatPreferencesStore.persist.rehydrate();
});
const state = useChatPreferencesStore.getState();
- assert.equal(state.collapseToolActivityByDefault, true);
- assert.equal(typeof state.setCollapseToolActivityByDefault, "function");
+ assert.equal(state.toolVisibility, "collapsed");
+ assert.equal(typeof state.setToolVisibility, "function");
+ assert.equal(typeof state.setThinkingVisibility, "function");
+ await rehydrateFrom(LEGACY_STATE);
+});
+
+// ---------------------------------------------------------------------------
+// Fold, and the one setting it cannot coexist with.
+// ---------------------------------------------------------------------------
+
+test("folding tool calls into Thinking gives way to always expanded", () => {
+ // Honouring both would pin the calls open inside something closed, so the fold stands down.
+ assert.equal(foldIsActive(true, "collapsed"), true);
+ assert.equal(foldIsActive(true, "auto"), true);
+ assert.equal(foldIsActive(true, "expanded"), false);
+ assert.equal(foldIsActive(false, "collapsed"), false);
+ assert.equal(foldIsActive(false, "expanded"), false);
+});
+
+test("the fold preference is only suspended, not cleared", async () => {
+ // Settings disables the row while it cannot apply, but the stored value has to survive.
+ await rehydrateFrom({
+ ...LEGACY_STATE,
+ foldToolActivityIntoThinking: true,
+ toolVisibility: "expanded",
+ });
+ const state = useChatPreferencesStore.getState();
+ assert.equal(state.foldToolActivityIntoThinking, true);
+ assert.equal(foldIsActive(state.foldToolActivityIntoThinking, "expanded"), false);
+ state.setToolVisibility("collapsed");
+ assert.equal(
+ foldIsActive(
+ useChatPreferencesStore.getState().foldToolActivityIntoThinking,
+ "collapsed",
+ ),
+ true,
+ );
await rehydrateFrom(LEGACY_STATE);
});
@@ -135,8 +212,8 @@ test("manual expansion survives updates while activity is collapsed", () => {
assert.equal(
resolveToolActivityOpen({
currentOpen: true,
- collapseByDefault: true,
- previousCollapseByDefault: true,
+ visibility: "collapsed",
+ previousVisibility: "collapsed",
isRunning: false,
hasText: true,
}),
@@ -144,12 +221,46 @@ test("manual expansion survives updates while activity is collapsed", () => {
);
});
-test("enabling collapsed activity closes an already open card", () => {
+test("always expanded keeps a card open through running, finished and answered", () => {
+ for (const [isRunning, hasText] of [
+ [true, false],
+ [false, false],
+ [false, true],
+ ] as const) {
+ assert.equal(
+ resolveToolActivityOpen({
+ currentOpen: true,
+ visibility: "expanded",
+ previousVisibility: "expanded",
+ isRunning,
+ hasText,
+ }),
+ true,
+ `closed itself at running=${isRunning} hasText=${hasText}`,
+ );
+ }
+});
+
+test("a card closed by hand stays closed under always expanded", () => {
+ // The setting says where a card starts, not where it stays.
+ assert.equal(
+ resolveToolActivityOpen({
+ currentOpen: false,
+ visibility: "expanded",
+ previousVisibility: "expanded",
+ isRunning: false,
+ hasText: true,
+ }),
+ false,
+ );
+});
+
+test("switching to collapsed closes an already open card", () => {
assert.equal(
resolveToolActivityOpen({
currentOpen: true,
- collapseByDefault: true,
- previousCollapseByDefault: false,
+ visibility: "collapsed",
+ previousVisibility: "auto",
isRunning: true,
hasText: false,
}),
@@ -157,12 +268,12 @@ test("enabling collapsed activity closes an already open card", () => {
);
});
-test("disabling collapsed activity restores automatic visibility", () => {
+test("switching to auto restores automatic visibility", () => {
assert.equal(
resolveToolActivityOpen({
currentOpen: false,
- collapseByDefault: false,
- previousCollapseByDefault: true,
+ visibility: "auto",
+ previousVisibility: "collapsed",
isRunning: true,
hasText: false,
}),
@@ -171,8 +282,8 @@ test("disabling collapsed activity restores automatic visibility", () => {
assert.equal(
resolveToolActivityOpen({
currentOpen: true,
- collapseByDefault: false,
- previousCollapseByDefault: false,
+ visibility: "auto",
+ previousVisibility: "auto",
isRunning: false,
hasText: true,
}),
@@ -180,16 +291,28 @@ test("disabling collapsed activity restores automatic visibility", () => {
);
});
-test("turning the preference off hands the card back to the automatic rules", () => {
- // Documented rather than accidental: a preference change is an explicit user
- // action, so it resets to whatever the automatic policy says rather than
- // preserving a manual expansion made under the old preference. The reverse
- // direction is the one that preserves manual state (first test above).
+test("switching to always expanded opens a card that was collapsed and finished", () => {
+ // A call that already ran, on a message already on screen, opening because the setting did.
+ assert.equal(
+ resolveToolActivityOpen({
+ currentOpen: false,
+ visibility: "expanded",
+ previousVisibility: "collapsed",
+ isRunning: false,
+ hasText: true,
+ }),
+ true,
+ );
+});
+
+test("changing the setting hands the card back to the automatic rules", () => {
+ // Deliberate: a setting change is an explicit action, so it resets rather than preserving a
+ // manual expansion made under the old setting. Between changes manual state is preserved.
assert.equal(
resolveToolActivityOpen({
currentOpen: true,
- collapseByDefault: false,
- previousCollapseByDefault: true,
+ visibility: "auto",
+ previousVisibility: "collapsed",
isRunning: false,
hasText: true,
}),
@@ -197,47 +320,218 @@ test("turning the preference off hands the card back to the automatic rules", ()
);
});
+test("switching to auto opens a running card on a message that already has text", () => {
+ // The call still running belongs to a message whose prose arrived first, so hasText is
+ // already true when the setting changes. Expand while running is about the call, not the text.
+ assert.equal(
+ resolveToolActivityOpen({
+ currentOpen: false,
+ visibility: "auto",
+ previousVisibility: "collapsed",
+ isRunning: true,
+ hasText: true,
+ }),
+ true,
+ "a running card stayed closed when the setting changed to Expand while running",
+ );
+ // A finished call on the same message still opens nothing.
+ assert.equal(
+ resolveToolActivityOpen({
+ currentOpen: false,
+ visibility: "auto",
+ previousVisibility: "collapsed",
+ isRunning: false,
+ hasText: true,
+ }),
+ false,
+ );
+});
+
+
+test("a hand-opened controlled card keeps its open when the answer starts", () => {
+ const transition = (hasText: boolean, override?: boolean | null) =>
+ resolveToolActivityOpen({
+ currentOpen: true,
+ visibility: "auto",
+ previousVisibility: "auto",
+ isRunning: false,
+ hasText,
+ override,
+ });
+ assert.equal(transition(false, true), true);
+ assert.equal(
+ transition(true, true),
+ true,
+ "the answer arriving closed a controlled card the user opened",
+ );
+ assert.equal(
+ transition(true),
+ false,
+ "an untouched card must still close when the answer starts",
+ );
+});
+
+
+test("the round boundary is the call starting again", () => {
+ // The reasoning block's rule, applied here: a round starts when the activity resumes.
+ assert.equal(startsNewToolRound(true, false), true);
+ assert.equal(startsNewToolRound(true, true), false);
+ assert.equal(startsNewToolRound(false, true), false);
+ assert.equal(startsNewToolRound(false, false), false);
+});
+
+test("a new round hands a controlled card back to the setting", () => {
+ // Regenerate reuses the card, so the previous round's hand-set state must not survive into
+ // the new one: the setting decides where the card starts again.
+ const rerun = (
+ visibility: "collapsed" | "auto" | "expanded",
+ override: boolean | null,
+ ) =>
+ resolveToolActivityOpen({
+ currentOpen: true,
+ visibility,
+ previousVisibility: visibility,
+ isRunning: true,
+ hasText: true,
+ override,
+ startedNewRound: true,
+ });
+ // The answer text arrived in the old round, so hasText is already true for this one too.
+ assert.equal(
+ rerun("auto", false),
+ true,
+ "a card closed in the old round stayed closed for the new run",
+ );
+ assert.equal(
+ rerun("collapsed", true),
+ false,
+ "a card opened in the old round stayed pinned open for the new run",
+ );
+ assert.equal(rerun("expanded", false), true);
+});
+
+
+test("an uncontrolled card starts fresh when its call runs again", () => {
+ // The same regenerate reuse the controlled cards take from the hook, reached here through
+ // `active`: generic, MCP, Terminal and Python cards keep their own state through this function.
+ const closedInOldRound = {
+ visibility: "auto" as const,
+ active: false,
+ override: false,
+ };
+ assert.equal(
+ toolActivityOpen(syncToolActivityPreference(closedInOldRound, "auto", true)),
+ true,
+ "a card closed in the old round stayed shut for the regenerated run",
+ );
+ const openedInOldRound = {
+ visibility: "collapsed" as const,
+ active: false,
+ override: true,
+ };
+ assert.equal(
+ toolActivityOpen(
+ syncToolActivityPreference(openedInOldRound, "collapsed", true),
+ ),
+ false,
+ "a card opened in the old round stayed pinned open for the regenerated run",
+ );
+ // Activity moving on its own, without the call restarting, still keeps a manual open.
+ assert.equal(
+ syncToolActivityPreference(
+ { visibility: "auto" as const, active: true, override: true },
+ "auto",
+ false,
+ ).override,
+ true,
+ );
+});
+
+
test("fallback cards react to live preference changes", () => {
const manuallyOpen = {
- collapseByDefault: false,
- open: true,
+ visibility: "auto" as const,
+ active: true,
+ override: true,
};
- const collapsed = syncToolActivityPreference(manuallyOpen, true, true);
- assert.deepEqual(collapsed, {
- collapseByDefault: true,
- open: false,
- });
- assert.deepEqual(syncToolActivityPreference(collapsed, false, true), {
- collapseByDefault: false,
- open: true,
- });
+ const collapsed = syncToolActivityPreference(manuallyOpen, "collapsed", true);
+ // The setting change drops the manual open, so the card follows the new setting.
+ assert.equal(collapsed.override, null);
+ assert.equal(toolActivityOpen(collapsed), false);
+ assert.equal(toolActivityOpen(syncToolActivityPreference(collapsed, "auto", true)), true);
+ // Always expanded ignores the card's own activity and opens it regardless.
+ assert.equal(
+ toolActivityOpen(syncToolActivityPreference(collapsed, "expanded", false)),
+ true,
+ );
});
test("fallback cards preserve manual state until the preference changes", () => {
const manuallyOpen = {
- collapseByDefault: true,
- open: true,
+ visibility: "collapsed" as const,
+ active: true,
+ override: true,
};
// Reference identity, not deep equality: the render-phase `if (synced !==
// state) setState(...)` in ToolFallbackRoot and ToolGroupRoot terminates only
- // because an unchanged preference returns the very same object.
+ // because an unchanged preference and activity return the very same object.
assert.equal(
- syncToolActivityPreference(manuallyOpen, true, true),
+ syncToolActivityPreference(manuallyOpen, "collapsed", true),
manuallyOpen,
);
+ const manuallyClosed = {
+ visibility: "expanded" as const,
+ active: true,
+ override: false,
+ };
+ assert.equal(
+ syncToolActivityPreference(manuallyClosed, "expanded", true),
+ manuallyClosed,
+ );
});
-test("disabling collapsed activity respects a closed fallback default", () => {
- assert.deepEqual(
- syncToolActivityPreference(
- { collapseByDefault: true, open: false },
- false,
- false,
+test("switching to auto respects a card whose call has finished", () => {
+ assert.equal(
+ toolActivityOpen(
+ syncToolActivityPreference(
+ { visibility: "collapsed", active: false, override: null },
+ "auto",
+ false,
+ ),
),
- { collapseByDefault: false, open: false },
+ false,
);
});
+test("an auto card closes itself when its call stops running", () => {
+ // The gap this covers: an uncontrolled card mounted with defaultOpen={isRunning} used to open
+ // and never close again, because an unchanged setting returned the state untouched.
+ const running = { visibility: "auto" as const, active: true, override: null };
+ assert.equal(toolActivityOpen(running), true);
+ const finished = syncToolActivityPreference(running, "auto", false);
+ assert.equal(toolActivityOpen(finished), false);
+});
+
+test("a hand-opened auto card survives its call finishing", () => {
+ // Activity moving on its own must not discard a manual open, only the setting may.
+ const opened = { visibility: "auto" as const, active: true, override: true };
+ const finished = syncToolActivityPreference(opened, "auto", false);
+ assert.equal(finished.override, true);
+ assert.equal(toolActivityOpen(finished), true);
+});
+
+test("a hand-closed running card stays closed while it runs", () => {
+ const closed = { visibility: "auto" as const, active: true, override: false };
+ assert.equal(toolActivityOpen(closed), false);
+ assert.equal(toolActivityOpen(syncToolActivityPreference(closed, "auto", true)), false);
+});
+
+test("always expanded opens a card that mounted with nothing running", () => {
+ // Generic and MCP cards render with whatever their status says; expanded ignores it.
+ const idle = { visibility: "expanded" as const, active: false, override: null };
+ assert.equal(toolActivityOpen(idle), true);
+});
+
// ---------------------------------------------------------------------------
// AST helpers for the .tsx claims.
// ---------------------------------------------------------------------------
@@ -287,24 +581,27 @@ function identifiersIn(node: ts.Node): Set<string> {
}
/**
- * The local name a file binds the preference to, resolved through the store
- * selector rather than assumed. Hard-coding "collapseByDefault" would make
- * these assertions fail on a rename that changes nothing.
+ * The local name a file binds the setting to, resolved through the store
+ * selector rather than assumed. Hard-coding "visibility" would make these
+ * assertions fail on a rename that changes nothing.
*/
-function preferenceBinding(root: ts.SourceFile): string {
- const declaration = find(root, (node) => {
+function preferenceBinding(
+ root: ts.SourceFile,
+ scope: ts.Node = root,
+): string {
+ const declaration = find(scope, (node) => {
if (!ts.isVariableDeclaration(node) || !node.initializer) return false;
const init = node.initializer;
return (
ts.isCallExpression(init) &&
ts.isIdentifier(init.expression) &&
init.expression.text === "useChatPreferencesStore" &&
- identifiersIn(init).has("collapseToolActivityByDefault")
+ identifiersIn(init).has("toolVisibility")
);
})[0] as ts.VariableDeclaration | undefined;
assert.ok(
declaration && ts.isIdentifier(declaration.name),
- `${root.fileName} never reads collapseToolActivityByDefault off the store`,
+ `${root.fileName} never reads toolVisibility off the store`,
);
return declaration.name.text;
}
@@ -350,8 +647,8 @@ test("the shared hook resolves through the preference and the shared policy", as
)[0];
assert.ok(selector, "the hook does not subscribe to the preference store");
assert.ok(
- identifiersIn(selector).has("collapseToolActivityByDefault"),
- "the hook subscribes to the store but not to this preference",
+ identifiersIn(selector).has("toolVisibility"),
+ "the hook subscribes to the store but not to this setting",
);
const resolve = find(
source,
@@ -364,10 +661,12 @@ test("the shared hook resolves through the preference and the shared policy", as
const passed = identifiersIn(resolve.arguments[0] ?? resolve);
for (const field of [
"currentOpen",
- "collapseByDefault",
- "previousCollapseByDefault",
+ "visibility",
+ "previousVisibility",
"isRunning",
"hasText",
+ // Without this the hook cannot clear the old round's manual state when a call re-runs.
+ "startedNewRound",
]) {
assert.ok(passed.has(field), `the policy is called without ${field}`);
}
@@ -468,7 +767,7 @@ test("a card awaiting approval opens above the preference", async () => {
assert.equal(
identifiersIn(isOpen.left).has(preferenceBinding(source)),
false,
- "the collapse preference can suppress an approval prompt's context",
+ "the visibility setting can suppress an approval prompt's context",
);
// Every card that (a) is wrapped in withToolConfirmation and (b) can be closed by
@@ -506,7 +805,12 @@ test("a pending approval forces a group open regardless of the preference", asyn
const source = await sourceOf(
"../src/components/assistant-ui/tool-group.tsx",
);
- const preference = preferenceBinding(source);
+ // Scoped to ToolGroupImpl: ToolGroupRoot reads the same setting above, for its own
+ // uncontrolled state, and resolving to that binding would test the wrong component.
+ const preference = preferenceBinding(
+ source,
+ initializerOf(source, "ToolGroupImpl"),
+ );
const forceOpen = initializerOf(source, "forceOpen");
assert.ok(
ts.isBinaryExpression(forceOpen) &&
@@ -553,7 +857,13 @@ test("a mounted group follows the preference like a mounted card", async () => {
const source = await sourceOf(
"../src/components/assistant-ui/tool-group.tsx",
);
- const preference = preferenceBinding(source);
+ const root = find(
+ source,
+ (node) =>
+ ts.isFunctionDeclaration(node) && node.name?.text === "ToolGroupRoot",
+ )[0];
+ assert.ok(root, "ToolGroupRoot is gone");
+ const preference = preferenceBinding(source, root);
const synced = find(
source,
(node) =>
@@ -578,7 +888,53 @@ test("a mounted group follows the preference like a mounted card", async () => {
);
});
-test("the Python script cell moves inside the collapsible when collapsing is on", async () => {
+test("the generic fallback card tells its root whether the call is running", async () => {
+ // Without this the root's defaultOpen stays false, so "Expand while running" could never
+ // reach an unknown or MCP tool call.
+ const source = await sourceOf(
+ "../src/components/assistant-ui/tool-fallback.tsx",
+ );
+ const impl = initializerOf(source, "ToolFallbackImpl");
+ const root = jsxElement(impl, "ToolFallbackRoot");
+ const attribute = jsxAttribute(root, "defaultOpen");
+ assert.ok(attribute, "the generic card mounts collapsed even while it runs");
+ assert.ok(
+ attribute.initializer &&
+ ts.isJsxExpression(attribute.initializer) &&
+ attribute.initializer.expression &&
+ identifiersIn(attribute.initializer.expression).has("isToolCallRunning"),
+ "the generic card pins defaultOpen instead of reading its live status",
+ );
+});
+
+test("a tool group tells its root whether its own calls are running", async () => {
+ const source = await sourceOf(
+ "../src/components/assistant-ui/tool-group.tsx",
+ );
+ const impl = initializerOf(source, "ToolGroupImpl");
+ const attribute = jsxAttribute(jsxElement(impl, "ToolGroupRoot"), "defaultOpen");
+ assert.ok(attribute, "a running group mounts collapsed under auto");
+ assert.ok(
+ attribute.initializer &&
+ ts.isJsxExpression(attribute.initializer) &&
+ attribute.initializer.expression &&
+ identifiersIn(attribute.initializer.expression).has("groupRunning"),
+ "the group pins defaultOpen instead of reading its live activity",
+ );
+ // Scoped to the group's own calls, not the whole message, so it goes quiet once they finish.
+ const running = initializerOf(source, "groupRunning");
+ const names = identifiersIn(running);
+ assert.ok(
+ names.has("startIndex") && names.has("endIndex"),
+ "the group's activity signal ignores which calls belong to it",
+ );
+ assert.ok(
+ names.has("result"),
+ "the group stays open for the whole turn instead of until its calls have results",
+ );
+});
+
+test("the Python script cell moves inside the collapsible when tool calls are collapsed", async () => {
// Two renders of one cell, each guarded by the opposite value: outside the
// collapsible so a reopened chat still shows the script (#7165), inside it
// when the user asked for quiet. Two copies of the same guard would render
diff --git a/studio/frontend/tsconfig.app.json b/studio/frontend/tsconfig.app.json
index 5f64d4efa6b..2d1ffbabfb4 100644
--- a/studio/frontend/tsconfig.app.json
+++ b/studio/frontend/tsconfig.app.json
@@ -41,6 +41,7 @@
"smoke-settings-main.tsx",
"smoke-shortcuts-main.tsx",
"smoke-stream-pacing-main.tsx",
- "smoke-code-block-flicker-main.tsx"
+ "smoke-code-block-flicker-main.tsx",
+ "smoke-tool-activity-main.tsx"
]
}