Skip to content

Fix #284: concurrent-session registry + bridge-ID publish#314

Open
ericleepi314 wants to merge 1 commit into
fix/issue-281-claude-env-filefrom
feature/issue-284-concurrent-sessions
Open

Fix #284: concurrent-session registry + bridge-ID publish#314
ericleepi314 wants to merge 1 commit into
fix/issue-281-claude-env-filefrom
feature/issue-284-concurrent-sessions

Conversation

@ericleepi314

Copy link
Copy Markdown
Collaborator

Closes #284

Stacked on #313 (deep stack down to #304). Merge in order; GitHub retargets automatically.

Summary

Two concurrent Python bridges in the same workspace didn't dedup — both appeared in claude.ai/code session lists. The TS updateSessionBridgeId() publish was a TODO-noop and utils/concurrentSessions had no Python port.

  • src/utils/concurrent_sessions.py — faithful port of typescript/src/utils/concurrentSessions.ts (reviewed against the TS source): per-session PID files under ~/.clawcodex/sessions/, cleanup-registered-before-write ordering (a crash after the write still reaps the file), session-switch keeps sessionId fresh, the strict ^\d+\.json$ filename guard (TS issue #34210 — a lenient prefix-parse swept user files as "stale"), pid <= 1 probe guard, WSL-aware stale sweep chained after registration (TS main.tsx parity). Deliberate subsetting (BG_SESSIONS/UDS_INBOX fields) and the EPERM→alive probe divergence are documented in-module.
  • Bridge publish: set_repl_bridge_handle now publishes update_session_bridge_id(get_self_bridge_compat_id()) on every set/clear — setting records the session_* compat ID for peer dedup; clearing publishes None so a stale ID can't suppress a legitimately-remote session after reconnect.
  • remote_io: session_id wired from bootstrap get_session_id() (closes the in-code TODO(parity) the issue references; transport consumers verified to use it for logging/task-naming only).
  • register_session() wired into the three session entrypoints (TUI / headless / REPL), fail-soft.

Test plan

  • 15 new tests: registration round-trip/idempotence/teammate-skip/session-switch refresh; bridge-ID publish+clear through the real set_repl_bridge_handle (incl. the cse_*session_* retag); name updates; counting with stale sweep, live-peer, pid≤1 sweep, missing dir, and the #34210 bystander-file guard (asserts contents survive)
  • remote_io test updated from pinning the TODO (None) to pinning the bootstrap ID
  • Full suite on the stack: 7848 passed, 0 failed, 5 skipped
  • Critic review loop: APPROVE after 1 revision round (8 TS-fidelity items verified against the TS source, incl. probe semantics, chmod failure handling, and sweep wiring)

🤖 Generated with Claude Code

…284)

Two Python bridges in the same workspace did not dedup — the TS
updateSessionBridgeId() publish was a TODO-noop and the registry module
didn't exist.

- src/utils/concurrent_sessions.py ports utils/concurrentSessions.ts:
  PID files under ~/.clawcodex/sessions/, cleanup-before-write
  ordering, session-switch refresh, strict <pid>.json filename guard
  (TS #34210), pid<=1 probe guard, WSL-aware stale sweep chained after
  registration (TS main.tsx); BG_SESSIONS/UDS_INBOX subsetting and the
  EPERM-alive probe divergence are documented
- set_repl_bridge_handle publishes get_self_bridge_compat_id() on every
  set/clear so peer enumeration dedups a session reachable over both
  UDS and bridge (clearing prevents a stale ID from suppressing a
  legitimately-remote session after reconnect)
- remote_io wires session_id from bootstrap get_session_id()
  (the TS getSessionId() parity TODO)
- register_session() wired into the TUI/headless/REPL entrypoints,
  fail-soft

Closes #284

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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