Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/app/src/agent-stream/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import {
prepareToolCallHistory,
projectToolCallDetailLevel,
} from "@/tool-calls/detail-level/projection";
import { formatThinkingText } from "@/utils/thinking-text-formatter";
import { OverviewToolCallGroupView } from "@/tool-calls/detail-level/overview/view";
import { type AgentStreamRenderModel, buildAgentStreamRenderModel } from "./model";
import { resolveStreamRenderStrategy } from "./strategy-resolver";
Expand Down Expand Up @@ -663,16 +664,20 @@ const AgentStreamViewComponent = forwardRef<AgentStreamViewHandle, AgentStreamVi

const renderThoughtItem = useCallback(
(layoutItem: StreamLayoutItem, item: Extract<StreamItem, { kind: "thought" }>) => {
const isThoughtActive = item.status !== "ready";
const isExpanded =
autoExpandReasoning === "expanded" ||
(autoExpandReasoning === "expand_active" && isThoughtActive);
return (
<ToolCallSlot
itemId={item.id}
onInlineDetailsExpandedChangeByItemId={setInlineDetailsExpanded}
toolName="thinking"
args={item.text}
args={formatThinkingText(item.text)}
status={item.status === "ready" ? "completed" : "executing"}
isLastInSequence={layoutItem.isLastInToolSequence}
defaultExpanded={autoExpandReasoning}
forceInline={autoExpandReasoning}
defaultExpanded={isExpanded}
forceInline={isExpanded}
/>
);
},
Expand Down
5 changes: 5 additions & 0 deletions packages/app/src/components/message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3061,6 +3061,11 @@ export const ToolCall = memo(function ToolCall({
}: ToolCallProps) {
const { openToolCall } = useToolCallSheet();
const [isExpanded, setIsExpanded] = useState(defaultExpanded ?? false);
const [prevDefaultExpanded, setPrevDefaultExpanded] = useState(defaultExpanded);
if (prevDefaultExpanded !== defaultExpanded) {
setPrevDefaultExpanded(defaultExpanded);
setIsExpanded(defaultExpanded ?? false);
}

const isMobile = useIsCompactFormFactor();
const shouldRenderInline = !isMobile || forceInline;
Expand Down
25 changes: 24 additions & 1 deletion packages/app/src/components/tool-call-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { HighlightedLines } from "./highlighted-content";
import { DiffViewer } from "./diff-viewer";
import { getCodeInsets } from "./code-insets";
import { isWeb } from "@/constants/platform";
import { formatThinkingText } from "@/utils/thinking-text-formatter";
import { MarkdownRenderer } from "./markdown/renderer";

const ScrollView = isWeb ? RNScrollView : GHScrollView;

Expand Down Expand Up @@ -506,6 +508,21 @@ function ScrollablePlainTextSection({ text, ds }: { text: string; ds: DetailStyl
);
}

function ScrollableMarkdownSection({ text, ds }: { text: string; ds: DetailStyles }) {
return (
<View style={styles.section}>
<ScrollView
style={ds.scrollAreaStyle}
contentContainerStyle={styles.scrollContent}
nestedScrollEnabled
showsVerticalScrollIndicator
>
<MarkdownRenderer text={text} compact enableHtmlish={false} />
</ScrollView>
</View>
);
}

interface SearchDetail {
query?: string;
content?: string;
Expand Down Expand Up @@ -582,7 +599,13 @@ function buildUnknownSections(detail: UnknownDetail, ds: DetailStyles, t: TFunct
typeof detail.input === "string" && detail.output === null ? detail.input : null;

if (plainInputText !== null) {
return [<ScrollablePlainTextSection key="unknown-plain-text" text={plainInputText} ds={ds} />];
return [
<ScrollableMarkdownSection
key="unknown-markdown-text"
text={formatThinkingText(plainInputText)}
ds={ds}
/>,
];
}

const sectionsFromTopLevel = [
Expand Down
39 changes: 39 additions & 0 deletions packages/app/src/hooks/use-settings/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,45 @@ describe("appearance settings", () => {
expect(result.toolCallDetailLevel).toBe("detailed");
});

it("loads thinking display detail enum values or migrates legacy boolean values", async () => {
const depsTrue = makeDeps({
storage: createInMemoryKeyValueStorage({
[APP_SETTINGS_KEY]: JSON.stringify({ autoExpandReasoning: true }),
}),
});
expect((await loadAppSettingsFromStorage(depsTrue)).autoExpandReasoning).toBe("expanded");

const depsFalse = makeDeps({
storage: createInMemoryKeyValueStorage({
[APP_SETTINGS_KEY]: JSON.stringify({ autoExpandReasoning: false }),
}),
});
expect((await loadAppSettingsFromStorage(depsFalse)).autoExpandReasoning).toBe("collapsed");

const depsActive = makeDeps({
storage: createInMemoryKeyValueStorage({
[APP_SETTINGS_KEY]: JSON.stringify({ autoExpandReasoning: "expand_active" }),
}),
});
expect((await loadAppSettingsFromStorage(depsActive)).autoExpandReasoning).toBe(
"expand_active",
);

const depsExpanded = makeDeps({
storage: createInMemoryKeyValueStorage({
[APP_SETTINGS_KEY]: JSON.stringify({ autoExpandReasoning: "expanded" }),
}),
});
expect((await loadAppSettingsFromStorage(depsExpanded)).autoExpandReasoning).toBe("expanded");

const depsInvalid = makeDeps({
storage: createInMemoryKeyValueStorage({
[APP_SETTINGS_KEY]: JSON.stringify({ autoExpandReasoning: "invalid" }),
}),
});
expect((await loadAppSettingsFromStorage(depsInvalid)).autoExpandReasoning).toBe("collapsed");
});

it("migrates the enabled compact tool call preference to overview", async () => {
const deps = makeDeps({
storage: createInMemoryKeyValueStorage({
Expand Down
34 changes: 29 additions & 5 deletions packages/app/src/hooks/use-settings/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type ServiceUrlBehavior = "ask" | "in-app" | "external";
export type WorkspaceTitleSource = "title" | "branch";
/** What a sidebar workspace row shows in the space to the right of its title. */
export type SidebarWorkspaceTrailing = "diff" | "timestamp" | "none";
export type ThinkingDisplayDetail = "collapsed" | "expand_active" | "expanded";
export type ToolCallDetailLevel = "overview" | "detailed";

const VALID_THEMES = new Set<string>(THEME_OPTIONS.map((option) => option.name));
Expand All @@ -39,6 +40,11 @@ const VALID_SIDEBAR_WORKSPACE_TRAILINGS = new Set<SidebarWorkspaceTrailing>([
"none",
]);
const VALID_TOOL_CALL_DETAIL_LEVELS = new Set<ToolCallDetailLevel>(["overview", "detailed"]);
const VALID_THINKING_DISPLAY_DETAILS = new Set<ThinkingDisplayDetail>([
"collapsed",
"expand_active",
"expanded",
]);
export const DEFAULT_TERMINAL_SCROLLBACK_LINES = 10_000;
export const MIN_TERMINAL_SCROLLBACK_LINES = 0;
export const MAX_TERMINAL_SCROLLBACK_LINES = 1_000_000;
Expand Down Expand Up @@ -66,7 +72,7 @@ export interface AppSettings {
sidebarWorkspaceTrailing: SidebarWorkspaceTrailing;
sidebarRowItems: SidebarRowItems;
sidebarChecksDisplay: SidebarChecksDisplay;
autoExpandReasoning: boolean;
autoExpandReasoning: ThinkingDisplayDetail;
toolCallDetailLevel: ToolCallDetailLevel;
chatOutlineEnabled: boolean;
vimKeybindings: boolean;
Expand Down Expand Up @@ -103,7 +109,9 @@ const StoredAppSettingsSchema = z.strictObject({
sidebarWorkspaceTrailing: z.enum(["diff", "timestamp", "none"]).optional(),
sidebarRowItems: SidebarRowItemsSchema.optional(),
sidebarChecksDisplay: z.enum(["iconAndText", "icon", "none"]).optional(),
autoExpandReasoning: z.boolean().optional(),
autoExpandReasoning: z
.union([z.enum(["collapsed", "expand_active", "expanded"]), z.boolean()])
.optional(),
toolCallDetailLevel: z.enum(["overview", "detailed"]).optional(),
compactToolCalls: z.boolean().optional(),
chatOutlineEnabled: z.boolean().optional(),
Expand Down Expand Up @@ -133,7 +141,7 @@ export const DEFAULT_CLIENT_SETTINGS: AppSettings = {
sidebarWorkspaceTrailing: "diff",
sidebarRowItems: DEFAULT_SIDEBAR_ROW_ITEMS,
sidebarChecksDisplay: DEFAULT_SIDEBAR_CHECKS_DISPLAY,
autoExpandReasoning: false,
autoExpandReasoning: "collapsed",
toolCallDetailLevel: "detailed",
chatOutlineEnabled: true,
vimKeybindings: false,
Expand Down Expand Up @@ -242,6 +250,21 @@ export function normalizeAppSettings(value: unknown): AppSettings {
};
}

function parseThinkingDisplayDetail(stored: StoredAppSettings): ThinkingDisplayDetail | null {
if (stored.autoExpandReasoning !== undefined) {
if (
typeof stored.autoExpandReasoning === "string" &&
VALID_THINKING_DISPLAY_DETAILS.has(stored.autoExpandReasoning as ThinkingDisplayDetail)
) {
return stored.autoExpandReasoning as ThinkingDisplayDetail;
}
if (typeof stored.autoExpandReasoning === "boolean") {
return stored.autoExpandReasoning ? "expanded" : "collapsed";
}
}
return null;
}

function parseToolCallDetailLevel(stored: StoredAppSettings): ToolCallDetailLevel | null {
if (stored.toolCallDetailLevel !== undefined) {
if (
Expand Down Expand Up @@ -362,8 +385,9 @@ function pickAppSettings(stored: StoredAppSettings): Partial<AppSettings> {
result.codeFontSize = codeFontSize;
}
Object.assign(result, pickBooleanAppSettings(stored));
if (typeof stored.autoExpandReasoning === "boolean") {
result.autoExpandReasoning = stored.autoExpandReasoning;
const thinkingDisplayDetail = parseThinkingDisplayDetail(stored);
if (thinkingDisplayDetail !== null) {
result.autoExpandReasoning = thinkingDisplayDetail;
}
const toolCallDetailLevel = parseToolCallDetailLevel(stored);
if (toolCallDetailLevel !== null) {
Expand Down
10 changes: 8 additions & 2 deletions packages/app/src/i18n/resources/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1841,8 +1841,14 @@ export const ar: TranslationResources = {
accessibilityLabel: "خطوط التمرير Terminal",
},
autoExpandReasoning: {
label: "عرض التفكير دائماً",
description: "إظهار تفكير الوكيل وخطوات الاستدلال بشكل كامل بشكل افتراضي",
label: "عرض التفكير",
description: "كيفية ظهور كتل التفكير في المخطط الزمني",
accessibilityLabel: "تحديد عرض التفكير ({{value}})",
options: {
collapsed: "مطوي",
expandActive: "توسيع النشط",
expanded: "توسيع دائماً",
},
},
toolCallDetail: {
label: "عرض استدعاءات الأدوات",
Expand Down
10 changes: 8 additions & 2 deletions packages/app/src/i18n/resources/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1851,8 +1851,14 @@ export const en = {
accessibilityLabel: "Terminal scrollback lines",
},
autoExpandReasoning: {
label: "Always expand reasoning",
description: "Show agent thinking and chain-of-thought blocks fully expanded by default",
label: "Thinking display",
description: "How agent thinking and chain-of-thought blocks appear in the timeline",
accessibilityLabel: "Select thinking display ({{value}})",
options: {
collapsed: "Collapsed",
expandActive: "Expand Active",
expanded: "Always expand",
},
},
toolCallDetail: {
label: "Tool call display",
Expand Down
11 changes: 8 additions & 3 deletions packages/app/src/i18n/resources/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1887,9 +1887,14 @@ export const es: TranslationResources = {
accessibilityLabel: "Líneas del historial de terminal",
},
autoExpandReasoning: {
label: "Siempre expandir razonamiento",
description:
"Mostrar los bloques de pensamiento y razonamiento del agente totalmente expandidos de forma predeterminada",
label: "Visualización de pensamiento",
description: "Cómo aparecen los bloques de pensamiento del agente en la cronología",
accessibilityLabel: "Seleccionar visualización de pensamiento ({{value}})",
options: {
collapsed: "Plegado",
expandActive: "Expandir activo",
expanded: "Expandir siempre",
},
},
toolCallDetail: {
label: "Visualización de llamadas a herramientas",
Expand Down
10 changes: 8 additions & 2 deletions packages/app/src/i18n/resources/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1890,8 +1890,14 @@ export const fr: TranslationResources = {
accessibilityLabel: "Lignes de défilementTerminal",
},
autoExpandReasoning: {
label: "Toujours afficher le raisonnement",
description: "Afficher le raisonnement de l'agent entièrement développé par défaut",
label: "Affichage de la réflexion",
description: "Comment les blocs de réflexion apparaissent dans la chronologie",
accessibilityLabel: "Sélectionner l'affichage de la réflexion ({{value}})",
options: {
collapsed: "Réduit",
expandActive: "Développer si actif",
expanded: "Toujours développer",
},
},
toolCallDetail: {
label: "Affichage des appels d’outils",
Expand Down
10 changes: 8 additions & 2 deletions packages/app/src/i18n/resources/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1856,8 +1856,14 @@ export const ja: TranslationResources = {
accessibilityLabel: "ターミナルスクロールバック行数",
},
autoExpandReasoning: {
label: "常に思考プロセスを展開",
description: "デフォルトでAIのエージェント思考・推論ブロックを完全に展開して表示します",
label: "思考プロセスの表示",
description: "タイムラインでの思考ブロックの表示方法",
accessibilityLabel: "思考プロセスの表示を選択 ({{value}})",
options: {
collapsed: "折りたたむ",
expandActive: "実行中のみ展開",
expanded: "常に展開",
},
},
toolCallDetail: {
label: "ツール呼び出しの表示",
Expand Down
10 changes: 8 additions & 2 deletions packages/app/src/i18n/resources/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1852,8 +1852,14 @@ export const ko: TranslationResources = {
accessibilityLabel: "터미널 스크롤백 줄 수",
},
autoExpandReasoning: {
label: "추론 항상 펼치기",
description: "에이전트의 사고 및 추론 블록을 기본적으로 모두 펼쳐 표시합니다.",
label: "사고 과정 표시",
description: "타임라인에 에이전트 사고 블록이 표시되는 방식",
accessibilityLabel: "사고 과정 표시 선택({{value}})",
options: {
collapsed: "접음",
expandActive: "실행 중일 때만 펼치기",
expanded: "항상 펼치기",
},
},
toolCallDetail: {
label: "도구 호출 표시",
Expand Down
11 changes: 8 additions & 3 deletions packages/app/src/i18n/resources/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1871,9 +1871,14 @@ export const ptBR: TranslationResources = {
accessibilityLabel: "Linhas do scrollback do terminal",
},
autoExpandReasoning: {
label: "Sempre expandir raciocínio",
description:
"Mostrar os blocos de pensamento e raciocínio do agente totalmente expandidos por padrão",
label: "Exibição de pensamento",
description: "Como os blocos de pensamento aparecem na linha do tempo",
accessibilityLabel: "Selecionar exibição de pensamento ({{value}})",
options: {
collapsed: "Recolhido",
expandActive: "Expandir ativo",
expanded: "Sempre expandir",
},
},
toolCallDetail: {
label: "Exibição de chamadas de ferramentas",
Expand Down
11 changes: 8 additions & 3 deletions packages/app/src/i18n/resources/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1875,9 +1875,14 @@ export const ru: TranslationResources = {
accessibilityLabel: "Линии прокрутки Terminal",
},
autoExpandReasoning: {
label: "Всегда разворачивать размышления",
description:
"По умолчанию показывать блоки размышлений и логики агента полностью развернутыми",
label: "Отображение мышления",
description: "Как блоки рассуждений агента отображаются в таймлайне",
accessibilityLabel: "Выбор отображения мышления ({{value}})",
options: {
collapsed: "Свернуто",
expandActive: "Разворачивать активный",
expanded: "Всегда разворачивать",
},
},
toolCallDetail: {
label: "Отображение вызовов инструментов",
Expand Down
10 changes: 8 additions & 2 deletions packages/app/src/i18n/resources/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1819,8 +1819,14 @@ export const zhCN: TranslationResources = {
accessibilityLabel: "终端回滚行数",
},
autoExpandReasoning: {
label: "始终展开推理过程",
description: "默认情况下完全展开 AI 的思考和推理过程",
label: "思考过程显示",
description: "智能体思考过程在时间线中的显示方式",
accessibilityLabel: "选择思考过程显示方式({{value}})",
options: {
collapsed: "折叠",
expandActive: "仅展开当前活动",
expanded: "始终展开",
},
},
toolCallDetail: {
label: "工具调用显示",
Expand Down
Loading