Repository navigation
Fix stale Claude notification sidebar status - #6473
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughFixes stale sidebar agent status by adding a ChangesStale agent status PID tracking fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 1 warning, 1 inconclusive)
✅ Passed checks (20 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 |
Greptile SummaryThis PR fixes a stale-sidebar-status bug where the Claude
Confidence Score: 5/5Safe to merge — the production change is a single-argument addition to an existing optional parameter, well covered by the new regression test. The production change is minimal and self-contained: No files require special attention. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Claude as Claude Agent
participant Hook as cmux CLI Hook
participant Socket as cmux Socket Server
participant Sweep as Stale-PID Sweep
Claude->>Hook: notification event (CMUX_CLAUDE_PID set)
Hook->>Hook: resolve claudePid from env/session
Hook->>Socket: "set_status claude_code Needs input --pid=claudePid"
Note over Socket: agentPIDs[claude_code] = claudePid
Hook->>Socket: notify_target_async ...
Claude--xHook: abrupt exit (no SessionEnd)
Sweep->>Socket: probe agentPIDs[claude_code]
Note over Sweep: Before fix: no PID, sweep skips,<br/>status stays stale forever
Note over Sweep: After fix: PID present, process gone,<br/>sweep clears stale status
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Claude as Claude Agent
participant Hook as cmux CLI Hook
participant Socket as cmux Socket Server
participant Sweep as Stale-PID Sweep
Claude->>Hook: notification event (CMUX_CLAUDE_PID set)
Hook->>Hook: resolve claudePid from env/session
Hook->>Socket: "set_status claude_code Needs input --pid=claudePid"
Note over Socket: agentPIDs[claude_code] = claudePid
Hook->>Socket: notify_target_async ...
Claude--xHook: abrupt exit (no SessionEnd)
Sweep->>Socket: probe agentPIDs[claude_code]
Note over Sweep: Before fix: no PID, sweep skips,<br/>status stays stale forever
Note over Sweep: After fix: PID present, process gone,<br/>sweep clears stale status
Reviews (6): Last reviewed commit: "Merge branch 'main' into issue-6441-stal..." | Re-trigger Greptile |
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 `@cmuxTests/AgentSessionAutoResumeSwiftTests.swift`:
- Around line 29-36: The assertion on line 36 uses sourcePanelId from the
pre-restore workspace when calling agentHibernationLifecycleState, but since
restoreSessionSnapshot(_:) remaps panel IDs, you need to use the
restored/remapped panel ID instead. Capture the panel ID that results from the
restoreSessionSnapshot(_:) call on the restored workspace, and use that remapped
panel ID in the agentHibernationLifecycleState(panelId:fallback:) assertion
instead of sourcePanelId to properly verify that the lifecycle state was cleared
on the restored panel.
🪄 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
Run ID: d86d471a-4ed1-4003-95aa-871aad893b20
📒 Files selected for processing (3)
CLI/cmux.swiftcmuxTests/AgentSessionAutoResumeSwiftTests.swiftcmuxTests/ClaudeHookSurfaceResolutionSwiftTests.swift
Root Cause
Claude notification hooks computed the live Claude PID, but the
Needs inputsidebar status write did not pass that PID intoset_status. That leftclaude_codestatus entries without a matchingagentPIDsentry, so the stale-PID sweep had nothing to probe after abrupt agent exits. Persisted agent status is also restart-unsafe because PIDs are not restorable; current restore code drops that runtime state, and this PR locks it with coverage.Fix
setClaudeStatuscall, matching the existing running-status paths.Tests
set_status claude_code Needs inputcommand includes--pid, which fails without the fix.claude_codestatus is serialized but not re-applied as live runtime state on session restore.Local note: I reproduced the missing-PID command with a mock Unix socket and an existing tagged CLI because this task forbids local builds/xcodebuild. I did not run local xcodebuild/reload.
Closes #6441
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Fixes stale Claude "Needs input" sidebar status by attaching the live PID to notification updates so the stale-PID sweep can clear dead statuses. Also keeps the CLI status command within the line-length budget and prevents restoring runtime agent status/PIDs/lifecycle after restart.
set_statuscall and keep the emitted command within the line-length budget.--pidis present; session-restore test confirms persistedclaude_codestatus and PIDs are not reapplied and lifecycle resets tounknown.Written for commit cf0fdc5. Summary will update on new commits.
Summary by CodeRabbit
Release Notes
Bug Fixes
New Features
Tests