Fix Fork Conversation live agent availability
Merged
AU
3mo ago+1826+1826+0123456789012345678901234567890123456789-311-311-012345678901234567890123456789
Closes #7286
Summary
- Load
SharedLiveAgentIndexthroughSharedLiveAgentIndexLoader, which includes process-detected snapshots instead of hook-store records only. - Preserve the context menu's
supportedWithoutProbecontract, but make hidden reasons inspectable through a DEBUG log and a testable availability helper. - Add regression coverage for a stale hook workspace/panel binding where the live scoped process is on the current panel.
Availability matrix
- Live Codex from cmux: supported without probe when a restorable snapshot is present.
- Live Claude from cmux: supported without probe when the transcript-backed snapshot is present.
- Restored after restart/hibernation: supported through
restoredAgentSnapshotsByPanelId. - Stale saved PID with restorable record: supported; stale PID does not block the snapshot.
- Codex launched inside Claude: unsupported launch capture is stripped before fork command derivation; kind fallback remains forkable.
- Remote/SSH with oversized startup input: unsupported when no launcher-free startup input exists.
- OpenCode direct local: requires probe, so context menu stays hidden; command palette can probe.
- OpenCode via
omoor remote-like context: supported without probe. - Vault/custom with
forkCommand: supported without probe; withoutforkCommand: unsupported. - Background/resumed with stale workspace/panel binding: fixed by including live process-detected snapshots in the shared index.
- Non-restorable hook/session-store data: unsupported.
Validation
./scripts/check-pbxproj.sh./scripts/lint-pbxproj-test-wiring.shpython3 scripts/swift_file_length_budget.pygit diff --check origin/main..HEAD- No reload, build, or
xcodebuildrun per request.
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.
Summary by cubic
Fixes Fork Conversation live agent availability by moving validation to an off‑main shared index with cached, scope‑checked agent PID identities and a bounded freshness window. Menus stay accurate across remaps and remain visible (disabled) during refresh; unvalidated or expired states fail closed.
- Bug Fixes
- Load
SharedLiveAgentIndexviaSharedLiveAgentIndexLoader, merging process‑detected snapshots with hook data andSurfaceResumeBindingIndexto fix stale workspace/panel links. - Run a serialized off‑main probe that validates cached agent PID identities and executable/session matches (
CachedAgentProcessIdentityValidator); serve cache while refreshing; refresh on menu open; fail closed until first load or on expiry; correct fallback validation for hook‑only snapshots. - Route availability through
WorkspaceForkAgentConversationAvailabilitywithagent_index_refreshing; show a disabled “Fork Conversation” while refreshing; gate actions on open availability; track only agent PIDs and identities, ignore unrelated child processes, and revalidate on process fingerprint changes.
- Load
Summary by CodeRabbit
- New Features
- Improved “fork conversation” context-menu availability with multi-state outcomes and richer hidden-reason diagnostics (including probe-required and unsupported scenarios).
- Added a dedicated shared live agent index loader to improve restoration/resume detection.
- Bug Fixes
- More reliable forking eligibility checks with clearer handling when terminal/workspace context is missing, plus correct stale-vs-live resolution.
- Tests
- Expanded coverage for live vs. stale restoration, fork availability transitions, and diagnostic reason reporting.