Skip to content

refactor(repl): extract onCompactProgress switch to helper (audit §1.1.1 slice #19) - #189

Merged
dahai80 merged 1 commit into
mainfrom
audit/repl-split-slice19-oncompactprogress
Aug 28, 2026
Merged

dahai80 merged 1 commit into
mainfrom
audit/repl-split-slice19-oncompactprogress

Conversation

@dahai80

@dahai80 dahai80 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Audit §1.1.1 god-module split — slice #19

Extract the 37-LOC onCompactProgress switch (inside getToolUseContext) into a pure routing helper src/utils/compactProgressState.ts.

What

The onCompactProgress callback routed 5 CompactProgressEvent cases to 3 spinner setters (setSpinnerColor/setSpinnerShimmerColor/setSpinnerMessage), reading the REPL-local COMPACT_STALL_HINT_MS const + formatDuration. Pure routing: no React hooks, no JSX, no async. Only side effect = call the 3 setters, matching the original body verbatim (incl. \u2026 ellipsis escapes + stall threshold gate).

REPL keeps a thin onCompactProgress wrapper passing closure-captured spinner setters + COMPACT_STALL_HINT_MS. The getToolUseContext useCallback deps array is unchanged (spinner setters + const are stable, not in deps). Downstream reads the same ProcessUserInputContext.onCompactProgress field → byte-identical.

Changes

  • src/utils/compactProgressState.ts (new) — applyOnCompactProgress(event, setters) + CompactProgressSetters type.
  • 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_end null-clears all 3.
  • src/screens/REPL.tsx — thin wrapper; formatDuration import dropped (now helper-only); CompactProgressEvent added 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 errors
  • bun test src/__tests__/ — 896 pass (was 887, +9 new)
  • bunx biome check on new files — clean
  • bun run build:dev — pass
  • REPL 6415 → 6386 (−29 net; 10 insertions / 39 deletions)

Cumulative (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]

…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]>
@dahai80
dahai80 merged commit 427400b into main Aug 28, 2026
1 check passed
@dahai80
dahai80 deleted the audit/repl-split-slice19-oncompactprogress branch August 28, 2026 15:17
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