Skip to content

Commit 1b63f99

Browse files
authored
fix(web): show current Fast mode in subagent lineage (#45314)
1 parent be0e8a5 commit 1b63f99

2 files changed

Lines changed: 112 additions & 10 deletions

File tree

‎apps/web/src/components/chat/ThreadRelationshipsControl.browser.test.tsx‎

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import "~/index.css";
22
import * as DateTime from "effect/DateTime";
3-
import { EnvironmentId, NodeId, ThreadId } from "@t3tools/contracts";
3+
import {
4+
EnvironmentId,
5+
NodeId,
6+
ProviderDriverKind,
7+
ProviderInstanceId,
8+
ThreadId,
9+
type OrchestrationV2ThreadProjection,
10+
type ServerProvider,
11+
} from "@t3tools/contracts";
412
import * as Cause from "effect/Cause";
513
import { AsyncResult } from "effect/reactivity";
614
import { expect, it, vi } from "vite-plus/test";
@@ -12,6 +20,7 @@ const state = vi.hoisted(() => ({
1220
projection: null as unknown,
1321
commandSucceeds: false,
1422
relatedShells: [] as unknown[],
23+
providers: new Map<EnvironmentId, ReadonlyArray<ServerProvider>>(),
1524
threadTitles: {} as Record<string, string>,
1625
archivedThreads: [] as unknown[],
1726
}));
@@ -46,7 +55,7 @@ vi.mock(import("../../state/environments"), () => ({
4655
useEnvironments: (() => []) as never,
4756
usePrimaryEnvironment: (() => null) as never,
4857
useEnvironment: (() => null) as never,
49-
useEnvironmentProviders: (() => new Map()) as never,
58+
useEnvironmentProviders: () => state.providers,
5059
}));
5160
vi.mock(import("../../state/peerLinks"), () => ({
5261
peerLinkEnvironment: { readThread: {} } as never,
@@ -81,6 +90,7 @@ function setup() {
8190
useRightPanelStore.setState(useRightPanelStore.getInitialState());
8291
state.commandSucceeds = false;
8392
state.relatedShells = [];
93+
state.providers = new Map();
8494
state.threadTitles = { source: "Source" };
8595
state.archivedThreads = [];
8696
state.projection = {
@@ -303,6 +313,98 @@ it("shows a lineage thread's full title in its tooltip", async () => {
303313
);
304314
});
305315

316+
it("updates the lineage hover card when a delegated child changes Fast mode", async () => {
317+
setup();
318+
const projection = makeThreadProjectionFixture();
319+
const childId = ThreadId.make("opus-child");
320+
const instanceId = ProviderInstanceId.make("claudeAgent");
321+
const model = "claude-opus-5-5";
322+
const title = "Opus child";
323+
const selection = (fastMode: boolean) => ({
324+
instanceId,
325+
model,
326+
options: [{ id: "fastMode", value: fastMode }],
327+
});
328+
const provider: ServerProvider = {
329+
instanceId,
330+
driver: ProviderDriverKind.make("claudeAgent"),
331+
enabled: true,
332+
installed: true,
333+
version: null,
334+
status: "ready",
335+
auth: { status: "authenticated" },
336+
checkedAt: DateTime.formatIso(projection.thread.updatedAt),
337+
models: [
338+
{
339+
slug: model,
340+
name: "Opus 5.5",
341+
isCustom: false,
342+
capabilities: {
343+
optionDescriptors: [{ id: "fastMode", label: "Fast", type: "boolean" }],
344+
},
345+
},
346+
],
347+
slashCommands: [],
348+
skills: [],
349+
};
350+
state.providers.set(environmentId, [provider]);
351+
state.projection = {
352+
...projection,
353+
subagents: [
354+
{
355+
id: NodeId.make("agent"),
356+
threadId: projection.thread.id,
357+
runId: null,
358+
parentNodeId: NodeId.make("parent"),
359+
childThreadId: childId,
360+
providerThreadId: null,
361+
nativeTaskRef: null,
362+
prompt: "Inspect the change",
363+
title,
364+
origin: "app_owned",
365+
createdBy: "agent",
366+
status: "running",
367+
driver: provider.driver,
368+
providerInstanceId: instanceId,
369+
model,
370+
modelSelection: selection(false),
371+
result: null,
372+
startedAt: projection.thread.updatedAt,
373+
completedAt: null,
374+
updatedAt: projection.thread.updatedAt,
375+
},
376+
],
377+
} satisfies OrchestrationV2ThreadProjection;
378+
const childShell = (fastMode: boolean) => ({
379+
...projection.thread,
380+
id: childId,
381+
title,
382+
providerInstanceId: instanceId,
383+
modelSelection: selection(fastMode),
384+
lineage: { parentThreadId: projection.thread.id, relationshipToParent: "subagent" },
385+
});
386+
const panel = () => (
387+
<ThreadRelationshipsPanel
388+
environmentId={environmentId}
389+
threadId={projection.thread.id}
390+
showLineage
391+
showSideChats={false}
392+
/>
393+
);
394+
395+
state.relatedShells = [childShell(true)];
396+
await using screen = await render(panel());
397+
await userEvent.hover(screen.getByText(title, { exact: true }));
398+
const popup = page.getByText("Opus 5.5", { exact: true });
399+
const fast = page.getByText("Fast mode on", { exact: true });
400+
await expect.element(fast).toBeInTheDocument();
401+
402+
state.relatedShells = [childShell(false)];
403+
await screen.rerender(panel());
404+
await expect.element(popup).toBeVisible();
405+
await expect.element(fast).not.toBeInTheDocument();
406+
});
407+
306408
it("shows a side chat's full title in its tooltip", async () => {
307409
setup();
308410
const longTitle = "Side chat question with a title that the side chat row truncates";

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -849,11 +849,11 @@ export function ThreadRelationshipsPanel(props: {
849849
threadId,
850850
isSubagent,
851851
});
852-
const provider = providers?.find(
853-
(entry) =>
854-
entry.instanceId === (agent?.providerInstanceId ?? node?.thread?.providerInstanceId),
855-
);
856-
const providerDriver = agent?.driver ?? provider?.driver;
852+
const childSelection = agent?.origin === "app_owned" ? node?.thread?.modelSelection : undefined;
853+
const providerInstanceId =
854+
childSelection?.instanceId ?? agent?.providerInstanceId ?? node?.thread?.providerInstanceId;
855+
const provider = providers?.find((entry) => entry.instanceId === providerInstanceId);
856+
const providerDriver = provider?.driver ?? agent?.driver;
857857
const canStopWorkflow =
858858
canOperateWorkflow &&
859859
workflowGroup?.workflow.status === "running" &&
@@ -873,10 +873,10 @@ export function ThreadRelationshipsPanel(props: {
873873
const relationshipTooltip = agent ? (
874874
<SubagentTooltipContent
875875
title={threadTitle}
876-
model={agent.model}
877-
providerInstanceId={agent.providerInstanceId}
876+
model={childSelection?.model ?? agent.model}
877+
providerInstanceId={childSelection?.instanceId ?? agent.providerInstanceId}
878878
origin={agent.origin}
879-
modelSelection={agent.modelSelection}
879+
modelSelection={childSelection ?? agent.modelSelection}
880880
provider={provider}
881881
providers={providers}
882882
driver={providerDriver}

0 commit comments

Comments
 (0)