Repository navigation
refactor(repl): extract nested-state updater helpers from getToolUseContext (audit §1.1.1 slice #20) - #190
Merged
Conversation
…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]>
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 #20 of the REPL.tsx decomposition (task #170).
What
updateFileHistoryState+updateAttributionStatewere two 14-LOC methods insidegetToolUseContextwith identical structure: same-ref-skipsetAppStatewrappers over a top-level slice. Both perf-critical (the skip avoids notifying all store listeners on everyfileHistoryTrackEditno-op).Extracted to a single generic helper
applyNestedStateUpdater<K extends "fileHistory" | "attribution">(setAppState, key, updater)insrc/utils/nestedStateUpdater.ts. TS infers the slice type from the literal key, so the REPL thin wrappers carry no inline type literal and match theToolUseContextsignatures via inference. Same-ref skip preserved verbatim.Numbers
Byte-identical
Downstream (FileEditTool/FileWriteTool/MultiEditTool/NotebookEditTool/BashTool) reads the same
updateFileHistoryState/updateAttributionStatefields on the context object — the thin wrappers preserve the exact signatures and same-ref-skip behavior.Gates
bun run typecheck— 0 errorsbun test src/__tests__/— 902 pass / 0 failbunx biome checkon new files — clean (REPL untouched, no autofix churn)bun run build:dev— passCo-Authored-By: Claude Fable 5 [email protected]