fix: detect Claude sessions started outside of Pixel Agents#101
Open
Commandershadow9 wants to merge 2 commits intopablodelucca:mainfrom
Open
fix: detect Claude sessions started outside of Pixel Agents#101Commandershadow9 wants to merge 2 commits intopablodelucca:mainfrom
Commandershadow9 wants to merge 2 commits intopablodelucca:mainfrom
Conversation
When Claude Code is started outside of Pixel Agents (e.g. from an existing terminal), the extension fails to detect and track the agent because: 1. ensureProjectScan pre-registers ALL existing JSONL files as "known", preventing active sessions from being picked up. Now files that are both large (≥3KB) and recently modified (<10min) are skipped during pre-registration, allowing them to be detected by terminal scanning. 2. scanForNewJsonlFiles only checks vscode.window.activeTerminal when adopting orphaned JSONL files. If the Claude terminal isn't focused, it's never found. Now all terminals are scanned to find an untracked terminal to adopt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The seeding logic (smart pre-registration that skips active JSONLs) was placed after `if (projectScanTimerRef.current) return`, meaning it only ran on the first call. Now it runs on every call, ensuring newly appeared files are always seeded correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8 tasks
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
Many users start Claude Code manually — from an existing VS Code terminal, via SSH Remote, or by opening a terminal before the extension loads. These sessions write JSONL files as expected but are never picked up by Pixel Agents. The office stays empty even though Claude is actively working.
This happens because of two issues in the detection logic.
Problem 1: Pre-registration blocks active sessions
ensureProjectScanseedsknownJsonlFileswith all existing.jsonlfiles on startup, including ones from currently running sessions. SincescanForNewJsonlFilesonly processes files NOT inknownJsonlFiles, these active sessions are permanently invisible.Fix: Skip pre-registration for files that appear to be from active sessions — files that are both large (≥3KB) and recently modified (<10 minutes). These stay "undiscovered" so the periodic scan can properly detect and adopt them.
Problem 2: Terminal matching only checks the focused terminal
scanForNewJsonlFilesonly tries to match new JSONL files againstvscode.window.activeTerminal. If the user is focused on a different terminal or the editor, the JSONL is detected but silently discarded because no terminal match is found.Fix: Iterate over all
vscode.window.terminalsto find the first untracked terminal instead of only checking the focused one.Changes
src/fileWatcher.ts— both fixes are small and focused:ensureProjectScan: Add size/age check before adding files toknownJsonlFilesscanForNewJsonlFiles: ReplaceactiveTerminallookup withterminalsiterationTest plan
🤖 Generated with Claude Code