Skip to content

refactor(screens): extract pickNewSpinnerTip to pure helper (REPL split slice #11) - #181

Merged
dahai80 merged 1 commit into
mainfrom
feat/repl-split-slice11-spinner-tip-picker
Aug 28, 2026
Merged

dahai80 merged 1 commit into
mainfrom
feat/repl-split-slice11-spinner-tip-picker

Conversation

@dahai80

@dahai80 dahai80 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Summary

audit §1.1.1 god-module split — slice #11. 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.tsx 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.

Changes

  • NEW src/utils/spinnerTipPicker.ts — pickNewSpinnerTip(setters) pure helper + SpinnerTipPickerSetters type. Body moved verbatim; all field access via setters.*.
  • MOD src/screens/REPL.tsx — import helper, replace body with thin wrapper, drop now-unused getTipToShowOnSpinner/recordShownTip import block.
  • MOD 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:
    • 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

Extraction 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 errors
  • bun test src/__tests__/ → 842 pass / 0 fail
  • bunx biome check (changed files) → clean
  • bun run build:dev → pass

byte-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]

…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]>
@dahai80
dahai80 merged commit 5fc73d6 into main Aug 28, 2026
1 check passed
@dahai80
dahai80 deleted the feat/repl-split-slice11-spinner-tip-picker branch August 28, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant