Repository navigation
feat: add existing-only session attach - #22
Conversation
Code Review Could Not Complete
|
| Options | Enabled |
|---|---|
| Bug | ✅ |
| Performance | ✅ |
| Security | ✅ |
| Business Logic | ✅ |
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Additional context used: Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Code Review Completed! 🔥The code review was successfully completed based on your current configurations.
Additional context used: Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Review disposition for 480fc5e: the nested-switch finding is fixed and its thread resolved. The auto-generated PR summary still says --existing carries into switch recursion; that sentence is now stale. Existing-only applies to the originally named recovery target, while a later explicit nested switch uses ordinary create-or-attach. The slow-daemon fallback suggestion was not adopted because reconnecting to an unverified peer would break recovery identity fencing; the rationale is in its still-open thread. Zig tests/build and an isolated PTY switch smoke passed. The latest Kody run failed in its review provider before completing, without a new inline code finding. |
Add permanently restricted typed attachments and explicit takeover while preserving frozen legacy tags. Serialize size claims and user batches through owned PTY operations and invalidate stale replies on epoch changes. Keep legacy attach's mixed-stdin limitation explicit. Add socket regression coverage and update retained-grid reattach expectations. Refs: Interactive-Buffoonery/awesomux#827
feat(leadership): add watch-only clients
A reattached Mac pane, or one left behind when the phone stops leading, dropped every resize until the user typed. Full-screen apps kept drawing at the old width and garbled. While no client leads, a legacy terminal attachment's Init or Resize now queues an ordered recovery claim at its requested size. When the leader leaves and exactly one such attachment remains, it claims too. Typed attachments, Watch and automation keep explicit claims.
A leaderless session now elects the Mac pane whose Init, Resize or ResizePixels arrived most recently, instead of only a sole survivor. awesoMux sends a pane's attach client SIGWINCH on focus, so the pane the user last looked at wins. A typed leader whose socket closes holds the session leaderless for 5 seconds first, so a phone that reconnects and claims again reflows the grid once. Any claim ends the wait; downgrades still elect at once.
…adership fix(pty): restore initial creator leadership
…ize-claim fix(pty): let Mac panes lead a leaderless session
…f-followups feat(pty): hand a dropped phone's grid to the last-focused pane
0f1ac1f to
250dad4
Compare
This comment has been minimized.
This comment has been minimized.
External contributor checklistThanks for contributing. A maintainer will handle the trusted checks and final merge.
|
Large pull requestThis PR has 1215 effective changed lines and is labeled |
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Why
Attach to an existing session without creating a replacement. This also brings the session leadership work already used by awesoMux onto main.
What's Included
attach --existing. It verifies a responsive daemon and reuses the verified connection. Ordinary attach keeps its best-effort identity probe.cwd_b64andcmd_b64, and reserve metadata label names so tabs and newlines cannot add false records.LEADERSHIP.md.UI / UX
Not applicable. This changes backend session and terminal behavior.
Notes
Models: Codex
Merge risk: high. This changes session leadership and live-daemon behavior; old/new daemon pairs and the rebased revision through awesoMux have not been checked. Recovery: revert for future builds; running daemons keep their state, and sent input or ended work cannot be restored.
Rebased onto main with merge topology retained. The kitty status fix was already on main; its duplicate was dropped. A GPT-6.1 Sol source review at
250dad4found no defects. The 16 older Kody threads remain resolved; the newersrc/loop.zig:1268thread remains open for Sarah. The fork-fit review judged that path unreachable. The managed summary below retains older wording. eD! left review comments, but no human approval is recorded.Current-head check:
git diff --checkpasses. Changes since250dad4are documentation only; runtime source is unchanged. At250dad4, macOS Zig 0.16 formatting, unit tests, build, 3 reattach cases, 49 CLI/session cases, 21 leadership regression scenarios, 24 creator scenarios, and the main leadership harness passed. These are prior-head results. No new physical-device or awesoMux runtime result is claimed.Original heads and downstream pins are preserved in task notes and safety refs. Keep the remote tags
awesomux-pin-cc24771andawesomux-pin-ffa16fa. Merge with a merge commit and keep the branches.Summary
Adds
attach --existingfor attaching only to an already-responsive session, plus a new read-onlywatch <name>client and a typed attachment/authority protocol for the daemon. The change also replaces the single PTY write buffer with a bounded, ordered operation queue and hardens session-list and label output framing.What Changed
Existing-only attach
zmx attach --existing <name>verifies the session socket exists and the daemon responds before attaching.--existingis rejected with--labels.watch <name>AttachRoleas watch.AttachAcceptedwithin one second; old daemons fail closed with no legacy fallback.Init, stdin, focus, resize, or terminal replies.Authority,Info,History,CwdQuery,LabelGet, andDetach; it cannot mutate labels/env, inject output, resize, take over, or kill.Typed roles and authority
InitthroughSend,Run,Write, orOutput; it permanently loses session-creation eligibility but normal user input can still claim leadership.Leaderless recovery
Ordered PTY operation queue
pty_write_bufwith a bounded queue: 256 KiB payload and 4096 operations.Input and parser hardening
Historyaccepts only an empty payload or exactly one supported format byte; malformed requests are ignored.List and label framing
listnow emitscwd_b64andcmd_b64instead of rawcwdandcmd; no raw compatibility aliases are emitted.name,pid,clients,created,cwd,cmd,daemon_pid,status, etc.list --short.Tests and docs
Security Impact
Performance / Behavior Impact
dropSourceandqueueResizealso perform linear scans, which may matter under heavy multi-client/queue pressure.Review Notes / Cleanup Opportunities
existing-only attach, but the change also adds a broad typed protocol, authority system, bounded queue, docs, and large test harnesses. This is significant scope creep for the title; consider splitting if the typed protocol is not required for the existing-only feature.writeSessionLineallocates a freshpage_allocatorbuffer for eachcwd_b64/cmd_b64field. A reusable buffer or direct writer-based encoding would be simpler and lighter forlist.queueOperationheap-duplicates every payload, including empty barrier operations. Avoiding allocations for empty data would reduce churn.queueOperationcall inhandleTypedand the large role-dispatch block are hard to audit; smaller helpers would improve maintainability.leadership.py,creator_leadership.py, andleadership_regressions.py. Consolidating shared helpers would reduce maintenance cost.LEADERSHIP.mdis detailed but very long and overlaps heavily with test expectations; keep it as the protocol contract only, not a second behavioral test log.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.