Repository navigation
feat(doctor): wire fixAction to /doctor UI keypress (press f to auto-fix) - #140
Merged
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR #131 landed the
fixActionframework in the data layer (doctorDiagnostic.tswarnings carry an optional callablefixAction, e.g.requestMlxGCfor MLX OOMhigh/imminent), but theDoctor.tsxUI only rendered the fix text — the callback was never invokable from the screen. The prior session deferred the UI wiring (auditenhance-0819.mdline 684) because:Doctor.tsxis vendored React-Compiler output (_c/$[N]memo slots) — hand-editing the slots is fragile.This PR resolves both defer reasons and wires
fto trigger auto-fix.Approach
Extract the warnings render into a new hand-written child component (
DoctorWarnings.tsx) that owns its ownuseInput. The parent's memo slot$[36]still depends only on thediagnostic.warningsarray reference, so the compiler output is untouched except for swappingdiagnostic.warnings.map(_temp10)→<DoctorWarnings warnings={diagnostic.warnings} />and removing the now-dead_temp10helper.TextInput,StatusLine,ExportDialog, which already exist hand-written in the repo).requestMlxGCis an in-process deterministic op (POST/api/v1/gc) needing no confirmation.Behavior
Warning: <issue>/Fix: <fix>).fixAction, show a dim hint:Press f to run auto-fix. Re-run /doctor to verify.f→runAutoFixiterates actionable warnings, calls eachfixAction, showsdone/errorfeedback with per-warning results. Guards against double-trigger while running.fixActionpresent → no hint, nouseInputeffect (byte-identical to today for warnings without auto-fix).useInputwith// eslint-disable-next-line custom-rules/prefer-use-keybindingsfor letter-key prompts (same class asy/ninDesktopHandoff).Files
src/components/DoctorWarnings.tsx(new) — hand-written component + exported purerunAutoFix(test seam) +DoctorWarning/FixStatetypes.src/screens/Doctor.tsx— swap render call to<DoctorWarnings>, add import, drop dead_temp10.src/__tests__/components/doctorWarnings.test.ts(new) — 9 tests onrunAutoFixpure logic.Tests
Repo has no ink render tests (terminal UI is not unit-rendered); the pure
runAutoFixlogic is unit-tested and theDoctor.tsxwiring is typecheck-verified. The data-layerfixAction: requestMlxGCcallable path is already covered bydoctorMlxHealth.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,
runningstate first, mock called once per warning.Gates
bun run typecheck— 0 errorsbun test src/__tests__/— 469 passbiome check— clean on new files (DoctorWarnings.tsx, test);Doctor.tsxhas 23 pre-existing React-Compilerlet tNimplicit-any errors (not linted by CI forsrc/screens, untouched by this PR)bun run build:dev— passes; binary boots (--versionverified)fixActionpresentE2E (real MLX)
fusion-mlx running (Llama-3.2-1B loaded).
/api/v1/gc+/v1/healthendpoints respond (auth-gated per PR #137 — 401 without token, adapter passes per-instance token; matches PR #125 fail-open design). Forcing OOMhigh/imminentto attachfixActionis not feasible without risking the running model; the callable path is unit-tested with mocked fetch.Co-Authored-By: Claude Fable 5 [email protected]