feat: global agent discovery — show all Claude sessions across the machine#103
Open
Commandershadow9 wants to merge 2 commits intopablodelucca:mainfrom
Open
feat: global agent discovery — show all Claude sessions across the machine#103Commandershadow9 wants to merge 2 commits intopablodelucca:mainfrom
Commandershadow9 wants to merge 2 commits intopablodelucca:mainfrom
Conversation
Scan ALL ~/.claude/projects/ directories for active Claude sessions, not just the current workspace. Sessions without a VS Code terminal (e.g., subprocess calls, external agents) appear as "headless" agents. Changes: - types.ts: terminalRef optional, isHeadless flag, lastActivityMs - constants.ts: global scan intervals, headless timeout (5min) - fileWatcher.ts: globalScanForAgents(), recursive subagent scanning, createHeadlessAgent(), checkHeadlessActivity() auto-despawn - agentManager.ts: headless-aware persist/restore - PixelAgentsViewProvider.ts: global scan timer, headless focus (opens JSONL file), headless close (direct removal) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wrap global scan and headless activity checks in try/catch to prevent extension crashes. Delay initial global scan by 3 seconds to let normal agent restoration complete first. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Today, Pixel Agents only shows Claude sessions that are either started via the extension's "+" button or detected in the current workspace's project directory. But Claude Code sessions can run in many places:
claude -p "..."invocations from scripts, CI/CD, or automation toolsAgenttool, each gets its own JSONL in asubagents/subdirectoryAll of these sessions write JSONL transcripts under
~/.claude/projects/, but only the current workspace's directory is scanned. The result: the office feels empty even when multiple Claude sessions are actively working.This PR makes one VS Code window show ALL active Claude sessions across the entire machine. Agents spawn when sessions start, animate when tools execute, and despawn when sessions end — the office becomes a live dashboard of everything Claude is doing.
Design decisions
Headless agents
Sessions without a VS Code terminal (e.g.,
claude -psubprocess calls, sessions from other windows) are represented as "headless" agents. They behave identically to regular agents in the UI — same animations, same tool status bubbles — but:terminalRefisundefined(guarded with optional chaining throughout)Activity-based lifecycle
Not every JSONL file represents an active session. To prevent the office from filling up with stale agents:
Subagent discovery
The
Agenttool creates JSONL files in<session-uuid>/subagents/agent-*.jsonl. The global scan recursively checks these directories for active subagent files and creates headless agents for them, labeled with"(sub)"in the folder name.Technical changes
src/types.tsterminalRefnow optional (vscode.Terminal | undefined), addedisHeadless?: booleanandlastActivityMs?: numbersrc/constants.tsGLOBAL_SCAN_INTERVAL_MS,HEADLESS_INACTIVITY_TIMEOUT_MS,HEADLESS_ACTIVITY_CHECK_INTERVAL_MS,ACTIVE_JSONL_MIN_SIZE,ACTIVE_JSONL_MAX_AGE_MSsrc/fileWatcher.tsglobalScanForAgents()(recursive scan of all project dirs + subagent dirs),createHeadlessAgent(),checkHeadlessActivity(), helper functionsisActiveJsonl(),isTrackedByAgent(),folderNameFromProjectDir()src/agentManager.tspersistAgents:terminalRef?.name(optional chaining).restoreAgents: skip terminal lookup for headless agents, restoreisHeadlessflag andlastActivityMssrc/PixelAgentsViewProvider.tsglobalScanTimer,headlessCheckTimer.startGlobalScan()method with 3s initial delay.focusAgent: headless → opens JSONL in editor.closeAgent: headless → callsremoveAgentdirectly.dispose(): cleans up new timersWhat users will see
claude -p "..."from a scriptAgenttool appear as additional characters labeled "(sub)"Relationship to other PRs
This PR builds on similar ideas as #101 (better detection) and #102 (multi-workspace), but goes further:
Test plan
claude -p "do something"in an external terminal — verify a headless agent spawns within ~3s🤖 Generated with Claude Code