Skip to content

Commit 28e4da8

Browse files
committed
feat(web): Final answers only mode shows each turn's last reply
1 parent 623009f commit 28e4da8

7 files changed

Lines changed: 88 additions & 15 deletions

File tree

‎apps/web/src/components/chat/MessagesTimeline.logic.test.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2734,7 +2734,7 @@ describe("v2 run and attempt history", () => {
27342734
const final = message("final", "assistant", "2026-01-01T00:00:20Z");
27352735
const rowIds = (
27362736
timelineEntries: ReadonlyArray<TimelineEntry>,
2737-
toolCallVisibility: "hideSuccessful" | "hideAll",
2737+
toolCallVisibility: "hideSuccessful" | "hideAll" | "finalAnswersOnly",
27382738
) =>
27392739
deriveMessagesTimelineRows({
27402740
timelineEntries,
@@ -2752,6 +2752,19 @@ describe("v2 run and attempt history", () => {
27522752
"final-entry",
27532753
]);
27542754
expect(rowIds([user, failed, final], "hideAll")).toEqual(["user-entry", "final-entry"]);
2755+
expect(rowIds([user, commentary, passed, failed, final], "finalAnswersOnly")).toEqual([
2756+
"user-entry",
2757+
"final-entry",
2758+
]);
2759+
const answering = deriveMessagesTimelineRows({
2760+
timelineEntries: [user, commentary, passed],
2761+
latestRun: { runId, status: "running", startedAt: user.createdAt, completedAt: null },
2762+
isWorking: true,
2763+
turnDiffSummaries: [],
2764+
supportsConversationRollback: false,
2765+
toolCallVisibility: "finalAnswersOnly",
2766+
});
2767+
expect(answering.map((row) => row.kind)).toEqual(["message", "working", "thinking"]);
27552768

27562769
const steer = message("steer", "user", "2026-01-01T00:00:10Z", "steer");
27572770
const steeredCommentary = message("commentary", "assistant", "2026-01-01T00:00:12Z");

‎apps/web/src/components/chat/MessagesTimeline.logic.ts‎

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,14 +1382,59 @@ function toolCallIsHidden(entry: TimelineEntry, visibility: ToolCallVisibility):
13821382
);
13831383
}
13841384

1385+
function shownAsFinalAnswerOnly(
1386+
entry: TimelineEntry,
1387+
terminalAssistantMessageIds: ReadonlySet<string>,
1388+
answeringRunId: RunId | null,
1389+
pendingApprovalRequestIds: ReadonlySet<RuntimeRequestId> | undefined,
1390+
): boolean {
1391+
if (entry.kind === "message") {
1392+
return (
1393+
entry.message.role !== "assistant" ||
1394+
(terminalAssistantMessageIds.has(entry.message.id) &&
1395+
(answeringRunId === null || entry.message.runId !== answeringRunId))
1396+
);
1397+
}
1398+
if (entry.kind === "event") return entry.projectedItem.item.type !== "subagent";
1399+
if (entry.kind !== "work") return true;
1400+
const work = entry.entry;
1401+
const item = work.projectedItem?.item;
1402+
return (
1403+
(item?.type === "approval_request" &&
1404+
pendingApprovalRequestIds?.has(item.requestId) === true) ||
1405+
work.questionAnswer !== undefined ||
1406+
work.tone === "error" ||
1407+
work.sourceActivityKind === "runtime.error" ||
1408+
(work.itemType === "error" && work.toolLifecycleStatus === "failed")
1409+
);
1410+
}
1411+
13851412
function timelineRowEntries(
1386-
entries: ReadonlyArray<TimelineEntry>,
1387-
toolCallVisibility: ToolCallVisibility = "showAll",
1413+
input: Pick<
1414+
MessagesTimelineRowsInput,
1415+
| "timelineEntries"
1416+
| "toolCallVisibility"
1417+
| "isWorking"
1418+
| "latestRun"
1419+
| "runningRunId"
1420+
| "pendingApprovalRequestIds"
1421+
>,
13881422
) {
1389-
const shown =
1390-
toolCallVisibility === "showAll"
1391-
? entries
1392-
: entries.filter((entry) => !toolCallIsHidden(entry, toolCallVisibility));
1423+
const visibility = input.toolCallVisibility ?? "showAll";
1424+
const entries = input.timelineEntries;
1425+
let shown = entries;
1426+
if (visibility === "finalAnswersOnly") {
1427+
const answeringRunId =
1428+
input.isWorking && input.latestRun?.turnEnded !== true
1429+
? deriveUnsettledRunId(input.latestRun ?? null, input.runningRunId ?? null)
1430+
: null;
1431+
const terminalIds = deriveTerminalAssistantMessageIds(entries);
1432+
shown = entries.filter((entry) =>
1433+
shownAsFinalAnswerOnly(entry, terminalIds, answeringRunId, input.pendingApprovalRequestIds),
1434+
);
1435+
} else if (visibility !== "showAll") {
1436+
shown = entries.filter((entry) => !toolCallIsHidden(entry, visibility));
1437+
}
13931438
return withoutSubagentDelegationRows(settleSupersededReasoning(shown));
13941439
}
13951440

@@ -1404,7 +1449,7 @@ function deriveTimelineTurnFolds(
14041449
| "toolCallVisibility"
14051450
>,
14061451
) {
1407-
const timelineEntries = timelineRowEntries(input.timelineEntries, input.toolCallVisibility);
1452+
const timelineEntries = timelineRowEntries(input);
14081453
const unsettledRunId = deriveUnsettledRunId(input.latestRun ?? null, input.runningRunId ?? null);
14091454
const failedRunIds = failedTimelineRunIds(timelineEntries, input.latestRun ?? null);
14101455
const activeVisualResponseRunIds = deriveActiveVisualResponseRunIds({
@@ -1442,7 +1487,7 @@ export function deriveMessagesTimelineRows(input: {
14421487
worktreeSetup?: WorktreeSetupSnapshot | null;
14431488
toolCallVisibility?: ToolCallVisibility;
14441489
}): MessagesTimelineRow[] {
1445-
const timelineEntries = timelineRowEntries(input.timelineEntries, input.toolCallVisibility);
1490+
const timelineEntries = timelineRowEntries(input);
14461491
const isPendingApproval = (entry: WorkLogEntry) => {
14471492
const item = entry.projectedItem?.item;
14481493
return (

‎apps/web/src/components/chat/MessagesTimeline.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,11 @@ const ConversationTimeline = memo(function ConversationTimeline({
573573
}
574574
}
575575

576-
const toolCallVisibility = useClientSettings((settings) => settings.toolCallVisibility);
576+
const preferredToolCallVisibility = useClientSettings((settings) => settings.toolCallVisibility);
577+
const toolCallVisibility =
578+
findActive && preferredToolCallVisibility === "finalAnswersOnly"
579+
? "hideAll"
580+
: preferredToolCallVisibility;
577581
// Imported turns and post-steer work fold under synthetic keys, not the entries' run ids.
578582
const findFoldRunIds = findActive
579583
? timelineTurnFoldRunIdsByEntryId({

‎apps/web/src/components/settings/LabsSettingsPanel.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ const TOOL_CALL_VISIBILITY_LABELS: Record<ToolCallVisibility, string> = {
8080
showAll: "Show all",
8181
hideSuccessful: "Hide successful",
8282
hideAll: "Hide all",
83+
finalAnswersOnly: "Final answers only",
8384
};
8485

8586
const isToolCallVisibility = Schema.is(ToolCallVisibility);
@@ -90,7 +91,7 @@ function ToolCallVisibilityRow() {
9091
return (
9192
<SettingsRow
9293
{...searchableSetting("tool-call-visibility")}
93-
description="Hide the commands, edits, and searches agents run, so a thread reads like a conversation. Hide successful keeps calls that fail. Approvals and questions always show."
94+
description="Hide the commands, edits, and searches agents run, so a thread reads like a conversation. Hide successful keeps calls that fail. Final answers only also hides the agent's in-between messages. Approvals, questions, and errors always show."
9495
control={
9596
<div className="w-full sm:w-40">
9697
<Select
@@ -106,6 +107,7 @@ function ToolCallVisibilityRow() {
106107
<SelectItem value="showAll">Show all</SelectItem>
107108
<SelectItem value="hideSuccessful">Hide successful</SelectItem>
108109
<SelectItem value="hideAll">Hide all</SelectItem>
110+
<SelectItem value="finalAnswersOnly">Final answers only</SelectItem>
109111
</SelectPopup>
110112
</Select>
111113
</div>

‎apps/web/src/components/settings/settingsSearch.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,9 @@ export const SETTINGS_SEARCH_ITEMS = [
469469
id: "tool-call-visibility",
470470
title: "Tool calls in chat",
471471
to: "/settings/labs",
472-
searchTerms: ["beta hide tool calls commands edits searches work log activity quiet chat"],
472+
searchTerms: [
473+
"beta hide tool calls commands edits searches work log activity quiet chat zen final answers only",
474+
],
473475
},
474476
{
475477
id: "guest-links",

‎docs/user/activity-log.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ were affected.
2323
On web and desktop, **Settings → Labs → Tool calls in chat** hides commands, file edits, searches,
2424
and MCP tool calls from the conversation. **Hide successful** shows a call while it runs and keeps
2525
it only if it fails. **Hide all** hides every call and shows **Thinking** while the agent works.
26-
Approvals, questions, errors, and the agent's messages always show. The setting applies to this
27-
browser or app only.
26+
**Final answers only** also hides the agent's in-between messages, so each turn shows your message
27+
and the agent's last reply, which appears when the turn ends. Find shows the in-between messages
28+
while it is open. Approvals, questions, and errors always show. The setting applies to this browser
29+
or app only.

‎packages/contracts/src/settings.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,12 @@ export type ChatWidth = typeof ChatWidth.Type;
332332
export const EffortDisplay = Schema.Literals(["label", "bars"]);
333333
export type EffortDisplay = typeof EffortDisplay.Type;
334334

335-
export const ToolCallVisibility = Schema.Literals(["showAll", "hideSuccessful", "hideAll"]);
335+
export const ToolCallVisibility = Schema.Literals([
336+
"showAll",
337+
"hideSuccessful",
338+
"hideAll",
339+
"finalAnswersOnly",
340+
]);
336341
export type ToolCallVisibility = typeof ToolCallVisibility.Type;
337342

338343
export const ModelFavorite = Schema.Struct({

0 commit comments

Comments
 (0)