You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Refactor passes: dead code, ThreadView split, shared Insights CSS, provider process helper #1447
Audit of main @ 6967e43 (knip, jscpd, eslint no-unused-vars, file sizes) turned up four behaviour-preserving passes that touch disjoint files, run as parallel workers.
Dead code (production-unused, some kept alive only by tests): crewIntegration.ts label helpers (6), uiPrefs verbose-tool-cards / run-duration / vim getters, SNOOZE_PRESETS, clearPaneLayouts, chunkForPath, browseQueryForSubmit, worktrees.js gitOutForDiff, orchServer unused import, automations PRESETS, memory-sup boundCoderMemoryUrl, session-record configureSessionRecord.
Duplication (~1% overall): provider adapters copy the JSON-lines child-process plumbing (cursor/muse/opencode/codex/claude/grok, about 300 lines). Insights-style views copy ~400 lines of page CSS (Activity/Insights/Fleet/Digest/Kanban/Planboard/PrList).
Passes
A: dead code removal
B: move ThreadView.tsx sibling components into src/components/thread/
C: shared page CSS for the Insights views
D: shared JSON-lines process helper for provider adapters
Not now
Splitting createRunner (8.6k-line closure) and the ThreadView component body: worth doing, but they need a design pass (state threading), not a mechanical move. Follow-up once A–D land.
Follow-ups, not started: split createRunner (8.6k-line closure) and the ThreadView component body. Both need a design pass on how state flows through them before they can be split mechanically.
Four more passes, all behaviour-preserving. None of them touch files in the open round-1 PRs (#1448–#1451).
E: split electron/services.js (5.8k lines, 175 flat functions) into domain modules. services.js stays as the barrel, so require("./services") callers don't change.
F: move ThreadCard (673 lines), SettledRow, the status helpers and the smaller components out of Sidebar.tsx into src/components/sidebar/, verbatim, the same way pass B did for ThreadView.
G: createRunner has 123 inner functions. Lift the ones that don't touch closure state into a module, and write a design note on how to split the rest (state map plus proposed module seams).
H: SettingsModal.tsx (3.2k lines): give each settings pane its own component file under src/components/settings/.
Safety tests first: Claude idle reap and LRU eviction, and CI-workflow sign-off failing closed. Today neither is covered before the steps that move that code.
CI note: test (windows-latest) intermittently times out on the whole test/sidebar.test.tsx file. It has happened 3 times today, including on electron-only PRs. That's a pre-existing flake, filed as a suggested-work chip.
electron/runner.js goes from 9,321 to 2,628 lines. 18 flat runner-*.js modules now hold the code that moved out; runnerHelpers.js holds pure helpers and the other 17 are create<Seam>(ctx) factories. Every step is verified: verbatim moves, eager ctx deps checked by script, construction order, the full electron suite, typecheck and the real-Electron smoke test.
Still open from the original audit: the ThreadView component body (~4.4k lines) and the other large React components (Sidebar body ~3k, useCoder ~3.5k, Composer ~3k). These need hook extraction, not file moves.
Round 4: hook extraction in the big React components
Three workers in parallel, one per file. None of the open PRs touch these files.
I: useCoder.ts (4,510 lines, one ~3,500-line hook). Split it into domain sub-hooks that useCoder composes; the UseCoderResult shape stays identical.
J: ThreadView.tsx (5,042 lines, a ~4,400-line component). Extract custom hooks for closed state groups (scroll/stick-to-bottom, header, git/PR state, …).
The rule that keeps this behaviour-preserving: React runs effects in declaration order. Only contiguous hook groups move, and each new custom hook is called exactly where its group was. Each worker also writes a short state map and seam plan for its component under docs/superpowers/specs/, and stops at whatever can't be moved safely.
Later: the Sidebar component body (after #1453) and App.tsx.
Each PR was checked with a script: once the custom hooks are expanded, the component has the same effects in the same order as on main. Each is also a pure move ignoring indentation, and passes typecheck, vite build and renderer 2701/2701.
Before merging, I combined all five on a throwaway branch: electron 4126/4126, renderer 2701/2701, typecheck, build and smoke A–E all pass. Main's tree after merging matches that branch exactly.
Merging once CI is green:
Split IPC_HANDLERS into per-namespace modules (#1447 pass S) #1472 S: IPC_HANDLERS split into 11 namespace modules (ipc.js 2,476 → 176). The 262-channel set and every handler's source are identical. The modules hold exactly 262 handlers, so none is duplicated. Verified merged onto current main: electron 4126/4126, typecheck including the sync-ipc-preload check, and smoke A–E.
Still left: ios-simulator.js (a 2,685-line factory closure, needs the runner-style ctx seams).
ios-simulator.js part 1: parsers to a module, 20 closure-free helpers lifted (#1447 pass V) #1473 V part 1: ios-simulator.js 3,244 → 2,781 lines. The parsers moved to ios-simulator-parse.js, 20 closure-free helpers were lifted, and the seam plan is in docs/superpowers/specs/2026-10-05-ios-simulator-split.md. The worker lost its session to a network error after this part. I verified and merged what was committed: exports identical, pure move, no lifted function touches closure state (checked by script), simulator tests 327/327, electron 4126/4126, smoke A–E.
V2: the seam extraction, following that plan. A fresh worker started from main 5a9c2698.
Also fixed along the way: the Windows sidebar.test.tsx timeout (#1468), plus new safety tests for CI sign-off fail-closed and Claude idle reap (#1457).
Known open flake, found today: macOS workflow.test.js "stopRun mid-analyze" waitFor timeout. It predates these changes; there's a suggested-work chip on the thread.
What's left is deliberate: the residues each spec documents (the ThreadView switch-reset effect, the useCoder core effects, the Composer model picker), which need behaviour-level changes rather than moves.
Activity
currentbits commentedon Oct 4, 2026
All four passes are verified and open as PRs. They touch disjoint files, and each is mergeable on its own:
runJsonLinesandoverlayHomesprovider helpers: One JSON-lines process helper for the provider adapters (#1447 pass D) #1451 (+545 / −1,194). Electron 4109/4109.Follow-ups, not started: split
createRunner(8.6k-line closure) and the ThreadView component body. Both need a design pass on how state flows through them before they can be split mechanically.Merge pull request #1448 from currentbits/coder/refactor-a-remove-dea…
Merge pull request #1449 from currentbits/coder/refactor-b-split-thre…
Merge pull request #1450 from currentbits/coder/refactor-c-shared-ins…
Merge pull request #1451 from currentbits/coder/refactor-d-shared-pro…
currentbits commentedon Oct 4, 2026
Round 2
Four more passes, all behaviour-preserving. None of them touch files in the open round-1 PRs (#1448–#1451).
electron/services.js(5.8k lines, 175 flat functions) into domain modules.services.jsstays as the barrel, sorequire("./services")callers don't change.ThreadCard(673 lines),SettledRow, the status helpers and the smaller components out ofSidebar.tsxintosrc/components/sidebar/, verbatim, the same way pass B did for ThreadView.createRunnerhas 123 inner functions. Lift the ones that don't touch closure state into a module, and write a design note on how to split the rest (state map plus proposed module seams).SettingsModal.tsx(3.2k lines): give each settings pane its own component file undersrc/components/settings/.currentbits commentedon Oct 4, 2026
Round 1 merged (#1448–#1451). Round 2 is verified and open:
docs/superpowers/specs/2026-10-04-runner-split-design.md): Lift closure-free createRunner helpers, add the runner split design (#1447 pass G) #1454Round 3: the createRunner split, per G's design
create<Seam>(ctx)mechanism, plus the watchdogs seam. This is stacked on Lift closure-free createRunner helpers, add the runner split design (#1447 pass G) #1454.currentbits commentedon Oct 4, 2026
Round 3 progress
electron/runner-<seam>.jsfiles, because the packagers copy onlyelectron/*.js. The design note is corrected to match.runner.jsgoes from 9,120 to 8,345 lines.Merge order: #1457, #1454, #1456, #1458. #1452, #1453 and #1455 are independent.
CI note:
test (windows-latest)intermittently times out on the wholetest/sidebar.test.tsxfile. It has happened 3 times today, including on electron-only PRs. That's a pre-existing flake, filed as a suggested-work chip.test(runner): CI sign-off is not honoured during a notice-driven turn (…
currentbits commentedon Oct 5, 2026
Round 3 complete: the createRunner split
electron/runner.jsgoes from 9,321 to 2,628 lines. 18 flatrunner-*.jsmodules now hold the code that moved out;runnerHelpers.jsholds pure helpers and the other 17 arecreate<Seam>(ctx)factories. Every step is verified: verbatim moves, eager ctx deps checked by script, construction order, the full electron suite, typecheck and the real-Electron smoke test.electron/runner-<seam>.js, because the packagers copy onlyelectron/*.js.Merge order: #1457 → #1454 → #1456 → #1458 → #1459 → #1460. Round 2's #1452, #1453 and #1455 are independent.
Still open from the original audit: the ThreadView component body (~4.4k lines) and the other large React components (Sidebar body ~3k, useCoder ~3.5k, Composer ~3k). These need hook extraction, not file moves.
currentbits commentedon Oct 5, 2026
Round 4: hook extraction in the big React components
Three workers in parallel, one per file. None of the open PRs touch these files.
useCoder.ts(4,510 lines, one ~3,500-line hook). Split it into domain sub-hooks thatuseCodercomposes; theUseCoderResultshape stays identical.ThreadView.tsx(5,042 lines, a ~4,400-line component). Extract custom hooks for closed state groups (scroll/stick-to-bottom, header, git/PR state, …).Composer.tsx(3,531 lines, a ~3,000-line component). Extract custom hooks (speech, attachments, mentions/slash menus, vim, …).The rule that keeps this behaviour-preserving: React runs effects in declaration order. Only contiguous hook groups move, and each new custom hook is called exactly where its group was. Each worker also writes a short state map and seam plan for its component under
docs/superpowers/specs/, and stops at whatever can't be moved safely.Later: the Sidebar component body (after #1453) and
App.tsx.currentbits commentedon Oct 5, 2026
Round 4 complete: hook extraction
Each PR was checked with a script: once the custom hooks are expanded, the component has the same effects in the same order as on main. Each is also a pure move ignoring indentation, and passes typecheck, vite build and renderer 2701/2701.
Round 5
electron/worktrees.js(6,757 lines, 159 flat functions). Split into flatworktrees-*.jsdomain modules behind the same exports, like Split services.js into domain modules behind the same barrel (#1447 pass E) #1452 did for services.src/devCoder.ts(6,696 lines, the browser demo backend). Split by domain.src/App.tsx(~2,500-line component). Extract hooks with the same effect-order rules as round 4.24 remaining items
Merge pull request #1472 from currentbits/coder/refactor-s-split-ipc-…
currentbits commentedon Oct 5, 2026
Round 6
Merged:
sidebar.test.tsxsplit so each file fits the 20 s per-file budget. This fixes the recurring Windows CI timeout.cli-sessions.js2,566 → per-provider modules (42 exports, identical).store.js4,185 → 2,052 lines. The real-store round-trip is byte-identical with the clock and ids frozen; the prototype descriptors are identical.workflow.js2,557 → 1,106 lines (15 exports, identical; workflow tests 97/97).Before merging, I combined all five on a throwaway branch: electron 4126/4126, renderer 2701/2701, typecheck, build and smoke A–E all pass. Main's tree after merging matches that branch exactly.
Merging once CI is green:
IPC_HANDLERSsplit into 11 namespace modules (ipc.js 2,476 → 176). The 262-channel set and every handler's source are identical. The modules hold exactly 262 handlers, so none is duplicated. Verified merged onto current main: electron 4126/4126, typecheck including the sync-ipc-preload check, and smoke A–E.Still left:
ios-simulator.js(a 2,685-line factory closure, needs the runner-style ctx seams).Merge pull request #1473 from currentbits/coder/refactor-v-split-ios-…
currentbits commentedon Oct 5, 2026
IPC_HANDLERSsplit, merged. Main CI was green across all of round 6.ios-simulator.js3,244 → 2,781 lines. The parsers moved toios-simulator-parse.js, 20 closure-free helpers were lifted, and the seam plan is indocs/superpowers/specs/2026-10-05-ios-simulator-split.md. The worker lost its session to a network error after this part. I verified and merged what was committed: exports identical, pure move, no lifted function touches closure state (checked by script), simulator tests 327/327, electron 4126/4126, smoke A–E.5a9c2698.Merge pull request #1474 from currentbits/coder/refactor-v2-ios-simul…
currentbits commentedon Oct 5, 2026
Done: every file on the original list is split
create<Seam>(ctx)modules.ios-simulator.jsgoes 2,781 → 1,697 lines (3,244 → 1,697 including ios-simulator.js part 1: parsers to a module, 20 closure-free helpers lifted (#1447 pass V) #1473). Exports and the service's 32 return keys are identical; eager deps were checked by script; ESLintno-undefreports 0, so no seam reads closure state. Simulator tests 327/327, electron 4126/4126, smoke A–E.electron/runner.jselectron/worktrees.jssrc/devCoder.tselectron/services.jselectron/store.jssrc/useCoder.tssrc/components/ThreadView.tsxsrc/components/Sidebar.tsxelectron/ios-simulator.jssrc/components/Composer.tsxsrc/components/SettingsModal.tsxsrc/App.tsxelectron/cli-sessions.jselectron/workflow.jselectron/ipc.jsAlso fixed along the way: the Windows
sidebar.test.tsxtimeout (#1468), plus new safety tests for CI sign-off fail-closed and Claude idle reap (#1457).Known open flake, found today: macOS
workflow.test.js"stopRun mid-analyze"waitFortimeout. It predates these changes; there's a suggested-work chip on the thread.What's left is deliberate: the residues each spec documents (the ThreadView switch-reset effect, the useCoder core effects, the Composer model picker), which need behaviour-level changes rather than moves.
currentbits commentedon Oct 5, 2026
Correction to the table above:
electron/cli-sessions.json main is 187 lines (measured), not ~130.currentbits commentedon Oct 9, 2026
Done: passes A–D merged (#1448–#1451). Closing in the 2026-10-09 board cleanup (#1532).