fix(work-loop): compose the PR from every task's delivery, not just the last#80
Conversation
…he last workTasks now merges all task deliveries (changes unioned per path — first-touch kind, latest summary; messages and progress concatenated) and hands the aggregate to openPr, so a multi-task group's PR body reflects the whole group's changes instead of only the final task. Closes #79
📝 WalkthroughWalkthroughAdds an exported ChangesmergeDeliveries and workTasks integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/aitm/src/loop/work-loop.ts (1)
413-448: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftPreserve already-committed task deliveries on resume.
deliveriesonly contains results from this invocation. If a run crashes afterrunOneTask()commits and persists an earlier task as done, but before the group PR opens, the next run skips that task at Line 430 and Line 447 merges only later deliveries, soopenPrcan still miss committed changes from the skipped task. Persist or reconstruct per-task deliveries before skippingdonetasks, or block opening the group PR until the full aggregate can be rebuilt.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/aitm/src/loop/work-loop.ts` around lines 413 - 448, The group delivery aggregation in workTasks is only using deliveries from the current invocation, so a resumed run can skip already-done tasks and still miss their committed changes when mergeDeliveries is called. Update workTasks (and any helper state around runOneTask, PrGroup, and task.done) to persist or reconstruct each task’s delivery before skipping done tasks, so openPr can rebuild the full aggregate for the group; otherwise, defer/block PR opening until the complete delivery set is available.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/aitm/src/loop/work-loop.ts`:
- Around line 413-448: The group delivery aggregation in workTasks is only using
deliveries from the current invocation, so a resumed run can skip already-done
tasks and still miss their committed changes when mergeDeliveries is called.
Update workTasks (and any helper state around runOneTask, PrGroup, and
task.done) to persist or reconstruct each task’s delivery before skipping done
tasks, so openPr can rebuild the full aggregate for the group; otherwise,
defer/block PR opening until the complete delivery set is available.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 42d6efcc-cbad-4438-a6c4-c34372b548f4
📒 Files selected for processing (2)
packages/aitm/src/loop/work-loop.test.tspackages/aitm/src/loop/work-loop.ts
Summary
A multi-task group's PR was composed from only the last task's
WorkerDelivery, so the body's## Changesunder-reported earlier tasks' edits.workTasksnow merges every task's delivery and hands the aggregate toopenPr.Changes
src/loop/work-loop.ts— newmergeDeliveries()(exported for tests): unionschangesper path (first-touchkind, latestsummary), joins draft messages and progress entries;workTasksaccumulates all deliveries and returns the merge.Testing
src/loop/work-loop.test.ts:mergeDeliveriesunit tests (single passthrough; union/first-touch-kind/latest-summary) + an integration test assertingopenPrreceives a delivery covering both tasks' changes.bun test+node --testgreen (39);biome+tscclean.Closes #79
Summary by CodeRabbit
New Features
Bug Fixes