Skip to content

Commit 3c78a5b

Browse files
committed
Merge remote-tracking branch 'origin/main' into t3code/pi-status-attached-recovery
2 parents da72b2c + 3d78e91 commit 3c78a5b

19 files changed

Lines changed: 753 additions & 43 deletions

‎apps/mobile/src/features/settings/ThreadSettingsSections.tsx‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import { serverEnvironment } from "../../state/server";
2121
import { useAtomCommand } from "../../state/use-atom-command";
2222
import { SettingsSection } from "./components/SettingsSection";
2323
import { SettingsSwitchRow } from "./components/SettingsSwitchRow";
24+
import { ListChoiceRow } from "../../components/ui/ListChoiceRow";
25+
import type { ToolCallVisibility } from "@t3tools/contracts/settings";
2426
import { SettingsScreen } from "./components/SettingsScreen";
2527
import { planAutoSettleSettingsSync, type AutoSettleSettings } from "./autoSettleSettingsSync";
2628
import { useSettingsEnvironmentFilter } from "./settings-environment-filter";
@@ -42,6 +44,7 @@ export function SettingsLabsRouteScreen() {
4244
contentContainerClassName="gap-6 px-5 pt-4"
4345
contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
4446
>
47+
<ToolCallVisibilitySection />
4548
<BetaSettingsSection />
4649
<LegacySettingsSection />
4750
</ScrollView>
@@ -271,6 +274,46 @@ function BetaSettingsSection() {
271274
);
272275
}
273276

