Replace agent-session quickpick with a smart dispatcher#5262
Replace agent-session quickpick with a smart dispatcher#5262ianhattendorf wants to merge 1 commit into
Conversation
🤖 Augment PR SummarySummary: This PR replaces the “open agent session” action quickpick with a deterministic dispatcher that chooses the best action based on session host + workspace state. Changes:
Technical Notes: Peer notification is best-effort and the UI wait is capped (~500ms) so unresponsive peers don’t stall the click. 🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Pull request overview
Replaces the “open agent session” action quickpick with a deterministic dispatcher that routes to the Claude Code VS Code extension, focuses the owning terminal, or coordinates with a peer GitLens window via a new IPC route.
Changes:
- Add session-host classification via Claude session metadata (
~/.claude/sessions/<pid>.json) and use it to choose extension vs CLI behavior - Add peer-window session pre-open support (
agents/sessions/openIPC handler +notifyPeerOpenSession) and wire it into session dispatch - Extract Claude extension availability checks into a shared utility and add unit tests for the new behaviors
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/plus/agents/agentRegistry.ts | Moves Claude extension constants/availability check into a shared util and re-exports them for agent picking/dispatch. |
| src/env/node/providers.ts | Wires a new callback to open sessions in the Claude Code extension from the host side. |
| src/agents/utils/claudeSessionFile.ts | Adds Claude session metadata parsing + host classification helper. |
| src/agents/utils/-webview/claudeExtension.ts | Centralizes Claude extension IDs/commands and availability detection. |
| src/agents/utils/tests/claudeSessionFile.test.ts | Adds unit tests for host classification (missing/malformed/stale/entrypoint variants). |
| src/agents/agentStatusService.ts | Replaces action quickpick with deterministic dispatch logic (extension/terminal/peer+openFolder). |
| packages/plus/agents/src/types.ts | Extends provider/callback contracts for peer session open + host-triggered extension open. |
| packages/plus/agents/src/providers/claudeCodeProvider.ts | Adds agents/sessions/open IPC handler and implements notifyPeerOpenSession to contact peers. |
| packages/plus/agents/src/tests/claudeCodeProvider.test.ts | Adds tests for the new IPC handler and peer notification behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Routes session opens deterministically by host: extension-hosted (entrypoint=claude-vscode) opens in the Claude Code extension, CLI-hosted focuses the owning terminal window, out-of-workspace asks a peer GitLens window to pre-open the session then switches the folder - Adds an `agents/sessions/open` IPC route so a peer window can open a session in its Claude Code extension on behalf of the current window; caps the peer-notify wait at 500ms so an unhealthy peer can't stall the click - Reads `~/.claude/sessions/<pid>.json` for the `entrypoint` field to classify the host, with a stale-file guard (pid mismatch returns undefined) and a sensible fallback when the file is missing
eb310f3 to
32a709d
Compare
Summary
Replaces the action-pick quickpick that fired on "open agent session" with a deterministic dispatcher that picks the right action based on session host + workspace state:
pidagents/sessions/openIPC route), thenvscode.openFolderto focus that peer's windowHost classification reads
~/.claude/sessions/<pid>.jsonfor theentrypointfield, with a stale-file guard (file'spidfield must match the filename) and a sensible "extension if installed, else CLI" fallback when the metadata file is missing.The peer-notify call is capped at 500 ms so an unhealthy peer can't stall the click — the POST keeps running in the background after
vscode.openFolderlands.Test plan
pnpm run test:packages(4 newagents/sessions/openIPC handler cases, 3 newnotifyPeerOpenSessioncases) andpnpm run test(7 newclassifyClaudeSessionHostcases) all passvscode.openFolderfalls through and the current window switches to the folder