Skip to content

feat: detect agents across all workspace folders in multi-root workspaces#102

Open
Commandershadow9 wants to merge 2 commits intopablodelucca:mainfrom
Commandershadow9:feat/multi-workspace-scanning
Open

feat: detect agents across all workspace folders in multi-root workspaces#102
Commandershadow9 wants to merge 2 commits intopablodelucca:mainfrom
Commandershadow9:feat/multi-workspace-scanning

Conversation

@Commandershadow9
Copy link

@Commandershadow9 Commandershadow9 commented Mar 9, 2026

Motivation

VS Code's multi-root workspaces let users open multiple project folders in a single window. Claude Code writes JSONL transcripts to a directory based on the workspace path — so each folder gets its own project directory under ~/.claude/projects/.

Currently, ensureProjectScan only registers the first workspace folder's project directory. If a user starts Claude Code in their second or third folder, those sessions are never detected because their JSONL directory isn't being watched.

Example: User has ~/frontend and ~/backend open as a multi-root workspace. They start Claude in ~/backend — the agent works fine but never appears in the Pixel Agents panel because only ~/frontend's project dir is scanned.

Changes

src/fileWatcher.ts

  • ensureProjectScan now maintains a module-level Set<string> of tracked project directories
  • The shared interval timer iterates over all tracked dirs instead of just one
  • Calling ensureProjectScan multiple times with different dirs is safe and idempotent — the seed logic always runs but the timer only starts once

src/PixelAgentsViewProvider.ts

  • On webviewReady, registers project dirs for all workspace folders (not just the first)
  • Each additional folder's project dir is logged for debugging

Backward compatibility

  • Single-folder workspaces: No behavior change — one dir is registered and scanned as before
  • No workspace open: No behavior change — the extension handles null project dir gracefully
  • Multi-folder workspaces: All folders' project dirs are now scanned
  • The ensureProjectScan function signature is unchanged — existing callers in agentManager.ts work without modification

Test plan

  • Single-root workspace: Verify agents are detected as before (no regression)
  • Multi-root workspace: Create one with 2+ folders (File → Add Folder to Workspace)
  • Start Claude Code in each folder
  • Verify all agents appear in the Pixel Agents panel regardless of which folder they run in
  • Check Developer Console for [Pixel Agents] Registering additional project dir: log messages
  • Remove a folder from the workspace — verify existing agents continue working

🤖 Generated with Claude Code

Shadow and others added 2 commits March 9, 2026 20:16
In multi-root workspaces, Claude Code sessions started in different
workspace folders write their JSONL transcripts to different project
directories (e.g. `-home-user-projectA/` vs `-home-user-projectB/`).
Currently only the first workspace folder's project dir is scanned,
making agents in other folders invisible.

Changes:
- ensureProjectScan now tracks all registered project dirs in a
  module-level Set and scans all of them in the shared interval timer.
  Calling it multiple times with different dirs is safe — the seed
  logic always runs, but the timer is only started once.
- PixelAgentsViewProvider registers project dirs for all workspace
  folders (not just the first) when webviewReady fires.

This means in a multi-root workspace with folders [~/projectA, ~/projectB],
Claude agents started in either folder will be discovered and tracked.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two fixes for multi-workspace scanning:

1. ensureProjectScan: Add smart pre-registration logic that skips
   files >3KB and modified within the last 10 minutes, so active
   JSONL files can still be picked up by terminal scanning.

2. scanForNewJsonlFiles: Iterate over all vscode.window.terminals
   instead of only vscode.window.activeTerminal, so agents in
   non-focused terminals are also discovered.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Commandershadow9 Commandershadow9 changed the title feat: support multi-root workspace agent scanning feat: detect agents across all workspace folders in multi-root workspaces Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant