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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
{
"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 expose task summaries even before Show is selected; opening a card adds an extra summary copy.",
"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"
}