fix(server): macOS support for live gjc session detection — remove Linux-only lsof/proc/locale assumptions - #1
Open
thisisjun786 wants to merge 2 commits into
Conversation
gjc 라이브 레인이 macOS에서 항상 0건이었다: - lsof -c gjc: comm 매칭이라 bun 런타임으로 도는 gjc(comm=bun)를 못 찾음 → -c gjc -c bun -c node로 확장 (SESSION_FILE_RE가 실질 필터, -c는 비용 절감용) - /proc/<pid>/stat, /proc/<pid>/cwd: macOS에 /proc 없음 → 조상 체인은 ps -eo pid=,ppid= 스냅샷 1회, holder cwd는 배치 lsof -d cwd로 대체 (둘 다 Linux에서도 동일 동작 — 플랫폼 분기 없음) 외부 CLI 레인: macOS ps -eo comm은 실행파일 풀 경로를 찍어 claude/codex descendant 분류가 전부 미스 → comm basename 정규화. 검증: 유닛 30/30, tsc 통과, 실기(darwin) getLiveGjcSessions() 5건 검출 (lineage/cwd/null 클레임 분류 정상).
launchd/systemd는 로케일 env를 안 준다. 비UTF-8 로케일의 tmux는 출력을 새니타이즈해 \t 필드 구분자가 '_'로 치환되고 비ASCII 경로가 이스케이프됨 → parseTmuxPanes가 전 행 파싱 실패 → 모든 라이브 세션 tmuxName:null (실측: launchd 서버에서 UI 전 세션 열람 전용으로 강등, 전송 불가). runCommand spawn env에 LANG UTF-8 강제 (양 서비스 동일 적용). 검증: env -i(launchd 재현)에서 lineage/cwd 클레임 정상 복원, 유닛 30/30, tsc 통과.
Author
|
Review note (independent architect lane over the combined branch): the |
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.
Problem
On macOS the sidebar always shows "no gjc sessions running in tmux" even with multiple gjc tmux sessions active (measured: 4 sessions running, 0 detected).
Root causes (Linux-only assumptions in live-sessions.service.ts)
lsof -c gjcmatches the process COMM, but a script install runs gjc under its runtime — on macOS the comm isbun, so lsof finds nothing./proc/<pid>/stat) and holder cwd (/proc/<pid>/cwd) depend on /proc, which does not exist on macOS — both lineage matching and the cwd fallback fail wholesale._and non-ASCII paths get escaped, so every pane row silently fails to parse (measured under launchd: every session hadtmuxName: null, demoting the whole UI to read-only).Changes
-c gjc -c bun -c node.SESSION_FILE_RE(the session-file path) remains the authoritative filter;-conly bounds scan cost — no false positives.ps -eo pid=,ppid=snapshot feeds pure helpersparsePidParents/buildPidChain; holder cwds come from one batchedlsof -a -p <pids> -d cwd -F pn(parseCwdByPidFromLsof). Single code path for Linux and macOS — no platform branching.LANGin the detectionrunCommandspawn env (both services).ps -eo commprints full executable paths, so claude/codex descendant classification missed everything — normalize comm to basename (test covers a real.apppath with spaces).Verification
tsx --test), 7 new pure-function cases (BSD ps padding, cycle guard, paths with spaces, full-path comm).tsc --noEmit -p server/tsconfig.jsonand eslint pass.getLiveGjcSessions()went from 0 to 5 sessions, with correct claim grades (lineage/cwd/null) — the lineage-only kill/relay safety contract is unchanged. Same result under a reproduced launchd env (env -i).Note
PR #2 (idle-lane macOS port) contains this PR as a subset. If you prefer landing everything at once, merge #2 with its base retargeted to
feat/gjc-providerand close this one.