Repository navigation
refactor(screens): extract stream message dispatch sub-block (audit 1.1.1 slice #30) - #201
Merged
Merged
Conversation
….1.1 slice #30) Extract REPL onQueryEvent → handleMessageFromStream first callback (L2954-3016, 62-LOC message-dispatch sub-block) into src/utils/streamMessageDispatch.ts as createStreamMessageDispatch(ctx) factory returning the (newMessage) => void callback. Routes incoming streamed message to the right setMessages mutation: - compact-boundary → replace (or append in fullscreen) + bump conversationId - ephemeral tool-progress tick → replace last same-tool tick (no array blowup) - otherwise → append Plus proactive context-block toggle on API errors / success. Pure-routing sub-block extraction class (proven via slices #19/#25-#29): reads only setters + module helpers, no React hooks, no closures over REPL state beyond the explicitly-passed ctx. ~9 deps via ctx object vs the parent onQueryEvent's 15+ — manageable, avoids the getToolUseContext factory ctx-reconstruct risk (lesson #18). REPL 6034 → 5976 (-58 net). Byte-identical behavior: factory passes the same setMessages/setConversationId/proactiveModule the inline closure captured. Removed now-unused isEphemeralToolProgress import (import-cleanup lesson #22); isCompactBoundaryMessage kept (still used at L3073). Gates: typecheck 0 / 921 tests pass / biome exit 0 / 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.
Audit §1.1.1 God-Module Split — slice #30
Extract REPL
onQueryEvent → handleMessageFromStreamfirst callback (L2954-3016, 62-LOC message-dispatch sub-block) intosrc/utils/streamMessageDispatch.tsascreateStreamMessageDispatch(ctx)factory returning the(newMessage) => voidcallback.What it does
Routes an incoming streamed message to the right
setMessagesmutation:conversationIdPlus proactive
setContextBlockedtoggle on API errors / success.Why this slice
Pure-routing sub-block extraction class (proven via slices #19/#25-#29): reads only setters + module helpers, no React hooks, no closures over REPL state beyond the explicitly-passed ctx. ~9 deps via ctx object vs the parent
onQueryEvent's 15+ — manageable, avoids thegetToolUseContextfactory ctx-reconstruct risk (lesson #18).Byte-identical
Factory passes the same
setMessages/setConversationId/proactiveModulethe inline closure captured. Removed now-unusedisEphemeralToolProgressimport (import-cleanup lesson #22);isCompactBoundaryMessagekept (still used at L3073).Gates
bun run typecheck— 0 errorsbun test src/__tests__/— 921 passbunx biome check— exit 0 (info-onlyuseNodejsImportProtocolmatches REPL's pre-existing"crypto"convention)bun run build:dev— passDelta
REPL 6034 → 5976 (−58 net). New file 105 LOC. Cumulative across 30 slices: REPL 7096 → 5976 (−1120).
Continues #170 (design-level REPL split). All slices byte-identical, no env gates.
Co-Authored-By: Claude Fable 5 [email protected]