Skip to content

feat(doctor): wire fixAction to /doctor UI keypress (press f to auto-fix) - #140

Merged
dahai80 merged 1 commit into
mainfrom
feat/doctor-fixaction-ui
Aug 26, 2026
Merged

dahai80 merged 1 commit into
mainfrom
feat/doctor-fixaction-ui

Conversation

@dahai80

@dahai80 dahai80 commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Summary

PR #131 landed the fixAction framework in the data layer (doctorDiagnostic.ts warnings carry an optional callable fixAction, e.g. requestMlxGC for MLX OOM high/imminent), but the Doctor.tsx UI only rendered the fix text — the callback was never invokable from the screen. The prior session deferred the UI wiring (audit enhance-0819.md line 684) because:

  1. Doctor.tsx is vendored React-Compiler output (_c/$[N] memo slots) — hand-editing the slots is fragile.
  2. Concern about shared Confirmation context affecting multiple dialogs.

This PR resolves both defer reasons and wires f to trigger auto-fix.

Approach

Extract the warnings render into a new hand-written child component (DoctorWarnings.tsx) that owns its own useInput. The parent's memo slot $[36] still depends only on the diagnostic.warnings array reference, so the compiler output is untouched except for swapping diagnostic.warnings.map(_temp10) → <DoctorWarnings warnings={diagnostic.warnings} /> and removing the now-dead _temp10 helper.

  • Neutralizes reason (1): no hand-editing of memo slots — the new component is plain hand-written React (like TextInput, StatusLine, ExportDialog, which already exist hand-written in the repo).
  • Neutralizes reason (2): Doctor has no Confirmation context, and requestMlxGC is an in-process deterministic op (POST /api/v1/gc) needing no confirmation.

Behavior

  • Warnings render identically (Warning: <issue> / Fix: <fix>).
  • When ≥1 warning has a fixAction, show a dim hint: Press f to run auto-fix. Re-run /doctor to verify.
  • Press f → runAutoFix iterates actionable warnings, calls each fixAction, shows done/error feedback with per-warning results. Guards against double-trigger while running.
  • No fixAction present → no hint, no useInput effect (byte-identical to today for warnings without auto-fix).
  • Matches repo convention: raw useInput with // eslint-disable-next-line custom-rules/prefer-use-keybindings for letter-key prompts (same class as y/n in DesktopHandoff).

Files

  • src/components/DoctorWarnings.tsx (new) — hand-written component + exported pure runAutoFix (test seam) + DoctorWarning/FixState types.
  • src/screens/Doctor.tsx — swap render call to <DoctorWarnings>, add import, drop dead _temp10.
  • src/__tests__/components/doctorWarnings.test.ts (new) — 9 tests on runAutoFix pure logic.

Tests

Repo has no ink render tests (terminal UI is not unit-rendered); the pure runAutoFix logic is unit-tested and the Doctor.tsx wiring is typecheck-verified. The data-layer fixAction: requestMlxGC callable path is already covered by doctorMlxHealth.test.ts (gc endpoint invoked).

9 new tests: all-success (count wording), singular-action wording, all-fail (joined messages), partial (ok + failed counts), non-Error throw (stringified), empty actionable, no-fixAction skip, running state first, mock called once per warning.

Gates

  • bun run typecheck — 0 errors
  • bun test src/__tests__/ — 469 pass
  • biome check — clean on new files (DoctorWarnings.tsx, test); Doctor.tsx has 23 pre-existing React-Compiler let tN implicit-any errors (not linted by CI for src/screens, untouched by this PR)
  • bun run build:dev — passes; binary boots (--version verified)
  • default behavior byte-identical when no fixAction present

E2E (real MLX)

fusion-mlx running (Llama-3.2-1B loaded). /api/v1/gc + /v1/health endpoints respond (auth-gated per PR #137 — 401 without token, adapter passes per-instance token; matches PR #125 fail-open design). Forcing OOM high/imminent to attach fixAction is not feasible without risking the running model; the callable path is unit-tested with mocked fetch.

Co-Authored-By: Claude Fable 5 [email protected]

…fix)

PR #131 landed the fixAction framework in the data layer (warnings carry
an optional callable fixAction, e.g. requestMlxGC for MLX OOM), but the
Doctor.tsx UI only rendered the fix text — the callback was never
invokable. The prior session deferred the UI wiring because Doctor.tsx is
vendored React-Compiler output (_c/$[N] memo slots) and hand-editing the
slots is fragile.

Resolve by extracting the warnings render into a new hand-written child
component (DoctorWarnings.tsx) that owns its own useInput. The parent's
memo slot $[36] still depends only on the warnings array reference, so
the compiler output is untouched except for swapping the render call.
This neutralizes both defer reasons: (1) no hand-editing of memo slots,
(2) no shared Confirmation context in Doctor (requestMlxGC is an in-process
deterministic op needing no confirmation).

Behavior:
- Warnings render identically (Warning: <issue> / Fix: <fix>).
- When >=1 warning has a fixAction, show "Press f to run auto-fix." hint.
- Press f -> runAutoFix iterates actionable warnings, calls each fixAction,
  shows done/error feedback with per-warning results. Guards against
  double-trigger while running. No fixAction -> no hint, no useInput effect.
- Matches repo convention: raw useInput with eslint-disable for letter-key
  prompts (same class as y/n in DesktopHandoff).

Tests: 9 new (runAutoFix pure logic — all-success/singular wording,
all-fail/partial/non-Error throw/empty/no-fixAction-skip/running-first/
mock-once). Repo has no ink render tests; pure logic is unit-tested and
the Doctor.tsx wiring is typecheck-verified.

Gates: typecheck 0, 469 tests pass, biome clean on new files, build:dev
passes, default behavior byte-identical when no fixAction present.

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit baf6ced into main Aug 26, 2026
1 check passed
@dahai80
dahai80 deleted the feat/doctor-fixaction-ui branch August 26, 2026 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant