fix: support grouped tmux sessions in session_map routing#69
Draft
dwong777 wants to merge 3 commits intosix-ddc:mainfrom
Draft
fix: support grouped tmux sessions in session_map routing#69dwong777 wants to merge 3 commits intosix-ddc:mainfrom
dwong777 wants to merge 3 commits intosix-ddc:mainfrom
Conversation
Grouped tmux sessions (created via `tmux new-session -t`) share windows, so the SessionStart hook can fire under any session name in the group. The monitor and session manager previously only read entries matching the configured prefix, missing entries written under other session names. - Hook: clean up duplicate session_map entries for the same window_id across different session name prefixes - Monitor/SessionManager: accept entries from any session name prefix (window IDs are globally unique in tmux) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Grouped tmux sessions accumulate multiple entries for the same window_id under different session name prefixes over time. When windows are reassigned (closed and recreated), stale entries can point to the wrong session_id. On startup, for each window_id with multiple entries, keep only the one whose CWD matches the live tmux window's CWD. This ensures the monitor picks up the correct session. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When multiple session_map entries for the same window_id all share the same CWD (common when sessions are created in the same directory), CWD matching alone can't determine which entry is current. Use the most recently modified JSONL file as a tiebreaker. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
|
An example of how our mapping looks like on a restart with grouped tmux sessions |
Author
|
Reminder to self, to have this consistently work I:
|
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.
Summary
Adds support for grouped tmux sessions (created via
tmux new-session -t <target>). Previously, the session_map was keyed bysession_name:window_idand the monitor/session manager only read entries matching the configuredtmux_session_nameprefix. With grouped sessions, windows are shared across all sessions in the group, and theSessionStarthook can fire under any of the group's session names — causing entries to be written under unpredictable prefixes that the monitor never reads.Symptom: Messages from Claude Code are not relayed to Telegram even though the session is connected (outbound messages and status polling work fine).
Changes
hook.py): Clean up duplicatesession_map.jsonentries for the samewindow_idacross different session name prefixes, so only one entry exists per windowsession_monitor.py): Accept entries from any session name prefix when loadingsession_map.json(window IDs are globally unique in tmux)session.py): Same prefix-agnostic loading inload_session_map()and_cleanup_stale_session_map_entries()Test plan
tmux new-session -t ccbot -s ccbot2)🤖 Generated with Claude Code