Skip to content

Commit b7465a3

Browse files
fix(mobile): stop the work log flickering during subagent runs and failing calls (pingdotgg#10273)
1 parent 4f782be commit b7465a3

4 files changed

Lines changed: 724 additions & 52 deletions

File tree

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

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ import {
153153
} from "./thread-feed-live-follow";
154154
import {
155155
collapsedWorkLogHeight,
156+
ThreadAgentSpawnCard,
156157
ThreadDisclosureChevron,
157158
ThreadWorkGroupToggle,
158159
ThreadThinkingRow,
@@ -504,12 +505,7 @@ function MessageAttachmentFile(props: {
504505
function MessageAttachmentUnknown(props: { readonly name: string }) {
505506
return (
506507
<View className="flex-row items-center gap-2 py-1">
507-
<SymbolView
508-
name="doc.text"
509-
size={16}
510-
tintColorClassName="accent-icon-subtle"
511-
type="monochrome"
512-
/>
508+
<SymbolView name="doc.text" size={16} tintColor="#a3a3a3" type="monochrome" />
513509
<Text className="min-w-0 flex-1 text-sm text-foreground" numberOfLines={1}>
514510
{props.name}
515511
</Text>
@@ -1357,7 +1353,7 @@ function renderFeedEntry(
13571353
accessibilityState={{ expanded: entry.expanded }}
13581354
onPress={() => props.onToggleTurnFold(entry.turnId)}
13591355
hitSlop={4}
1360-
className="mb-1 min-h-11 flex-row items-center gap-2 border-b border-border px-2"
1356+
className="mb-1 min-h-11 flex-row items-center gap-2 border-b border-adaptive-neutral-200-a80-white-a8 px-2"
13611357
style={{
13621358
minHeight: Math.max(TURN_FOLD_HEIGHT - 3.5, props.workRowSizing.estimatedRowHeight),
13631359
}}
@@ -1382,6 +1378,19 @@ function renderFeedEntry(
13821378
return <ThreadThinkingRow rowSizing={props.workRowSizing} iconSubtleColor={iconSubtleColor} />;
13831379
}
13841380

1381+
if (entry.type === "agent-spawn") {
1382+
return (
1383+
<ThreadAgentSpawnCard
1384+
summary={entry.summary}
1385+
expanded={entry.expanded}
1386+
iconSubtleColor={iconSubtleColor}
1387+
rowSizing={props.workRowSizing}
1388+
onToggle={() => props.onToggleWorkGroup(entry.id, entry.id)}
1389+
onCopy={() => props.onCopyWorkRow(entry.activity.id, entry.activity.getCopyText())}
1390+
/>
1391+
);
1392+
}
1393+
13851394
if (entry.type === "work-toggle") {
13861395
return (
13871396
<ThreadWorkGroupToggle
@@ -1411,7 +1420,7 @@ function renderFeedEntry(
14111420
accessibilityLabel={label}
14121421
className="mb-3 flex-row items-center gap-3 px-1 py-1"
14131422
>
1414-
<View className="h-px flex-1 bg-border" />
1423+
<View className="h-px flex-1 bg-adaptive-neutral-200-a80-white-a8" />
14151424
<View className="shrink-0 flex-row items-center gap-1.5">
14161425
<SymbolView
14171426
name="arrow.down.right.and.arrow.up.left"
@@ -1421,7 +1430,7 @@ function renderFeedEntry(
14211430
/>
14221431
<Text className="font-t3-medium text-xs text-foreground-muted">{label}</Text>
14231432
</View>
1424-
<View className="h-px flex-1 bg-border" />
1433+
<View className="h-px flex-1 bg-adaptive-neutral-200-a80-white-a8" />
14251434
</View>
14261435
);
14271436
}
@@ -1508,7 +1517,7 @@ function renderFeedEntry(
15081517
})}
15091518
</View>
15101519
<View className="mt-1 flex-row items-center justify-end gap-1 pr-0.5">
1511-
<Text className="font-t3-medium text-xs tabular-nums text-foreground-secondary">
1520+
<Text className="font-t3-medium text-xs tabular-nums text-adaptive-neutral-600-400">
15121521
{timestampLabel}
15131522
</Text>
15141523
{message.text.trim().length > 0 ? (
@@ -1557,7 +1566,7 @@ function renderFeedEntry(
15571566
attachmentId={attachment.id}
15581567
name={attachment.name}
15591568
mimeType={attachment.mimeType}
1560-
className="mt-1.5 aspect-[1.3] w-full rounded-[18px] bg-subtle-strong"
1569+
className="mt-1.5 aspect-[1.3] w-full rounded-[18px] bg-adaptive-neutral-200-800"
15611570
onPressPreview={props.onPressPreview}
15621571
/>
15631572
) : isFileAttachment(attachment) ? (
@@ -1581,7 +1590,7 @@ function renderFeedEntry(
15811590
buttonSize={28}
15821591
iconSize={13}
15831592
/>
1584-
<Text className="font-t3-medium text-xs tabular-nums text-foreground-secondary">
1593+
<Text className="font-t3-medium text-xs tabular-nums text-adaptive-neutral-600-400">
15851594
{timestampLabel}
15861595
</Text>
15871596
</View>

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

Lines changed: 172 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ import { AppText as Text } from "../../components/AppText";
3434
import { T3Wordmark } from "../../components/T3Wordmark";
3535
import { cn } from "../../lib/cn";
3636
import { THREAD_WORK_ROW_MIN_HEIGHT, type deriveThreadWorkLogSizing } from "../../lib/layout";
37-
import { type ThreadFeedActivity, workEntryRowLabel } from "../../lib/threadActivity";
37+
import {
38+
type AgentSpawnSummary,
39+
type ThreadFeedActivity,
40+
workEntryRowLabel,
41+
} from "../../lib/threadActivity";
3842
import {
3943
resolveThreadWorkGroupInitialScroll,
4044
shouldFollowThreadWorkGroupAppend,
@@ -135,6 +139,7 @@ export function ThreadDisclosureChevron(props: {
135139
}
136140

137141
function ShimmerWorkContent(props: {
142+
readonly compact?: boolean;
138143
readonly environmentId?: EnvironmentId;
139144
readonly highlighted: boolean;
140145
readonly icon: WorkContentIcon;
@@ -147,26 +152,29 @@ function ShimmerWorkContent(props: {
147152
}) {
148153
return (
149154
<View className="flex-row items-center gap-1.5">
150-
<View className="h-6 w-6 shrink-0 items-center justify-center">
151-
{props.showIcon && props.toolIcon && props.environmentId ? (
152-
<ToolActivityIconView
153-
environmentId={props.environmentId}
154-
icon={props.toolIcon}
155-
fallback={props.icon}
156-
fallbackColor={props.iconSubtleColor}
157-
themeAppearance={props.themeAppearance ?? "light"}
158-
/>
159-
) : props.showIcon ? (
160-
<WorkLogIcon
161-
icon={props.icon}
162-
color={props.iconSubtleColor}
163-
highlighted={props.highlighted}
164-
/>
165-
) : null}
166-
</View>
155+
{props.showIcon ? (
156+
<View className="h-6 w-6 shrink-0 items-center justify-center">
157+
{props.toolIcon && props.environmentId ? (
158+
<ToolActivityIconView
159+
environmentId={props.environmentId}
160+
icon={props.toolIcon}
161+
fallback={props.icon}
162+
fallbackColor={props.iconSubtleColor}
163+
themeAppearance={props.themeAppearance ?? "light"}
164+
/>
165+
) : (
166+
<WorkLogIcon
167+
icon={props.icon}
168+
color={props.iconSubtleColor}
169+
highlighted={props.highlighted}
170+
/>
171+
)}
172+
</View>
173+
) : null}
167174
<Text
168175
className={cn(
169-
"min-w-0 shrink text-sm",
176+
"min-w-0 shrink",
177+
props.compact ? "text-xs" : "text-sm",
170178
props.highlighted ? "text-foreground" : "text-foreground-muted",
171179
)}
172180
numberOfLines={1}
@@ -179,6 +187,8 @@ function ShimmerWorkContent(props: {
179187
}
180188

181189
export function ShimmeringWorkContent(props: {
190+
/** Secondary line: no icon slot, caption size. */
191+
readonly compact?: boolean;
182192
readonly environmentId?: EnvironmentId;
183193
readonly icon: WorkContentIcon;
184194
readonly iconSubtleColor: ColorValue;
@@ -194,7 +204,10 @@ export function ShimmeringWorkContent(props: {
194204
const screenIsFocused = useIsFocused();
195205
const progress = useSharedValue(0);
196206
const gradientId = `work-shimmer-${useId().replaceAll(":", "")}`;
197-
const contentWidth = Math.min(availableWidth, SHIMMER_ICON_AND_GAP_WIDTH + Math.ceil(textWidth));
207+
const contentWidth = Math.min(
208+
availableWidth,
209+
(props.showIcon ? SHIMMER_ICON_AND_GAP_WIDTH : 0) + Math.ceil(textWidth),
210+
);
198211

199212
useEffect(() => {
200213
const subscription = AppState.addEventListener("change", (state) => {
@@ -250,6 +263,7 @@ export function ShimmeringWorkContent(props: {
250263
onLayout={(event) => setAvailableWidth(event.nativeEvent.layout.width)}
251264
>
252265
<ShimmerWorkContent
266+
compact={props.compact}
253267
environmentId={props.environmentId}
254268
highlighted={false}
255269
icon={props.icon}
@@ -290,6 +304,7 @@ export function ShimmeringWorkContent(props: {
290304
>
291305
<Animated.View style={[{ width: availableWidth }, counterSweepStyle]}>
292306
<ShimmerWorkContent
307+
compact={props.compact}
293308
environmentId={props.environmentId}
294309
highlighted
295310
icon={props.icon}
@@ -773,7 +788,7 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
773788
color={props.iconSubtleColor}
774789
colorClassName={
775790
iconIsDestructive
776-
? "accent-danger-foreground"
791+
? "accent-adaptive-rose-600-400"
777792
: failed
778793
? "accent-danger-foreground/40"
779794
: undefined
@@ -784,7 +799,7 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
784799
<Text
785800
className={cn(
786801
"min-w-0 flex-1 text-sm text-foreground-muted",
787-
iconIsDestructive && "font-t3-medium text-danger-foreground",
802+
iconIsDestructive && "font-t3-medium text-adaptive-rose-600-400",
788803
)}
789804
numberOfLines={1}
790805
>
@@ -832,7 +847,7 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
832847
entering={WORK_LOG_DETAIL_ENTER_TRANSITION}
833848
exiting={WORK_LOG_DETAIL_EXIT_TRANSITION}
834849
layout={WORK_LOG_LAYOUT_TRANSITION}
835-
className="ml-7 border-l border-border pb-1 pl-3 pt-0.5"
850+
className="ml-7 border-l border-adaptive-neutral-300-a60-white-a12 pb-1 pl-3 pt-0.5"
836851
>
837852
{viewedImagePath ? (
838853
<View className="pb-1.5">
@@ -938,6 +953,140 @@ export function ThreadWorkGroupToggle(props: {
938953
);
939954
}
940955

956+
const AGENT_SPAWN_TONE_DOT_CLASS = {
957+
working: "bg-adaptive-sky-600-400",
958+
completed: "bg-adaptive-emerald-600-400",
959+
failed: "bg-adaptive-rose-600-400",
960+
stopped: "bg-foreground-muted",
961+
} as const satisfies Record<AgentSpawnSummary["tone"], string>;
962+
963+
/**
964+
* A batch of spawned subagents. The status line updates in place as members
965+
* report progress; expanding lists each member. Text nodes carry keys tied to
966+
* the row identity only, so a progress tick re-renders the labels without
967+
* remounting the card (see the batch key in appendActivityGroupRows).
968+
*/
969+
export const ThreadAgentSpawnCard = memo(function ThreadAgentSpawnCard(props: {
970+
readonly summary: AgentSpawnSummary;
971+
readonly expanded: boolean;
972+
readonly iconSubtleColor: ColorValue;
973+
readonly rowSizing: ReturnType<typeof deriveThreadWorkLogSizing>;
974+
readonly onToggle: () => void;
975+
readonly onCopy: () => void;
976+
}) {
977+
const { summary, expanded } = props;
978+
const working = summary.tone === "working";
979+
const memberCount = summary.members.length;
980+
const canExpand = memberCount > 0;
981+
return (
982+
<Animated.View layout={WORK_LOG_LAYOUT_TRANSITION} className="-mx-1 mb-1 px-1">
983+
<Pressable
984+
accessibilityRole={canExpand ? "button" : undefined}
985+
accessibilityState={canExpand ? { expanded } : undefined}
986+
accessibilityLabel={`${summary.title}, ${summary.status}`}
987+
accessibilityHint={
988+
canExpand
989+
? `Double tap to ${expanded ? "hide" : "show"} ${memberCount} ${memberCount === 1 ? "subagent" : "subagents"}. Long press to copy.`
990+
: "Long press to copy."
991+
}
992+
hitSlop={4}
993+
onPress={() => {
994+
if (!canExpand) return;
995+
void Haptics.selectionAsync();
996+
props.onToggle();
997+
}}
998+
onLongPress={props.onCopy}
999+
className="rounded-xl border border-adaptive-neutral-200-a80-white-a8 bg-card px-2.5 py-2 active:bg-subtle"
1000+
>
1001+
<View className="flex-row items-center gap-2">
1002+
<View className="h-6 w-6 shrink-0 items-center justify-center">
1003+
<SymbolView
1004+
name={{ ios: "sparkles", android: "auto_awesome" }}
1005+
size={14}
1006+
weight="medium"
1007+
tintColor={props.iconSubtleColor}
1008+
type="monochrome"
1009+
/>
1010+
</View>
1011+
<View className="min-w-0 flex-1 gap-0.5">
1012+
<Text
1013+
key={props.rowSizing.textSizeKey}
1014+
className="font-t3-medium text-sm text-foreground"
1015+
numberOfLines={1}
1016+
>
1017+
{summary.title}
1018+
</Text>
1019+
<View className="flex-row items-center gap-1.5">
1020+
<View
1021+
className={cn(
1022+
"h-1.5 w-1.5 shrink-0 rounded-full",
1023+
AGENT_SPAWN_TONE_DOT_CLASS[summary.tone],
1024+
)}
1025+
/>
1026+
{working ? (
1027+
<ShimmeringWorkContent
1028+
key={props.rowSizing.textSizeKey}
1029+
compact
1030+
icon="brain"
1031+
iconSubtleColor={props.iconSubtleColor}
1032+
label={summary.status}
1033+
showIcon={false}
1034+
/>
1035+
) : (
1036+
<Text className="min-w-0 flex-1 text-xs text-foreground-muted" numberOfLines={1}>
1037+
{summary.status}
1038+
</Text>
1039+
)}
1040+
</View>
1041+
</View>
1042+
{canExpand ? (
1043+
<ThreadDisclosureChevron
1044+
expanded={expanded}
1045+
collapsedDirection="down"
1046+
size={11}
1047+
tintColor={props.iconSubtleColor}
1048+
/>
1049+
) : null}
1050+
</View>
1051+
{expanded && canExpand ? (
1052+
<Animated.View
1053+
entering={WORK_LOG_DETAIL_ENTER_TRANSITION}
1054+
exiting={WORK_LOG_DETAIL_EXIT_TRANSITION}
1055+
layout={WORK_LOG_LAYOUT_TRANSITION}
1056+
className="ml-8 mt-1.5 gap-1.5 border-l border-adaptive-neutral-300-a60-white-a12 pl-3"
1057+
>
1058+
{summary.members.map((member) => (
1059+
<View key={member.title} className="gap-px">
1060+
<View className="flex-row items-center gap-1.5">
1061+
<View
1062+
className={cn(
1063+
"h-1.5 w-1.5 shrink-0 rounded-full",
1064+
AGENT_SPAWN_TONE_DOT_CLASS[member.tone],
1065+
)}
1066+
/>
1067+
<Text className="min-w-0 flex-1 text-xs text-foreground" numberOfLines={1}>
1068+
{member.title}
1069+
</Text>
1070+
<Text className="shrink-0 text-2xs text-foreground-muted">{member.status}</Text>
1071+
</View>
1072+
{member.detail ? (
1073+
<Text
1074+
selectable
1075+
className="pl-3 font-mono text-2xs leading-normal text-foreground-muted"
1076+
numberOfLines={expanded ? 6 : 1}
1077+
>
1078+
{member.detail}
1079+
</Text>
1080+
) : null}
1081+
</View>
1082+
))}
1083+
</Animated.View>
1084+
) : null}
1085+
</Pressable>
1086+
</Animated.View>
1087+
);
1088+
});
1089+
9411090
export function ThreadThinkingRow(props: {
9421091
readonly rowSizing: ReturnType<typeof deriveThreadWorkLogSizing>;
9431092
readonly iconSubtleColor: ColorValue;

0 commit comments

Comments
 (0)