Keep agent lifecycle through display-level status clears - #9303
azooz2003-bit wants to merge 9 commits into
Conversation
The tests job has been red on main since #9091: "Live PID routing and runtime mutations include a Dock-owned terminal" expects an agent's lifecycle to survive a bare clear_status, but controlSidebarScheduleStatusClear also runs clearAgentPID, and both owners dropped agentLifecycleStates[statusKey] there even when the key never recorded any PID state. A display-key clear therefore made a live agent hibernatable. The failure was masked until #9279 because workflow-guard-tests short-circuited the tests job for every PR. Gate the lifecycle removal on actual PID ownership: the workspace side clears lifecycle only for a key registered in agentPIDPanelIdsByKey, and the Dock side only when the clear actually removed PID state. Owned-key teardown (agent PID clears, hibernation entry, stale structured-hook keys) keeps clearing lifecycle, and explicit clears still go through clearAgentLifecycle. Fixes #9295 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe control-sidebar status clear now enforces agent PID ownership. The Dock-owned terminal mutation test preserves the running lifecycle state and verifies that queued status clearing follows a moved panel without clearing its PID or lifecycle state. ChangesAgent status cleanup
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 25✅ Passed checks (25 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@Sources/DockSplitStore`+RestoredAgentLifecycle.swift:
- Around line 247-256: Preserve status-scoped lifecycle state until its final
owner is removed: in Sources/DockSplitStore+RestoredAgentLifecycle.swift lines
247-256, remove lifecycle state only when no remaining runtime.agentPIDKeys
entry maps to statusKey; in Sources/Workspace+PanelLifecycle.swift lines
324-330, after removeAgentPIDOwnership, apply the equivalent check against
agentPIDKeysByPanelId[ownedPanelId] and lifecycleStatusKey. Add behavior-level
coverage that clears one of two same-status owners and verifies lifecycle state
remains, then clears the final owner and verifies it is removed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 6d3290d8-a694-4016-8091-40de7ecaa5e0
📒 Files selected for processing (2)
Sources/DockSplitStore+RestoredAgentLifecycle.swiftSources/Workspace+PanelLifecycle.swift
Keep clearAgentPID cleanup semantics unchanged for explicit teardown, including missing PID records. The display clear path now opts into requireOwnedKey so it cannot erase lifecycle owned by a different structured PID key.
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |
Fixes #9295.
clear_statusremoved the visible entry, then calledclearAgentPIDwith the bare status key. Workspace and Dock owners consequently removed lifecycle state even when that key did not own the structured agent PID. A live Dock-owned agent could lose its spinner, including when a stale Dock target followed the panel into a workspace.The shared status-clear route now requires PID-key ownership before performing PID and lifecycle teardown. The status entry still clears, structured PID and lifecycle state survive, and explicit
clear_agent_pidplus hibernation teardown keep their existing cleanup behavior. The implementation changes one operation boundary and leaves both owner implementations unchanged.Regression coverage proves the Dock-owned lifecycle survives the first display clear, removes the old fake lifecycle re-report, then proves a stale-owner clear follows a Dock-to-workspace transfer without removing PID or lifecycle state.
Evidence:
main: https://github.com/manaflow-ai/cmux/actions/runs/30686234195Both 34-test hibernation runs pass the explicit PID teardown regressions and fail only the same unrelated
testResumePreparationWithoutStartupInputStillLeavesHibernationexpectation. The independentrestoreCLIArgumentcompile repair is onmainthrough #9334.#9293 proposes the opposite product contract, where clearing a status also clears lifecycle state. This PR follows the existing regression expectation that display status and process lifecycle are separate.