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: make CoS run outcomes and failure guidance visible

[._.]/ Adam Eivy6cc2e981cae9
diff --git a/client/src/components/cos/tabs/RunsTab.browser.test.js b/client/src/components/cos/tabs/RunsTab.browser.test.js
index da346dbb64..205c684b6e 100644
--- a/client/src/components/cos/tabs/RunsTab.browser.test.js
+++ b/client/src/components/cos/tabs/RunsTab.browser.test.js
@@ -10,6 +10,8 @@ import { resolveTestChrome } from '../../../../../scripts/lib/testChrome.js';
const auditCdp = process.env.PORTOS_AUDIT_CDP;
const chrome = resolveTestChrome();
+const failureReason = 'Example provider could not start after validating the configured connection and model.\nThe selected model is unavailable: https://example.invalid/' + 'model-segment-'.repeat(20);
+const suggestedFix = 'Open AI Services and choose an available model before resuming this run.';
// Happy DOM cannot expose hover-gated opacity or real touch geometry. Exercise
// the actual row actions and stylesheet, without calling the running instance.
@@ -51,11 +53,12 @@ describe.skipIf(!chrome && !auditCdp)('run actions without hover', () => {
providerName: 'Example provider', model: 'sample-model', prompt: 'Example running task',
startTime: '2026-01-01T12:00:00Z' };
const failed = { ...running, id: 'failed-example', success: false,
- prompt: 'Example failed task', error: 'Example failure', exitCode: 1 };
+ prompt: 'Example failed task', error: new URLSearchParams(location.search).has('failure') ? ${JSON.stringify(failureReason)} : 'Example failure', suggestedFix: ${JSON.stringify(suggestedFix)}, exitCode: 1 };
let stopped = false;
window.runsFixture = { loads: 0, stops: [] };
export async function getRuns() {
window.runsFixture.loads++;
+ if (new URLSearchParams(location.search).has('failure')) return { runs: [failed] };
return { runs: [stopped ? { ...running, success: false, exitCode: 143 } : running, failed] };
}
export function stopRun(id) {
@@ -141,6 +144,53 @@ describe.skipIf(!chrome && !auditCdp)('run actions without hover', () => {
})().finally(() => fixture?.close());
});
+ it('keeps complete failure guidance in narrow desktop containers without opening diagnostics', async () => {
+ await cdp.send('Emulation.setDeviceMetricsOverride', { width: 1440, height: 900, deviceScaleFactor: 1, mobile: false });
+ await cdp.send('Emulation.setTouchEmulationEnabled', { enabled: false });
+ const url = `${fixture.origin}runs-test?failure=1`;
+ await cdp.send('Page.navigate', { url });
+ await page.waitForURL(url, { timeout: 20000 });
+ await page.getByRole('alert').waitFor({ timeout: 20000 });
+ if (auditCdp) await page.evaluate(() => { window.name = 'portos-ui-quality-audit'; });
+
+ const guidance = page.getByRole('alert');
+ expect(await guidance.innerText()).toContain(failureReason);
+ expect(await guidance.innerText()).toContain(suggestedFix);
+ expect(await page.getByRole('button', { name: 'Collapse run details' }).count()).toBe(0);
+ for (const width of [240, 320, 480]) {
+ await page.evaluate(width => { document.getElementById('root').style.width = `${width}px`; }, width);
+ const geometry = await guidance.evaluate(el => {
+ const rect = el.getBoundingClientRect();
+ const text = el.querySelector('p');
+ const textRect = text.getBoundingClientRect();
+ return { x: rect.x, right: rect.right, width: rect.width,
+ textLeft: textRect.left, textRight: textRect.right,
+ scrollWidth: text.scrollWidth, clientWidth: text.clientWidth };
+ });
+ expect(geometry.width).toBeGreaterThan(0);
+ expect(geometry.x).toBeGreaterThanOrEqual(0);
+ expect(geometry.right).toBeLessThanOrEqual(width);
+ expect(geometry.textLeft).toBeGreaterThanOrEqual(geometry.x);
+ expect(geometry.textRight).toBeLessThanOrEqual(geometry.right);
+ expect(geometry.scrollWidth).toBeLessThanOrEqual(geometry.clientWidth + 1);
+ const actions = await page.getByTestId('run-row-failed-example').evaluate(row => {
+ const card = row.closest('[class*="bg-port-card"][class*="border-port-border"]');
+ const cardRect = card.getBoundingClientRect();
+ return [...row.querySelectorAll('button')].map(el => {
+ const rect = el.getBoundingClientRect();
+ return { label: el.getAttribute('aria-label'), left: rect.left - cardRect.left,
+ right: rect.right - cardRect.left, cardWidth: cardRect.width };
+ });
+ });
+ for (const action of actions) {
+ expect(action.left, action.label).toBeGreaterThanOrEqual(0);
+ expect(action.right, action.label).toBeLessThanOrEqual(action.cardWidth);
+ }
+ }
+ expect(page.url()).toBe(url);
+ expect(errors).toEqual([]);
+ }, 30000);
+
it.each([[360, 800, true], [768, 1024, true], [1440, 900, false]])(
'keeps row actions visible and reachable at %ix%i (touch=%s)', async (width, height, touch) => {
await cdp.send('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: 1, mobile: touch });
diff --git a/client/src/components/cos/tabs/RunsTab.deepLink.test.jsx b/client/src/components/cos/tabs/RunsTab.deepLink.test.jsx
index 13a3fe32fc..d79e8f123d 100644
--- a/client/src/components/cos/tabs/RunsTab.deepLink.test.jsx
+++ b/client/src/components/cos/tabs/RunsTab.deepLink.test.jsx
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
-import { fireEvent, render, screen } from '@testing-library/react';
+import { act, fireEvent, render, screen, within } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
const api = vi.hoisted(() => ({
@@ -60,6 +60,38 @@ describe('RunsTab ?run= deep link', () => {
expect(api.getRunPrompt).not.toHaveBeenCalled();
});
+ it('shows each execution state and complete failure guidance before optional diagnostics', async () => {
+ const error = 'The provider could not start after checking the configured connection and model.\nChoose an available model for this service.';
+ const suggestedFix = 'Open AI Services and reconnect the provider before resuming.';
+ api.getRuns.mockResolvedValue({ runs: [
+ { ...RUNS[0], id: 'failed', success: false, error, suggestedFix, exitCode: 1 },
+ { ...RUNS[0], id: 'running', success: null },
+ RUNS[1],
+ ] });
+ renderTab('/cos/runs');
+
+ expect(await screen.findByText(/Choose an available model for this service/)).toHaveTextContent(error.replace('\n', ' '));
+ expect(screen.getByText(/Open AI Services and reconnect/)).toBeVisible();
+ for (const [id, label] of [['failed', 'Failed'], ['running', 'Running'], ['run-b', 'Succeeded']]) {
+ expect(within(screen.getByTestId(`run-row-${id}`)).getByText(label)).toBeVisible();
+ }
+ expect(api.getRunPrompt).not.toHaveBeenCalled();
+ expect(api.getRunOutput).not.toHaveBeenCalled();
+
+ await act(async () => {
+ fireEvent.click(within(screen.getByTestId('run-row-failed')).getByRole('button', { name: 'Expand run details' }));
+ });
+ expect(await screen.findByText('full output for run-b')).toBeVisible();
+ expect(screen.getAllByText(/Choose an available model for this service/)).toHaveLength(1);
+ expect(screen.getAllByRole('button', { name: /View system logs/i })).toHaveLength(1);
+
+ await act(async () => {
+ fireEvent.click(within(screen.getByTestId('run-row-run-b')).getByRole('button', { name: 'Expand run details' }));
+ });
+ expect(screen.getAllByRole('button', { name: 'Resume run' })).toHaveLength(2);
+ expect(screen.queryByRole('button', { name: 'Continue Conversation' })).not.toBeInTheDocument();
+ });
+
it('renders a failed runs read as an error row with Retry, not "No AI runs yet"', async () => {
api.getRuns.mockRejectedValueOnce(new Error('runs 500'));
renderTab('/cos/runs');
diff --git a/client/src/components/cos/tabs/RunsTab.jsx b/client/src/components/cos/tabs/RunsTab.jsx
index eaad5b5e88..718aaa238b 100644
--- a/client/src/components/cos/tabs/RunsTab.jsx
+++ b/client/src/components/cos/tabs/RunsTab.jsx
@@ -1,6 +1,6 @@
import { useState, useEffect, useCallback, useRef } from 'react';
import { useNavigate, useSearchParams } from 'react-router';
-import { Trash2, RotateCcw, MessageSquarePlus, ScrollText, Square } from 'lucide-react';
+import { Trash2, RotateCcw, ScrollText, Square } from 'lucide-react';
import * as api from '../../../services/api';
import { formatTime, formatRuntime, formatBytes, formatDateTime } from '../../../utils/formatters';
import BrailleSpinner from '../../BrailleSpinner';
@@ -116,24 +116,6 @@ export default function RunsTab() {
expandRun(deepLinkRunId);
}, [deepLinkRunId, loading, runs, expandRun]);
- const handleContinue = (run) => {
- const details = expandedDetails[run.id] || {};
- navigate('/devtools/runner', {
- state: {
- continueFrom: {
- prompt: details.prompt || run.prompt,
- output: details.output || '',
- runId: run.id,
- providerId: run.providerId,
- providerName: run.providerName,
- model: run.model,
- workspacePath: run.workspacePath,
- workspaceName: run.workspaceName
- }
- }
- });
- };
-
const handleResume = async (run, e) => {
e.stopPropagation();
// Fetch details if not already loaded
@@ -274,8 +256,8 @@ export default function RunsTab() {
onKeyDown={onActivateKeyDown(() => toggleExpand(run.id))}
data-testid={`run-row-${run.id}`}
>
- <div className="flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4">
- <div className="flex items-center gap-3 flex-1 min-w-0">
+ <div className="flex flex-wrap items-center gap-2 sm:gap-4">
+ <div className="flex items-center gap-3 flex-1 basis-64 min-w-0">
<button
type="button"
className="text-gray-400 hover:text-white shrink-0"
@@ -309,23 +291,13 @@ export default function RunsTab() {
<div className="text-xs text-gray-500 font-mono truncate mt-1">
{run.prompt?.substring(0, 100)}{run.prompt?.length > 100 ? '...' : ''}
</div>
- {/* Show error preview for failed runs in collapsed view */}
- {run.success === false && expandedId !== run.id && (
- <div className="text-xs text-port-error/80 font-mono truncate mt-1">
- ⚠ {run.error
- ? (() => {
- const firstLine = run.error.split('\n')[0] || '';
- return `${firstLine.substring(0, 80)}${firstLine.length > 80 ? '...' : ''}`;
- })()
- : run.errorCategory && run.errorCategory !== 'unknown'
- ? `${run.errorCategory}: ${run.suggestedFix || 'See details'}`
- : `${getExitCodeInfo(run.exitCode).label}: ${getExitCodeInfo(run.exitCode).description}`}
- </div>
- )}
</div>
</div>
- <div className="flex items-center gap-3 pl-8 sm:pl-0">
- <span className={`w-2 h-2 rounded-full shrink-0 ${run.success ? 'bg-port-success' : run.success === false ? 'bg-port-error' : 'bg-port-warning'}`} />
+ <div className="flex flex-wrap items-center gap-3 min-w-0">
+ <span className="inline-flex items-center gap-1.5 text-sm text-gray-400 shrink-0">
+ <span aria-hidden="true" className={`w-2 h-2 rounded-full shrink-0 ${run.success ? 'bg-port-success' : run.success === false ? 'bg-port-error' : 'bg-port-warning'}`} />
+ {run.success ? 'Succeeded' : run.success === false ? 'Failed' : 'Running'}
+ </span>
<span className="text-sm text-gray-500 shrink-0">{formatTime(run.startTime)}</span>
{run.success === false && (
<button
@@ -372,6 +344,26 @@ export default function RunsTab() {
</div>
</div>
+ {/* Failure guidance stays visible; only execution diagnostics collapse. */}
+ {(run.error || run.success === false) && (() => {
+ const exitInfo = getExitCodeInfo(run.exitCode);
+ const hasExitCode = run.exitCode !== undefined && run.exitCode !== null && run.exitCode !== 0;
+ return (
+ <div className="px-3 pb-3 sm:px-4 sm:pb-4 min-w-0">
+ <Banner tone="error" size="md" title="Run failed" srLabel={false}>
+ <p className="whitespace-pre-wrap [overflow-wrap:anywhere]">
+ {run.error || (hasExitCode ? exitInfo.description : 'This run did not complete successfully.')}
+ </p>
+ {run.suggestedFix && (
+ <p className="mt-2 whitespace-pre-wrap [overflow-wrap:anywhere]">
+ <span className="font-medium">Suggested fix: </span>{run.suggestedFix}
+ </p>
+ )}
+ </Banner>
+ </div>
+ );
+ })()}
+
{/* Expanded Details */}
{expandedId === run.id && (
<div className="px-4 pb-4 bg-port-bg border-t border-port-border">
@@ -422,6 +414,12 @@ export default function RunsTab() {
</div>
</div>
)}
+ {run.errorCategory && run.errorCategory !== 'unknown' && (
+ <div>
+ <div className="text-xs text-gray-500 uppercase tracking-wide mb-1">Failure category</div>
+ <div className="text-gray-300 [overflow-wrap:anywhere]">{run.errorCategory}</div>
+ </div>
+ )}
{run.outputSize && (
<div>
<div className="text-xs text-gray-500 uppercase tracking-wide mb-1">Output Size</div>
@@ -430,6 +428,15 @@ export default function RunsTab() {
)}
</div>
+ {run.errorDetails && run.errorDetails !== run.error && (
+ <div>
+ <div className="text-xs text-gray-500 uppercase tracking-wide mb-2">Additional error details</div>
+ <pre className="text-xs text-port-error/80 font-mono whitespace-pre-wrap break-all">
+ {run.errorDetails}
+ </pre>
+ </div>
+ )}
+
{/* Prompt */}
<div>
<div className="text-xs text-gray-500 uppercase tracking-wide mb-2">Prompt</div>
@@ -453,79 +460,6 @@ export default function RunsTab() {
</div>
</div>
)}
-
- {/* Error - show for failed runs with error message OR exit code */}
- {(run.error || (run.success === false && run.exitCode !== 0)) && (() => {
- const exitInfo = getExitCodeInfo(run.exitCode);
- return (
- <div>
- <div className="text-xs text-gray-500 uppercase tracking-wide mb-2 flex items-center gap-2">
- Error
- {run.exitCode !== undefined && run.exitCode !== null && run.exitCode !== 0 && (
- <span className="text-port-error/70">(exit code: {run.exitCode})</span>
- )}
- {run.errorCategory && run.errorCategory !== 'unknown' ? (
- <span className="px-1.5 py-0.5 bg-port-error/20 text-port-error/80 rounded text-xs">
- {run.errorCategory}
- </span>
- ) : run.exitCode !== 0 && exitInfo.label !== 'Unknown' && (
- <span className="px-1.5 py-0.5 bg-port-error/20 text-port-error/80 rounded text-xs">
- {exitInfo.label}
- </span>
- )}
- </div>
- <Banner tone="error" size="md">
- <pre className="text-sm font-mono whitespace-pre-wrap break-all">
- {run.error || exitInfo.description}
- </pre>
- </Banner>
- {/* Show additional error details if available and different from error */}
- {run.errorDetails && run.errorDetails !== run.error && (
- <div role="status" className="mt-2 bg-port-error/5 border border-port-error/20 rounded-lg p-3">
- <div className="text-xs text-gray-500 mb-1">Additional Details</div>
- <pre className="text-xs text-port-error/80 font-mono whitespace-pre-wrap break-all">
- {run.errorDetails}
- </pre>
- </div>
- )}
- {/* Show suggested fix if available, or fallback to exit code info */}
- {(run.suggestedFix || (!run.error && exitInfo.description)) && (
- <Banner tone="warning" size="md" className="mt-2">
- <div className="text-xs font-medium mb-1">Suggested Fix</div>
- <div className="text-sm text-gray-300">
- {run.suggestedFix || 'Check the output above for specific error details. If the output is empty, the process may have been terminated before producing output.'}
- </div>
- </Banner>
- )}
- {/* Jump straight to the system logs for the full error context,
- for operators who don't know where the logs live. */}
- <div className="mt-3">
- <button
- onClick={() => setLogModalRun(run)}
- className="flex items-center gap-2 px-3 py-1.5 text-sm bg-port-card border border-port-border hover:border-port-accent text-gray-300 hover:text-white rounded-lg transition-colors"
- data-testid={`view-logs-expanded-${run.id}`}
- >
- <ScrollText size={14} />
- View System Logs
- </button>
- </div>
- </div>
- );
- })()}
-
- {/* Continue Button */}
- {run.success && expandedDetails[run.id]?.output && (
- <div className="flex justify-end pt-2">
- <button
- onClick={() => handleContinue(run)}
- className="flex items-center gap-2 px-4 py-2 bg-port-accent hover:bg-port-accent/80 text-white rounded-lg transition-colors"
- data-testid="continue-conversation-btn"
- >
- <MessageSquarePlus size={16} />
- Continue Conversation
- </button>
- </div>
- )}
</div>
</div>
)}