Repository navigation
refactor(screens): extract restoreReadFileState to pure helper (REPL split slice #12) - #182
Merged
Merged
Conversation
…split slice #12) audit 1.1.1 god-module split. Extract the restoreReadFileState useCallback body from REPL.tsx into a pure helper src/utils/readFileStateRestore.ts. No React, no JSX, no hooks; only side effect mutates the two passed-in refs (readFileState.current = mergeFileStateCaches, bashTools.current.add), matching the original deps=[] useCallback verbatim. REPL keeps a thin useCallback wrapper (deps unchanged); downstream reads the same const name -> byte-identical. Two now-unused imports dropped (mergeFileStateCaches, extractBashToolsFromMessages). Tests: src/__tests__/utils/readFileStateRestore.test.ts (5 cases) assert bashTools accumulation, cross-call Set union, readFileState.current ref reassignment (merge returns clone), non-bash skip, non-string-command skip. Gates: typecheck 0 / 847 tests / lint clean new files / build:dev 3769 modules. REPL 6538 -> 6529 (-9 LOC; -567 cumulative off 7096 baseline). 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.
Context
audit §1.1.1 god-module split (task #170). Continues the multi-session REPL.tsx extraction series (slices #168-#181 landed). This slice extracts the
restoreReadFileStateuseCallback body into a pure helper.Change
src/utils/readFileStateRestore.ts— pure helperrestoreReadFileState(messages, cwd, setters). No React, no JSX, no hooks. Only side effect: mutates the two passed-in refs (readFileState.current = mergeFileStateCaches(...),bashTools.current.add(tool)), matching the originaldeps=[]useCallback body verbatim. ExportsRestoreReadFileStateSetterstype.src/screens/REPL.tsx— import the helper asrestoreReadFileStateImpl; replace the useCallback body with a thin wrapper that forwards{ readFileState, bashTools }. Downstream reads the sameconst restoreReadFileStatename → byte-identical. Two now-unused imports dropped (mergeFileStateCaches,extractBashToolsFromMessages).src/__tests__/utils/readFileStateRestore.test.ts— 5 cases: bashTools accumulation, cross-call Set union (no dup), readFileState.current ref reassignment (merge returns clone → new ref), non-bash tool_use skip, non-string command skip.byte-identical proof
deps=[]on the REPL useCallback is unchanged (no closure deps — refs are passed in). The helper reproduces the exact mutation order (merge then add). Downstream call sites read the sameconst restoreReadFileStateand pass the same args. Off = today's behavior (no env gate needed — this is a pure extraction, no new behavior).Gates
bun run typecheck— 0 errorsbun test src/__tests__/— 847 pass / 0 failbunx biome checkon new files — clean (REPL.tsx baseline net-zero, untouched)bun run build:dev— 3769 modules,./fusion-code-devbuiltREPL 6538 → 6529 (−9 LOC; −567 cumulative off 7096 baseline).
Co-Authored-By: Claude Fable 5 [email protected]