Repository navigation
refactor(repl): extract composedOnScroll routing (audit §1.1.1 slice #15) - #185
Merged
Merged
Conversation
) Extract the composedOnScroll scroll-routing logic from REPL.tsx into a pure helper src/utils/composedOnScroll.ts (applyComposedOnScroll). No React hooks, no JSX, no await — only side effects are mutating lastUserScrollTsRef.current and dispatching to 4 callbacks/setters, byte-identical to the inlined useCallback body. REPL keeps a thin useCallback wrapper whose deps array [onRepin, onScrollAway, maybeLoadOlder, setAppState] is unchanged verbatim (feature() is a bun:bundle build-time DCE macro, not a runtime dep). Downstream reads the same const name. Tests (src/__tests__/utils/composedOnScroll.test.ts, 5 cases) cover the non-feature paths: timestamp write, sticky->onRepin, non-sticky-> onScrollAway(handle). KAIROS/BUDDY arms are DCE-off under bun test (no flag) and asserted not-invoked; production build:dev:full covers them. Gates: typecheck 0 / 865 tests / biome clean / build:dev pass. REPL 6468 -> 6455 (-13). Cumulative across 15 slices: -641. 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 #15
Extract the
composedOnScrollscroll-routing logic fromsrc/screens/REPL.tsxinto a pure helper.What
src/utils/composedOnScroll.ts—applyComposedOnScroll(sticky, handle, setters): no React hooks, no JSX, no await. Only side effects: mutatelastUserScrollTsRef.current+ dispatch to 4 callbacks/setters (onRepin/onScrollAway/maybeLoadOlder/setAppState). Byte-identical to the inlineduseCallbackbody.src/screens/REPL.tsx—composedOnScrolluseCallbackreplaced with thin wrapper; deps array[onRepin, onScrollAway, maybeLoadOlder, setAppState]unchanged verbatim (feature()is abun:bundlebuild-time DCE macro, not a runtime dep). Downstream reads same const name.src/__tests__/utils/composedOnScroll.test.ts— 5 cases: timestamp write, sticky→onRepin, non-sticky→onScrollAway(handle), every-scroll timestamp invariant, KAIROS/BUDDY arms DCE-off asserted.feature()DCE constraintfeature("KAIROS")/feature("BUDDY")arebun:bundlecompile-time macros. Underbun test(no build flag) they DCE tofalse→ themaybeLoadOlder+setAppState(clearcompanionReaction) arms are unreachable in unit tests (same pattern asfocusedDialogSelector.test.ts). Tests assert those arms not-invoked; productionbuild:dev:full(flags on) covers them.Gates (all pass)
bun run typecheckbun test src/__tests__/bunx biome check(new files)bun run build:devLOC
REPL 6468 → 6455 (−13). Cumulative across 15 slices: −641.
byte-identical
useCallbackdeps array unchanged verbatim → closure identity preserved.feature()branches untouched → same DCE behavior per build config.Co-Authored-By: Claude Fable 5 [email protected]