feat(react-doctor): interactive code-health TUI as a `tui` subcommand
Adds an interactive React code-health terminal UI to react-doctor, available as a tui subcommand. Built on Ink, with a focused single-screen dashboard, monorepo project picker, watch mode, and a master/detail diagnostic browser.
react-doctor tui . # picker if monorepo, else dashboard
react-doctor tui . --watch # rescan on file changes
react-doctor tui . --review # open straight into the diagnostic browser
react-doctor tui . --project ami # preselect a workspace package
Project picker (monorepo support)
Mirrors the standard CLI's selectProjects behaviour, but as an Ink screen since the TUI owns the TTY. Shown only when 2+ React workspace packages are discovered:
~/projects/ami
Multiple React projects found. Pick one to scan:
ami packages/ami
▸ admin packages/admin
docs packages/docs
[↑↓] move [↵] scan this project [q] quit
- Reuses
listWorkspacePackages→discoverReactSubprojectsfallback from the existing CLI. - 0 packages → scan the root directly. 1 package → auto-select. 2+ → picker.
--project <name|basename>skips the picker for non-interactive flows (e.g. inside an editor task).
Dashboard
Answers three questions, in order:
- How healthy is the codebase? → score gauge with delta vs. last scan
- What's most broken? → focused issue with rule, message, help, file:line, and a source-snippet preview
- What else? → compact list of remaining rules with site counts
~/projects/ami
┌─────┐ 82 / 100 Great ▲ 4
│ ◠ ◠ │ █████████████████████████░░░░░
│ ▽ │
└─────┘
✗ react-doctor/no-fetch-in-effect 2 sites
Avoid fetch inside useEffect.
→ Use a data-fetching library like TanStack Query.
src/UserCard.tsx:42
40│ const [user, setUser] = useState(null);
41│ useEffect(() => {
▸ 42│ fetch(`/api/${id}`).then(r => r.json()).then(setUser);
43│ }, [id]);
+ 1 more site
⚠ no-array-index-as-key 5 sites
Last scan 2.3s · 7 issues across 6 files · ● watching
[d] review [r] rescan [w] watch off [?] help [q] quit
Header is just the project path (home-dir aware: ~/foo/bar). Watching status, scan elapsed time, and offline mode all live in the single-line footer where they belong. The doctor face stays as the cute 4-line ASCII branding next to the score; mood tracks the score.
Review screen
Master/detail diagnostic browser with severity-coloured rule list, source-snippet preview, and an inline filter (/) that searches across rule, plugin, category, message, and file path. Stacks vertically on narrow terminals.
How it's wired up
ScanReporterinterface and discriminatedScanEventunion added toreact-doctor/api.scan()emits structured events alongside its existing stdout output. When no reporter is supplied, behaviour is unchanged.- The TUI lives in-package at
src/tui/and ships as a separatevite-plusbuild entry (dist/tui.js). The CLI lazy-loads it on demand so non-TUI scans never touch Ink/React/chokidar. chokidarwatch loop with debounce.useTerminalSizehook subscribes to stdoutresizeevents; layout adapts at 60- and 90-col breakpoints (score bar shrinks, review panes split master/detail vertically).- TTY guard with a clear fallback message for non-interactive shells.
- During scanning, a single inline spinner with active step +
M/Ncounter — not a 10-row checklist. - Re-scans keep the dashboard visible and append
rescanning…to the footer. - Errored scans render a red one-line banner above the score gauge with a recovery hint.
- Empty scans show
✓ No issues detected — nice work.
Doctor-face fix
The "first 1-2 lines show double" rendering glitch was a width mismatch: the eyes row (│ ◠ ◠ │ = 7 chars) and the mouth row (│ ─ │ = 5 chars) had different widths, so Ink's incremental redraw left stale chars from the previous frame on the shorter row. Every frame across every mood is now exactly 5 inner chars; a unit test enforces this. Animation interval slowed from 240ms to 480ms; a setTimeout leak in the blink scheduler is plugged.
Validation
pnpm format— cleanpnpm lint— 0 warnings, 0 errorspnpm typecheck— cleanpnpm test— 662 tests passing across 55 test filespnpm build—dist/tui.jsbuilds alongsidedist/cli.js,dist/index.js, and the lint plugins
Out of scope (follow-ups)
- Apply-suppression action that writes a
react-doctor-disable-next-linecomment from the review screen. - Open-in-
$EDITORjump from the detail pane. - Multi-project scan in a single TUI session (currently one project per session).
- Persisting score history to
.react-doctor/history.jsonso the trend survives across runs.
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Actions | Updated (UTC) |
|---|---|---|---|
| react-doctor-website | Preview, Comment | May 8, 2026 1:03pm |

