Repository navigation
refactor(repl): extract setInputValue routing (audit §1.1.1 slice #17) - #187
Merged
Merged
Conversation
Extract setInputValue useCallback body (27 LOC, 3 deps) to pure-helper src/utils/inputValueState.ts applySetInputValue(). Same aggregate-input pattern as slices #15/#16: typed InputValueStateSetters (7 fields), REPL keeps useCallback thin wrapper, deps array [setIsPromptInputActive, repinScroll, trySuggestBgPRIntercept] unchanged verbatim. RECENT_SCROLL_REPIN_WINDOW_MS (REPL-local const 3000) passed as recentScrollRepinWindowMs field to keep helper pure-agnostic. Behavior: (1) trySuggestBgPRIntercept(prev,value) hit -> early return; (2) empty->non-empty + scroll-stale (>= window) -> repinScroll; (3) sync inputValueRef.current + setInputValueRaw + setIsPromptInputActive(trim>0). Tests: 8 cases (repin+write+activate, intercept early-return, non-empty guard, scroll within-window/boundary, empty deactivate, whitespace guard, ref-sync-before-setters). 881/881 pass, typecheck 0, biome clean, build:dev ok. REPL 6434 -> 6420 (-14). Cumulative 7096 -> 6420 (-676) across 16 slices. Zero REPL import churn. Byte-identical behavior (deps + ref reads unchanged). 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 #17.
Extract
useCallback body (27 LOC, 3 deps) → pure-helper
src/utils/inputValueState.tsapplySetInputValue().Same aggregate-input pattern as slices #15 (
composedOnScroll) + #16 (setMessages):InputValueStateSetters(7 fields):trySuggestBgPRIntercept,repinScroll,setInputValueRaw,setIsPromptInputActive,inputValueRef,lastUserScrollTsRef,recentScrollRepinWindowMs.useCallbackthin wrapper, deps array[setIsPromptInputActive, repinScroll, trySuggestBgPRIntercept]unchanged verbatim.RECENT_SCROLL_REPIN_WINDOW_MS(REPL-local const = 3000) passed asrecentScrollRepinWindowMsfield to keep helper pure-agnostic.Behavior (byte-identical)
trySuggestBgPRIntercept(prev, value)hit → early return (no side effects).Date.now() - lastUserScrollTsRef >= window) →repinScroll()(fullscreen typing re-pin;lastUserScrollTsRefstarts 0 so first keypress always repins).inputValueRef.current+setInputValueRaw(value)+setIsPromptInputActive(value.trim().length > 0).Tests
src/__tests__/utils/inputValueState.test.ts— 8 cases:>=)active=false(trim().length > 0)Gates
bun run typecheckbun test src/__tests__/bunx biome check(new files)bun run build:devgit diffgrep empty)LOC
REPL 6434 → 6420 (−14). Cumulative 7096 → 6420 (−676) across 16 slices.
Continues audit §1.1.1 (task #170). Surgical, byte-identical behavior.
Co-Authored-By: Claude Fable 5 [email protected]