Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: calibrate goal-fidelity review for nested summary disclosure

[._.]/ Adam Eivy8f4fc1a4b118
diff --git a/server/services/codeReview.js b/server/services/codeReview.js
index fa11cf4f32..f14f1c8743 100644
--- a/server/services/codeReview.js
+++ b/server/services/codeReview.js
@@ -540,6 +540,12 @@ For an objective to align a default process manifest with production startup and
Before choosing a verdict, independently trace each requested outcome through the production changes. Diff context lines (leading space) survive unchanged; only lines prefixed "-" are removed. Assertions describe intended behavior, never override a contradictory implementation, and do not prove a test passed. If any production entry or branch still performs behavior the objective asks to remove, name that retained behavior in missing and return fix-first or rethink. Seed/config-only changes do not establish repair of existing records unless the diff shows how existing records consume them. Conversely, matching runtime and seed changes with fresh/legacy registry tests can establish expected-process behavior without a separate UI edit or assertion.
+For completed-card summary disclosure objectives, judge the following conditions IN THE ACTUAL DIFF; these examples are not claims that those conditions are present. Reconstruct the after-change tree using only added (+) and retained (space) hunk lines; discard deleted (-) lines. In a relocation, the deleted old summary outside the panel is NOT a surviving summary.
+1. Find the enclosing production JSX condition around the ADDED summary. A retained \` {expanded && (\` hides ALL its descendants when expanded=false. The inner taskSummary condition inherits that enclosing guard and does NOT need a second expanded check. A retained \` {true && (\` instead renders unconditionally: return fix-first, missing: ["summary remains visible while collapsed"]. Comments and tests cannot supply a missing outer guard.
+2. Find the production condition around the transcript. With \`transcriptExpanded\` initialized to false, \`(!taskSummary || transcriptExpanded)\` suppresses the transcript while a summary exists, until the separate control toggles transcriptExpanded. An unconditional transcript condition instead leaves a duplicate after Show: return fix-first, missing: ["transcript duplicates the summary before its separate disclosure"]. State variables and buttons alone cannot supply this render guard.
+3. If BOTH production guards above and the control transition are actually present, the nested summary is hidden while collapsed, renders once after Show, and may repeat only after explicitly opening the full transcript. Those are delivered disclosure requirements, even if the same summary text occurs in raw transcript data. Matching local/remote interaction assertions are verification coverage, not proof that tests ran or passed.
+Check production conditions before considering the tests. A test-only diff lacks the production evidence needed to establish these disclosure requirements: return fix-first or rethink, never ship. Likewise positive tests cannot override a broken production guard. Do not infer guards outside the supplied diff. This interpretation covers only avoiding duplication BEFORE the separate transcript action; do not waive an objective that explicitly forbids summary repetition even after opening the full transcript. For the complete guarded shape with no other missing/unrequested requirement, return ship with empty lists. For an incomplete shape, name its violated disclosure instead.
+
Answer these three questions and nothing else: is anything the objective asked for missing from the diff, is anything in the diff outside what the objective asked for, and does the diff carry real evidence that its work was verified (tests, checks, a stated verification step).
Return exactly one JSON object and no markdown:
diff --git a/server/services/codeReview.test.js b/server/services/codeReview.test.js
index 265cc6838d..155958ed44 100644
--- a/server/services/codeReview.test.js
+++ b/server/services/codeReview.test.js
@@ -85,6 +85,15 @@ const launchMusicCases = [
['service readiness guard removed', launchMusicCase.diff.replace(/^(\+For the service method only:.*)$/m, line => line.replace('If none is ready, report the setup requirement and stop.', 'If none is ready, continue anyway with the unready engine.')), 'fix-first'],
]
+// Complete production + interaction-test diff from the overturned JSX finding.
+const summaryDisclosureCase = JSON.parse(readFileSync(new URL('../test/fixtures/goal-fidelity-summary-disclosure.json', import.meta.url), 'utf8'))
+const summaryDisclosureCases = [
+ ['nested summary and separately disclosed transcript', summaryDisclosureCase.diff, 'ship'],
+ ['summary visible while collapsed', summaryDisclosureCase.diff.replace(' {expanded && (', ' {true && ('), 'fix-first'],
+ ['duplicate transcript visible after Show', summaryDisclosureCase.diff.replace('+ {(!taskSummary || transcriptExpanded) && <>', '+ {true && <>'), 'fix-first'],
+ ['interaction tests without production changes', summaryDisclosureCase.diff.split(/(?=^diff --git )/m).find(part => part.startsWith('diff --git a/client/src/components/cos/tabs/AgentCard.test.jsx')), 'rethink'],
+]
+
// Minimal stand-ins for the deps resolveReviewLoopOptions is handed by its
// callers (agentCliSpawning / agentCompletionCleanup) — kept trivial so the
// test exercises the resolver's own model-map assembly, not validation.js.
@@ -1109,6 +1118,48 @@ describe('codeReview helpers', () => {
else expect(['fix-first', 'rethink'], JSON.stringify(result)).toContain(result.verdict)
}, 190_000)
+ it('sends the nested JSX disclosure calibration and its narrow exclusions with the full PR evidence', async () => {
+ global.fetch = vi.fn(async (_url, init) => {
+ const { messages } = JSON.parse(init.body)
+ const rubric = messages[0].content
+ expect(rubric).toContain('conditions IN THE ACTUAL DIFF')
+ expect(rubric).toContain('inherits that enclosing guard')
+ expect(rubric).toContain('these examples are not claims that those conditions are present')
+ expect(rubric).toContain('does NOT need a second expanded check')
+ expect(rubric).toContain('initialized to false')
+ expect(rubric).toContain('may repeat only after explicitly opening the full transcript')
+ expect(rubric).toContain('positive tests cannot override a broken production guard')
+ expect(rubric).toContain('test-only diff lacks the production evidence')
+ expect(rubric).toContain('explicitly forbids summary repetition even after opening the full transcript')
+ expect(rubric).toContain('not proof that tests ran or passed')
+ expect(messages[1].content).toContain(summaryDisclosureCase.objective)
+ expect(messages[1].content).toContain(summaryDisclosureCase.diff.trim())
+ return completion(shipVerdict)
+ })
+ // Transport contract only. Real judgement (including negative controls)
+ // is exercised by the opt-in local-model regression below.
+ expect(await runLocalGoalFidelityReview({ backend: 'ollama', model: 'example-model', ...summaryDisclosureCase }))
+ .toMatchObject({ ok: true, verdict: 'ship', missing: [], unrequested: [] })
+ expect(global.fetch).toHaveBeenCalledTimes(1)
+ })
+
+ // Real judgement regression: no mocked oracle; also reject deliberately broken
+ // guards even though the original positive interaction assertions remain.
+ it.runIf(Boolean(process.env.GOAL_FIDELITY_EVAL_MODEL)).each(summaryDisclosureCases)('judges summary disclosure with a real local model: %s', async (name, diff, expected) => {
+ global.fetch = nativeFetch
+ const result = await runLocalGoalFidelityReview({
+ backend: 'ollama', model: process.env.GOAL_FIDELITY_EVAL_MODEL,
+ objective: summaryDisclosureCase.objective, diff, timeoutMs: 180_000,
+ })
+ console.log(`🔍 Summary disclosure evaluation ${name}: ${result.verdict}; ${result.evidence || result.error}`)
+ expect(result.ok, result.error).toBe(true)
+ if (expected === 'ship') expect(result).toMatchObject({ verdict: 'ship', missing: [], unrequested: [] })
+ else {
+ expect(['fix-first', 'rethink'], JSON.stringify(result)).toContain(result.verdict)
+ expect(result.missing.length).toBeGreaterThan(0)
+ }
+ }, 190_000)
+
// A primary ship must not override contradictory surviving code.
const incompleteRemoval = [
'diff --git a/seed.json b/seed.json',
diff --git a/server/test/fixtures/goal-fidelity-summary-disclosure.json b/server/test/fixtures/goal-fidelity-summary-disclosure.json
new file mode 100644
index 0000000000..6b037d0a93
--- /dev/null
+++ b/server/test/fixtures/goal-fidelity-summary-disclosure.json
@@ -0,0 +1,5 @@
+{
+ "source": "Reconstructed requirement and complete diff from PR #9365, reviewed head d8c0fe765b330e463a1f3d066da989a920d0f3d0. All example records in the diff are synthetic test data.",
+ "objective": "Completed agent cards show the task summary before I click Show, and after Show the same summary appears again in the transcript. Keep the summary hidden until Show, show it once when expanded, and put the full transcript behind a separate explicit disclosure. Apply this to local and remote cards.",
+ "diff": "diff --git a/client/src/components/cos/tabs/AgentCard.jsx b/client/src/components/cos/tabs/AgentCard.jsx\nindex b96ae37c08..395de0a7b4 100644\n--- a/client/src/components/cos/tabs/AgentCard.jsx\n+++ b/client/src/components/cos/tabs/AgentCard.jsx\n@@ -403,6 +403,7 @@ function GoalFidelityFollowUp({ followUp }) {\n \n export default function AgentCard({ agent, onPause, onKill, onDelete, onResume, onRelaunch, completed, paused = false, liveOutput, durations, onFeedbackChange, remote, peerName, initiallyExpanded = false }) {\n const [expanded, setExpanded] = useState(initiallyExpanded);\n+ const [transcriptExpanded, setTranscriptExpanded] = useState(false);\n const [now, setNow] = useState(Date.now());\n // Every surface of this card that renders the agent's own prose resolves a\n // bare `#7640` against the run's tracker through the one resolver.\n@@ -621,6 +622,7 @@ export default function AgentCard({ agent, onPause, onKill, onDelete, onResume,\n ? (fullOutput?.lines || agent.output || [])\n : (liveOutput || agent.output || [])\n ), [inactive, fullOutput, liveOutput, agent.output]);\n+ const taskSummary = completed && (fullMetadata?.taskSummary ?? agent.metadata?.taskSummary);\n const lastOutput = output.length > 0 ? output[output.length - 1]?.line : null;\n \n // Why this run has NO \"Open Shell\" link. Scoped to the one case where the user\n@@ -1162,29 +1164,14 @@ export default function AgentCard({ agent, onPause, onKill, onDelete, onResume,\n <InvestigateFindingsButton key={agent.id} agent={agent} />\n )}\n \n- {completed && (agent.metadata?.taskSummary || agent.metadata?.malwareScan?.reportUrl) && (\n- <div className=\"mt-2 bg-port-bg/50 border border-port-border/50 rounded p-2.5\">\n- <div className=\"text-[11px] text-gray-500 mb-1 flex items-center gap-1\">\n- <Sparkles size={10} aria-hidden=\"true\" className=\"text-emerald-400\" />\n- Task Summary\n- </div>\n- {agent.metadata?.taskSummary && <MarkdownOutput content={fullMetadata?.taskSummary ?? agent.metadata.taskSummary} linkifyText={linkifyIssues} />}\n- {agent.metadata?.taskSummaryTruncated && !fullMetadata?.taskSummary && (\n- <p className=\"mt-1 text-xs text-port-text-muted\">\n- Summary preview. {!remote && <button type=\"button\" className=\"text-port-accent hover:underline\" disabled={loadingOutput}\n- onClick={() => { setFullOutput(null); setExpanded(true); }}>Load full summary</button>}\n- </p>\n- )}\n- {agent.metadata?.malwareScan?.reportUrl && (\n- <a\n- href={api.normalizeBrainScanReportPath(agent.metadata.malwareScan.reportUrl)}\n- className={`mt-2 inline-flex items-center gap-1 text-xs hover:underline ${agent.metadata.malwareScan.verdict === 'DANGEROUS' ? 'text-port-error' : 'text-port-accent'}`}\n- >\n- {agent.metadata.malwareScan.verdict === 'DANGEROUS' ? <Skull size={13} /> : <ExternalLink size={13} />}\n- View scan report{agent.metadata.malwareScan.verdict ? ` (${agent.metadata.malwareScan.verdict})` : ''}\n- </a>\n- )}\n- </div>\n+ {completed && agent.metadata?.malwareScan?.reportUrl && (\n+ <a\n+ href={api.normalizeBrainScanReportPath(agent.metadata.malwareScan.reportUrl)}\n+ className={`mt-2 inline-flex items-center gap-1 text-xs hover:underline ${agent.metadata.malwareScan.verdict === 'DANGEROUS' ? 'text-port-error' : 'text-port-accent'}`}\n+ >\n+ {agent.metadata.malwareScan.verdict === 'DANGEROUS' ? <Skull size={13} /> : <ExternalLink size={13} />}\n+ View scan report{agent.metadata.malwareScan.verdict ? ` (${agent.metadata.malwareScan.verdict})` : ''}\n+ </a>\n )}\n \n {/* Feedback section - shown for completed, manually-run, non-system local\n@@ -1295,89 +1282,114 @@ export default function AgentCard({ agent, onPause, onKill, onDelete, onResume,\n {/* Expanded output view */}\n {expanded && (\n <div className=\"border-t border-port-border bg-port-bg/50 p-3 min-w-0 overflow-y-auto max-h-dvh-cap [--dvh-cap:60dvh]\">\n- {/* Pipeline stage tabs */}\n- {pipelineStages && (\n- <div className=\"flex items-center gap-1 mb-2 overflow-x-auto\">\n- {pipelineStages.map((stage) => {\n- const isActive = activeStageTab === stage.index;\n- return (\n- <button\n- key={stage.index}\n- onClick={() => setActiveStageTab(stage.index)}\n- className={`flex items-center gap-1.5 px-2.5 py-1 text-xs rounded whitespace-nowrap transition-colors ${\n- isActive\n- ? 'bg-purple-500/20 text-purple-400'\n- : 'text-gray-500 hover:text-gray-300 hover:bg-port-border/30'\n- }`}\n- >\n- {stage.completed && (\n- <span className={stage.success ? 'text-port-success' : 'text-port-error'}>\n- {stage.success ? '\u25cf' : '\u2715'}\n- </span>\n- )}\n- {stage.isCurrent && !stage.completed && (\n- <span className=\"text-port-accent animate-pulse\">\u25cf</span>\n- )}\n- {!stage.isCurrent && !stage.completed && (\n- <span className=\"text-gray-600\">\u25cb</span>\n- )}\n- {stage.name}\n- </button>\n- );\n- })}\n+ {taskSummary && (\n+ <div className=\"mt-2 bg-port-bg/50 border border-port-border/50 rounded p-2.5\">\n+ <div className=\"text-[11px] text-gray-500 mb-1 flex items-center gap-1\">\n+ <Sparkles size={10} aria-hidden=\"true\" className=\"text-emerald-400\" />\n+ Task Summary\n+ </div>\n+ {taskSummary && <MarkdownOutput content={taskSummary} linkifyText={linkifyIssues} />}\n+ {agent.metadata?.taskSummaryTruncated && !fullMetadata?.taskSummary && (\n+ <p className=\"mt-1 text-xs text-port-text-muted\">\n+ Summary preview. {!remote && <button type=\"button\" className=\"text-port-accent hover:underline\" disabled={loadingOutput}\n+ onClick={() => { setFullOutput(null); setExpanded(true); }}>Load full summary</button>}\n+ </p>\n+ )}\n+\n </div>\n )}\n- {/* Output content: show stage-specific output for pipeline agents */}\n- {(() => {\n- // For pipeline agents viewing a prior stage\n- const activeStage = pipelineStages?.[activeStageTab];\n- if (activeStage && !activeStage.isCurrent && activeStage.agentId) {\n- const stageOut = stageOutputs[activeStage.agentId];\n- if (loadingStageId === activeStage.agentId) {\n+\n+ {taskSummary && (\n+ <button type=\"button\" className=\"mt-2 text-xs text-port-accent hover:underline\"\n+ aria-expanded={transcriptExpanded} onClick={() => setTranscriptExpanded(value => !value)}>\n+ {transcriptExpanded ? 'Hide full transcript' : 'Show full transcript'}\n+ </button>\n+ )}\n+ {(!taskSummary || transcriptExpanded) && <>\n+ {/* Pipeline stage tabs */}\n+ {pipelineStages && (\n+ <div className=\"flex items-center gap-1 mb-2 overflow-x-auto\">\n+ {pipelineStages.map((stage) => {\n+ const isActive = activeStageTab === stage.index;\n+ return (\n+ <button\n+ key={stage.index}\n+ onClick={() => setActiveStageTab(stage.index)}\n+ className={`flex items-center gap-1.5 px-2.5 py-1 text-xs rounded whitespace-nowrap transition-colors ${\n+ isActive\n+ ? 'bg-purple-500/20 text-purple-400'\n+ : 'text-gray-500 hover:text-gray-300 hover:bg-port-border/30'\n+ }`}\n+ >\n+ {stage.completed && (\n+ <span className={stage.success ? 'text-port-success' : 'text-port-error'}>\n+ {stage.success ? '\u25cf' : '\u2715'}\n+ </span>\n+ )}\n+ {stage.isCurrent && !stage.completed && (\n+ <span className=\"text-port-accent animate-pulse\">\u25cf</span>\n+ )}\n+ {!stage.isCurrent && !stage.completed && (\n+ <span className=\"text-gray-600\">\u25cb</span>\n+ )}\n+ {stage.name}\n+ </button>\n+ );\n+ })}\n+ </div>\n+ )}\n+ {/* Output content: show stage-specific output for pipeline agents */}\n+ {(() => {\n+ // For pipeline agents viewing a prior stage\n+ const activeStage = pipelineStages?.[activeStageTab];\n+ if (activeStage && !activeStage.isCurrent && activeStage.agentId) {\n+ const stageOut = stageOutputs[activeStage.agentId];\n+ if (loadingStageId === activeStage.agentId) {\n+ return (\n+ <div className=\"flex items-center gap-2 text-gray-500 text-sm\">\n+ <Loader2 size={14} aria-hidden=\"true\" className=\"animate-spin\" />\n+ Loading stage output...\n+ </div>\n+ );\n+ }\n+ // A truncated transcript whose tail window yielded no renderable\n+ // lines still has to say so \u2014 falling through to \"No output\n+ // captured\" would call a multi-MB log empty.\n+ if (stageOut?.lines.length > 0 || stageOut?.truncated) {\n+ return (\n+ <>\n+ <TranscriptTruncationNotice transcript={stageOut} />\n+ {stageOut.lines.length > 0 && <OutputBlocks key={activeStage.agentId} output={stageOut.lines} linkifyText={linkifyIssues} />}\n+ </>\n+ );\n+ }\n+ return <div className=\"text-gray-500 text-sm\">No output captured for this stage</div>;\n+ }\n+ // For pipeline agents viewing a future stage (not yet run)\n+ if (activeStage && !activeStage.isCurrent && !activeStage.agentId) {\n+ return <div className=\"text-gray-500 text-sm\">This stage has not run yet</div>;\n+ }\n+ // Current stage or non-pipeline agent: existing behavior\n+ if (loadingOutput) {\n return (\n <div className=\"flex items-center gap-2 text-gray-500 text-sm\">\n <Loader2 size={14} aria-hidden=\"true\" className=\"animate-spin\" />\n- Loading stage output...\n+ Loading full output...\n </div>\n );\n }\n- // A truncated transcript whose tail window yielded no renderable\n- // lines still has to say so \u2014 falling through to \"No output\n- // captured\" would call a multi-MB log empty.\n- if (stageOut?.lines.length > 0 || stageOut?.truncated) {\n+ const truncated = inactive && fullOutput?.truncated;\n+ if (output.length > 0 || truncated) {\n return (\n <>\n- <TranscriptTruncationNotice transcript={stageOut} />\n- {stageOut.lines.length > 0 && <OutputBlocks key={activeStage.agentId} output={stageOut.lines} linkifyText={linkifyIssues} />}\n+ {truncated && <TranscriptTruncationNotice transcript={fullOutput} />}\n+ {output.length > 0 && <OutputBlocks output={output} linkifyText={linkifyIssues} />}\n </>\n );\n }\n- return <div className=\"text-gray-500 text-sm\">No output captured for this stage</div>;\n- }\n- // For pipeline agents viewing a future stage (not yet run)\n- if (activeStage && !activeStage.isCurrent && !activeStage.agentId) {\n- return <div className=\"text-gray-500 text-sm\">This stage has not run yet</div>;\n- }\n- // Current stage or non-pipeline agent: existing behavior\n- if (loadingOutput) {\n- return (\n- <div className=\"flex items-center gap-2 text-gray-500 text-sm\">\n- <Loader2 size={14} aria-hidden=\"true\" className=\"animate-spin\" />\n- Loading full output...\n- </div>\n- );\n- }\n- const truncated = inactive && fullOutput?.truncated;\n- if (output.length > 0 || truncated) {\n- return (\n- <>\n- {truncated && <TranscriptTruncationNotice transcript={fullOutput} />}\n- {output.length > 0 && <OutputBlocks output={output} linkifyText={linkifyIssues} />}\n- </>\n- );\n- }\n- return <div className=\"text-gray-500 text-sm\">No output captured</div>;\n- })()}\n+ return <div className=\"text-gray-500 text-sm\">No output captured</div>;\n+ })()}\n+ </>}\n </div>\n )}\n <Modal\ndiff --git a/client/src/components/cos/tabs/AgentCard.test.jsx b/client/src/components/cos/tabs/AgentCard.test.jsx\nindex b7cec93350..cd7fc265b4 100644\n--- a/client/src/components/cos/tabs/AgentCard.test.jsx\n+++ b/client/src/components/cos/tabs/AgentCard.test.jsx\n@@ -19,6 +19,7 @@ const socket = vi.hoisted(() => {\n vi.mock('../../../services/socket', () => ({ default: socket }));\n \n vi.mock('../../../services/api', () => ({\n+ normalizeBrainScanReportPath: path => path,\n submitCosAgentFeedback: vi.fn(),\n sendCosAgentBtw: vi.fn(),\n getCosAgent: vi.fn(),\n@@ -1174,7 +1175,8 @@ describe('AgentCard truncated task description', () => {\n // agent wrote in its own sentinel summary is followable from the card. The\n // pattern lives in lib/issueRefs.test.js \u2014 this pins the WIRING, the half that\n // silently regresses when a prop is dropped in a refactor.\n-it('links a task-summary issue reference at the tracker the run was stamped with', () => {\n+it('links a task-summary issue reference at the tracker the run was stamped with', async () => {\n+ api.getCosAgent.mockResolvedValue({ ...agent, output: [] });\n render(\n <MemoryRouter>\n <AgentCard\n@@ -1187,6 +1189,7 @@ it('links a task-summary issue reference at the tracker the run was stamped with\n />\n </MemoryRouter>\n );\n+ await userEvent.click(screen.getByRole('button', { name: 'Show', exact: true }));\n expect(screen.getByRole('link', { name: '#7640' }))\n .toHaveAttribute('href', 'https://github.com/atomantic/PortOS/issues/7640');\n });\n@@ -1204,9 +1207,9 @@ it('loads process stats only after opening an active agent with no output', asyn\n it('loads a clipped summary only when the reader asks for the detail', async () => {\n api.getCosAgent.mockResolvedValue({ ...agent, metadata: { ...agent.metadata, taskSummary: 'The full summary with its conclusion.' }, output: [] });\n render(<MemoryRouter><AgentCard agent={{ ...agent, metadata: { ...agent.metadata, taskSummary: 'The preview', taskSummaryTruncated: true } }} completed /></MemoryRouter>);\n- expect(screen.getByText('The preview')).toBeInTheDocument();\n+ expect(screen.queryByText('The preview')).not.toBeInTheDocument();\n expect(api.getCosAgent).not.toHaveBeenCalled();\n- await userEvent.click(screen.getByRole('button', { name: 'Load full summary' }));\n+ await userEvent.click(screen.getByRole('button', { name: 'Show', exact: true }));\n expect(await screen.findByText('The full summary with its conclusion.')).toBeInTheDocument();\n expect(screen.queryByText('Summary preview.')).not.toBeInTheDocument();\n });\n@@ -1271,3 +1274,59 @@ it('drops an outstanding stats response when collapsed and reads afresh on reope\n await act(async () => socket.receive('cos:agent:updated', { id: agent.id }));\n expect(screen.getByText('11.1%')).toBeInTheDocument();\n });\n+\n+\n+it.each([false, true])('keeps a completed summary behind Show and its duplicate transcript behind a separate disclosure (remote=%s)', async (remote) => {\n+ const summary = 'Completed the example task.';\n+ const record = { ...agent, metadata: { ...agent.metadata, taskSummary: summary }, output: [{ type: 'stdout', line: summary }] };\n+ api.getCosAgent.mockResolvedValue(record);\n+ render(<MemoryRouter><AgentCard agent={record} completed remote={remote} /></MemoryRouter>);\n+ expect(screen.queryByText(summary)).not.toBeInTheDocument();\n+ await userEvent.click(screen.getByRole('button', { name: 'Show', exact: true }));\n+ expect(await screen.findByText(summary)).toBeInTheDocument();\n+ await userEvent.click(screen.getByRole('button', { name: 'Show full transcript' }));\n+ expect(screen.getAllByText(summary)).toHaveLength(2);\n+ await userEvent.click(screen.getByRole('button', { name: 'Hide full transcript' }));\n+ expect(screen.getAllByText(summary)).toHaveLength(1);\n+ await userEvent.click(screen.getByRole('button', { name: 'Hide', exact: true }));\n+ expect(screen.queryByText(summary)).not.toBeInTheDocument();\n+});\n+\n+\n+it('retries a clipped summary after the expanded detail request fails', async () => {\n+ api.getCosAgent.mockRejectedValueOnce(new Error('Temporary failure'))\n+ .mockResolvedValueOnce({ ...agent, metadata: { ...agent.metadata, taskSummary: 'Recovered full summary.' }, output: [] });\n+ render(<MemoryRouter><AgentCard agent={{ ...agent, metadata: { ...agent.metadata, taskSummary: 'Clipped preview', taskSummaryTruncated: true } }} completed /></MemoryRouter>);\n+ await userEvent.click(screen.getByRole('button', { name: 'Show', exact: true }));\n+ const retry = await screen.findByRole('button', { name: 'Load full summary' });\n+ await waitFor(() => expect(retry).toBeEnabled());\n+ await userEvent.click(retry);\n+ expect(await screen.findByText('Recovered full summary.')).toBeInTheDocument();\n+ expect(api.getCosAgent).toHaveBeenCalledTimes(2);\n+});\n+\n+\n+it('keeps a dangerous scan report visible while the summary is collapsed', () => {\n+ render(<MemoryRouter><AgentCard agent={{ ...agent, metadata: {\n+ ...agent.metadata, taskSummary: 'Example scan summary',\n+ malwareScan: { verdict: 'DANGEROUS', reportUrl: '/example-report' },\n+ } }} completed /></MemoryRouter>);\n+ expect(screen.getByRole('link', { name: 'View scan report (DANGEROUS)' })).toHaveAttribute('href', '/example-report');\n+ expect(screen.queryByText('Example scan summary')).not.toBeInTheDocument();\n+});\n+\n+\n+it('loads prior pipeline stage output through the full transcript disclosure', async () => {\n+ const record = { ...agent, metadata: { ...agent.metadata, taskSummary: 'Pipeline complete', pipeline: {\n+ stages: [{ name: 'Plan' }, { name: 'Implement' }], currentStage: 1,\n+ stageResults: [{ stage: 0, agentId: 'prior-stage', success: true }],\n+ } }, output: [{ line: 'Implementation transcript' }] };\n+ api.getCosAgent.mockImplementation(async id => id === 'prior-stage'\n+ ? { output: [{ line: 'Prior planning transcript' }] } : record);\n+ render(<MemoryRouter><AgentCard agent={record} completed /></MemoryRouter>);\n+ await userEvent.click(screen.getByRole('button', { name: 'Show', exact: true }));\n+ await userEvent.click(screen.getByRole('button', { name: 'Show full transcript' }));\n+ expect(await screen.findByText('Implementation transcript')).toBeInTheDocument();\n+ await userEvent.click(screen.getByRole('button', { name: /Plan/ }));\n+ expect(await screen.findByText('Prior planning transcript')).toBeInTheDocument();\n+});\n"
+}