Skip to content

Commit d5c5684

Browse files
perf(web): provider status pushes no longer re-render every timeline row
MessagesTimeline put the environment's provider list in TimelineRowCtx, so a providerStatuses push (only checkedAt changes) gave every row that reads the context a new value. Only subagent avatars, subagent tooltips and handoff rows use providers; they now read them from serverEnvironment.providersValueAtom at the leaf, and the avatar selects just displayName and iconUrl. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 2fbd431 commit d5c5684

4 files changed

Lines changed: 80 additions & 48 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5560,10 +5560,6 @@ export default function ChatView(props: ChatViewProps) {
55605560
const timelineSkills = activeProviderStatus
55615561
? resolveProviderSkillsForCwd(activeProviderStatus, gitCwd)
55625562
: EMPTY_PROVIDER_SKILLS;
5563-
const timelineProviders =
5564-
environmentById.get(
5565-
displayedThreadRef?.environmentId ?? activeThread?.environmentId ?? environmentId,
5566-
)?.serverConfig?.providers ?? EMPTY_PROVIDERS;
55675563
const threadFindControlsRef = useRef<ThreadFindControls | null>(null);
55685564
const [isThreadFindActive, setIsThreadFindActive] = useState(false);
55695565
const openThreadFind = () => threadFindControlsRef.current?.open();
@@ -8134,7 +8130,6 @@ export default function ChatView(props: ChatViewProps) {
81348130
}
81358131
listRef={legendListRef}
81368132
timelineEntries={displayedTimeline.entries}
8137-
providerStatuses={timelineProviders}
81388133
runs={paintOnlyDisplayedTimeline ? [] : (serverProjection?.runs ?? [])}
81398134
latestRun={paintOnlyDisplayedTimeline ? null : activeActivityRun}
81408135
runningRunId={paintOnlyDisplayedTimeline ? null : activeRunningTurnId}

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ function buildProps() {
404404
listRef: createRef<LegendListRef | null>(),
405405
latestRun: null,
406406
turnDiffSummaries: [],
407-
providerStatuses: [],
408407
runs: [],
409408
routeThreadKey: "environment-local:thread-1",
410409
onOpenTurnDiff: () => {},
@@ -1975,10 +1974,21 @@ describe("MessagesTimeline", () => {
19751974
} as never,
19761975
});
19771976

1978-
const markup = renderToStaticMarkup(
1977+
const { RegistryProvider } = await import("@effect/atom-react");
1978+
const { serverEnvironment } = await import("../../state/server");
1979+
const renderWithProviders = (element: ReactElement) =>
1980+
renderToStaticMarkup(
1981+
<RegistryProvider
1982+
initialValues={[
1983+
[serverEnvironment.providersValueAtom(ACTIVE_THREAD_ENVIRONMENT_ID), providerStatuses],
1984+
]}
1985+
>
1986+
{element}
1987+
</RegistryProvider>,
1988+
);
1989+
const markup = renderWithProviders(
19791990
<MessagesTimeline
19801991
{...buildProps()}
1981-
providerStatuses={providerStatuses}
19821992
timelineEntries={[
19831993
buildHandoffEntry({
19841994
fromProviderInstanceIds: ["codex_personal"],
@@ -2010,10 +2020,9 @@ describe("MessagesTimeline", () => {
20102020
modelSelection: { instanceId: "claudeAgent", model: "claude-fable-5" },
20112021
},
20122022
] as never;
2013-
const legacyMarkup = renderToStaticMarkup(
2023+
const legacyMarkup = renderWithProviders(
20142024
<MessagesTimeline
20152025
{...buildProps()}
2016-
providerStatuses={providerStatuses}
20172026
runs={legacyRuns}
20182027
timelineEntries={[
20192028
buildHandoffEntry({
@@ -2028,10 +2037,9 @@ describe("MessagesTimeline", () => {
20282037
expect(legacyMarkup).toContain("Claude Fable 5");
20292038
expect(legacyMarkup).not.toContain("Full conversation context");
20302039

2031-
const bareMarkup = renderToStaticMarkup(
2040+
const bareMarkup = renderWithProviders(
20322041
<MessagesTimeline
20332042
{...buildProps()}
2034-
providerStatuses={providerStatuses}
20352043
timelineEntries={[
20362044
buildHandoffEntry({
20372045
fromProviderInstanceIds: ["codex_personal"],

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

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
type OrchestrationV2TurnItem,
2929
type RunAttemptId,
3030
type ScopedThreadRef,
31-
type ServerProvider,
3231
type ServerProviderSkill,
3332
type RunId,
3433
ThreadId,
@@ -286,7 +285,7 @@ import { useV2ItemSupport } from "../../state/v2ItemSupport";
286285
import { Collapsible, CollapsibleTrigger, CollapsiblePanel } from "../ui/collapsible";
287286
import {
288287
isV2LifecycleItem,
289-
SubagentAvatar,
288+
EnvironmentSubagentAvatar,
290289
SubagentElapsed,
291290
SubagentNotificationLink,
292291
V2LifecycleRow,
@@ -315,7 +314,6 @@ interface TimelineRowSharedState {
315314
resolvedTheme: "light" | "dark";
316315
workspaceRoot: string | undefined;
317316
skills: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">>;
318-
providerStatuses: ReadonlyArray<ServerProvider>;
319317
runs: ReadonlyArray<HandoffTimelineRun>;
320318
activeThreadEnvironmentId: EnvironmentId;
321319
onRevertToTurnCount: (targetTurnCount: number, messageId: MessageId) => void;
@@ -493,7 +491,6 @@ interface MessagesTimelineProps {
493491
timestampFormat: TimestampFormat;
494492
workspaceRoot: string | undefined;
495493
skills?: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">>;
496-
providerStatuses: ReadonlyArray<ServerProvider>;
497494
runs: ReadonlyArray<HandoffTimelineRun>;
498495
anchorMessageId: MessageId | null;
499496
onAnchorReady: (messageId: MessageId, anchorIndex: number) => void;
@@ -589,7 +586,6 @@ const ConversationTimeline = memo(function ConversationTimeline({
589586
timestampFormat,
590587
workspaceRoot,
591588
skills = EMPTY_TIMELINE_SKILLS,
592-
providerStatuses,
593589
runs: runsProp,
594590
anchorMessageId,
595591
onAnchorReady,
@@ -1219,7 +1215,6 @@ const ConversationTimeline = memo(function ConversationTimeline({
12191215
resolvedTheme,
12201216
workspaceRoot,
12211217
skills,
1222-
providerStatuses,
12231218
runs,
12241219
activeThreadEnvironmentId,
12251220
onRevertToTurnCount,
@@ -2936,7 +2931,6 @@ function V2EventTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "event"
29362931
resourceSummary={row.resourceSummary}
29372932
createdAt={row.createdAt}
29382933
timestampFormat={ctx.timestampFormat}
2939-
providerStatuses={ctx.providerStatuses}
29402934
runs={ctx.runs}
29412935
onOpenThread={ctx.onOpenThread}
29422936
/>
@@ -3185,12 +3179,11 @@ const V2SubagentGroup = memo(function V2SubagentGroup({
31853179
>
31863180
<span className="flex shrink-0 items-center -space-x-1.5" aria-hidden>
31873181
{agents.slice(0, 3).map(({ item, status }) => (
3188-
<SubagentAvatar
3182+
<EnvironmentSubagentAvatar
31893183
key={item.id}
3184+
environmentId={ctx.activeThreadEnvironmentId}
3185+
providerInstanceId={item.providerInstanceId}
31903186
driver={item.driver}
3191-
provider={ctx.providerStatuses.find(
3192-
(provider) => provider.instanceId === item.providerInstanceId,
3193-
)}
31943187
status={agents.length === 1 ? status : undefined}
31953188
/>
31963189
))}
@@ -3233,7 +3226,6 @@ const V2SubagentGroup = memo(function V2SubagentGroup({
32333226
item={item}
32343227
createdAt={row.createdAt}
32353228
timestampFormat={ctx.timestampFormat}
3236-
providerStatuses={ctx.providerStatuses}
32373229
runs={ctx.runs}
32383230
onOpenThread={ctx.onOpenThread}
32393231
/>
@@ -5195,7 +5187,6 @@ const SimpleWorkEntryRow = memo(function SimpleWorkEntryRow(props: WorkEntryRowP
51955187
outcome={item.outcome}
51965188
createdAt={props.workEntry.createdAt}
51975189
timestampFormat={ctx.timestampFormat}
5198-
providerStatuses={ctx.providerStatuses}
51995190
onOpenThread={ctx.onOpenThread}
52005191
fallback={<WorkEntryLogRow {...props} />}
52015192
/>

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

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { SubagentTooltipContent } from "./SubagentTooltipContent";
77
import { useAtomValue } from "@effect/atom-react";
88
import { scopeThreadRef, scopeProjectRef } from "@t3tools/client-runtime/environment";
99
import { environmentThreadDetails } from "../../state/threads";
10+
import { EMPTY_SERVER_PROVIDERS, serverEnvironment } from "../../state/server";
1011
import { MiddleTruncate } from "../ui/middle-truncate";
1112
import * as DateTime from "effect/DateTime";
1213
import { WorkLogRow } from "./WorkLog";
@@ -72,7 +73,6 @@ export function V2LifecycleRow(props: {
7273
readonly resourceSummary?: boolean | undefined;
7374
readonly createdAt: string;
7475
readonly timestampFormat: TimestampFormat;
75-
readonly providerStatuses: ReadonlyArray<ServerProvider>;
7676
readonly runs: ReadonlyArray<HandoffTimelineRun>;
7777
readonly onOpenThread: (threadId: ThreadId) => void;
7878
}) {
@@ -125,9 +125,9 @@ export function V2LifecycleRow(props: {
125125
}
126126
if (item.type === "handoff") {
127127
return (
128-
<HandoffRow
128+
<EnvironmentHandoffRow
129+
environmentId={props.environmentId}
129130
endpoints={resolveHandoffEndpoints(item, props.runs)}
130-
providers={props.providerStatuses}
131131
failed={item.status === "failed"}
132132
/>
133133
);
@@ -192,10 +192,6 @@ export function V2LifecycleRow(props: {
192192
origin={item.origin}
193193
status={item.status}
194194
driver={item.driver}
195-
provider={props.providerStatuses.find(
196-
(provider) => provider.instanceId === item.providerInstanceId,
197-
)}
198-
providers={props.providerStatuses}
199195
title={formatSubagentDisplayTitle(item.title ?? "Subagent")}
200196
result={item.result}
201197
progress={item.progress}
@@ -253,14 +249,16 @@ export function SubagentElapsed({ agent }: { agent: Parameters<typeof AgentElaps
253249
return <AgentElapsed agent={agent} />;
254250
}
255251

256-
export function SubagentAvatar({
252+
function SubagentAvatar({
257253
driver,
258-
provider,
254+
displayName,
255+
iconUrl,
259256
status,
260257
className,
261258
}: {
262259
driver?: ProviderDriverKind | undefined;
263-
provider?: ServerProvider | undefined;
260+
displayName?: string | undefined;
261+
iconUrl?: string | undefined;
264262
status?: OrchestrationV2TurnItem["status"] | undefined;
265263
className?: string;
266264
}) {
@@ -275,8 +273,8 @@ export function SubagentAvatar({
275273
{driver ? (
276274
<ProviderInstanceIcon
277275
driverKind={driver}
278-
displayName={provider?.displayName ?? driver}
279-
acpRegistryIconUrl={provider?.iconUrl}
276+
displayName={displayName ?? driver}
277+
acpRegistryIconUrl={iconUrl}
280278
className="z-auto"
281279
iconClassName="size-3.5"
282280
/>
@@ -295,6 +293,35 @@ export function SubagentAvatar({
295293
);
296294
}
297295

296+
/**
297+
* Reads only the two provider fields the avatar draws. Provider status pushes
298+
* replace the provider objects (fresh `checkedAt`), so selecting strings keeps
299+
* the avatar from re-rendering when nothing it shows changed.
300+
*/
301+
export function EnvironmentSubagentAvatar({
302+
environmentId,
303+
providerInstanceId,
304+
...props
305+
}: {
306+
environmentId: EnvironmentId;
307+
providerInstanceId: ProviderInstanceId;
308+
driver?: ProviderDriverKind | undefined;
309+
status?: OrchestrationV2TurnItem["status"] | undefined;
310+
}) {
311+
const providersAtom = serverEnvironment.providersValueAtom(environmentId);
312+
const displayName = useAtomValue(
313+
providersAtom,
314+
(providers) =>
315+
providers?.find((provider) => provider.instanceId === providerInstanceId)?.displayName,
316+
);
317+
const iconUrl = useAtomValue(
318+
providersAtom,
319+
(providers) =>
320+
providers?.find((provider) => provider.instanceId === providerInstanceId)?.iconUrl,
321+
);
322+
return <SubagentAvatar {...props} displayName={displayName} iconUrl={iconUrl} />;
323+
}
324+
298325
const NOTIFICATION_OUTCOME_STATUS: Record<
299326
OrchestrationV2Notification["outcome"],
300327
OrchestrationV2TurnItem["status"] | null
@@ -320,7 +347,6 @@ export function SubagentNotificationLink(props: {
320347
readonly outcome: OrchestrationV2Notification["outcome"];
321348
readonly createdAt: string;
322349
readonly timestampFormat: TimestampFormat;
323-
readonly providerStatuses: ReadonlyArray<ServerProvider>;
324350
readonly onOpenThread: (threadId: ThreadId) => void;
325351
readonly fallback: ReactNode;
326352
}) {
@@ -339,10 +365,6 @@ export function SubagentNotificationLink(props: {
339365
origin={agent.origin}
340366
status={agent.status}
341367
driver={agent.driver}
342-
provider={props.providerStatuses.find(
343-
(provider) => provider.instanceId === agent.providerInstanceId,
344-
)}
345-
providers={props.providerStatuses}
346368
title={formatSubagentDisplayTitle(agent.title ?? "Subagent")}
347369
result={agent.result}
348370
progress={agent.progress}
@@ -365,8 +387,6 @@ function SubagentTimelineLink(props: {
365387
readonly providerInstanceId: ProviderInstanceId;
366388
readonly origin: OrchestrationV2Subagent["origin"];
367389
readonly driver: ProviderDriverKind;
368-
readonly provider: ServerProvider | undefined;
369-
readonly providers: ReadonlyArray<ServerProvider>;
370390
readonly title: string;
371391
readonly result: string | null;
372392
readonly progress: string | undefined;
@@ -403,9 +423,10 @@ function SubagentTimelineLink(props: {
403423
};
404424
const content = (
405425
<>
406-
<SubagentAvatar
426+
<EnvironmentSubagentAvatar
427+
environmentId={props.parentRef.environmentId}
428+
providerInstanceId={props.providerInstanceId}
407429
driver={props.driver}
408-
provider={props.provider}
409430
status={status ?? undefined}
410431
/>
411432
<span className="min-w-0 flex-1">
@@ -501,6 +522,10 @@ function SubagentTimelineTooltip(
501522
},
502523
) {
503524
const environmentId = props.parentRef.environmentId;
525+
// The popup only mounts while open, so the full provider list is read here
526+
// instead of in every timeline row.
527+
const providers =
528+
useAtomValue(serverEnvironment.providersValueAtom(environmentId)) ?? EMPTY_SERVER_PROVIDERS;
504529
const parent = useThreadShell(props.parentRef)?.source;
505530
const child = useThreadShell(
506531
props.threadId ? scopeThreadRef(environmentId, props.threadId) : null,
@@ -516,8 +541,8 @@ function SubagentTimelineTooltip(
516541
providerInstanceId={props.providerInstanceId}
517542
origin={props.origin}
518543
modelSelection={props.modelSelection}
519-
provider={props.provider}
520-
providers={props.providers}
544+
provider={providers.find((provider) => provider.instanceId === props.providerInstanceId)}
545+
providers={providers}
521546
driver={props.driver}
522547
elapsed={props.elapsed}
523548
status={props.status}
@@ -531,6 +556,19 @@ function SubagentTimelineTooltip(
531556
);
532557
}
533558

559+
function EnvironmentHandoffRow({
560+
environmentId,
561+
...props
562+
}: {
563+
readonly environmentId: EnvironmentId;
564+
readonly endpoints: HandoffEndpoints;
565+
readonly failed: boolean;
566+
}) {
567+
const providers =
568+
useAtomValue(serverEnvironment.providersValueAtom(environmentId)) ?? EMPTY_SERVER_PROVIDERS;
569+
return <HandoffRow {...props} providers={providers} />;
570+
}
571+
534572
export function HandoffRow(props: {
535573
readonly endpoints: HandoffEndpoints;
536574
readonly providers: ReadonlyArray<ServerProvider>;

0 commit comments

Comments
 (0)