Repository navigation
refactor(screens): extract pickNewSpinnerTip to pure helper (REPL split slice #11) - #181
Merged
Merged
Conversation
…it slice #11) audit §1.1.1 god-module split. Extract the 35-LOC spinner-tip pick useCallback body from REPL.tsx into src/utils/spinnerTipPicker.ts as a pure-helper bundle (no React, no JSX, no hooks). REPL keeps a thin useCallback wrapper (deps array [setAppState, theme] unchanged verbatim) that passes refs + setters via a typed SpinnerTipPickerSetters object; downstream reads the same const name (byte-identical). Also fixes 3 pre-existing typecheck errors in the slice #10 test file rewindMessageState.test.ts (committed in PR #180), per the rule that any failing case must be located+fixed regardless of relation to the current change: - makeSetters messagesRef typed {current: Message[]} not {current: unknown[]} - promptSuggestion toEqual cast to Record<string, unknown> (prev literal narrowed the type, excess-prop check on the 5-field literal failed) - spyOn logSpy dropped 'as never' so .mockRestore() is not on 'never' REPL 6565 → 6538 (−27); cumulative off 7096 now −558. Gates: typecheck 0 / test 842 pass / lint clean / 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.
Summary
audit §1.1.1 god-module split — slice #11. Extract the 35-LOC spinner-tip pick
useCallbackbody fromREPL.tsxintosrc/utils/spinnerTipPicker.tsas a pure-helper bundle (no React, no JSX, no hooks).REPL.tsxkeeps a thinuseCallbackwrapper (deps array[setAppState, theme]unchanged verbatim) that passes refs + setters via a typedSpinnerTipPickerSettersobject. Downstream reads the same const name → byte-identical.Changes
src/utils/spinnerTipPicker.ts—pickNewSpinnerTip(setters)pure helper +SpinnerTipPickerSetterstype. Body moved verbatim; all field access viasetters.*.src/screens/REPL.tsx— import helper, replace body with thin wrapper, drop now-unusedgetTipToShowOnSpinner/recordShownTipimport block.src/__tests__/utils/rewindMessageState.test.ts— fix 3 pre-existing typecheck errors (committed in PR refactor(screens): extract rewindConversationTo + restoreMessageSync into rewindMessageState (audit 1.1.1) #180), per the rule that any failing case must be located + fixed regardless of relation to the current change:makeSettersmessagesReftyped{current: Message[]}not{current: unknown[]}promptSuggestiontoEqualcast toRecord<string, unknown>(prevliteral narrowed the type, excess-prop check on the 5-field literal failed)spyOnlogSpydroppedas neverso.mockRestore()is not onneverExtraction class
PURE-HELPER BUNDLE — lowest byte-identical risk. 2 closure deps (
setAppState,theme), 4 refs passable as fields. 35-LOC real async body (compute + fetch + state write). Replacement is a 1-line call amortizing the setters-object overhead. Avoids the slice #9 failure mode (trivial OR-chains net-INCREASE REPL).Verification
Gates (commit-must-pass):
bun run typecheck→ 0 errorsbun test src/__tests__/→ 842 pass / 0 failbunx biome check(changed files) → cleanbun run build:dev→ passbyte-identical default-off proof: helper is unconditional (no feature flag), but the REPL wrapper calls it with the same refs/setters and deps array as the inline body; downstream reads the same const. Behavior identical.
LOC
REPL 6565 → 6538 (−27); cumulative off 7096 now −558.
Continues task #170 (design-level REPL split). Prior slices: PR #168/#171/#172/#174/#175/#177/#178/#179/#180.
Co-Authored-By: Claude Fable 5 [email protected]