Skip to content

fix(tui): release stale daemon viewer leases - #8475

Closed
lawrencecchen wants to merge 12 commits into
codex/cmux-tui-durable-state-rootfrom
codex/cmux-tui-viewer-lease-release
Closed

lawrencecchen wants to merge 12 commits into
codex/cmux-tui-durable-state-rootfrom
codex/cmux-tui-viewer-lease-release

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #8460.

The durable daemon-side Admin connection used to remain a host viewer at its snapshot grid. After Chromium cut over from the compatibility control attachment to a direct renderer, the old Admin lease could keep the canonical terminal at 80x24 forever.

This PR:

  • adds a red integration regression first, followed by the fix;
  • auto-registers only resize-capable Renderer connections as snapshot viewers;
  • explicitly releases Admin on every connect for compatibility with live protocol-v1 hosts from the parent branch;
  • tracks the mux desired Admin lease across failed writes and replays it atomically during reconnect;
  • propagates a missing effective mux viewer as ReleaseViewer;
  • preserves smallest-viewer arbitration, same-size re-registration, and restores the direct renderer size after a TUI detaches.

Validation:

  • regression repeated 20 times;
  • terminal_host_recovery: 17 passed;
  • cmux-tui-core: 223 unit + 44 integration/doc tests passed;
  • cargo fmt --check and git diff --check passed.

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Summary by cubic

Fixes stale daemon viewer leases that could pin the PTY after switching to the direct renderer, and hardens zero‑width startup to avoid attach panics. Leases now release and re‑apply so the terminal follows the smallest active viewer; the sidebar stays hidden until a real size arrives.

  • Bug Fixes
    • Only resize‑capable Renderer connections auto‑register as viewers; Admin and mirror clients never pin the grid.
    • On Admin connect, start from the snapshot and unconditionally release its lease (upgrades protocol‑v1 hosts).
    • Persist desired viewer size in the host across failed writes; replay atomically on reconnect/runtime swap and skip unchanged replays.
    • If a surface has no effective mux viewer, explicitly release the daemon mirror lease; re‑apply on the next viewer report and avoid redundant host reflows when sizes already match.
    • Preserve smallest‑viewer arbitration: the direct renderer becomes sole viewer after control disconnect, and its size restores after TUI detach; defer sidebar width clamp to tolerate zero‑width startup.

Written for commit 59dfa84. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Ready Ready Preview, Comment Jul 19, 2026 10:41am
cmux-staging Building Building Preview, Comment Jul 19, 2026 10:41am

@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ab062f66-1381-43ee-bfd0-b9e1663b3e43

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/cmux-tui-viewer-lease-release

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lawrencecchen
lawrencecchen force-pushed the codex/cmux-tui-viewer-lease-release branch from 021a8e3 to 293b538 Compare July 20, 2026 02:58
@lawrencecchen
lawrencecchen force-pushed the codex/cmux-tui-durable-state-root branch from 99f2f25 to 5031e22 Compare July 20, 2026 02:58
@lawrencecchen

Copy link
Copy Markdown
Contributor Author

Superseded and landed cumulatively in #8717 (merge commit ea51d55). Closing this review-stack entry so the merged main branch is the canonical review surface.

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