mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-12-03 00:47:18 +00:00
## Summary Improves the web UI's React Doctor audit score by separating reusable helpers from React component modules, tightening effect/state ownership, and extracting real component boundaries in the install wizard, stage activity view, run-files diff browser, RunDetail route, and Runs workspace. The branch removes the previously deferred RunDetail and Runs giant-component diagnostics without changing RunDetail UX, route contracts, action ordering, or Runs workspace behavior. | Metric | Main baseline | Initial PR | Current PR | |--------|---------------|------------|------------| | React Doctor score | 63 | 71 | 99 | | React Doctor errors | 123 | 0 | 0 | | React Doctor warnings | 241 | 163 | 3 | | React Doctor diagnostics | 364 | 163 | 3 | ## Changes - Moves exported helper logic out of component files so Fast Refresh/component-export rules no longer dominate the audit. - Adds a targeted React Doctor config exception for React Router route modules, where non-component exports like route metadata are intentional. - Refactors low-risk state/effect patterns: keyed interview question state, reducer-backed editable run title state, event-owned preview opening, route-keyed insights editor initialization, refresh timer ownership, and selection/derived list cleanup. - Reworks `InstallApp` around an install reducer, a controller hook for install lifecycle state, and focused wizard step components for LLM, server, object-store, sandbox, and GitHub setup. - Moves `RunStages` selected-stage activity into a keyed boundary for panel/debug detail state while preserving stage activity filters across navigation. - Extracts the `RunFiles` loaded diff-browser view from route/query coordination so the route owns data/URL state and the loaded view owns rendering. - Splits `RunDetail` into route-local header, actions, tab shell, docked controls, model, and lifecycle-toast modules; the actions menu now uses grouped descriptors instead of a large boolean/callback prop matrix. - Extracts Runs workspace preference ownership into `useRunsWorkspacePreferences` and moves toolbar rendering into `RunsToolbar`, leaving the route focused on data, DnD state, filtering, and view selection. - Guards `InsightsEditor` query execution with a latest-run id and timeout cleanup so stale or unmounted mock query runs cannot overwrite newer results. - Adds regression coverage for archived-run deletion from RunDetail and stale-result handling in InsightsEditor. - Improves semantic/accessibility coverage with labeled controls, native meter/section semantics, decorative status dots, and clearer unavailable copy. - Removes dead UI code and applies local suppressions only where the rule is a documented false positive or an intentional imperative integration boundary. ## Remaining React Doctor warnings Current score is 99 with 0 errors and 3 warnings. The remaining warnings are intentionally left for separate judgment rather than mechanical churn: - `prefer-useReducer` (3): `AutomationsNew`, `InsightsEditor`, and `CreateSecretForm` need reducers only if they encode real coupled transitions, not simple field setters. ## Verification - `cd apps/fabro-web && bun test app/routes/run-detail.test.ts` -> `22 pass`, `0 fail` - `cd apps/fabro-web && bun test app/routes/insights-editor.test.tsx app/routes/runs.preferences.test.tsx` -> `7 pass`, `0 fail` - `cd apps/fabro-web && bun run typecheck` - `cd apps/fabro-web && bun test --isolate` -> `490 pass`, `0 fail` - `cd apps/fabro-web && bunx react-doctor@latest --full --json > /tmp/fabro-react-doctor-runs-insights.json` -> score `99`, `0` errors, `3` warnings - Earlier branch verification also included `cd apps/fabro-web && bun run build` - `git diff --check` --- [](https://github.com/EveryInc/compound-engineering-plugin) 🤖 Generated with GPT-5 (context not reported, default reasoning) via [Codex](https://openai.com/codex)
100 lines
3.8 KiB
TypeScript
100 lines
3.8 KiB
TypeScript
import { Link, useNavigate } from "react-router";
|
|
import {
|
|
SparklesIcon,
|
|
ClockIcon,
|
|
ExclamationTriangleIcon,
|
|
ServerStackIcon,
|
|
CommandLineIcon,
|
|
} from "@heroicons/react/24/outline";
|
|
|
|
const templateQueries = [
|
|
{
|
|
title: "Run duration by workflow",
|
|
description: "Average execution time and run count per workflow",
|
|
icon: ClockIcon,
|
|
sql: "SELECT workflow_name, AVG(duration_seconds) as avg_duration,\n COUNT(*) as run_count\nFROM runs\nGROUP BY workflow_name\nORDER BY avg_duration DESC\nLIMIT 20",
|
|
},
|
|
{
|
|
title: "Daily failure rate",
|
|
description: "Failures, totals, and failure percentage by day",
|
|
icon: ExclamationTriangleIcon,
|
|
sql: "SELECT date_trunc('day', created_at) as day,\n COUNT(*) FILTER (WHERE status = 'failed') as failures,\n COUNT(*) as total,\n ROUND(100.0 * COUNT(*) FILTER (WHERE status = 'failed') / COUNT(*), 1) as failure_rate\nFROM runs\nGROUP BY 1\nORDER BY 1 DESC\nLIMIT 30",
|
|
},
|
|
{
|
|
title: "Top repos by activity",
|
|
description: "Run count and code churn per repository",
|
|
icon: ServerStackIcon,
|
|
sql: "SELECT repo, COUNT(*) as runs, SUM(additions) as total_additions,\n SUM(deletions) as total_deletions\nFROM runs\nGROUP BY repo\nORDER BY runs DESC",
|
|
},
|
|
];
|
|
|
|
export default function InsightsNew() {
|
|
const navigate = useNavigate();
|
|
|
|
return (
|
|
<div className="mx-auto max-w-2xl py-12">
|
|
{/* LLM input */}
|
|
<div className="space-y-3">
|
|
<div className="flex items-center gap-2">
|
|
<SparklesIcon className="size-5 text-teal-500" />
|
|
<h2 className="text-lg font-semibold text-fg">New Query</h2>
|
|
</div>
|
|
<textarea
|
|
aria-label="Insight prompt"
|
|
placeholder="Ask assistant to generate a report"
|
|
className="w-full rounded-lg border border-line bg-page/80 px-4 py-3.5 text-sm text-fg-2 placeholder-fg-muted outline-none transition-colors focus:border-focus"
|
|
rows={4}
|
|
/>
|
|
<div className="flex justify-end">
|
|
<button
|
|
type="button"
|
|
className="inline-flex items-center gap-1.5 rounded-md border border-teal-500/30 bg-teal-500/10 px-4 py-2 text-sm font-medium text-teal-300 transition-all hover:border-teal-500/50 hover:bg-teal-500/20 hover:text-fg"
|
|
>
|
|
<SparklesIcon className="size-3.5" />
|
|
Generate
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Template cards */}
|
|
<div className="mt-10 space-y-3">
|
|
<h3 className="text-[11px] font-semibold uppercase tracking-wider text-fg-muted">
|
|
Start from a template
|
|
</h3>
|
|
<div className="grid gap-3">
|
|
{templateQueries.map((tpl) => (
|
|
<button
|
|
key={tpl.title}
|
|
type="button"
|
|
onClick={() => {
|
|
navigate("/insights", { state: { sql: tpl.sql, name: tpl.title } });
|
|
}}
|
|
className="flex items-start gap-3.5 rounded-lg border border-line bg-panel/60 px-4 py-3.5 text-left transition-colors hover:border-line-strong hover:bg-panel/80"
|
|
>
|
|
<tpl.icon className="mt-0.5 size-5 shrink-0 text-fg-muted" />
|
|
<div>
|
|
<span className="text-sm font-medium text-fg-2">
|
|
{tpl.title}
|
|
</span>
|
|
<p className="mt-0.5 text-xs text-fg-muted">
|
|
{tpl.description}
|
|
</p>
|
|
</div>
|
|
</button>
|
|
))}
|
|
</div>
|
|
</div>
|
|
|
|
{/* SQL link */}
|
|
<div className="mt-10 text-center">
|
|
<Link
|
|
to="/insights"
|
|
className="inline-flex items-center gap-1.5 text-sm text-fg-muted transition-colors hover:text-fg-3"
|
|
>
|
|
<CommandLineIcon className="size-4" />
|
|
<span className="font-semibold">Write my own report with SQL</span>
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|