feat(terminal): per-connection grouped sessions for externally-discovered sessions#168
Draft
0x79H wants to merge 3 commits into
Draft
feat(terminal): per-connection grouped sessions for externally-discovered sessions#1680x79H wants to merge 3 commits into
0x79H wants to merge 3 commits into
Conversation
…isplay-message -c - display-message -p -c expands formats against the most recently active client's session, not the -c client (verified on tmux 3.4 and 3.5a), causing false ERR_TMUX_SWITCH_FAILED whenever another tmux client on the server was more recently active - resolve the identity from list-clients -F filtered by client_tty, the same approach discoverClientTty already uses - teach the spawn harness to answer list-clients per requested format like real tmux (its display-message -c mock implemented the semantics the code assumed, which is how this survived the unit tests), and add a regression test where a foreign client is the most recently active one
- paste() targeted the grouped ws session unconditionally; after switching into an externally-discovered session the buffer landed in the ws session's bootstrap window and the paste was lost - track lastEffectiveSession from the verified switch identity and paste into that session's active pane, falling back to the ws session before the first switch
…ered sessions - joining an external session directly shares its current-window pointer and window size with the user's own attached clients: switching in the browser flips the user's terminal and vice versa, and copy-mode entered locally swallows browser keystrokes - create agentboard-ws-<conn>-x-<session> grouped with the raw session on first switch and keep focus independent - validate staleness by window-set membership, not session_group equality (group names lie once ghost members survive a raw-session kill/recreate); use = exact matching plus has-session guards for every tmux -t; evacuate our own client before killing a stale derived session (detach-on-destroy would kill the proxy) - destroy derived sessions on switch-away and dispose; degrade to attaching the raw session directly when recreation lands in a ghost group; block resurrection after dispose via a disposed flag
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.
Reference implementation for #163 — opened as a draft on purpose: if you prefer a different approach, close this freely and keep the pitfall list in the issue; it applies to any solution in this space.
Stacked on #165 and #166 — until those land, only the last commit here is new material (the client-evacuation logic relies on #165's reliable identity readout). Once they merge I'll rebase and this diff shrinks to the grouped-session change alone. Suggested review/merge order: #165 → #166 → this one; #167 is independent.
What
On first switch into an externally-discovered session S, create
agentboard-ws-<conn>-x-<S>grouped with S (new-session -d -t =S) and switch the client into that. Windows stay shared; focus and per-window sizing become independent of the user's own attached clients, and copy-mode entered from the user's terminal no longer swallows browser keystrokes.Robustness
Each of these guards a failure hit during adversarial testing on tmux 3.4:
list-windows -F '#{window_id}'contains the requested@id), not#{session_group}equality — group names are keyed by name and lie once ghost members survive a kill/recreate of S. Window ids are server-global and never reused, so membership is a sound invariant.-tuses=exact matching, andnew-sessionis preceded by ahas-sessionguard (new-session -t =missingsilently creates an unrelated group literally named=missinginstead of failing).detach-on-destroy, killing the session under the client would take the whole proxy down.disposedflag blocks a lost-race in-flight attach from resurrecting the proxy after dispose and leaking sessions.Known trade-offs (accepted for our deployment, maintainer call for upstream)
kill-sessionon S does not kill its windows until the viewer switches away.tmux lsshows the per-connection derived sessions.Verification
HOSTNAME=127.0.0.1): full suite including the real-tmux layer — green; coverage mode and build pass.