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

Reorganize the app Quality page around the score, chart, and breakdown

[._.]/ Adam Eivy1520ea7afd49
diff --git a/client/src/components/apps/AppQuality.jsx b/client/src/components/apps/AppQuality.jsx
index 16bd0812cf..834c0b3358 100644
--- a/client/src/components/apps/AppQuality.jsx
+++ b/client/src/components/apps/AppQuality.jsx
@@ -1,11 +1,20 @@
import AppQualityRunner from './AppQualityRunner';
import AppQualityHistory from './AppQualityHistory';
import AppQualityScheduleForm from './AppQualityScheduleForm';
-import { Fragment, useId, useState } from 'react';
+import { useId, useState } from 'react';
+import { CalendarClock, Play } from 'lucide-react';
import { Link, useSearchParams } from 'react-router';
import { formatDateShort } from '../../utils/formatters';
import { publishAppQualitySnapshot } from '../../services/apiApps';
import toast from '../ui/Toast';
+import InfoTooltip from '../ui/InfoTooltip';
+import OverflowMenu from '../ui/OverflowMenu';
+import Drawer from '../Drawer';
+import useDrawerTab from '../../hooks/useDrawerTab';
+
+// Run/schedule forms live in a slide-out keyed by ?qualityPanel so the page
+// itself stays a metrics view; the value is the drawer title.
+const PANELS = { run: 'Run quality checks', schedule: 'Weekly quality schedule' };
// The server refuses rather than fails when there is nothing to publish, so each
// `published: false` reason gets its own plain-language explanation.
@@ -26,6 +35,7 @@ export default function AppQuality({ app, detail = false }) {
const [publishing, setPublishing] = useState(false);
const [categorySort, setCategorySort] = useState('score');
const categorySortId = useId();
+ const [panel, setPanel] = useDrawerTab('qualityPanel', null, Object.keys(PANELS));
// User-initiated, so every outcome toasts (the wrapper is silent).
const publishSnapshot = async () => {
setPublishing(true);
@@ -40,12 +50,6 @@ export default function AppQuality({ app, detail = false }) {
toast(PUBLISH_SKIPPED[result?.reason] || 'Nothing to publish to .quality.json');
};
const quality = app.quality;
- const selectedCategory = quality?.categories?.find(category => category.id === params.get('qualityCheck'));
- const runnerLink = categoryId => {
- const next = new URLSearchParams(params);
- next.set('qualityCheck', categoryId);
- return { search: next.toString(), hash: '#quality-runner' };
- };
const score = quality?.score;
const sortedCategories = quality?.categories
? [...quality.categories].sort((a, b) => {
@@ -73,123 +77,145 @@ export default function AppQuality({ app, detail = false }) {
{label}{score != null && ` · ${quality.ratedCategories}/${quality.totalCategories} categories`}
</Link>
);
+ const panelLink = (name, categoryId) => {
+ const next = new URLSearchParams(params);
+ next.set('qualityPanel', name);
+ // Header actions open on the default selection; a row's Run preselects it.
+ if (categoryId) next.set('qualityCheck', categoryId);
+ else next.delete('qualityCheck');
+ return { search: next.toString() };
+ };
+ const menuItems = [
+ { id: 'runners', label: 'Scheduled audit runners', to: '/cos/schedule' },
+ { id: 'agents', label: 'View agents', to: '/cos/agents' },
+ ...(app.publishQualitySnapshot === true
+ ? [{ id: 'publish', label: publishing ? 'Publishing snapshot…' : 'Publish snapshot now', onSelect: publishSnapshot, disabled: publishing }]
+ : []),
+ ];
+ const federation = quality?.federation;
return (
- <AppQualityRunner key={app.id} app={app}>{runner => <section aria-label="App quality" className="bg-port-card border border-port-border rounded-lg p-4 space-y-3">
- <h3 className="font-semibold text-white">{label}</h3>
- <p className="text-xs text-gray-400">
- Assessments describe the code before fixes. The overall score is the equal-weight mean of broad, medium/high-confidence assessments from the last 30 days.
- {' '}{quality?.ratedCategories ?? 0}/{quality?.totalCategories ?? 0} categories contribute. Missing, partial, low-confidence and stale assessments are excluded, not counted as perfect.
- </p>
- <details className="text-xs text-gray-400">
- <summary className="cursor-pointer text-port-accent">How audit scores work</summary>
- <p className="mt-1">
- Scores are the auditing agent’s evidence-based assessment, not a calculation from the number of issues filed.
- {' '}90–100 means no material defect found after broad review; 70–89 means localized moderate debt;
- {' '}40–69 means significant recurring or widespread problems; 10–39 means severe defects in core workflows;
- {' '}0–9 means pervasive critical failure. A run with no findings can therefore score below 100.
- {' '}Worst severity 0/10 means no material finding was verified, not a perfect category score.
- {' '}Assessment details contain the agent’s stated rationale; coverage and confidence describe the strength of its evidence.
- </p>
- </details>
- {quality?.federation && (
- <p className="text-xs text-gray-400">
- Unified app score: newest assessment per category across this install and {quality.federation.available ?? 0} available sync peers with the same repository. Versions may differ.
- {' '}Peer evidence is fetched when viewed; offline peers do not contribute.
- {quality.federation.failed && ' Peer quality could not be loaded; the score may be incomplete.'}
- {quality.federation.unavailable > 0 && ` ${quality.federation.unavailable} peers unavailable or incompatible; the score may be incomplete.`}
- </p>
- )}
- {score == null && !quality?.unavailable && (
- <p className="text-sm text-gray-400">
- {hasAssessments
- ? 'Saved assessments do not currently qualify for an overall score. Check the category breakdown for coverage, confidence and age.'
- : 'No audit assessment has been saved. Completed maintenance tasks only supply a score when they return a valid quality report. Earlier runs are not scored retroactively; run a scheduled audit to collect an assessment.'}
- </p>
- )}
- <div className="flex flex-wrap items-center gap-2">
- <Link
- to="/cos/schedule"
- className="inline-flex items-center rounded border border-port-border bg-port-bg/60 px-2.5 py-1.5 text-xs font-medium text-gray-200 transition-colors hover:border-port-accent hover:text-white"
- >
- Scheduled audit runners
- </Link>
- <Link
- to="/cos/agents"
- className="inline-flex items-center rounded border border-port-border bg-port-bg/60 px-2.5 py-1.5 text-xs font-medium text-gray-200 transition-colors hover:border-port-accent hover:text-white"
- >
- View agents
- </Link>
- {app.publishQualitySnapshot === true && (
- <button
- type="button"
- onClick={publishSnapshot}
- disabled={publishing}
- className="inline-flex items-center rounded border border-port-accent bg-port-accent/15 px-2.5 py-1.5 text-xs font-medium text-port-accent transition-colors hover:bg-port-accent/25 disabled:opacity-40 disabled:cursor-not-allowed"
- >
- {publishing ? 'Publishing snapshot…' : 'Publish snapshot now'}
- </button>
- )}
+ <AppQualityRunner key={app.id} app={app}>{(runner, activeRuns) => <section aria-label="App quality" className="space-y-4">
+ <div className="bg-port-card border border-port-border rounded-lg p-4 flex flex-wrap items-center justify-between gap-3">
+ <div className="flex items-center gap-4 min-w-0">
+ <div className="text-4xl font-semibold tabular-nums text-white" aria-hidden="true">
+ {score ?? '—'}<span className="text-base font-normal text-gray-500">/100</span>
+ </div>
+ <div className="min-w-0">
+ <h3 className="flex items-center gap-1.5 font-semibold text-white">
+ {label}
+ <InfoTooltip label="How the quality score works" placement="below" align="start" panelClassName="w-80">
+ <p>Equal-weight mean of broad, medium/high-confidence assessments from the last 30 days. Missing, partial, low-confidence and stale assessments are excluded, not counted as perfect. Assessments describe the code before fixes.</p>
+ <p className="mt-1.5">Scores are the auditing agent’s evidence-based judgment, not an issue count: 90–100 no material defect · 70–89 localized debt · 40–69 significant problems · 10–39 severe defects · 0–9 pervasive failure. A run with no findings can score below 100.</p>
+ {federation && <p className="mt-1.5">Unified score: the newest assessment per category across this install and sync peers with the same repository. Offline peers do not contribute.</p>}
+ {score == null && !hasAssessments && <p className="mt-1.5">Maintenance tasks only supply a score when they return a valid quality report. Earlier runs are not scored retroactively.</p>}
+ </InfoTooltip>
+ </h3>
+ <p className="text-xs text-gray-400">
+ {quality?.ratedCategories ?? 0}/{quality?.totalCategories ?? 0} categories contribute
+ {federation && ` · ${federation.available ?? 0} sync peers`}
+ </p>
+ </div>
+ </div>
+ <div className="flex flex-wrap items-center gap-2">
+ <Link to={panelLink('run')} className="inline-flex items-center gap-1.5 rounded bg-port-accent px-3 py-1.5 text-xs font-medium text-port-bg hover:opacity-90">
+ <Play size={14} aria-hidden="true" />Run checks
+ {activeRuns > 0 && <span className="rounded-full bg-port-bg/30 px-1.5">{activeRuns} running</span>}
+ </Link>
+ <Link to={panelLink('schedule')} className="inline-flex items-center gap-1.5 rounded border border-port-border bg-port-bg/60 px-3 py-1.5 text-xs font-medium text-gray-200 hover:border-port-accent hover:text-white">
+ <CalendarClock size={14} aria-hidden="true" />Schedule
+ </Link>
+ <OverflowMenu label="More quality actions" items={menuItems} />
+ </div>
+ {(federation?.failed || federation?.unavailable > 0) && <p className="basis-full text-xs text-port-warning">
+ {federation.failed ? 'Peer quality could not be loaded; the score may be incomplete.' : `${federation.unavailable} peers unavailable or incompatible; the score may be incomplete.`}
+ </p>}
+ {score == null && !quality?.unavailable && <p className="basis-full text-sm text-gray-400">
+ {hasAssessments ? 'Saved assessments do not qualify for an overall score yet. See the breakdown for coverage, confidence and age.' : 'No audit assessment saved yet. Run checks to collect one.'}
+ </p>}
</div>
- <div className="grid grid-cols-1 xl:grid-cols-2 gap-5 items-start">
- <div className="min-w-0 space-y-4">
- {!selectedCategory && runner}
- <AppQualityScheduleForm app={app} />
+ <div className="grid grid-cols-1 xl:grid-cols-2 gap-4 items-start">
<AppQualityHistory appId={app.id} categories={quality?.categories} />
+ {!!quality?.categories?.length && (
+ <section aria-label="Category breakdown" className="min-w-0 bg-port-card border border-port-border rounded-lg p-4">
+ <div className="mb-2 flex flex-wrap items-center justify-between gap-2">
+ <h4 className="text-sm font-medium">Category breakdown</h4>
+ <label htmlFor={categorySortId} className="flex items-center gap-2 text-xs text-gray-400">
+ Sort by
+ <select
+ id={categorySortId}
+ value={categorySort}
+ onChange={event => setCategorySort(event.target.value)}
+ className="rounded border border-port-border bg-port-bg px-2 py-1 text-port-text"
+ >
+ <option value="score">Worst score</option>
+ <option value="oldest-run">Oldest last run</option>
+ </select>
+ </label>
+ </div>
+ <table className="w-full text-sm text-left">
+ <thead className="text-xs text-gray-400">
+ <tr>
+ <th className="py-1.5 px-2">Category</th>
+ <th className="py-1.5 px-2">Score</th>
+ <th className="py-1.5 px-2 hidden sm:table-cell">Evidence</th>
+ <th className="py-1.5 px-2"><span className="sr-only">Actions</span></th>
+ </tr>
+ </thead>
+ <tbody>{sortedCategories.map(category => <CategoryRow key={category.id} category={category}
+ below={score != null && category.score != null && category.coverage !== 'not-applicable' && category.score < score}
+ runLink={panelLink('run', category.id)} />)}</tbody>
+ </table>
+ </section>
+ )}
</div>
- {!!quality?.categories?.length && (
- <section aria-label="Category breakdown" className="min-w-0">
- <div className="mb-2 flex flex-wrap items-center justify-between gap-2">
- <h4 className="text-sm font-medium">Category breakdown</h4>
- <label htmlFor={categorySortId} className="flex items-center gap-2 text-xs text-gray-400">
- Sort by
- <select
- id={categorySortId}
- value={categorySort}
- onChange={event => setCategorySort(event.target.value)}
- className="rounded border border-port-border bg-port-bg px-2 py-1 text-port-text"
- >
- <option value="score">Worst score</option>
- <option value="oldest-run">Oldest last run</option>
- </select>
- </label>
- </div>
- <table className="w-full text-sm text-left">
- <thead className="text-gray-400 sticky top-0 bg-port-card">
- <tr>
- <th className="py-2 px-3">Category</th>
- <th className="py-2 px-3">Score</th>
- <th className="py-2 px-3">Evidence</th>
- </tr>
- </thead>
- <tbody>{sortedCategories.map(category => (
- <Fragment key={category.id}><tr className={`border-t border-port-border align-top${score != null && category.score != null && category.coverage !== 'not-applicable' && category.score < score ? ' bg-port-warning/10' : ''}`}>
- <th scope="row" className="py-2.5 px-3 font-medium">{category.label}<Link className="block text-xs font-normal text-port-accent hover:underline" to={`/cos/schedule?task=${encodeURIComponent(category.id)}`} aria-label={`${category.label} runner`}>Runner settings</Link></th>
- <td className="py-2.5 px-3 whitespace-nowrap">{category.score == null ? '—' : `${category.score}/100`}</td>
- <td className="py-2.5 px-3 text-xs text-gray-400">
- <div>{category.stale ? 'Stale · ' : ''}{category.coverage}{category.confidence && ` · ${category.confidence} confidence`}
- {category.assessedAt && ` · ${formatDateShort(category.assessedAt)}`}</div>
- <Link to={runnerLink(category.id)} aria-label={`Configure and run ${category.label}`} className="mt-2 inline-flex items-center rounded border border-port-accent bg-port-accent/15 px-2.5 py-1.5 text-xs font-medium text-port-accent transition-colors hover:bg-port-accent/25">Configure and run</Link>
- {category.summary && <details className="mt-1"><summary className="cursor-pointer text-port-accent">Assessment details</summary><p className="break-words">{category.summary}</p></details>}
- {category.id === 'better-dependency-freedom' && <p className="mt-1 text-xs">
- Dependency freedom assesses whether packages earn their place, not whether the project has zero dependencies.
- {' '}There is no automatic penalty for dependency count. Zero removal candidates or issues filed does not guarantee 100/100:
- {' '}the clean-audit range is 90–100. The assessment rationale should explain the chosen score.
- </p>}
- {category.totalFiles > 0 && <div>{category.scannedFiles}/{category.totalFiles} files scanned · Worst severity: {category.worstSeverity}/10</div>}
- {category.sourcePeerName && !category.sourcePeerId && <div>Source: {category.sourcePeerName}</div>}
- {category.sourcePeerId && <div>Source: {category.sourcePeerName || 'federated peer'} · <Link className="text-port-accent hover:underline" to="/instances">View instances</Link></div>}
- {!category.sourcePeerId && category.agentId && <Link className="mt-2 inline-flex items-center rounded border border-port-border bg-port-bg/40 px-2.5 py-1.5 text-xs font-medium text-port-text-muted transition-colors hover:border-port-accent/60 hover:text-port-accent" to={`/cos/agents/${category.agentId}`} aria-label={`View audit run for ${category.label}`}>View audit run</Link>}
- </td>
- </tr>
- {selectedCategory?.id === category.id && <tr><td colSpan={3} className="px-3 pb-3">
- {runner}
- </td></tr>}
- </Fragment>
- ))}</tbody>
- </table>
- </section>
- )}
- </div>
+ <Drawer open={!!panel} onClose={() => setPanel(null)} title={PANELS[panel]} size="md" closeLabel="Close"
+ // The schedule form holds an unapplied plan; a stray Esc/backdrop click would discard it.
+ closeOnEsc={panel !== 'schedule'} closeOnBackdrop={panel !== 'schedule'}>
+ {panel === 'run' && runner}
+ {panel === 'schedule' && <AppQualityScheduleForm app={app} />}
+ </Drawer>
</section>}</AppQualityRunner>
);
}
+
+function CategoryRow({ category, below, runLink }) {
+ const details = category.summary || category.totalFiles > 0 || category.id === 'better-dependency-freedom';
+ const menuItems = [
+ { id: 'settings', label: 'Runner settings', to: `/cos/schedule?task=${encodeURIComponent(category.id)}` },
+ ...(!category.sourcePeerId && category.agentId ? [{ id: 'run', label: 'View audit run', to: `/cos/agents/${category.agentId}` }] : []),
+ ...(category.sourcePeerId ? [{ id: 'instances', label: 'View instances', to: '/instances' }] : []),
+ ];
+ const evidence = <>
+ {category.stale ? 'Stale · ' : ''}{category.coverage}{category.confidence && ` · ${category.confidence}`}
+ {category.assessedAt && ` · ${formatDateShort(category.assessedAt)}`}
+ {category.sourcePeerId || category.sourcePeerName ? ` · ${category.sourcePeerName || 'federated peer'}` : ''}
+ </>;
+ return (
+ <tr className={`border-t border-port-border align-middle${below ? ' bg-port-warning/10' : ''}`}>
+ <th scope="row" className="py-1.5 px-2 font-medium">
+ <span className="inline-flex items-center gap-1.5">
+ {category.label}
+ {details && <InfoTooltip label={`${category.label} assessment details`} placement="below" align="start" panelClassName="w-72 max-h-64 overflow-auto font-normal">
+ {category.summary && <p className="break-words">{category.summary}</p>}
+ {category.totalFiles > 0 && <p className="mt-1">{category.scannedFiles}/{category.totalFiles} files scanned · Worst severity: {category.worstSeverity}/10</p>}
+ {category.id === 'better-dependency-freedom' && <p className="mt-1">Assesses whether packages earn their place; dependency count carries no automatic penalty.</p>}
+ </InfoTooltip>}
+ </span>
+ </th>
+ <td className="py-1.5 px-2 tabular-nums">
+ <span className="whitespace-nowrap">{category.score == null ? '—' : `${category.score}/100`}</span>
+ <span className="block text-xs text-gray-400 sm:hidden">{evidence}</span>
+ </td>
+ <td className="py-1.5 px-2 text-xs text-gray-400 hidden sm:table-cell">{evidence}</td>
+ <td className="py-1.5 px-2">
+ <div className="flex items-center justify-end gap-1">
+ <Link to={runLink} aria-label={`Run ${category.label} check`} title="Run this check"
+ className="inline-flex min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 items-center justify-center rounded border border-port-accent/60 bg-port-accent/10 p-1.5 text-port-accent hover:bg-port-accent/25">
+ <Play size={12} aria-hidden="true" />
+ </Link>
+ <OverflowMenu label={`${category.label} actions`} items={menuItems} />
+ </div>
+ </td>
+ </tr>
+ );
+}
diff --git a/client/src/components/apps/AppQuality.test.jsx b/client/src/components/apps/AppQuality.test.jsx
index afb62f7cf7..0c9c98bca8 100644
--- a/client/src/components/apps/AppQuality.test.jsx
+++ b/client/src/components/apps/AppQuality.test.jsx
@@ -14,7 +14,7 @@ vi.mock('../ui/Toast', () => ({ default: Object.assign(vi.fn(), { success: vi.fn
import { publishAppQualitySnapshot } from '../../services/apiApps';
import toast from '../ui/Toast';
-it('shows zero as a real score and explains excluded categories in the breakdown', async () => {
+it('shows zero as a real score up front and keeps the scoring explanation in a tooltip', async () => {
const app = { id: 'portos-default', quality: { score: 0, ratedCategories: 1, totalCategories: 25, categories: [
{ id: 'security', label: 'Security', score: 0, coverage: 'broad', confidence: 'high', summary: 'Critical failure', scannedFiles: 5, totalFiles: 5, worstSeverity: 10 },
{ id: 'ux', label: 'UX', score: 80, coverage: 'partial', stale: true, summary: 'Only one journey inspected' },
@@ -22,10 +22,16 @@ it('shows zero as a real score and explains excluded categories in the breakdown
render(<MemoryRouter><AppQuality app={app} detail /></MemoryRouter>);
await screen.findByText(/No scored assessments/);
expect(screen.getByRole('heading', { name: 'Quality: 0/100' })).toBeInTheDocument();
- expect(screen.getByText('Stale · partial')).toBeInTheDocument();
+ expect(screen.getAllByText('Stale · partial')).not.toHaveLength(0);
expect(screen.getByText(/1\/25 categories contribute/)).toBeInTheDocument();
- expect(screen.getByRole('link', { name: /Scheduled audit runners/ })).toHaveAttribute('href', '/cos/schedule');
- expect(screen.getByRole('table').parentElement).not.toHaveClass('overflow-auto', 'xl:max-h-[calc(100vh-19rem)]');
+ expect(screen.queryByText(/Equal-weight mean/)).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'How the quality score works' }));
+ expect(screen.getByRole('tooltip')).toHaveTextContent(/Equal-weight mean/);
+ // Metrics-only visitors never see the run or schedule forms until they ask.
+ expect(screen.queryByText('Runner')).not.toBeInTheDocument();
+ expect(screen.queryByText('Schedule form')).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'More quality actions' }));
+ expect(screen.getByRole('menuitem', { name: 'Scheduled audit runners' })).toHaveAttribute('href', '/cos/schedule');
});
it('links an unassessed tile to its app quality tab without inventing a score', () => {
@@ -36,8 +42,9 @@ it('links an unassessed tile to its app quality tab without inventing a score',
it('explains why completed maintenance can still have no saved assessment', async () => {
render(<MemoryRouter><AppQuality app={{ id: 'example', quality: { score: null, categories: [] } }} detail /></MemoryRouter>);
await screen.findByText(/No scored assessments/);
- expect(screen.getByText(/Earlier runs are not scored retroactively/)).toBeInTheDocument();
- expect(screen.getByRole('link', { name: /Scheduled audit runners/ })).toHaveAttribute('href', '/cos/schedule');
+ expect(screen.getByText(/No audit assessment saved yet/)).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'How the quality score works' }));
+ expect(screen.getByRole('tooltip')).toHaveTextContent(/Earlier runs are not scored retroactively/);
});
it('distinguishes saved but excluded evidence from an app that was never assessed', async () => {
@@ -48,7 +55,7 @@ it('distinguishes saved but excluded evidence from an app that was never assesse
expect(screen.getByRole('link', { name: 'Quality: no qualifying score' })).toBeInTheDocument();
rerender(<MemoryRouter><AppQuality app={app} detail /></MemoryRouter>);
await screen.findByText(/No scored assessments/);
- expect(screen.getByText(/Saved assessments do not currently qualify/)).toBeInTheDocument();
+ expect(screen.getByText(/Saved assessments do not qualify/)).toBeInTheDocument();
expect(screen.getByText('60/100')).toBeInTheDocument();
});
@@ -59,22 +66,23 @@ it('identifies federated evidence and incomplete scores without linking to a loc
render(<MemoryRouter><AppQuality app={app} detail /></MemoryRouter>);
await screen.findByText(/No scored assessments/);
expect(screen.getByText(/1 peers unavailable or incompatible/)).toBeInTheDocument();
- expect(screen.getByRole('link', { name: 'View instances' })).toHaveAttribute('href', '/instances');
- expect(screen.queryByRole('link', { name: 'Audit run' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'Security actions' }));
+ expect(screen.getByRole('menuitem', { name: 'View instances' })).toHaveAttribute('href', '/instances');
+ expect(screen.queryByRole('menuitem', { name: 'View audit run' })).not.toBeInTheDocument();
});
-it('makes the category actions and header navigation look like distinct clickable controls', async () => {
- const app = { id: 'example', publishQualitySnapshot: true, quality: { categories: [
- { id: 'security', label: 'Security', score: 80, coverage: 'broad', confidence: 'high', agentId: 'run-1' },
+it('keeps secondary category actions in a row menu beside the run shortcut', async () => {
+ const app = { id: 'example', quality: { categories: [
+ { id: 'security', label: 'Security', score: 80, coverage: 'broad', confidence: 'high', agentId: 'run-1', summary: 'No material defects' },
] } };
render(<MemoryRouter><AppQuality app={app} detail /></MemoryRouter>);
await screen.findByText(/No scored assessments/);
- expect(screen.getByRole('link', { name: 'Scheduled audit runners' })).toHaveClass('inline-flex', 'border', 'rounded');
- expect(screen.getByRole('link', { name: 'View agents' })).toHaveClass('inline-flex', 'border', 'rounded');
- expect(screen.getByRole('button', { name: 'Publish snapshot now' })).toHaveClass('inline-flex', 'border', 'rounded');
- expect(screen.getByRole('link', { name: 'Configure and run Security' })).toHaveClass('inline-flex', 'bg-port-accent/15', 'border', 'rounded');
- expect(screen.getByRole('link', { name: 'View audit run for Security' })).toHaveClass('inline-flex', 'border', 'bg-port-bg/40', 'rounded');
- expect(screen.getByRole('rowheader', { name: /Security/ })).toHaveClass('px-3', 'py-2.5');
+ expect(screen.queryByText('No material defects')).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'Security assessment details' }));
+ expect(screen.getByRole('tooltip')).toHaveTextContent('No material defects');
+ fireEvent.click(screen.getByRole('button', { name: 'Security actions' }));
+ expect(screen.getByRole('menuitem', { name: 'Runner settings' })).toHaveAttribute('href', '/cos/schedule?task=security');
+ expect(screen.getByRole('menuitem', { name: 'View audit run' })).toHaveAttribute('href', '/cos/agents/run-1');
});
it('sorts the category breakdown by worst score or oldest last run', async () => {
@@ -89,27 +97,30 @@ it('sorts the category breakdown by worst score or oldest last run', async () =>
const sortBy = screen.getByRole('combobox', { name: 'Sort by' });
expect(sortBy).toHaveValue('score');
let rowLabels = screen.getAllByRole('row').slice(1).map(row => within(row).queryByRole('rowheader')?.textContent);
- expect(rowLabels.filter(Boolean)).toEqual(['SecurityRunner settings', 'TestsRunner settings', 'UXRunner settings', 'PerfRunner settings']);
+ expect(rowLabels.filter(Boolean)).toEqual(['Security', 'Tests', 'UX', 'Perf']);
fireEvent.change(sortBy, { target: { value: 'oldest-run' } });
rowLabels = screen.getAllByRole('row').slice(1).map(row => within(row).queryByRole('rowheader')?.textContent);
- expect(rowLabels.filter(Boolean)).toEqual(['PerfRunner settings', 'TestsRunner settings', 'UXRunner settings', 'SecurityRunner settings']);
+ expect(rowLabels.filter(Boolean)).toEqual(['Perf', 'Tests', 'UX', 'Security']);
});
-it('opens the shared runner beside unavailable category evidence while preserving URL filters', async () => {
+it('opens the run and schedule forms in a deep-linked drawer while preserving URL filters', async () => {
const app = { id: 'example', quality: { categories: [
{ id: 'security', label: 'Security', score: null, coverage: 'unavailable' },
{ id: 'ux', label: 'UX', score: null, coverage: 'unavailable' },
] } };
render(<MemoryRouter initialEntries={['/apps/example/quality?period=30']}><AppQuality app={app} detail /></MemoryRouter>);
await screen.findByText(/No scored assessments/);
- const link = screen.getByRole('link', { name: 'Configure and run Security' });
- expect(link).toHaveAttribute('href', '/apps/example/quality?period=30&qualityCheck=security#quality-runner');
+ const link = screen.getByRole('link', { name: 'Run Security check' });
+ expect(link).toHaveAttribute('href', '/apps/example/quality?period=30&qualityPanel=run&qualityCheck=security');
fireEvent.click(link);
- const table = screen.getByRole('table');
- expect(within(table).getByText('Runner')).toBeInTheDocument();
- expect(screen.getAllByText('Runner')).toHaveLength(1);
- expect(screen.getAllByText('unavailable')).toHaveLength(2);
+ expect(within(screen.getByRole('dialog', { name: 'Run quality checks' })).getByText('Runner')).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'Close' }));
+ expect(screen.queryByText('Runner')).not.toBeInTheDocument();
+ // The header's Run drops the row preselection so it opens on the default set.
+ expect(screen.getByRole('link', { name: 'Run checks' })).toHaveAttribute('href', '/apps/example/quality?period=30&qualityPanel=run');
+ fireEvent.click(screen.getByRole('link', { name: 'Schedule' }));
+ expect(within(screen.getByRole('dialog', { name: 'Weekly quality schedule' })).getByText('Schedule form')).toBeInTheDocument();
});
describe('AppQuality snapshot publishing', () => {
@@ -118,10 +129,13 @@ describe('AppQuality snapshot publishing', () => {
it('offers the publish action only for an app that opted in', async () => {
const { rerender } = render(<MemoryRouter><AppQuality app={{ ...publishingApp, publishQualitySnapshot: false }} detail /></MemoryRouter>);
await screen.findByText(/No scored assessments/);
- expect(screen.queryByRole('button', { name: 'Publish snapshot now' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'More quality actions' }));
+ expect(screen.queryByRole('menuitem', { name: 'Publish snapshot now' })).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'More quality actions' }));
rerender(<MemoryRouter><AppQuality app={publishingApp} detail /></MemoryRouter>);
- expect(screen.getByRole('button', { name: 'Publish snapshot now' })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'More quality actions' }));
+ expect(screen.getByRole('menuitem', { name: 'Publish snapshot now' })).toBeInTheDocument();
});
it('reports the pull request that carries the snapshot into the repo', async () => {
@@ -132,7 +146,8 @@ describe('AppQuality snapshot publishing', () => {
render(<MemoryRouter><AppQuality app={publishingApp} detail /></MemoryRouter>);
await screen.findByText(/No scored assessments/);
- fireEvent.click(screen.getByRole('button', { name: 'Publish snapshot now' }));
+ fireEvent.click(screen.getByRole('button', { name: 'More quality actions' }));
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Publish snapshot now' }));
await waitFor(() => expect(publishAppQualitySnapshot).toHaveBeenCalledWith('example'));
await waitFor(() => expect(toast.success).toHaveBeenCalledWith(
@@ -144,7 +159,8 @@ describe('AppQuality snapshot publishing', () => {
render(<MemoryRouter><AppQuality app={publishingApp} detail /></MemoryRouter>);
await screen.findByText(/No scored assessments/);
- fireEvent.click(screen.getByRole('button', { name: 'Publish snapshot now' }));
+ fireEvent.click(screen.getByRole('button', { name: 'More quality actions' }));
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Publish snapshot now' }));
await waitFor(() => expect(toast).toHaveBeenCalledWith('Snapshot already up to date in .quality.json'));
expect(toast.success).not.toHaveBeenCalled();
@@ -155,7 +171,8 @@ describe('AppQuality snapshot publishing', () => {
render(<MemoryRouter><AppQuality app={publishingApp} detail /></MemoryRouter>);
await screen.findByText(/No scored assessments/);
- fireEvent.click(screen.getByRole('button', { name: 'Publish snapshot now' }));
+ fireEvent.click(screen.getByRole('button', { name: 'More quality actions' }));
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Publish snapshot now' }));
await waitFor(() => expect(toast).toHaveBeenCalledWith(
'The committed quality file is in an unsupported format. Publish left it in place.'));
diff --git a/client/src/components/apps/AppQualityHistory.jsx b/client/src/components/apps/AppQualityHistory.jsx
index a61b7d9969..edf8e752ad 100644
--- a/client/src/components/apps/AppQualityHistory.jsx
+++ b/client/src/components/apps/AppQualityHistory.jsx
@@ -1,7 +1,9 @@
import { useEffect, useState } from 'react';
import { useSearchParams } from 'react-router';
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts';
+import { RefreshCw } from 'lucide-react';
import { getAppQualityHistory } from '../../services/apiApps';
+import InfoTooltip from '../ui/InfoTooltip';
export default function AppQualityHistory({ appId, categories = [] }) {
const [params, setParams] = useSearchParams();
@@ -31,21 +33,34 @@ export default function AppQualityHistory({ appId, categories = [] }) {
}));
const measured = points.filter(p => p.value !== null);
return (
- <div className="space-y-3">
- <h4 className="text-sm font-medium">Quality over time</h4>
- <div className="flex flex-wrap gap-3 text-sm">
- <label htmlFor="quality-period">Period <select id="quality-period" className="bg-port-bg border border-port-border rounded p-1" value={days} onChange={e => change('qualityDays', e.target.value)}>
- <option value="30">30 days</option><option value="90">90 days</option><option value="365">1 year</option>
- </select></label>
- <label htmlFor="quality-history-category" className="min-w-0">Category <select id="quality-history-category" className="bg-port-bg border border-port-border rounded p-1 max-w-full" value={category} onChange={e => change('qualityCategory', e.target.value)}>
- <option value="overall">Overall</option>{categories.map(c => <option key={c.id} value={c.id}>{c.label}</option>)}
- </select></label>
- <button type="button" className="text-port-accent hover:underline" onClick={() => setRefresh(n => n + 1)}>Refresh history</button>
+ <section aria-label="Quality over time" className="bg-port-card border border-port-border rounded-lg p-4 space-y-3 min-w-0">
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <h4 className="flex items-center gap-1.5 text-sm font-medium">
+ Quality over time
+ <InfoTooltip label="About quality history" placement="below" align="start" panelClassName="w-72">
+ Daily snapshots (UTC), higher is healthier. Scores carry forward for up to 30 days; gaps mean no fresh evidence. Coverage changes can move the overall mean. Category views include provisional assessments.
+ {state.data?.federation && ` Includes ${state.data.federation.available ?? 0} available full-sync peers; peer availability can change historical coverage.`}
+ </InfoTooltip>
+ </h4>
+ <div className="flex flex-wrap items-center gap-2 text-xs">
+ <label htmlFor="quality-period" className="sr-only">Period</label>
+ <select id="quality-period" className="bg-port-bg border border-port-border rounded p-1" value={days} onChange={e => change('qualityDays', e.target.value)}>
+ <option value="30">30 days</option><option value="90">90 days</option><option value="365">1 year</option>
+ </select>
+ <label htmlFor="quality-history-category" className="sr-only">Category</label>
+ <select id="quality-history-category" className="bg-port-bg border border-port-border rounded p-1 max-w-[12rem]" value={category} onChange={e => change('qualityCategory', e.target.value)}>
+ <option value="overall">Overall</option>{categories.map(c => <option key={c.id} value={c.id}>{c.label}</option>)}
+ </select>
+ <button type="button" aria-label="Refresh history" title="Refresh history" className="min-h-[44px] min-w-[44px] inline-flex items-center justify-center text-gray-400 hover:text-port-accent" onClick={() => setRefresh(n => n + 1)}>
+ <RefreshCw size={14} aria-hidden="true" />
+ </button>
+ </div>
</div>
- <p className="text-xs text-gray-400">Daily snapshots (UTC), higher is healthier. Scores carry forward for up to 30 days; gaps mean no fresh evidence. Coverage changes can move the overall mean. Category views include provisional assessments.</p>
- {state.data?.federation && <p className="text-xs text-gray-400">Unified history includes {state.data.federation.available ?? 0} available full-sync peers. {state.data.federation.failed ? 'Peer quality could not be loaded; history may be incomplete.' : state.data.federation.unavailable > 0 ? `${state.data.federation.unavailable} peers unavailable or incompatible; history may be incomplete.` : 'Peer availability can change historical coverage.'}</p>}
+ {(state.data?.federation?.failed || state.data?.federation?.unavailable > 0) && <p className="text-xs text-port-warning">
+ {state.data.federation.failed ? 'Peer quality could not be loaded; history may be incomplete.' : `${state.data.federation.unavailable} peers unavailable or incompatible; history may be incomplete.`}
+ </p>}
{state.loading ? <p role="status">Loading quality history…</p> : state.error ? <p role="alert">Quality history could not be loaded. Use Refresh history to retry.</p> : !measured.length ? <p className="text-sm text-gray-400">No scored assessments in this period. Run an audit to start the history.</p> : <>
- <div className="h-48 w-full" role="img" aria-label="Daily quality scores from 0 to 100; values and evidence are available in the history table below">
+ <div className="h-56 w-full" role="img" aria-label="Daily quality scores from 0 to 100; values and evidence are available in the history table below">
<ResponsiveContainer width="100%" height="100%">
<LineChart data={points} margin={{ top: 8, right: 12, bottom: 8, left: 0 }}>
<CartesianGrid strokeDasharray="3 3" stroke="#374151" />
@@ -56,13 +71,13 @@ export default function AppQualityHistory({ appId, categories = [] }) {
</LineChart>
</ResponsiveContainer>
</div>
- <details><summary className="cursor-pointer text-sm text-port-accent">History values and coverage</summary>
+ <details><summary className="cursor-pointer text-xs text-port-accent">History values and coverage</summary>
<div className="max-h-64 overflow-auto"><table className="w-full text-left text-xs">
<thead><tr><th>Date (UTC)</th><th>Score</th><th>Evidence</th></tr></thead>
<tbody>{points.map(point => <tr key={point.date}><th scope="row" className="py-1 font-normal">{point.date}</th><td>{point.value == null ? '—' : `${point.value}/100`}</td><td>{point.evidence}</td></tr>)}</tbody>
</table></div>
</details>
</>}
- </div>
+ </section>
);
}
diff --git a/client/src/components/apps/AppQualityRunner.jsx b/client/src/components/apps/AppQualityRunner.jsx
index 18fc0cf8a4..c337cbbf85 100644
--- a/client/src/components/apps/AppQualityRunner.jsx
+++ b/client/src/components/apps/AppQualityRunner.jsx
@@ -56,8 +56,7 @@ export default function AppQualityRunner({ app, children }) {
if (response) setRuns(previous => previous.map(entry => entry.id === response.run.id ? response.run : entry));
setBusy(false);
};
- const controls = <section id="quality-runner" aria-label="Run quality checks" className="border-t border-port-border pt-3 space-y-3">
- <h4 className="font-medium">Run quality checks</h4>
+ const controls = <section id="quality-runner" aria-label="Run quality checks" className="space-y-3">
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3 text-sm">
<label htmlFor="quality-checks">Checks
<select id="quality-checks" className="block w-full bg-port-bg border border-port-border rounded p-2" value={selection} disabled={busy} onChange={event => setSelection(event.target.value)}>
@@ -75,7 +74,7 @@ export default function AppQualityRunner({ app, children }) {
availableModels={picker.availableModels} onProviderChange={value => { picker.setSelectedProviderId(value); setEffort(''); }}
onModelChange={picker.setSelectedModel} effort={effort} onEffortChange={setEffort} loading={picker.loading} disabled={busy}
emptyProviderOption="Select a subscription provider" emptyModelOption="Select a model" includeDefaultModel highlightToolUse />
- <p className="text-xs text-gray-400">{taskTypes.length} scheduled agents, run sequentially within this batch. Launch another batch to run checks in parallel. {mode === 'fix' ? 'Each selected audit can change code and open a PR.' : 'Findings become issues; no fixes or backlog claim jobs.'} Schedules can stay disabled. The Improve setting still applies.</p>
+ <p className="text-xs text-gray-400">Runs sequentially; launch another batch to run in parallel. {mode === 'fix' ? 'Each audit can change code and open a PR.' : 'Findings become issues; no fixes.'}</p>
<details className="text-xs"><summary className="cursor-pointer text-port-accent">Selected checks ({taskTypes.length})</summary><p className="mt-1">{categories.filter(category => taskTypes.includes(category.id)).map(category => category.label).join(', ') || 'No checks need evidence. Unavailable assessments and N/A categories are excluded.'}</p></details>
<button type="button" onClick={start} disabled={busy || picker.loading || !picker.selectedProviderId || !picker.selectedModel || !taskTypes.length || app.quality?.unavailable}
className="px-3 py-2 rounded bg-port-accent text-port-bg text-sm font-medium disabled:opacity-50">{taskTypes.length === 1 ? 'Run now' : `Run ${taskTypes.length} checks now`}</button>
@@ -87,5 +86,6 @@ export default function AppQualityRunner({ app, children }) {
{run.status === 'running' && <button type="button" className="text-xs text-port-accent" disabled={busy} onClick={() => stop(run.id)}>Stop remaining checks</button>}
</div>)}
</section>;
- return children ? children(controls) : controls;
+ const activeRuns = runs.filter(run => run.status === 'running').length;
+ return children ? children(controls, activeRuns) : controls;
}
diff --git a/client/src/components/apps/AppQualityRunner.test.jsx b/client/src/components/apps/AppQualityRunner.test.jsx
index ba293a1df0..5df814a4e5 100644
--- a/client/src/components/apps/AppQualityRunner.test.jsx
+++ b/client/src/components/apps/AppQualityRunner.test.jsx
@@ -40,13 +40,15 @@ it('allows one category and recovers from launch failure without reporting a run
expect(startMaintenanceRun.mock.calls[0][0]).toMatchObject({ mode: 'file-issues', taskTypes: ['performance'] });
});
-it('preserves run overrides when moving controls into a category row', async () => {
+it('preserves run overrides when reopening the drawer for one category', async () => {
startMaintenanceRun.mockResolvedValue({ run: { id: 'run-2', status: 'running', steps: [] } });
render(<MemoryRouter><AppQuality app={app} detail /></MemoryRouter>);
+ fireEvent.click(screen.getByRole('link', { name: 'Run checks' }));
await findEnabledByRole('button', { name: 'Run 2 checks now' });
fireEvent.change(screen.getByLabelText('Mode'), { target: { value: 'fix' } });
fireEvent.click(screen.getByText('Use high effort'));
- fireEvent.click(screen.getByRole('link', { name: 'Configure and run Security' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Close' }));
+ fireEvent.click(screen.getByRole('link', { name: 'Run Security check' }));
expect(screen.getByLabelText('Checks')).toHaveValue('security');
expect(screen.getByLabelText('Mode')).toHaveValue('fix');
fireEvent.click(screen.getByRole('button', { name: 'Run now' }));
diff --git a/client/src/components/apps/AppQualityScheduleForm.jsx b/client/src/components/apps/AppQualityScheduleForm.jsx
index 0e0fd80610..676f1ecee4 100644
--- a/client/src/components/apps/AppQualityScheduleForm.jsx
+++ b/client/src/components/apps/AppQualityScheduleForm.jsx
@@ -125,8 +125,8 @@ export default function AppQualityScheduleForm({ app }) {
toast.success(`Scheduled ${result.plan.slots.length} quality checks across the week`);
};
- if (error && !data) return <section aria-label="Weekly quality schedule" className="border-t border-port-border pt-3">
- <h4 className="font-medium">Weekly quality schedule</h4>
+ if (error && !data) return <section aria-label="Weekly quality schedule">
+ <h4 className="sr-only">Weekly quality schedule</h4>
<p role="alert" className="text-sm text-port-error">{error}</p>
<button type="button" onClick={() => { setError(''); setReloadToken(token => token + 1); }}
className="mt-2 text-xs text-port-accent hover:underline">Try again</button>
@@ -159,13 +159,12 @@ export default function AppQualityScheduleForm({ app }) {
: null;
return (
- <section aria-label="Weekly quality schedule" className="border-t border-port-border pt-3 space-y-3">
- <h4 className="font-medium">Weekly quality schedule</h4>
+ <section aria-label="Weekly quality schedule" className="space-y-3">
+ <h4 className="sr-only">Weekly quality schedule</h4>
<p className="text-xs text-gray-400">
- Spreads the selected checks over {daysUsed === 7 ? 'all seven days' : `${daysUsed} day${daysUsed === 1 ? '' : 's'}`} and picks the hours itself, avoiding the windows this app’s other
- scheduled jobs already run in. {applicable.length} of {checks.length} checks apply to this repository
- {complete ? '' : ' (the repository could not be fully scanned, so every check is offered)'}
- {skipped.length > 0 && `; ${skipped.length} skipped`}. Nothing is saved until you press Apply.
+ {applicable.length} of {checks.length} checks apply to this repository
+ {complete ? '' : ' (scan incomplete, so every check is offered)'}
+ {skipped.length > 0 && `; ${skipped.length} skipped`}. Spread over {daysUsed === 7 ? 'all seven days' : `${daysUsed} day${daysUsed === 1 ? '' : 's'}`}, clear of this app’s other scheduled jobs.
</p>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 text-sm">
@@ -297,8 +296,7 @@ export default function AppQualityScheduleForm({ app }) {
<Link to="/cos/schedule" className="text-xs text-port-accent hover:underline">Review on the Schedule page</Link>
</div>
<p className="text-xs text-gray-500">
- Applying enables the selected checks on this app with the planned cron expressions and DISABLES the ones you left out.
- Other task types are untouched, and every entry stays editable on the Schedule page afterwards.
+ Apply enables the selected checks and disables the unselected ones. Other task types are untouched.
</p>
</section>
);