Repository navigation
refactor(repl): extract onCompactProgress switch to helper (audit §1.1.1 slice #19) - #189
Merged
Merged
Conversation
…ate helper (audit §1.1.1 slice #19) Extract the 37-LOC onCompactProgress switch (REPL getToolUseContext, 5 CompactProgressEvent cases routing 3 spinner setters) into a pure routing helper src/utils/compactProgressState.ts. No React hooks, no JSX, no async; only side effect = call 3 spinner setters, matching the original useCallback body verbatim (including \u2026 ellipsis escapes and COMPACT_STALL_HINT_MS threshold gate). REPL keeps a thin onCompactProgress wrapper passing the closure-captured spinner setters + COMPACT_STALL_HINT_MS; the getToolUseContext useCallback deps array is unchanged (spinner setters + const are stable refs/values, not in deps). Downstream reads the same ProcessUserInputContext.onCompactProgress field = byte-identical. formatDuration import dropped from REPL (now only used by the helper); CompactProgressEvent type added to the Tool.ts import. - REPL 6415 -> 6386 (-29 net; 10 insertions / 39 deletions) - New helper: src/utils/compactProgressState.ts (applyOnCompactProgress) - New test: src/__tests__/utils/compactProgressState.test.ts (9 tests, 19 assertions: all 5 event types, stall threshold boundary, configurable hint, compact_end null-clears) - Gates: typecheck 0 / 896 tests pass / biome clean / build:dev ok 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.
Audit §1.1.1 god-module split — slice #19
Extract the 37-LOC
onCompactProgressswitch (insidegetToolUseContext) into a pure routing helpersrc/utils/compactProgressState.ts.What
The
onCompactProgresscallback routed 5CompactProgressEventcases to 3 spinner setters (setSpinnerColor/setSpinnerShimmerColor/setSpinnerMessage), reading the REPL-localCOMPACT_STALL_HINT_MSconst +formatDuration. Pure routing: no React hooks, no JSX, no async. Only side effect = call the 3 setters, matching the original body verbatim (incl.\u2026ellipsis escapes + stall threshold gate).REPL keeps a thin
onCompactProgresswrapper passing closure-captured spinner setters +COMPACT_STALL_HINT_MS. ThegetToolUseContextuseCallback deps array is unchanged (spinner setters + const are stable, not in deps). Downstream reads the sameProcessUserInputContext.onCompactProgressfield → byte-identical.Changes
src/utils/compactProgressState.ts(new) —applyOnCompactProgress(event, setters)+CompactProgressSetterstype.src/__tests__/utils/compactProgressState.test.ts(new) — 9 tests, 19 assertions: all 5 event types, stall threshold boundary (below/at/above), configurable hint (not hardcoded 30s),compact_endnull-clears all 3.src/screens/REPL.tsx— thin wrapper;formatDurationimport dropped (now helper-only);CompactProgressEventadded to Tool.ts import.Surgical proof
REPL import diff = only 3 intended lines (+compactProgressState, −formatDuration, +CompactProgressEvent). 3 pre-existing biome autofix-collapsed multi-line imports restored to main's form (Rule 3).
Verification
bun run typecheck— 0 errorsbun test src/__tests__/— 896 pass (was 887, +9 new)bunx biome checkon new files — cleanbun run build:dev— passCumulative (audit §1.1.1)
18 slices landed (PR #168–#188). REPL 7096 → 6386 (−710 cumulative). This PR = slice #19.
Co-Authored-By: Claude Fable 5 [email protected]