feat(ipc): Attach stops kicking other clients and resizes in place - #309
Merged
Merged
Conversation
Attach ran `tmux attach -d`, so the phone attaching detached the Mac app's pane (and any other client). Drop -d: tmux's default window-size latest follows whoever typed last, so neither front end needs to kick the other. The pty size was also fixed at attach time, so the phone reattached (and redrew the pane from scratch) whenever the software keyboard showed or it rotated. A successful Attach now returns an `attach` token in its one response line, and the new one-shot ResizeAttach method sets that live attach's pty size by token. The token is forgotten when the attach closes. Both are backward compatible: old clients ignore the extra result key, and new clients fall back to reattaching when `attach` is absent or ResizeAttach fails.
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.
Two backward-compatible changes to the core's
Attach(contract:docs/wire-protocol.md), matching an iPhone client change in moomux-mac.1. Don't kick other clients
Attachrantmux attach -d, which detached the Mac app's pane (and any other client) every time the phone attached.-dis gone; tmux's defaultwindow-size latestfollows whoever typed last.EnsureTmux,TERM=xterm-256colorand theTMUX/TMUX_PANEstripping are unchanged.2. Resize a live attach instead of reattaching
{"result":{"ok":true,"attach":"<32 hex chars>"}}(128 random bits). It is valid only while that attach connection is open.ResizeAttach{"attach":"<token>","cols":N,"rows":M}callspty.Setsizeon that attach's pty (same 80x24 floor asAttach) and returns{"result":{"ok":true}}, orerr: "unknown attach"for a token that isn't live. It goes throughdispatch, so it follows the same listener/auth rules as every other method, tailnet included.attachis absent orResizeAttachfails.Attachment.TokenandClient.ResizeAttach.Tests
TestAttachKeepsEveryByteWrittenBehindTheResponseLinenow sends a token and checks it's parsed without moving the response-line/pty split.TestResizeAttachSetsTheLivePtySize(unit, real pty): resize, the 80x24 floor, token format, andunknown attachfor a dead or empty token.TestAttachIsAPtyOverTheWire: resize to 70 columns reaches the tmux window; the token returnsunknown attachafter close.TestAttachDoesNotDetachOtherClients: two attaches give two tmux clients, and both stay attached.Each new test fails when its fix is reverted.
go test ./... -race -shuffle=onandgo test -tags e2e ./e2e/... -race -shuffle=onboth pass locally.session.Sessionis untouched. The only thing the Swift side sees is the new optionalattachkey.