refactor(progress-monitor): extract 4 single-responsibility modules from god class#538
Conversation
|
✨ On it — checking the progress monitor refactor Progress: [███░░░░░░░] 30% (iteration 21/70) 🔍 Code Review Update (1 min) I've completed a thorough review of the Last updated: iteration 21 · review |
nhopeatall
left a comment
There was a problem hiding this comment.
LGTM — Clean extraction of a god class into four focused, single-responsibility modules. The decomposition preserves the original behavior faithfully, the public API is unchanged, and the new module boundaries (accumulation, scheduling, PM posting, GitHub posting) are well-chosen.
One minor observation (not blocking): ProgressAccumulator.startTime is now set at construction time (readonly startTime = Date.now()) rather than being reset in ProgressMonitor.start() as the original code did. In practice this is negligible — the gap between constructor and start() is milliseconds, and elapsed time is reported in minutes — but worth noting for completeness.
The 46 new tests cover each extracted module's key behaviors well, and all 44 existing integration-level tests continue to pass unchanged, which is strong evidence the refactoring is behavioral-preserving.
Summary
Refactors
src/backends/progressMonitor.tsfrom a 423-line god class with 5+ mixed responsibilities into a thin orchestrator (~245 lines) that composes four single-responsibility modules.Card: https://trello.com/c/699dd8e10c3df6b4b67541ec
Extracted modules
src/backends/progressState/accumulator.ts— Ring buffer state accumulation (ProgressAccumulator): tool calls, text snippets, completed tasks, iteration tracking, plussummarizeToolParams()andgetSnapshot().src/backends/progressState/scheduler.ts— Progressive timer scheduling (ProgressScheduler): fires ticks at [1, 3, 5] min, thenintervalMinutessteady-state. Pure scheduling — no business logic.src/backends/progressState/pmPoster.ts— PM comment lifecycle (PMProgressPoster): create-once / update-in-place / fallback-to-new pattern with state file coordination.src/backends/progressState/githubPoster.ts— GitHub PR comment updates (GitHubProgressPoster): session state lookup, comment formatting, andupdatePRComment()call.Changes to
progressMonitor.tsProgressMonitorConfig,ProgressMonitor,ProgressReporterinterface,start(),stop(),getProgressCommentId()all preservedNew unit tests (46 tests across 4 files)
accumulator.test.ts— Ring buffer bounds, param summarization, snapshot copiesscheduler.test.ts— Progressive schedule, steady-state fallback, stop-during-tick safetypmPoster.test.ts— Create/update/fallback lifecycle, state file coordinationgithubPoster.test.ts— Session state lookup, comment body substitutionTest plan
npm test→ 3185 tests passing)npm run typecheck)npm run lint) — pre-existingadapter.tswarning is unchanged🤖 Generated with Claude Code