Repository navigation
refactor(screens): extract spinner-state derives from god module REPL.tsx (audit 1.1.1) - #171
Merged
Merged
Conversation
….tsx (audit 1.1.1) Second surgical extraction from REPL.tsx (audit §1.1.1 god-module split, continues PR #168 checkpoint). Two pure useMemo derives — onlySleepToolActive and stopHookSpinnerSuffix — moved to src/utils/spinnerState.ts as pure functions taking their closure deps as args. REPL keeps thin useMemo cache wrappers. Zero closure mutation, zero behavior change. Removed 3 now-unused REPL imports (truncateToWidth, ProgressMessage, HookProgress) re-homed into spinnerState.ts. REPL.tsx 6811→6741 (−70 LOC). Gates: typecheck 0 / 704 tests pass / lint net-zero 4601 / build:dev 3756 modules. Co-Authored-By: Claude Fable 5 <[email protected]>
dahai80
added a commit
that referenced
this pull request
Aug 28, 2026
…sx (audit 1.1.1) (#172) Third surgical extraction in the REPL.tsx god-module split (audit §1.1.1). The three viewed-task derives (viewedTask / viewedTeammateTask / viewedAgentTask) move from inline in REPL.tsx to a pure-function selector module: src/tasks/viewedTaskSelector.ts. No React, no side effects — deps as args. - getViewedTask: raw record lookup by id - getViewedTeammateTask: teammate-only narrowed (in_progress_teammate) - getViewedAgentTask: teammate OR local_agent — drives downstream boolean checks REPL keeps the three const bindings as thin call wrappers (identical names, identical downstream usage) — pure relocation + import wiring, byte-identical behavior. Removed now-unused isInProcessTeammateTask guard import from REPL (sole call site moved out); kept InProcessTeammateTaskState type (still used at the panel helper) and isLocalAgentTask (two other call sites). REPL.tsx 6741 → 6732 LOC (-9). viewedTaskSelector.ts +36 LOC (new). Cohesion win: selector logic now reusable + unit-testable in isolation. Gates: typecheck 0 / 714 tests pass (+10 new) / lint net-zero vs 4601 baseline / build:dev 3757 modules. Follows PR #168 (leaf components, -285) + PR #171 (spinner derives, -70) in the multi-session split. Task #170 stays in_progress — full 4-6wk split continues in follow-up PRs. Co-authored-by: Claude Fable 5 <[email protected]>
dahai80
added a commit
that referenced
this pull request
Aug 28, 2026
…odule (audit 1.1.1) (#174) Fourth surgical extraction — pure-helper bundle class (matches PR #171 spinnerState.ts pattern). 5 chained pure derives moved out of REPL.tsx: isWaitingForApproval (4 queue/pending inputs → boolean) isShowingLocalJSXCommand (toolJSX → boolean, phantom-overlay guard) titleIsAnimating (isLoading + 2 above → boolean) sessionStatus (2 above → TabStatusKind idle/busy/waiting) waitingFor (sessionStatus + queues → string|undefined) New src/utils/terminalApprovalState.ts (90 LOC): - deriveIsWaitingForApproval(input) - deriveIsShowingLocalJSXCommand(toolJSX) - deriveTerminalApprovalState(input) — aggregate, returns all 5 Types: TerminalApprovalInput + TerminalApprovalState + ToolJsxLike. REPL keeps the hook-bound vars (haikuTitle/setHaikuTitle useState, haikuTitleAttemptedRef useRef, terminalTitleFromRename useAppState, agentTitle, sessionTitle, terminalTitle) + the two useEffects (prevent-sleep 1399, PID-file status push 1425). Only the 5 pure derives (no hooks, no JSX) move out. REPL calls deriveTerminalApprovalState once, destructures to same const names → downstream reads unchanged (byte-identical). Removed now-unused TabStatusKind import from REPL (helper owns the type now). Why not the #1 survey-stack candidate: survey-stack is a leaf-component (JSX, React-compiler form to preserve) — higher byte-identical risk. This pure-helper bundle has no JSX, no hooks — plain functions, lowest risk, matches the proven PR #171 extraction pattern. Test: src/__tests__/utils/terminalApprovalState.test.tsx (14 tests): - isWaitingForApproval: empty=false, each queue/pending → true - isShowingLocalJSXCommand: null/undefined/false, phantom-overlay guard (isLocalJSXCommand true + jsx null = false), true case - aggregate: idle/busy/waiting + titleIsAnimating suppression, waitingFor fallthrough chain (approve→worker→sandbox→dialog→input), local-JSX suppresses animation when loading REPL.tsx 6732 → 6715 (−17). Cumulative off 7096 god module: PR#168 −285 + PR#171 −70 + PR#172 −9 + this −17 = −381 LOC. Gates: typecheck 0 / 735 tests (+14 new) / lint net-zero 4601 / build:dev 3763 modules. Co-authored-by: Claude Fable 5 <[email protected]>
dahai80
added a commit
that referenced
this pull request
Aug 28, 2026
…t 1.1.1) (#175) Third spinner-visibility derive (onlySleepToolActive/stopHookSpinnerSuffix landed in #171) now joined by deriveShowSpinner — completes the spinner cluster in utils/spinnerState.ts. REPL.tsx 2034-2053 inline 20-line boolean expression moved out as a pure helper taking an aggregate input object (11 deps). Byte-identical: helper body is the original expression verbatim; deps passed eagerly (getCommandQueueLength has no side effects, only reads .length). REPL keeps the toolJSX/queue/isLoading/etc bindings and calls deriveShowSpinner once. -6 LOC off the god module (6715 -> 6709). Types aligned to real sources: userInputOnProcessing is string|undefined (truthy-checked as in original), pendingWorkerRequest {toolName}|null. 15 new unit tests (spinnerStateShowSpinner.test.ts) cover each gate: toolJSX showSpinner flag, confirm/prompt queue gating, 4 busy arms (loading/userInput/teammates/queue), pendingWorkerRequest suppress, onlySleepToolActive suppress, visibleStreamingText suppress + isBriefOnly exemption, all-suppressors case. Gates: typecheck 0 / 750 tests (+15) / lint 4601 net-zero / build:dev 3763. Co-authored-by: Claude Fable 5 <[email protected]>
dahai80
added a commit
that referenced
this pull request
Aug 28, 2026
…State (audit 1.1.1) (#176) (#177) Sixth surgical extraction for audit §1.1.1 god-module split. Bundle 3 chained pure derives out of REPL.tsx (was 5748-5769): - usesSyncMessages (showStreamingText||!isLoading) - displayedMessages (agent view|sync|deferred, ref-preserving) - placeholderText (input-baseline gate) src/utils/messageDisplayState.ts NEW — deriveUsesSyncMessages + deriveDisplayedMessages + derivePlaceholderText + aggregate deriveMessageDisplayState. No React, no hooks, deps as args. Returns ORIGINAL array refs (no spread copy) — preserves ref-identity for Messages memo + length checks downstream. Byte-identical to inline. REPL keeps useDeferredValue(messages) + userInputBaselineRef ref; calls deriveMessageDisplayState once, destructures to SAME const names → downstream reads unchanged. Picked 7-dep bundle over survey #1 getFocusedInputDialog (90 LOC but 23 deps) — strategy = fewest-dep pure-helper = lowest byte-identical risk (per proven PR #174/#175 pattern). Tests: messageDisplayState.test.ts 19 tests — usesSyncMessages 3 arms, displayedMessages ref-identity + agent-override + empty-array, placeholderText baseline gate + agent suppress, aggregate 7 cases including ref-identity assertion (not a copy). REPL.tsx 6709 → 6696 (−13). Cumulative off 7096: #168(−285)+#171(−70)+#172(−9)+#174(−17)+#175(−6)+#176(−13) = −400 LOC. Gates: typecheck 0 / 769 tests (+19) / lint net-zero 4601 / build:dev 3764. Co-authored-by: Claude Fable 5 <[email protected]>
This was referenced Aug 28, 2026
Merged
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 (2nd extraction, continues PR #168)
Second surgical extraction from
REPL.tsx(audit~/fusion/audit/fusion-code-audit-result-0827.md§1.1.1 "god module"). Follows the PR #168 pattern: extract leaf / pure-helper with zero closure mutation, byte-identical behavior, independently mergeable.What moved
Two pure
useMemoderives (both spinner-visibility state, no React state mutation, no refs) → newsrc/utils/spinnerState.tsas plain pure functions taking their closure deps as args:onlySleepToolActivemessages,inProgressToolUseIDsstopHookSpinnerSuffixmessages,isLoadingREPL keeps thin
useMemocache wrappers (deps unchanged) — pure logic + caching split cleanly.Imports cleaned
3 now-unused REPL imports removed (re-homed into
spinnerState.ts):truncateToWidth(format.js),ProgressMessage(message.js type),HookProgress(hooks.js type).count+isInternalBuildkept — still used elsewhere in REPL.LOC
REPL.tsx6811 → 6741 (−70 LOC).spinnerState.ts+101 (incl. header comment + 2 functions).Gates (commit-must-pass)
bun run typecheck— 0 errorsbun test src/__tests__/— 704 pass / 0 failbun run lint— net-zero 4601 errors (baseline exact match; new filespinnerState.tsclean, 0 new diagnostics)bun run build:dev— pass, 3756 modulesbyte-identical
Both derives are pure reads of their args → output identical for same inputs.
useMemodeps arrays unchanged ([messages, inProgressToolUseIDs]/[messages, isLoading]). No behavior change, no feature flag.Continues
#170 design-level split. PR #168 was the 1st extraction (3 leaf components +
median()→ array.ts, REPL 7096→6811). This is the 2nd. Full 4-6wk split continues in follow-up PRs (REPL() cohesive-subsystem extractions; §1.1.2 ctx seam decision; §1.1.3 layer enforcement; §1.3.1 KV-cache adapter — all multi-session design work).Co-Authored-By: Claude Fable 5 [email protected]