@@ -35,19 +35,37 @@ vi.mock(import("@tanstack/react-router"), async (original) => ({ |
35 | 35 | vi.mock(import("../../state/entities"), async (original) => ({ |
36 | 36 | ...(await original()), |
37 | 37 | useThreadShells: (() => state.shells) as never, |
| 38 | + // Only the viewed thread is loaded; agent rows and previews that read a child thread find it |
| 39 | + // unloaded, as before its subscription delivers. |
38 | 40 | useThreadProjection: ((ref: ScopedThreadRef | null) => |
39 | 41 | ref === null |
40 | 42 | ? undefined |
41 | | - : { |
42 | | - projection: state.projections |
43 | | - ? state.projections.get(scopedThreadKey(ref)) |
44 | | - : state.projection, |
45 | | - }) as never, |
| 43 | + : state.projections |
| 44 | + ? { projection: state.projections.get(scopedThreadKey(ref)) } |
| 45 | + : (state.projection as { thread?: { id?: string } } | null)?.thread?.id === ref.threadId |
| 46 | + ? { projection: state.projection } |
| 47 | + : null) as never, |
46 | 48 | useThreadRelationshipShells: ((ref: { readonly environmentId: string }) => |
47 | 49 | (state.shells as ReadonlyArray<{ readonly environmentId: string; readonly source: unknown }>) |
48 | 50 | .filter((shell) => shell.environmentId === ref.environmentId) |
49 | 51 | .map((shell) => shell.source)) as never, |
50 | 52 | useProjects: (() => state.projects) as never, |
| 53 | + // Agent previews compare an agent's workspace with its owner's. |
| 54 | + useThreadShell: ((ref: ScopedThreadRef | null) => { |
| 55 | + if (ref === null) return null; |
| 56 | + const viewed = (state.projection as { thread?: { id?: string } } | null)?.thread; |
| 57 | + const source = |
| 58 | + (state.shells as ReadonlyArray<{ readonly source: { readonly id?: string } }>).find( |
| 59 | + (shell) => shell.source.id === ref.threadId, |
| 60 | + )?.source ?? (viewed?.id === ref.threadId ? viewed : null); |
| 61 | + return source === null ? null : { ...source, environmentId: ref.environmentId, source }; |
| 62 | + }) as never, |
| 63 | + useProject: ((ref: { readonly environmentId: string; readonly projectId: string } | null) => |
| 64 | + ref === null |
| 65 | + ? null |
| 66 | + : ((state.projects as ReadonlyArray<{ id: string; environmentId: string }>).find( |
| 67 | + (project) => project.id === ref.projectId && project.environmentId === ref.environmentId, |
| 68 | + ) ?? null)) as never, |
51 | 69 | })); |
52 | 70 | vi.mock(import("../../state/environments"), async (original) => ({ |
53 | 71 | ...(await original()), |
@@ -106,6 +124,7 @@ vi.mock(import("../ui/preview-card"), async (original) => ({ |
106 | 124 | state.showTooltips ? <div role="tooltip">{children}</div> : null) as never, |
107 | 125 | })); |
108 | 126 |
|
| 127 | +import { STATUS_VISUALS } from "../AgentStatus"; |
109 | 128 | import { ThreadRelationshipsPanel } from "./ThreadRelationshipsControl"; |
110 | 129 |
|
111 | 130 | let root: Root; |
@@ -357,6 +376,7 @@ it("opens the correct chat for every workflow phase and unphased member", async |
357 | 376 | providerInstanceId: "claude-work", |
358 | 377 | childThreadId: "workflow-chat", |
359 | 378 | title: "Checkout review", |
| 379 | + prompt: "Review the checkout flow", |
360 | 380 | status: "running", |
361 | 381 | startedAt: null, |
362 | 382 | completedAt: null, |
@@ -372,6 +392,9 @@ it("opens the correct chat for every workflow phase and unphased member", async |
372 | 392 | lineage: { parentThreadId: "workflow-chat", relationshipToParent: "subagent" }, |
373 | 393 | status: "completed", |
374 | 394 | activityRunStatus: null, |
| 395 | + createdAt: DateTime.makeUnsafe("2026-09-21T12:00:00Z"), |
| 396 | + providerInstanceId: "claude-work", |
| 397 | + modelSelection: { instanceId: "claude-work", model: "claude-sonnet-4-6" }, |
375 | 398 | })); |
376 | 399 | state.shells = memberShells.map((source) => ({ environmentId: "other", source })); |
377 | 400 | const panel = ( |
@@ -410,7 +433,8 @@ it("opens the correct chat for every workflow phase and unphased member", async |
410 | 433 | }); |
411 | 434 | } |
412 | 435 | const rendered = textNodes("|"); |
413 | | - expect(rendered.match(/Sonnet · Work account/g)).toHaveLength(7); |
| 436 | + // Each member's preview names its account, then its model as the account's catalog does. |
| 437 | + expect(rendered.match(/Work account\| · \|Sonnet\|/g)).toHaveLength(7); |
414 | 438 | expect(rendered).not.toContain("Personal account"); |
415 | 439 | for (const phase of phases) expect(rendered).toContain(phase.title); |
416 | 440 | expect(rendered).not.toContain(" phases"); |
@@ -451,6 +475,7 @@ it("groups and counts a workflow by its run status instead of its coordinator ch |
451 | 475 | providerInstanceId: "claudeAgent", |
452 | 476 | childThreadId: "workflow-chat", |
453 | 477 | title: "Checkout review", |
| 478 | + prompt: "Review the checkout flow", |
454 | 479 | status: "running", |
455 | 480 | startedAt: DateTime.makeUnsafe("2026-09-21T12:00:00Z"), |
456 | 481 | progress: "Inspecting the checkout workflow", |
@@ -475,6 +500,7 @@ it("groups and counts a workflow by its run status instead of its coordinator ch |
475 | 500 | id: "workflow-chat", |
476 | 501 | title: "Coordinator chat", |
477 | 502 | createdAt: DateTime.makeUnsafe("2026-09-16T12:00:00Z"), |
| 503 | + modelSelection: { instanceId: "claudeAgent", model: "claude-opus-5-5" }, |
478 | 504 | lineage: { parentThreadId: "parent", relationshipToParent: "subagent" }, |
479 | 505 | status: "completed", |
480 | 506 | activityRunStatus: null, |
@@ -506,6 +532,8 @@ it("groups and counts a workflow by its run status instead of its coordinator ch |
506 | 532 | }, |
507 | 533 | ], |
508 | 534 | }; |
| 535 | + // A finished workflow's chat is no longer waiting on a follow-up. |
| 536 | + state.shells = [{ environmentId: "test", source: child }]; |
509 | 537 | await update(); |
510 | 538 | expect(heading()).toBe("Lineage"); |
511 | 539 | expect(text()).toContain("Previous agents"); |
@@ -763,6 +791,8 @@ it("keeps active supervisor status, progress, and task timing after its child tu |
763 | 791 | source: { |
764 | 792 | id: "child-1", |
765 | 793 | title: "Supervisor", |
| 794 | + modelSelection: { instanceId: "claudeAgent", model: "claude-opus-5-5" }, |
| 795 | + createdAt: DateTime.makeUnsafe("2026-09-16T12:00:00Z"), |
766 | 796 | status: "completed", |
767 | 797 | activityRunStatus: null, |
768 | 798 | latestRunId: "run-child-1", |
@@ -802,7 +832,7 @@ it("keeps active supervisor status, progress, and task timing after its child tu |
802 | 832 | }, |
803 | 833 | ], |
804 | 834 | }; |
805 | | - for (const status of ["pending", "running", "waiting"]) { |
| 835 | + for (const status of ["pending", "running", "waiting"] as const) { |
806 | 836 | state.projection = { |
807 | 837 | ...projection, |
808 | 838 | subagents: [{ ...projection.subagents[0], status }], |
@@ -817,8 +847,12 @@ it("keeps active supervisor status, progress, and task timing after its child tu |
817 | 847 | expect(heading()).toBe(status === "running" ? "Lineage · 1 running" : "Lineage"); |
818 | 848 | expect(textNodes(" ")).not.toContain("Previous agents"); |
819 | 849 | expect(buttons().some((button) => button.textContent?.includes("Supervisor"))).toBe(true); |
820 | | - const tooltip = container.querySelector('[role="tooltip"]')?.textContent; |
821 | | - expect.soft(tooltip).toContain(status); |
| 850 | + // The panel header's "Open in Agents panel" button has its own tooltip. |
| 851 | + const tooltip = Array.from( |
| 852 | + container.querySelectorAll('[role="tooltip"]'), |
| 853 | + (node) => node.textContent, |
| 854 | + ).find((content) => content?.includes("Supervisor")); |
| 855 | + expect.soft(tooltip).toContain(STATUS_VISUALS[status].label); |
822 | 856 | expect.soft(tooltip).toContain("Waiting for the worker to finish"); |
823 | 857 | expect.soft(tooltip).toContain("5m 15s"); |
824 | 858 | } |
@@ -931,27 +965,24 @@ it("shows readable models and only differing workspace details in agent tooltips |
931 | 965 | expect(text()).not.toContain("Worktree"); |
932 | 966 | expect(text()).not.toContain("Workspace"); |
933 | 967 |
|
934 | | - for (const [model, expected] of [ |
935 | | - [null, "Not reported"], |
936 | | - ["", "Not reported"], |
937 | | - [" ", "Not reported"], |
938 | | - ["model-alias", "My GPT"], |
939 | | - ["gpt-5.5", "GPT-5.5"], |
940 | | - ["custom/model-v1", "custom/model-v1"], |
| 968 | + // An agent that reports no model is named by its own thread's model, which carries its effort. |
| 969 | + for (const [model, expected, effort] of [ |
| 970 | + [null, "My GPT", true], |
| 971 | + ["", "My GPT", true], |
| 972 | + [" ", "My GPT", true], |
| 973 | + ["model-alias", "My GPT", true], |
| 974 | + ["gpt-5.5", "GPT-5.5", false], |
| 975 | + ["custom/model-v1", "custom/model-v1", false], |
941 | 976 | ] as const) { |
942 | 977 | state.projection = { |
943 | 978 | ...projection, |
944 | 979 | subagents: [{ ...projection.subagents[0], model }], |
945 | 980 | }; |
946 | 981 | await update(); |
947 | | - expect(text()).toContain(expected); |
948 | | - if (!model?.trim() || model === "gpt-5.5" || model === "custom/model-v1") { |
949 | | - expect(text()).not.toContain(" · high"); |
950 | | - } else { |
951 | | - expect(text()).toContain(`${expected} · high`); |
952 | | - } |
| 982 | + expect(text()).toContain(effort ? `${expected} · high` : expected); |
| 983 | + if (!effort) expect(text()).not.toContain(" · high"); |
953 | 984 | expect(text()).not.toContain("Unknown"); |
954 | | - if (!model?.trim()) expect(text()).not.toContain("My GPT"); |
| 985 | + expect(text()).not.toContain("Not reported"); |
955 | 986 | } |
956 | 987 |
|
957 | 988 | for (const driver of [ |
@@ -969,8 +1000,8 @@ it("shows readable models and only differing workspace details in agent tooltips |
969 | 1000 | subagents: [{ ...projection.subagents[0], driver, model: null }], |
970 | 1001 | }; |
971 | 1002 | await update(); |
972 | | - expect(text()).toContain("Not reported"); |
973 | | - expect(text()).not.toContain("My GPT"); |
| 1003 | + expect(text()).toContain("My GPT"); |
| 1004 | + expect(text()).not.toContain("Not reported"); |
974 | 1005 | } |
975 | 1006 |
|
976 | 1007 | state.projection = projection; |
@@ -1093,8 +1124,8 @@ it("shows readable models and only differing workspace details in agent tooltips |
1093 | 1124 | { id: "serviceTier", value: "priority" }, |
1094 | 1125 | ]; |
1095 | 1126 | await rerender(); |
1096 | | - expect(text(true)).toContain("My GPT · Work account · high"); |
1097 | | - expect(text()).toContain("My GPT · Work account · Fast mode onhigh"); |
| 1127 | + expect(text(true)).toContain("Work account · My GPT · high"); |
| 1128 | + expect(text()).toContain("Work account · My GPT · Fast mode onhigh"); |
1098 | 1129 | expect(text()).not.toContain("Personal account"); |
1099 | 1130 | state.projection = nativeProjection; |
1100 | 1131 | await update(); |
@@ -1131,7 +1162,7 @@ it("shows readable models and only differing workspace details in agent tooltips |
1131 | 1162 | if (status === "completed") { |
1132 | 1163 | await click(sectionToggle(false)); |
1133 | 1164 | } |
1134 | | - expect(text()).toContain("My GPT · Work account · Ultrafast mode onlow"); |
| 1165 | + expect(text()).toContain("Work account · My GPT · Ultrafast mode onlow"); |
1135 | 1166 | expect(text()).not.toContain(" · high"); |
1136 | 1167 | } |
1137 | 1168 | await click(sectionToggle(true)); |
@@ -1184,8 +1215,11 @@ it("shows readable models and only differing workspace details in agent tooltips |
1184 | 1215 | await click(sectionToggle(false)); |
1185 | 1216 | expect(text()).toContain("Final checks passed."); |
1186 | 1217 | expect(text()).not.toContain("Stale progress"); |
1187 | | - expect(text()).not.toContain("Hidden tail"); |
1188 | | - expect(text()).not.toContain(result); |
| 1218 | + // The preview clamps a long outcome to a few lines rather than cutting its text. |
| 1219 | + const outcome = [...container.querySelectorAll("p")].find((node) => |
| 1220 | + node.textContent?.startsWith("Final checks passed."), |
| 1221 | + ); |
| 1222 | + expect(outcome?.classList.contains("line-clamp-3")).toBe(true); |
1189 | 1223 | state.projection = projection; |
1190 | 1224 |
|
1191 | 1225 | child.worktreePath = "/main/worktrees/checker"; |
|