feat(web): a Labs setting hides tool calls so threads read like a chat #30000
Mergedflamboh(GitHub profile, opens in a new tab)merged 17 commits into
main fromrefs/pull/30000/headmerged by maria-rcks View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/components/settings/LabsSettingsPanel.tsx line 103Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -74,0 +82,21 @@82+ hideAll: "Hide all",83+};84+85+const isToolCallVisibility = Schema.is(ToolCallVisibility);86+87+function ToolCallVisibilityRow() {88+ const settings = useScopedSettings();89+ const updateSettings = useUpdateScopedSettings();90+ return (91+ <SettingsRow92+ {...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+ control={95+ <div className="w-full sm:w-40">96+ <Select97+ value={settings.toolCallVisibility}98+ onValueChange={(value) => {99+ if (isToolCallVisibility(value)) updateSettings({ toolCallVisibility: value });100+ }}101+ >102+ <SelectTrigger size="sm" className="w-full min-w-0" aria-label="Tool calls in chat">
- apps/web/src/components/chat/MessagesTimeline.logic.ts line 1394OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1365,0 +1374,21 @@1374+ if (entry.kind !== "work" || !HIDEABLE_TOOL_CALL_ITEM_TYPES.has(entry.entry.itemType)) {1375+ return false;1376+ }1377+ if (visibility === "hideAll") return true;1378+ return (1379+ visibility === "hideSuccessful" &&1380+ entry.entry.toolLifecycleStatus === "completed" &&1381+ !workEntryDisplayIndicatesToolFailure(entry.entry)1382+ );1383+}1384+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) &&apps/web/src/components/chat/MessagesTimeline.logic.ts line 1522Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1407,5 +1485,6 @@14071485 threadStartCheckpointReady?: boolean;14081486 availableRevertTurnCounts?: ReadonlySet<number> | undefined;14091487 worktreeSetup?: WorktreeSetupSnapshot | null;1488+ toolCallVisibility?: ToolCallVisibility;14101489 }): MessagesTimelineRow[] {1411- const timelineEntries = timelineRowEntries(input.timelineEntries);1490+ const timelineEntries = timelineRowEntries(input);apps/web/src/components/chat/MessagesTimeline.logic.ts lines 1408 to 1408OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1365,0 +1388,21 @@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")
- apps/web/src/components/chat/MessagesTimeline.logic.ts lines 1394 to 1395OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1365,0 +1375,21 @@1375+ return false;1376+ }1377+ if (visibility === "hideAll") return true;1378+ return (1379+ visibility === "hideSuccessful" &&1380+ entry.entry.toolLifecycleStatus === "completed" &&1381+ !workEntryDisplayIndicatesToolFailure(entry.entry)1382+ );1383+}1384+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))apps/web/src/components/chat/MessagesTimeline.logic.ts line 1408OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1365,0 +1388,21 @@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")
- apps/web/src/components/chat/MessagesTimeline.logic.ts lines 1406 to 1406OutdatedResolvedby flamboh(GitHub profile, opens in a new tab)@@ -1365,0 +1386,21 @@1386+function workShownAsFinalAnswerOnly(1387+ entry: TimelineEntry,1388+ pendingApprovalRequestIds: ReadonlySet<RuntimeRequestId> | undefined,1389+): boolean {1390+ if (entry.kind === "event") return entry.projectedItem.item.type !== "subagent";1391+ if (entry.kind !== "work") return true;1392+ const work = entry.entry;1393+ const item = work.projectedItem?.item;1394+ return (1395+ (item?.type === "approval_request" &&1396+ pendingApprovalRequestIds?.has(item.requestId) === true) ||1397+ work.questionAnswer !== undefined ||1398+ timelineEntryIsCompaction(entry) ||1399+ work.tone === "error" ||1400+ work.sourceActivityKind === "runtime.error" ||1401+ (work.itemType === "error" && work.toolLifecycleStatus !== "completed")1402+ );1403+}1404+1405+export function liveAnswerPreview(entries: ReadonlyArray<TimelineEntry>): string | null {1406+ for (let index = entries.length - 1; index > lastResponseBoundaryIndex(entries); index -= 1) {
- apps/web/src/components/chat/MessagesTimeline.logic.ts line 1449Resolvedby flamboh(GitHub profile, opens in a new tab)@@ -1365,0 +1408,21 @@1408+ | "toolCallVisibility"1409+ | "revealedMessageId"1410+ | "isWorking"1411+ | "latestRun"1412+ | "runningRunId"1413+ | "pendingApprovalRequestIds"1414+ >,1415+) {1416+ const visibility = input.toolCallVisibility ?? "showAll";1417+ const entries = input.timelineEntries;1418+ let shown = entries;1419+ if (visibility === "finalAnswersOnly") {1420+ const answering = input.isWorking && input.latestRun?.turnEnded !== true;1421+ const answeringRunId = answering1422+ ? deriveUnsettledRunId(input.latestRun ?? null, input.runningRunId ?? null)1423+ : null;1424+ const answeringFrom = answering ? lastResponseBoundaryIndex(entries) + 1 : entries.length;1425+ const terminalIds = deriveTerminalAssistantMessageIds(entries);1426+ shown = entries.filter((entry, index) => {1427+ if (entry.kind !== "message") {1428+ return workShownAsFinalAnswerOnly(entry, input.pendingApprovalRequestIds);
- apps/web/src/components/chat/MessagesTimeline.logic.ts line 1757OutdatedResolvedby flamboh(GitHub profile, opens in a new tab)@@ -1652,3 +1754,4 @@16521754 : (resumeCompactionEntry?.entry.runId ?? null);16531755 const appendWorkingRow = () => {16541756 if (compactionOnlyRunFinished) return;1757+ if (input.toolCallVisibility === "finalAnswersOnly" && input.latestRun?.turnEnded === true) {
- apps/web/src/components/chat/MessagesTimeline.logic.ts line 1439Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1365,0 +1417,21 @@1417+ if (line !== "") return line;1418+ }1419+ return null;1420+}1421+1422+function timelineRowEntries(1423+ input: Pick<1424+ MessagesTimelineRowsInput,1425+ | "timelineEntries"1426+ | "toolCallVisibility"1427+ | "revealedMessageId"1428+ | "isWorking"1429+ | "latestRun"1430+ | "runningRunId"1431+ | "pendingApprovalRequestIds"1432+ >,1433+) {1434+ const visibility = input.toolCallVisibility ?? "showAll";1435+ const entries = input.timelineEntries;1436+ let shown = entries;1437+ if (visibility === "zen") {
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/mobile/src/lib/threadActivity.ts lines 1453 to 1455OutdatedResolvedby flamboh(GitHub profile, opens in a new tab)@@ -1349,0 +1435,21 @@1435+ if (answering && startsResponse(entry)) answeringFrom = index + 1;1436+ if (entry.type === "message" && entry.message.role === "user") {1437+ userMessages += 1;1438+ awaitingReply = isSteerMessage(entry.message);1439+ } else if (reply !== null) {1440+ replies.push({ message: reply, index });1441+ lastReplyByResponse.set(reply.runId ?? `runless:${userMessages}`, reply.id);1442+ if (awaitingReply) {1443+ candidate = reply.id;1444+ awaitingReply = false;1445+ }1446+ }1447+ }1448+ const terminal = new Set(lastReplyByResponse.values());1449+ return new Set(1450+ replies1451+ .filter(1452+ ({ message, index }) =>1453+ (terminal.has(message.id) || steerAnswers.has(message.id)) &&1454+ index < answeringFrom &&1455+ (answeringRunId === null || message.runId !== answeringRunId),apps/web/src/components/chat/MessagesTimeline.logic.ts line 1455OutdatedResolvedby flamboh(GitHub profile, opens in a new tab)@@ -1365,0 +1435,21 @@1435+) {1436+ const visibility = input.toolCallVisibility ?? "showAll";1437+ const entries = input.timelineEntries;1438+ let shown = entries;1439+ if (visibility === "zen") {1440+ const answering = input.isWorking && input.latestRun?.turnEnded !== true;1441+ const answeringRunId = answering1442+ ? deriveUnsettledRunId(input.latestRun ?? null, input.runningRunId ?? null)1443+ : null;1444+ const answeringFrom = answering ? lastResponseBoundaryIndex(entries) + 1 : entries.length;1445+ const terminalIds = deriveTerminalAssistantMessageIds(entries);1446+ const steerAnswerIds = deriveInFlightSteerAnswerIds(entries);1447+ shown = entries.filter((entry, index) => {1448+ if (entry.kind !== "message") {1449+ return workShownAsFinalAnswerOnly(entry, input.pendingApprovalRequestIds);1450+ }1451+ const { message } = entry;1452+ return (1453+ message.role !== "assistant" ||1454+ message.id === input.revealedMessageId ||1455+ ((terminalIds.has(message.id) || steerAnswerIds.has(message.id)) &&
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
maria-rcks merged this3d78e91
maria-rcks closed this
Sign in to join this conversation.





























macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed