Skip to content

fix: VS Code sessions causing false active dots - #78

Merged
grimmerk merged 1 commit into
developfrom
fix/vscode-session-false-active
Mar 31, 2026
Merged

fix: VS Code sessions causing false active dots#78
grimmerk merged 1 commit into
developfrom
fix/vscode-session-false-active

Conversation

@grimmerk

@grimmerk grimmerk commented Mar 31, 2026

Copy link
Copy Markdown
Owner

Summary

VS Code Claude Code sessions (entrypoint: "claude-vscode") were causing false purple active dots on unrelated terminal sessions.

Root cause

Detection flow in detectActiveSessions() (PR #67):

  1. Read ~/.claude/sessions/<PID>.json → PID alive ✓ (VS Code is running)
  2. Match sessionId against history.jsonlno match (VS Code sessions are not written to history.jsonl)
  3. Fall to cwd fallback → find a closed terminal session with the same cwd in history.jsonl
  4. cwdCandidates.length === 1 → mark that closed session as active → wrong purple dot

The user observed:

  • codex-ff project showed purple dot, but no terminal had that session open
  • The actual active session was VS Code's Claude Code extension (different content)
  • Clicking the session couldn't switch to it
  • Closing VS Code made the dot disappear

Fix

Skip non-CLI sessions at step 1:

const entrypoint = data.entrypoint as string;
// Skip non-terminal sessions (VS Code, Claude Desktop) — can't switch to them
if (entrypoint && entrypoint !== 'cli') continue;

Known entrypoint values (from ~/.claude/sessions/<PID>.json):

entrypoint Source Action
cli Terminal (iTerm2, Ghostty, cmux) ✓ Proceed with detection
claude-vscode VS Code extension Skip
claude-desktop Claude Desktop app Skip
undefined Old Claude Code PID files ✓ Proceed (backward compat)

No side effects

  • Legacy fallback (sessions/ dir doesn't exist): unaffected — it uses ps aux, not sessions/ files
  • Cross-ref disambiguation: unaffected — non-cli PIDs never enter needsCrossRef
  • Future VS Code support (issue Feature / TODO list — remaining: detail view, AI Assistant cleanup, remote control #66 item chore: test ci #5): this is the correct foundation — when we add [VSCODE] badge and VS Code window activation, we'll handle non-cli entrypoints in a separate code path instead of letting them fall into the terminal detection flow

Test plan

  • VS Code with active Claude Code session in codex-ff → no purple dot on terminal sessions
  • Close VS Code → no change (dot was already absent)
  • Terminal sessions still show purple dots correctly

🤖 Generated with Claude Code

🤖 On behalf of @grimmerk — generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@grimmerk
grimmerk merged commit f97d84a into develop Mar 31, 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