Repository navigation
refactor(screens): extract viewedTask selector from god module REPL.tsx (audit 1.1.1) - #172
Merged
Merged
Conversation
…sx (audit 1.1.1) 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]>
This was referenced Aug 28, 2026
Merged
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.
Context
Third surgical extraction in the REPL.tsx god-module split (audit §1.1.1, task #170).
src/screens/REPL.tsxis a 7096-LOC god module (render tree + keybindings + task lists + compaction + tool permissions + session management in one file). The multi-session split strategy: survey → rank by closure-dependency count → extract the fewest-depend pure-helper / leaf cohesive subsystem first (safe, byte-identical, independently mergeable).Follows PR #168 (3 leaf components +
median(), −285 LOC) and PR #171 (2 spinner-state derives →utils/spinnerState.ts, −70 LOC).Change
The three viewed-task derives move from inline in REPL.tsx to a pure-function selector module — same pattern as PR #171 (pure-helper class, deps as args, no React, no side effects):
src/tasks/viewedTaskSelector.ts(NEW, 36 LOC):getViewedTask(tasks, viewingAgentTaskId)— raw record lookup by idgetViewedTeammateTask(viewedTask)— teammate-only narrowed (drivesinProgressToolUseIDsaccess)getViewedAgentTask(viewedTask, viewedTeammateTask)— teammate OR local_agent, drives downstream boolean checks (displayedMessages,placeholderText,hidePill,isBriefOnly, …)src/screens/REPL.tsx: the 6-line inline block replaced by 3 thin const call wrappers (identical namesviewedTask/viewedTeammateTask/viewedAgentTask→ identical downstream usage). Pure relocation + import wiring, byte-identical behavior. Removed now-unusedisInProcessTeammateTaskguard import (sole call site moved out). KeptInProcessTeammateTaskStatetype (still used at panel helper :4580) andisLocalAgentTask(two other call sites :796/:805/:4583).src/__tests__/tasks/viewedTaskSelector.test.ts(NEW, 10 tests) — selector narrowing branches: teammate preference, local_agent fallback, undefined/non-agent cases.LOC
src/screens/REPL.tsx: 6741 → 6732 (−9)src/tasks/viewedTaskSelector.ts: +36 (new)LOC win on the god module is small here, but the cohesion win is real — the selector logic (teammate-vs-local narrowing) is now reusable + unit-testable in isolation, and REPL's render function sheds one more inline derivation cluster.
Gates
bun run typecheck— 0 errorsbun test src/__tests__/— 714 pass (+10 new), 0 failbun run lint— net-zero vs 4601-error baseline (new file clean)bun run build:dev— 3757 modules, passesByte-identical
Pure relocation + import wiring. The three const bindings keep identical names and downstream usage; only the derivation moves out. Removed import (
isInProcessTeammateTask) had its single call site moved to the selector. Existing 704 tests cover the REPL render paths that consumeviewedAgentTask.Task #170 stays in_progress — full 4-6wk split continues in follow-up PRs.
Co-Authored-By: Claude Fable 5 [email protected]