Skip to content

refactor(repl): extract nested-state updater helpers from getToolUseContext (audit §1.1.1 slice #20) - #190

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

dahai80 merged 1 commit into
mainfrom
audit/repl-split-slice20-nestedstateupdater

Conversation

@dahai80

@dahai80 dahai80 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Audit §1.1.1 god-module split — slice #20 of the REPL.tsx decomposition (task #170).

What

updateFileHistoryState + updateAttributionState were two 14-LOC methods inside getToolUseContext with identical structure: same-ref-skip setAppState wrappers over a top-level slice. Both perf-critical (the skip avoids notifying all store listeners on every fileHistoryTrackEdit no-op).

Extracted to a single generic helper applyNestedStateUpdater<K extends "fileHistory" | "attribution">(setAppState, key, updater) in src/utils/nestedStateUpdater.ts. TS infers the slice type from the literal key, so the REPL thin wrappers carry no inline type literal and match the ToolUseContext signatures via inference. Same-ref skip preserved verbatim.

Numbers

  • REPL 6386 → 6361 (−25 net: −27 body +2 wrapper)
  • 19 → 20 slices, cumulative −710 → −735
  • 2 new files: helper (26 LOC) + 6 tests (13 assertions)

Byte-identical

Downstream (FileEditTool/FileWriteTool/MultiEditTool/NotebookEditTool/BashTool) reads the same updateFileHistoryState / updateAttributionState fields on the context object — the thin wrappers preserve the exact signatures and same-ref-skip behavior.

Gates

  • bun run typecheck — 0 errors
  • bun test src/__tests__/ — 902 pass / 0 fail
  • bunx biome check on new files — clean (REPL untouched, no autofix churn)
  • bun run build:dev — pass

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

…ontext (audit §1.1.1 slice #20)

updateFileHistoryState + updateAttributionState were two 14-LOC methods
inside getToolUseContext with identical structure: same-ref-skip
setAppState wrappers over a top-level slice. Both perf-critical (the
skip avoids notifying all store listeners on every fileHistory no-op).

Extract to a single generic helper applyNestedStateUpdater<K extends
'fileHistory'|'attribution'>(setAppState, key, updater) in
src/utils/nestedStateUpdater.ts. TS infers the slice type from the
literal key, so the REPL thin wrappers carry no inline type literal and
match the ToolUseContext signatures via inference. Same-ref skip
preserved verbatim.

REPL 6386 -> 6361 (-25 net: -27 body +2 wrapper). 19 -> 20 slices,
cumulative -710 -> -735. Byte-identical: downstream reads the same
updateFileHistoryState / updateAttributionState fields on the context.

4 gates: typecheck 0 / bun test src/__tests__/ 902 pass / biome new
files clean (REPL untouched, no autofix churn) / build:dev pass.

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit 0d7101e into main Aug 28, 2026
1 check passed
@dahai80
dahai80 deleted the audit/repl-split-slice20-nestedstateupdater branch August 28, 2026 15:36
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