Repository navigation
refactor(screens): extract message-display derive into messageDisplayState (audit 1.1.1) - #177
Merged
Merged
Conversation
…State (audit 1.1.1) (#176) 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.
Sixth surgical extraction for audit §1.1.1 god-module split (
src/screens/REPL.tsx).What
Bundle 3 chained pure derives out of REPL.tsx (was lines 5748-5769):
usesSyncMessages(showStreamingText || !isLoading)displayedMessages(agent view | sync | deferred)placeholderText(input-baseline gate)New
src/utils/messageDisplayState.ts—deriveUsesSyncMessages+deriveDisplayedMessages+derivePlaceholderText+ aggregatederiveMessageDisplayState. No React, no hooks, deps as args.Byte-identical: returns ORIGINAL array refs (no spread copy) — preserves ref-identity for
Messagesmemo + length checks downstream. REPL keepsuseDeferredValue(messages)+userInputBaselineRefref, callsderiveMessageDisplayStateonce, destructures to SAME const names → downstream reads unchanged.Why this pick
Survey ranked
getFocusedInputDialog#1 (90 LOC) but it has 23 closure deps — survey's own stated #1 criterion was "fewest deps = safest". Contradiction. Per proven strategy (PR #174/#175): fewest-dep pure-helper = lowest byte-identical risk. Picked the 7-dep message-display bundle instead.Tests
messageDisplayState.test.ts— 19 tests:usesSyncMessages3 arms,displayedMessagesref-identity + agent-override + empty-array,placeholderTextbaseline gate + agent suppress, aggregate 7 cases incl. explicit ref-identity assertion (not a copy).Gates
bun run typecheck— 0 errorsbun test src/__tests__/— 769 pass (+19 new)bun run lint— net-zero vs baseline (4 lint-error lines unchanged)bun run build:dev— 3764 modulesCumulative
REPL.tsx 6709 → 6704. Cumulative off 7096: #168(−285)+#171(−70)+#172(−9)+#174(−17)+#175(−6)+#176(−5) = −392 LOC off the god module.
Co-Authored-By: Claude Fable 5 [email protected]