277+
const TOOL_CALL_VISIBILITY_OPTIONS: ReadonlyArray<{
278+
readonly value: ToolCallVisibility;
279+
readonly label: string;
280+
}> = [
281+
{ value: "showAll", label: "Show all" },
282+
{ value: "hideSuccessful", label: "Hide successful" },
283+
{ value: "hideAll", label: "Hide all" },
284+
{ value: "zen", label: "Zen" },
285+
];
286+
287+
function ToolCallVisibilitySection() {
288+
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
289+
const preferences = useAtomValue(mobilePreferencesAtom);
290+
const selected = AsyncResult.isSuccess(preferences)
291+
? (preferences.value.toolCallVisibility ?? "showAll")
292+
: null;
293+
294+
return (
295+
<View className="gap-3">
296+
<SettingsSection title="Beta: Tool calls in chat">
297+
{TOOL_CALL_VISIBILITY_OPTIONS.map((option, index) => (
298+
<ListChoiceRow
299+
key={option.value}
300+
label={option.label}
301+
selected={selected === option.value}
302+
separated={index > 0}
303+
disabled={selected === null}
304+
onPress={() => savePreferences({ toolCallVisibility: option.value })}
305+
/>
306+
))}
307+
</SettingsSection>
308+
<Text className="px-2 text-sm text-foreground-muted">
309+
Hide the commands, edits, and searches agents run, so a thread reads like a conversation.
310+
Hide successful keeps calls that fail. Zen also hides the agent&apos;s in-between messages
311+
and shows only final answers. Approvals, questions, and errors always show.
312+
</Text>
313+
</View>
314+
);
315+
}
316+
274317
function LegacySettingsSection() {
275318
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
276319
const preferences = useAtomValue(mobilePreferencesAtom);

‎apps/mobile/src/features/settings/settings-search.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,19 @@ const SETTINGS_SEARCH_TERMS = {
9898
"submodules",
9999
"start from remote",
100100
],
101-
SettingsLabs: ["legacy", "plan mode", "beta", "linked environments", "link machine"],
101+
SettingsLabs: [
102+
"legacy",
103+
"plan mode",
104+
"beta",
105+
"linked environments",
106+
"link machine",
107+
"tool calls in chat",
108+
"hide tool calls",
109+
"commands edits searches",
110+
"work log",
111+
"zen",
112+
"final answers only",
113+
],
102114
SettingsEnvironmentMaintenance: ["updates", "provider updates", "restart", "manage environments"],
103115
SettingsAbout: [
104116
"version",

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import { AsyncResult, Atom } from "effect/reactivity";
1111
import * as Dialog from "../../components/ui/Dialog";
1212
import { useAtomMount, useAtomValue } from "@effect/atom-react";
13+
import { mobilePreferencesAtom } from "../../state/preferences";
1314
import { parseThreadKey, threadKey } from "@t3tools/client-runtime/state/entities";
1415
import { createThreadVisitTracker } from "@t3tools/client-runtime/state/thread-visits";
1516
import { useChildThreadInputs, useThreadReportedModelSelection } from "../../state/entities";
@@ -482,6 +483,10 @@ function ThreadDetailBody(
482483
threadId: props.selectedThread.id,
483484
});
484485
const composerError = useAtomValue(threadComposerErrorsAtom)[selectedThreadKey]?.message ?? null;
486+
const preferences = useAtomValue(mobilePreferencesAtom);
487+
const toolCallVisibility = AsyncResult.isSuccess(preferences)
488+
? (preferences.value.toolCallVisibility ?? "showAll")
489+
: "showAll";
485490
const queuedCount = useThreadQueuedCount(props.selectedThreadDetailRef);
486491
const turnSubagents = useThreadTurnSubagents(props.selectedThreadDetailRef);
487492
const agentsSegment = resolveSubagentPillSegment(turnSubagents);
@@ -1486,6 +1491,7 @@ function ThreadDetailBody(
14861491
>
14871492
<WorkspaceMutationIdProvider threadRef={props.selectedThreadDetailRef}>
14881493
<ThreadFeed
1494+
toolCallVisibility={toolCallVisibility}
14891495
environmentId={props.environmentId}
14901496
threadId={props.selectedThread.id}
14911497
detailRef={props.selectedThreadDetailRef}

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import {
5959
type ScheduledTaskId,
6060
type ScopedThreadRef,
6161
} from "@t3tools/contracts";
62+
import type { ToolCallVisibility } from "@t3tools/contracts/settings";
6263
import { renderAssistantCitationsAsText } from "@t3tools/shared/assistantCitations";
6364
import { encodeComposerContextFragment } from "@t3tools/shared/composerContextClipboard";
6465
import { hostedThreadLink, parseThreadLinkHref } from "@t3tools/shared/threadLinks";
@@ -339,6 +340,7 @@ export interface ThreadFeedHandle {
339340
}
340341

341342
export interface ThreadFeedProps {
343+
readonly toolCallVisibility?: ToolCallVisibility;
342344
readonly worktreeSetup?: WorktreeSetupCardProps | null;
343345
readonly setupWorkingStartedAt?: string | null;
344346
readonly queuedMessages: ReadonlyArray<QueuedThreadMessage>;
@@ -1739,7 +1741,13 @@ function renderFeedEntry(
17391741
}
17401742

17411743
if (entry.type === "thinking") {
1742-
return <ThreadThinkingRow rowSizing={props.workRowSizing} iconSubtleColor={iconSubtleColor} />;
1744+
return (
1745+
<ThreadThinkingRow
1746+
rowSizing={props.workRowSizing}
1747+
iconSubtleColor={iconSubtleColor}
1748+
label={entry.label}
1749+
/>
1750+
);
17431751
}
17441752

17451753
if (entry.type === "html-render") {
@@ -2565,6 +2573,7 @@ function useThreadFeedPresentation(
25652573
props: ThreadFeedProps,
25662574
expandedTurnIds: ReadonlySet<RunId>,
25672575
expandedWorkGroups: Record<string, boolean>,
2576+
revealedMessageId: MessageId | null,
25682577
) {
25692578
const [feedCache] = useState(createThreadFeedCache);
25702579
return appendPendingThreadMessages(
@@ -2580,6 +2589,7 @@ function useThreadFeedPresentation(
25802589
props.activeWorkStartedAt,
25812590
props.runlessWorkActive ?? false,
25822591
feedCache,
2592+
{ toolCallVisibility: props.toolCallVisibility ?? "showAll", revealedMessageId },
25832593
),
25842594
props.feed,
25852595
props.queuedMessages,
@@ -2735,13 +2745,16 @@ export const ThreadFeed = memo(function ThreadFeed({
27352745
readonly expandedWorkGroups: Record<string, boolean>;
27362746
readonly expandedWorkRows: Record<string, boolean>;
27372747
readonly expandedTurnIds: ReadonlySet<RunId>;
2748+
readonly revealedMessageId: MessageId | null;
27382749
}>({
27392750
copiedRowId: null,
27402751
expandedWorkGroups: {},
27412752
expandedWorkRows: {},
27422753
expandedTurnIds: new Set(),
2754+
revealedMessageId: null,
27432755
});
2744-
const { copiedRowId, expandedWorkGroups, expandedWorkRows, expandedTurnIds } = interactionState;
2756+
const { copiedRowId, expandedWorkGroups, expandedWorkRows, expandedTurnIds, revealedMessageId } =
2757+
interactionState;
27452758
const markdownLinkRequest = useRef<AbortController | null>(null);
27462759
const onInlinePlaybackStart = () => {
27472760
markdownLinkRequest.current?.abort();
@@ -3301,8 +3314,11 @@ export const ThreadFeed = memo(function ThreadFeed({
33013314
const [loadedListKey, setLoadedListKey] = useState<string | null>(null);
33023315
const { jumpToMessageId } = props;
33033316
const jumpReady = !!jumpToMessageId && loadedListKey === `${feedThreadKey}:filled`;
3317+
if (jumpReady && revealedMessageId !== jumpToMessageId) {
3318+
setInteractionState((current) => ({ ...current, revealedMessageId: jumpToMessageId }));
3319+
}
33043320
const presentedFeed = appendGuestPendingMessages(
3305-
useThreadFeedPresentation(props, expandedTurnIds, expandedWorkGroups),
3321+
useThreadFeedPresentation(props, expandedTurnIds, expandedWorkGroups, revealedMessageId),
33063322
guestShare,
33073323
);
33083324
const jumpRunId =

‎apps/mobile/src/features/threads/thread-work-log.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,19 +1456,21 @@ export function ThreadWorkGroupToggle(props: {
14561456
export function ThreadThinkingRow(props: {
14571457
readonly rowSizing: ReturnType<typeof deriveThreadWorkLogSizing>;
14581458
readonly iconSubtleColor: ColorValue;
1459+
readonly label?: string;
14591460
}) {
1461+
const label = props.label ?? "Thinking";
14601462
return (
14611463
<View
14621464
accessible
1463-
accessibilityLabel="Thinking"
1465+
accessibilityLabel={label}
14641466
className="-mx-1 min-h-8 flex-row items-center px-1.5 py-0"
14651467
style={{ minHeight: props.rowSizing.estimatedRowHeight }}
14661468
>
14671469
<ShimmeringWorkContent
14681470
key={props.rowSizing.textSizeKey}
14691471
icon="brain"
14701472
iconSubtleColor={props.iconSubtleColor}
1471-
label="Thinking"
1473+
label={label}
14721474
showIcon
14731475
/>
14741476
</View>

‎apps/mobile/src/lib/threadActivity.test.ts‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,90 @@ describe("buildThreadFeed", () => {
12571257
),
12581258
).toEqual([]);
12591259
});
1260+
it("hides tool calls or everything but the final answer", () => {
1261+
const at = (second: number) => `2026-06-20T00:00:${String(second).padStart(2, "0")}.000Z`;
1262+
const say = (name: string, second: number, user = false, steer = false) => ({
1263+
...(user ? userMessage(at(second)) : assistantMessage(at(second))),
1264+
id: TurnItemId.make(name),
1265+
messageId: MessageId.make(name),
1266+
text: name,
1267+
...(steer ? { inputIntent: "steer" as const } : {}),
1268+
});
1269+
const ran = (name: string, second: number, status: "completed" | "failed") => ({
1270+
...command(at(second)),
1271+
id: TurnItemId.make(name),
1272+
status,
1273+
});
1274+
const [user, step, passed, failed, final] = [
1275+
say("user", 1, true),
1276+
say("step", 2),
1277+
ran("passed", 3, "completed"),
1278+
ran("failed", 4, "failed"),
1279+
say("final", 5),
1280+
];
1281+
const running = { runId, status: "running" as const, startedAt: at(1), completedAt: null };
1282+
const rows = (
1283+
items: ReadonlyArray<OrchestrationV2TurnItem>,
1284+
toolCallVisibility: "hideSuccessful" | "hideAll" | "zen",
1285+
latestRun: ThreadFeedLatestRun | null = null,
1286+
) =>
1287+
deriveThreadFeedPresentation(
1288+
buildThreadFeed(items.map((item, index) => projected(item, index))),
1289+
latestRun,
1290+
new Set([runId]),
1291+
new Set(),
1292+
latestRun ? at(1) : null,
1293+
false,
1294+
undefined,
1295+
{ toolCallVisibility, revealedMessageId: null },
1296+
).map((row) =>
1297+
row.type === "activity-group"
1298+
? row.activities.map((activity) => activity.projectedItem.item.id).join("+")
1299+
: row.type === "thinking"
1300+
? `thinking:${row.label ?? ""}`
1301+
: row.type === "run-fold"
1302+
? "fold"
1303+
: row.id,
1304+
);
1305+
1306+
const turn = [user, step, passed, failed, final];
1307+
expect(rows(turn, "hideSuccessful")).toEqual(["user", "fold", "step", "failed", "final"]);
1308+
expect(rows(turn, "hideAll")).toEqual(["user", "fold", "step", "final"]);
1309+
expect(rows(turn, "zen")).toEqual(["user", "final"]);
1310+
const [steer, answer] = [say("steer", 2, true, true), say("answer", 3)];
1311+
expect(rows([user, steer, answer, final], "zen")).toEqual(["user", "steer", "answer", "final"]);
1312+
expect(rows([user, steer, step, passed, final], "zen")).toEqual(["user", "steer", "final"]);
1313+
expect(rows([user, steer, answer, step], "zen", running)).toEqual([
1314+
"user",
1315+
"steer",
1316+
"answer",
1317+
"thinking:step",
1318+
]);
1319+
expect(rows([user, step, passed], "zen", running)).toEqual(["user", "thinking:step"]);
1320+
expect(rows(turn, "zen", { ...running, turnEnded: true })).toEqual(["user", "final"]);
1321+
const nextRun = { ...running, runId: RunId.make("run-2") };
1322+
const followUp = { ...say("follow-up", 6, true), runId: nextRun.runId };
1323+
expect(rows([...turn, followUp], "zen", nextRun)).toEqual([
1324+
"user",
1325+
"final",
1326+
"follow-up",
1327+
"thinking:",
1328+
]);
1329+
const wake: OrchestrationV2TurnItem = {
1330+
...base("wake", at(6), 5),
1331+
runId: nextRun.runId,
1332+
type: "notification",
1333+
source: { kind: "background_task" },
1334+
outcome: "completed",
1335+
summary: "Task finished",
1336+
};
1337+
expect(rows([user, final, wake], "zen", nextRun)).toEqual([
1338+
"user",
1339+
"final",
1340+
"wake",
1341+
"thinking:",
1342+
]);
1343+
});
12601344
});
12611345

12621346
describe("retained v2 feed presentation", () => {

0 commit comments

Comments
 (0)