Skip to content

fix: macOS process detection for session discovery#2

Open
bbsngg wants to merge 1 commit intomainfrom
fix/macos-process-detection
Open

fix: macOS process detection for session discovery#2
bbsngg wants to merge 1 commit intomainfrom
fix/macos-process-detection

Conversation

@bbsngg
Copy link
Copy Markdown

@bbsngg bbsngg commented Mar 27, 2026

Summary

  • Replace pgrep -af . with ps -eo pid,args in _scan_processes_via_pgrep() for macOS compatibility
  • Keep pgrep as fallback if ps is unavailable
  • Fixes the root cause where macOS pgrep only outputs PIDs without command lines, making agent pattern matching impossible

Fixes #1

Root Cause

macOS pgrep -af . outputs only bare PIDs (e.g., 35024), while Linux outputs PID command_line (e.g., 35024 node /usr/bin/codex). The downstream _matches_agent() regex cannot match agent patterns against pure numbers.

Solution

ps -eo pid,args is POSIX-standard and outputs PID full_command on both macOS and Linux. This is used as the primary method, with pgrep -af . retained as a fallback.

Test plan

  • Verified on macOS Darwin 25.3.0 (arm64) — dashboard now shows 31 detected sessions
  • Verify no regression on Linux
  • Verify Windows path is unaffected (early return for os.name == "nt")

🤖 Generated with Claude Code

macOS pgrep -af only outputs PIDs without command lines, causing
session discovery to fail. Replace with ps -eo pid,args which works
on both macOS and Linux, with pgrep as fallback.

Fixes #1

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bbsngg bbsngg requested a review from Mr-Tieguigui March 27, 2026 15:25
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.

macOS: Session discovery fails - pgrep -af does not output command line

1 participant