Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 apps/web/src/components/chat/MessagesTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function timelineListStateFor(identity: string): {
rememberedPosition,
workGroupViewState: rememberedPosition?.disclosures?.workGroupState ?? {
scrollPositions: new Map(),
expandedEntries: new Set(),
entryExpansion: new Map(),
},
};
}
Expand Down Expand Up @@ -639,6 +639,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
}

const preferredToolCallVisibility = useClientSettings((settings) => settings.toolCallVisibility);
const toolCallDetailsExpanded = useClientSettings((settings) => settings.toolCallDetailsExpanded);
const screenReaderAnnouncements = useClientSettings(
(settings) => settings.screenReaderAnnouncements,
);
Expand Down Expand Up @@ -1140,8 +1141,11 @@ const ConversationTimeline = memo(function ConversationTimeline({
onToggleTurnFold,
onToggleAttemptFold,
onToggleWorkGroup,
onToggleWorkEntry: (anchorKey, collapsed, entryId) =>
preserveDisclosurePosition(anchorKey, collapsed ? undefined : { entryId }),
onToggleWorkEntry: (anchorKey, collapsed, entryId) => {
preserveDisclosurePosition(anchorKey, collapsed ? undefined : { entryId });
// Positions are otherwise remembered on scroll, so a toggle in an unscrolled thread was lost.
rememberPosition(liveFollowEnabled && !anchoredEndSpace);
},
onWorkEntryContentReady: (anchorKey, entryId) => {
const pending = disclosureRevealRef.current;
if (
Expand All @@ -1161,6 +1165,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
onWorktreeSetupWorkLocally: onWorktreeSetupWorkLocally ?? null,
onOpenWorktreeSetupTerminal: onOpenWorktreeSetupTerminal ?? null,
workGroupViewState,
toolCallDetailsExpanded,
};
const compactionAwaitingRow =
isCompacting &&
Expand Down
7 changes: 3 additions & 4 deletions apps/web/src/components/chat/TimelineV2EventRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ const V2SubagentGroup = memo(function V2SubagentGroup({
const gt = useGT();
const m = useMessages();
const groupId = `subagent-group:${row.id}`;
const [expanded, setExpanded] = useState(() =>
ctx.workGroupViewState.expandedEntries.has(groupId),
const [expanded, setExpanded] = useState(
() => ctx.workGroupViewState.entryExpansion.get(groupId) ?? false,
);
const members = (row.subagents ?? [row.projectedItem]).flatMap(({ item }) =>
item.type === "subagent" ? [item] : [],
Expand Down Expand Up @@ -92,8 +92,7 @@ const V2SubagentGroup = memo(function V2SubagentGroup({
);
const toggleExpanded = (open: boolean) => {
ctx.onToggleWorkEntry(row.id, expanded);
if (open) ctx.workGroupViewState.expandedEntries.add(groupId);
else ctx.workGroupViewState.expandedEntries.delete(groupId);
ctx.workGroupViewState.entryExpansion.set(groupId, open);
setExpanded(open);
};
return (
Expand Down
35 changes: 35 additions & 0 deletions apps/web/src/components/chat/TimelineWorkEntryRow.logic.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { describe, expect, it } from "vite-plus/test";

import { workEntryStartsExpanded } from "./TimelineWorkEntryRow.logic";
import type { TimelineWorkEntry } from "./timelineRowContext";

const entry = (fields: Partial<TimelineWorkEntry>): TimelineWorkEntry => ({
id: "entry",
createdAt: "2026-01-01T00:00:00.000Z",
label: "Ran command",
tone: "tool",
...fields,
});

describe("workEntryStartsExpanded", () => {
it.each([
["a command with the setting off", entry({ itemType: "command_execution" }), false, false],
["a command with the setting on", entry({ itemType: "command_execution" }), true, true],
[
"a thought with text",
entry({ itemType: "reasoning", detail: "Plan the change" }),
true,
true,
],
["a thought with no text yet", entry({ itemType: "reasoning", detail: " " }), true, false],
["a viewed image", entry({ viewedImagePath: "/repo/screen.png" }), true, false],
[
"an answered question",
entry({ questionAnswer: { answers: {}, attachmentsByQuestionId: {} } as never }),
true,
false,
],
])("%s", (_name, workEntry, expandedByDefault, expected) => {
expect(workEntryStartsExpanded(workEntry, expandedByDefault)).toBe(expected);
});
});
12 changes: 12 additions & 0 deletions apps/web/src/components/chat/TimelineWorkEntryRow.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Root, RootContent } from "mdast";
import {
resolveWorkEntryToolPresentation,
toolGroupAction,
workEntryViewedImagePath,
} from "@t3tools/client-runtime/work-log/presentation";
import { isJavaScriptReplTool } from "@t3tools/shared/toolActivity";
import { formatWorkspaceRelativePath } from "../../filePathDisplay";
Expand Down Expand Up @@ -92,6 +93,17 @@ export function workEntryRawCommand(
return rawCommand === workEntry.command.trim() ? null : rawCommand;
}

/** Whether a row the user has not opened or closed starts open. */
export function workEntryStartsExpanded(
workEntry: TimelineWorkEntry,
expandedByDefault: boolean,
): boolean {
if (!expandedByDefault || workEntry.questionAnswer) return false;
// Viewed images already show in the group's strip; a thought has nothing to show until it has text.
if (workEntryViewedImagePath(workEntry) !== null) return false;
return workEntry.itemType !== "reasoning" || /\S/.test(workEntry.detail ?? "");
}

export function buildToolCallExpandedBody(
workEntry: TimelineWorkEntry,
workspaceRoot: string | undefined,
Expand Down
19 changes: 8 additions & 11 deletions apps/web/src/components/chat/TimelineWorkEntryRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import {
import {
workToneIcon,
workEntryRawCommand,
workEntryStartsExpanded,
buildToolCallExpandedBody,
workEntryIconName,
thoughtPreviewPlugins,
Expand Down Expand Up @@ -295,23 +296,19 @@ function WorkEntryLogRow(props: WorkEntryRowProps) {
? notificationChildThreadId(workEntry.projectedItem.item.source)
: undefined;
const groupView = use(WorkGroupViewCtx);
const [expanded, setExpanded] = useState(
() => groupView?.state.expandedEntries.has(workEntry.id) ?? false,
);
const { entryExpansion } = ctx.workGroupViewState;
const [userExpanded, setUserExpanded] = useState(() => entryExpansion.get(workEntry.id));
const expanded = userExpanded ?? workEntryStartsExpanded(workEntry, ctx.toolCallDetailsExpanded);
const onInitialOutputReady = () => {
if (groupView) groupView.onContentReady?.(workEntry.id);
else props.onContentReady?.();
};
const toggleExpanded = () => {
const next = !expanded;
if (groupView) {
groupView.onToggleEntry(!next, workEntry.id);
if (next) groupView.state.expandedEntries.add(workEntry.id);
else groupView.state.expandedEntries.delete(workEntry.id);
} else {
props.onToggleEntry?.(!next);
}
setExpanded(next);
if (groupView) groupView.onToggleEntry(!next, workEntry.id);
else props.onToggleEntry?.(!next);
entryExpansion.set(workEntry.id, next);
setUserExpanded(next);
};
const failureItem = workEntry.projectedItem?.item;
const pendingApproval =
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/chat/TimelineWorkGroupRows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ function ExpandedWorkGroupEntries({

const viewedImages = useWorkGroupViewedImages(groupedEntries);
const groupView = {
state: viewState,
viewedImages,
onToggleEntry: (collapsed: boolean, entryId: string) =>
onToggleWorkEntry(disclosureAnchorKey, collapsed, entryId),
Expand Down Expand Up @@ -291,8 +290,9 @@ function ExpandedWorkGroupEntries({
const updateExpandedContentHeight = () => {
const state = listRef.current?.getState();
let height = 0;
for (const entryId of viewState.expandedEntries) {
if (state?.indexByKey(entryId) === undefined) continue;
// Only rows the user opened grow the panel; rows open by default scroll inside its cap.
for (const [entryId, open] of viewState.entryExpansion) {
if (!open || state?.indexByKey(entryId) === undefined) continue;
height += Math.max(
0,
(state.sizes.get(entryId) ?? compactWorkEntryHeight) - compactWorkEntryHeight,
Expand Down
5 changes: 3 additions & 2 deletions apps/web/src/components/chat/timelineRowContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export interface TimelineRowSharedState {
onWorktreeSetupWorkLocally: (() => void) | null;
onOpenWorktreeSetupTerminal: ((terminalId: string) => void) | null;
workGroupViewState: WorkGroupViewState;
toolCallDetailsExpanded: boolean;
}

export interface TimelineRowActivityState {
Expand All @@ -124,7 +125,8 @@ export const TimelineRowActivityCtx = createContext<TimelineRowActivityState>(nu

export interface WorkGroupViewState {
scrollPositions: Map<string, WorkGroupScrollAnchor>;
expandedEntries: Set<string>;
/** Rows the user opened or closed; the rest follow the expanded-by-default setting. */
entryExpansion: Map<string, boolean>;
}

/** One image the group's agent viewed; `item` is null until its URL resolves. */
Expand All @@ -134,7 +136,6 @@ export interface WorkGroupViewedImage {
}

export const WorkGroupViewCtx = createContext<{
state: WorkGroupViewState;
viewedImages: ReadonlyArray<WorkGroupViewedImage>;
onToggleEntry: (collapsed: boolean, entryId: string) => void;
onContentReady?: ((entryId: string) => void) | undefined;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/chat/timelineScrollAnchoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export interface RememberedTimelinePosition {
readonly attempts: ReadonlySet<RunAttemptId>;
readonly workGroupState: {
scrollPositions: Map<string, { readonly entryId: string; readonly offset: number }>;
expandedEntries: Set<string>;
entryExpansion: Map<string, boolean>;
};
};
}
Expand Down
63 changes: 63 additions & 0 deletions apps/web/src/components/settings/SettingsPanels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@ export function useSettingsRestore(onRestored?: () => void) {
...(settings.toolCallVisibility !== DEFAULT_UNIFIED_SETTINGS.toolCallVisibility
? [gt("Tool calls in chat")]
: []),
...(settings.toolCallDetailsExpanded !== DEFAULT_UNIFIED_SETTINGS.toolCallDetailsExpanded
? [gt("Tool call details")]
: []),
...(settings.screenReaderAnnouncements !== DEFAULT_UNIFIED_SETTINGS.screenReaderAnnouncements
? [gt("Screen reader announcements")]
: []),
Expand Down Expand Up @@ -711,6 +714,7 @@ export function useSettingsRestore(onRestored?: () => void) {
sendShortcut: DEFAULT_UNIFIED_SETTINGS.sendShortcut,
followUpBehavior: DEFAULT_UNIFIED_SETTINGS.followUpBehavior,
toolCallVisibility: DEFAULT_UNIFIED_SETTINGS.toolCallVisibility,
toolCallDetailsExpanded: DEFAULT_UNIFIED_SETTINGS.toolCallDetailsExpanded,
screenReaderAnnouncements: DEFAULT_UNIFIED_SETTINGS.screenReaderAnnouncements,
screenReaderWindowTitle: DEFAULT_UNIFIED_SETTINGS.screenReaderWindowTitle,
environmentIdentificationMode: DEFAULT_UNIFIED_SETTINGS.environmentIdentificationMode,
Expand Down Expand Up @@ -1395,6 +1399,7 @@ export function ChatSettingsPanel() {

<SettingsSection id="activity" title={gt("Activity")}>
<ToolCallVisibilityRow />
<ToolCallDetailsRow />
</SettingsSection>

<SettingsSection id="screen-reader" title={gt("Screen reader")}>
Expand Down Expand Up @@ -1461,6 +1466,64 @@ function ToolCallVisibilityRow() {
);
}

const TOOL_CALL_DETAILS_LABELS = {
collapsed: msg("Collapsed", { $context: "tool call details start closed" }),
expanded: msg("Expanded", { $context: "tool call details start open" }),
} as const;

function ToolCallDetailsRow() {
const messages = useMessages();
const setting = useSearchableSetting();
const gt = useGT();
const settings = useScopedSettings();
const updateSettings = useUpdateScopedSettings();
const selected = settings.toolCallDetailsExpanded ? "expanded" : "collapsed";
return (
<SettingsRow
{...setting("tool-call-details")}
description={gt(
"Start tool calls and thoughts in chat open or closed. A row you open or close keeps that until you reload.",
)}
resetAction={
settings.toolCallDetailsExpanded !== DEFAULT_UNIFIED_SETTINGS.toolCallDetailsExpanded ? (
<SettingResetButton
ariaLabel={gt("Reset tool call details to default")}
onClick={() =>
updateSettings({
toolCallDetailsExpanded: DEFAULT_UNIFIED_SETTINGS.toolCallDetailsExpanded,
})
}
/>
) : null
}
control={
<div className="w-full sm:w-40">
<Select
value={selected}
onValueChange={(value) => {
if (value === "expanded" || value === "collapsed") {
updateSettings({ toolCallDetailsExpanded: value === "expanded" });
}
}}
>
<SelectTrigger size="sm" aria-label={gt("Tool call details")}>
<SelectValue>{messages(TOOL_CALL_DETAILS_LABELS[selected])}</SelectValue>
</SelectTrigger>
<SelectPopup align="end" alignItemWithTrigger={false}>
<SelectItem hideIndicator value="collapsed">
{messages(TOOL_CALL_DETAILS_LABELS.collapsed)}
</SelectItem>
<SelectItem hideIndicator value="expanded">
{messages(TOOL_CALL_DETAILS_LABELS.expanded)}
</SelectItem>
</SelectPopup>
</Select>
</div>
}
/>
);
}

const SCREEN_READER_ANNOUNCEMENTS_LABELS: Record<ScreenReaderAnnouncements, string> = {
status: msg("Status only"),
messages: msg("Status and messages"),
Expand Down
10 changes: 10 additions & 0 deletions apps/web/src/components/settings/settingsSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,16 @@ export const SETTINGS_SEARCH_ITEMS = [
),
],
},
{
id: "tool-call-details",
title: msg("Tool call details"),
to: "/settings/chat",
searchTerms: [
msg(
"expand collapse open closed tool calls commands output thoughts reasoning details by default work log activity",
),
],
},
{
id: "screen-reader-announcements",
title: msg("Screen reader announcements"),
Expand Down
6 changes: 6 additions & 0 deletions apps/web/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -9748,6 +9748,8 @@
"9d6cc6ac23312071": "Doppelt drücken",
"f001fa7b329c8fbf": "Erfolgreiche ausblenden",
"c80e4bb3201efd71": "Zen",
"1c576b2a683debb4": "Eingeklappt",
"d841feab2cabf7bd": "Ausgeklappt",
"0cb9ffcd1fb46b0c": "Nur Status",
"cf0f7fc3df26fa75": "Status und Nachrichten",
"3bf40445a706e4c9": "Alles",
Expand Down Expand Up @@ -9796,6 +9798,7 @@
"64b8fd2c284c3137": "Tastenkürzel zum Senden",
"6163f91bddf474ae": "Verhalten bei Folgenachrichten",
"856812e7e1fc445e": "Tool-Aufrufe im Chat",
"24aacf0d9565868b": "Details zu Tool-Aufrufen",
"216ed20b6f40fa6f": "Screenreader-Ansagen",
"0ce04933a7047deb": "Fenstertitel für Screenreader",
"3426d304db392999": "Antwort-Streaming",
Expand Down Expand Up @@ -9855,6 +9858,8 @@
"162108e16ed96771": "Screenreader",
"18807e775248380c": "Die Befehle, Bearbeitungen und Suchen ausblenden, die Agenten ausführen. „Erfolgreiche ausblenden“ behält Fehler. „Zen“ zeigt nur endgültige Antworten. Genehmigungen, Fragen und Fehler werden immer angezeigt.",
"5848a9c1d77f45b2": "Tool-Aufrufe im Chat auf Standard zurücksetzen",
"b058c6e02ab86c77": "Tool-Aufrufe und Gedanken im Chat geöffnet oder geschlossen anzeigen. Eine Zeile, die du öffnest oder schließt, bleibt so, bis du neu lädst.",
"5c032f58bf30a141": "Details zu Tool-Aufrufen auf Standard zurücksetzen",
"8cf1b5b0cc0dc218": "Was ein Screenreader vom geöffneten Thread hört: wenn eine Runde beginnt, dich braucht und endet. „Status und Nachrichten“ ergänzt, was der Agent vor seiner letzten Nachricht schreibt. „Alles“ ergänzt jeden Schritt.",
"cffe3d745e6c9e34": "Screenreader-Ansagen auf Standard zurücksetzen",
"45d544caaabd1a31": "Den Fenstertitel mit dem Status des Threads, etwa „Genehmigung erforderlich“, und seinem Namen beginnen, damit Screenreader sie beim App-Wechsel zuerst vorlesen. Taskleisten, geteilte Bildschirme und Zeiterfassungen sehen ihn auch.",
Expand Down Expand Up @@ -11520,6 +11525,7 @@
"405a2295152c9d77": "beta ordner projektbaum klassische seitenleiste",
"de42c4690914cee4": "beta schlichte seitenleiste ordner zeilen mehrzeilig branch pull request details",
"8f71bc7c325e23e3": "tool-aufrufe ausblenden befehle bearbeitungen suchen arbeitsprotokoll aktivität ruhiger chat zen nur endgültige antworten",
"5658e33eb5df1d59": "aufklappen einklappen öffnen geschlossen tool-aufrufe befehle ausgabe gedanken denken details standard arbeitsprotokoll aktivität",
"5a3af411a0d5354c": "barrierefreiheit a11y screenreader nvda jaws voiceover orca sprachausgabe ansagen vorlesen nachrichten aktivität schritte",
"d443390c4d2dcfd4": "barrierefreiheit a11y screenreader nvda jaws voiceover orca sprachausgabe fenstertitel tab-titel alt tab taskleiste thread status reihenfolge arbeitet genehmigung",
"6826fa9579c22035": "beta teilen gast einladen link teammitglied zuschauen t3 connect tunnel",
Expand Down
6 changes: 6 additions & 0 deletions apps/web/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9757,6 +9757,8 @@
"9d6cc6ac23312071": "Double press",
"f001fa7b329c8fbf": "Hide successful",
"c80e4bb3201efd71": "Zen",
"1c576b2a683debb4": "Collapsed",
"d841feab2cabf7bd": "Expanded",
"0cb9ffcd1fb46b0c": "Status only",
"cf0f7fc3df26fa75": "Status and messages",
"3bf40445a706e4c9": "Everything",
Expand Down Expand Up @@ -9805,6 +9807,7 @@
"64b8fd2c284c3137": "Send shortcut",
"6163f91bddf474ae": "Follow-up behavior",
"856812e7e1fc445e": "Tool calls in chat",
"24aacf0d9565868b": "Tool call details",
"216ed20b6f40fa6f": "Screen reader announcements",
"0ce04933a7047deb": "Screen reader window title",
"3426d304db392999": "Response streaming",
Expand Down Expand Up @@ -9864,6 +9867,8 @@
"162108e16ed96771": "Screen reader",
"18807e775248380c": "Hide the commands, edits, and searches agents run. Hide successful keeps failures. Zen shows only final answers. Approvals, questions, and errors always show.",
"5848a9c1d77f45b2": "Reset tool calls in chat to default",
"b058c6e02ab86c77": "Start tool calls and thoughts in chat open or closed. A row you open or close keeps that until you reload.",
"5c032f58bf30a141": "Reset tool call details to default",
"8cf1b5b0cc0dc218": "What a screen reader hears from the open thread: a turn starting, needing you, and ending. Status and messages adds what the agent writes before its last message. Everything adds each step.",
"cffe3d745e6c9e34": "Reset screen reader announcements to default",
"45d544caaabd1a31": "Start the window title with the thread's status, like Needs approval, and its name, so screen readers read them first when you switch apps. Taskbars, shared screens, and time trackers see it too.",
Expand Down Expand Up @@ -11528,6 +11533,7 @@
"405a2295152c9d77": "beta folders project tree classic sidebar",
"de42c4690914cee4": "beta boring sidebar folder rows multiline branch pull request details",
"8f71bc7c325e23e3": "hide tool calls commands edits searches work log activity quiet chat zen final answers only",
"5658e33eb5df1d59": "expand collapse open closed tool calls commands output thoughts reasoning details by default work log activity",
"5a3af411a0d5354c": "accessibility a11y screen reader nvda jaws voiceover orca narrator speech announce read aloud messages activity steps",
"d443390c4d2dcfd4": "accessibility a11y screen reader nvda jaws voiceover orca narrator window title tab title alt tab taskbar thread status order working approval",
"6826fa9579c22035": "beta share guest invite link teammate watch t3 connect tunnel",
Expand Down
Loading
Loading