Skip to content

Commit c83b038

Browse files
committed
feat(mobile): add the Tool calls in chat Labs setting
Mobile gets the same Show all, Hide successful, Hide all, and Zen modes as web. The tool-call hiding predicate moves to client-runtime so both clients share it.
1 parent 46e6e42 commit c83b038

10 files changed

Lines changed: 390 additions & 50 deletions

File tree

‎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
@@ -83,7 +83,19 @@ const SETTINGS_SEARCH_TERMS = {
8383
"submodules",
8484
"start from remote",
8585
],
86-
SettingsLabs: ["legacy", "plan mode", "beta", "linked environments", "link machine"],
86+
SettingsLabs: [
87+
"legacy",
88+
"plan mode",
89+
"beta",
90+
"linked environments",
91+
"link machine",
92+
"tool calls in chat",
93+
"hide tool calls",
94+
"commands edits searches",
95+
"work log",
96+
"zen",
97+
"final answers only",
98+
],
8799
SettingsEnvironmentMaintenance: ["updates", "provider updates", "restart", "manage environments"],
88100
SettingsAbout: [
89101
"version",

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ import { appAtomRegistry } from "../../state/atom-registry";
268268
import { environmentThreadShells, threadEnvironment } from "../../state/threads";
269269
import { ThreadWorkflowOpening, useWorkflowOpening } from "./thread-workflow-opening";
270270
import { useAtomCommand } from "../../state/use-atom-command";
271+
import { mobilePreferencesAtom } from "../../state/preferences";
272+
import { useAtomValue } from "@effect/atom-react";
273+
import { AsyncResult } from "effect/reactivity";
271274
import { useV2ItemSupport } from "../../state/v2-item-support";
272275
import {
273276
fileRoutePathSegments,
@@ -1749,7 +1752,13 @@ function renderFeedEntry(
17491752
}
17501753

17511754
if (entry.type === "thinking") {
1752-
return <ThreadThinkingRow rowSizing={props.workRowSizing} iconSubtleColor={iconSubtleColor} />;
1755+
return (
1756+
<ThreadThinkingRow
1757+
rowSizing={props.workRowSizing}
1758+
iconSubtleColor={iconSubtleColor}
1759+
label={entry.label}
1760+
/>
1761+
);
17531762
}
17541763

17551764
if (entry.type === "html-render") {
@@ -2575,8 +2584,13 @@ function useThreadFeedPresentation(
25752584
props: ThreadFeedProps,
25762585
expandedTurnIds: ReadonlySet<RunId>,
25772586
expandedWorkGroups: Record<string, boolean>,
2587+
revealedMessageId: MessageId | null,
25782588
) {
25792589
const [feedCache] = useState(createThreadFeedCache);
2590+
const preferences = useAtomValue(mobilePreferencesAtom);
2591+
const toolCallVisibility = AsyncResult.isSuccess(preferences)
2592+
? (preferences.value.toolCallVisibility ?? "showAll")
2593+
: "showAll";
25802594
return appendPendingThreadMessages(
25812595
deriveThreadFeedPresentation(
25822596
props.feed,
@@ -2590,6 +2604,7 @@ function useThreadFeedPresentation(
25902604
props.activeWorkStartedAt,
25912605
props.runlessWorkActive ?? false,
25922606
feedCache,
2607+
{ toolCallVisibility, revealedMessageId },
25932608
),
25942609
props.feed,
25952610
props.queuedMessages,
@@ -2746,13 +2761,16 @@ export const ThreadFeed = memo(function ThreadFeed({
27462761
readonly expandedWorkGroups: Record<string, boolean>;
27472762
readonly expandedWorkRows: Record<string, boolean>;
27482763
readonly expandedTurnIds: ReadonlySet<RunId>;
2764+
readonly revealedMessageId: MessageId | null;
27492765
}>({
27502766
copiedRowId: null,
27512767
expandedWorkGroups: {},
27522768
expandedWorkRows: {},
27532769
expandedTurnIds: new Set(),
2770+
revealedMessageId: null,
27542771
});
2755-
const { copiedRowId, expandedWorkGroups, expandedWorkRows, expandedTurnIds } = interactionState;
2772+
const { copiedRowId, expandedWorkGroups, expandedWorkRows, expandedTurnIds, revealedMessageId } =
2773+
interactionState;
27562774
const markdownLinkRequest = useRef<AbortController | null>(null);
27572775
const onInlinePlaybackStart = () => {
27582776
markdownLinkRequest.current?.abort();
@@ -3313,8 +3331,11 @@ export const ThreadFeed = memo(function ThreadFeed({
33133331
const [loadedListKey, setLoadedListKey] = useState<string | null>(null);
33143332
const { jumpToMessageId } = props;
33153333
const jumpReady = !!jumpToMessageId && loadedListKey === `${feedThreadKey}:filled`;
3334+
if (jumpReady && revealedMessageId !== jumpToMessageId) {
3335+
setInteractionState((current) => ({ ...current, revealedMessageId: jumpToMessageId }));
3336+
}
33163337
const presentedFeed = appendGuestPendingMessages(
3317-
useThreadFeedPresentation(props, expandedTurnIds, expandedWorkGroups),
3338+
useThreadFeedPresentation(props, expandedTurnIds, expandedWorkGroups, revealedMessageId),
33183339
guestShare,
33193340
);
33203341
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
@@ -1425,19 +1425,21 @@ export function ThreadWorkGroupToggle(props: {
14251425
export function ThreadThinkingRow(props: {
14261426
readonly rowSizing: ReturnType<typeof deriveThreadWorkLogSizing>;
14271427
readonly iconSubtleColor: ColorValue;
1428+
readonly label?: string;
14281429
}) {
1430+
const label = props.label ?? "Thinking";
14291431
return (
14301432
<View
14311433
accessible
1432-
accessibilityLabel="Thinking"
1434+
accessibilityLabel={label}
14331435
className="-mx-1 min-h-8 flex-row items-center px-1.5 py-0"
14341436
style={{ minHeight: props.rowSizing.estimatedRowHeight }}
14351437
>
14361438
<ShimmeringWorkContent
14371439
key={props.rowSizing.textSizeKey}
14381440
icon="brain"
14391441
iconSubtleColor={props.iconSubtleColor}
1440-
label="Thinking"
1442+
label={label}
14411443
showIcon
14421444
/>
14431445
</View>

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

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,84 @@ describe("buildThreadFeed", () => {
12381238
),
12391239
).toEqual([]);
12401240
});
1241+
it("hides tool calls or everything but the final answer", () => {
1242+
const at = (second: number) => `2026-06-20T00:00:${String(second).padStart(2, "0")}.000Z`;
1243+
const say = (name: string, second: number, user = false, steer = false) => ({
1244+
...(user ? userMessage(at(second)) : assistantMessage(at(second))),
1245+
id: TurnItemId.make(name),
1246+
messageId: MessageId.make(name),
1247+
text: name,
1248+
...(steer ? { inputIntent: "steer" as const } : {}),
1249+
});
1250+
const ran = (name: string, second: number, status: "completed" | "failed") => ({
1251+
...command(at(second)),
1252+
id: TurnItemId.make(name),
1253+
status,
1254+
});
1255+
const [user, step, passed, failed, final] = [
1256+
say("user", 1, true),
1257+
say("step", 2),
1258+
ran("passed", 3, "completed"),
1259+
ran("failed", 4, "failed"),
1260+
say("final", 5),
1261+
];
1262+
const running = { runId, status: "running" as const, startedAt: at(1), completedAt: null };
1263+
const rows = (
1264+
items: ReadonlyArray<OrchestrationV2TurnItem>,
1265+
toolCallVisibility: "hideSuccessful" | "hideAll" | "zen",
1266+
latestRun: ThreadFeedLatestRun | null = null,
1267+
) =>
1268+
deriveThreadFeedPresentation(
1269+
buildThreadFeed(items.map((item, index) => projected(item, index))),
1270+
latestRun,
1271+
new Set([runId]),
1272+
new Set(),
1273+
latestRun ? at(1) : null,
1274+
false,
1275+
undefined,
1276+
{ toolCallVisibility, revealedMessageId: null },
1277+
).map((row) =>
1278+
row.type === "activity-group"
1279+
? row.activities.map((activity) => activity.projectedItem.item.id).join("+")
1280+
: row.type === "thinking"
1281+
? `thinking:${row.label ?? ""}`
1282+
: row.type === "run-fold"
1283+
? "fold"
1284+
: row.id,
1285+
);
1286+
1287+
const turn = [user, step, passed, failed, final];
1288+
expect(rows(turn, "hideSuccessful")).toEqual(["user", "fold", "step", "failed", "final"]);
1289+
expect(rows(turn, "hideAll")).toEqual(["user", "fold", "step", "final"]);
1290+
expect(rows(turn, "zen")).toEqual(["user", "final"]);
1291+
const [steer, answer] = [say("steer", 2, true, true), say("answer", 3)];
1292+
expect(rows([user, steer, answer, final], "zen")).toEqual(["user", "steer", "answer", "final"]);
1293+
expect(rows([user, steer, step, passed, final], "zen")).toEqual(["user", "steer", "final"]);
1294+
expect(rows([user, step, passed], "zen", running)).toEqual(["user", "thinking:step"]);
1295+
expect(rows(turn, "zen", { ...running, turnEnded: true })).toEqual(["user", "final"]);
1296+
const nextRun = { ...running, runId: RunId.make("run-2") };
1297+
const followUp = { ...say("follow-up", 6, true), runId: nextRun.runId };
1298+
expect(rows([...turn, followUp], "zen", nextRun)).toEqual([
1299+
"user",
1300+
"final",
1301+
"follow-up",
1302+
"thinking:",
1303+
]);
1304+
const wake: OrchestrationV2TurnItem = {
1305+
...base("wake", at(6), 5),
1306+
runId: nextRun.runId,
1307+
type: "notification",
1308+
source: { kind: "background_task" },
1309+
outcome: "completed",
1310+
summary: "Task finished",
1311+
};
1312+
expect(rows([user, final, wake], "zen", nextRun)).toEqual([
1313+
"user",
1314+
"final",
1315+
"wake",
1316+
"thinking:",
1317+
]);
1318+
});
12411319
});
12421320

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

0 commit comments

Comments
 (0)