Skip to content

Fix tmux startup resize failure - #67

Merged
h3nock merged 2 commits into
mainfrom
fix/tmux-startup-resize
Aug 14, 2026
Merged

Fix tmux startup resize failure#67
h3nock merged 2 commits into
mainfrom
fix/tmux-startup-resize

Conversation

@h3nock

@h3nock h3nock commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Summary

Fix a startup race that could show tmux: resize failed even when the session connected successfully.

Viewport updates received before the native tmux client starts are now retained. The latest viewport becomes the client’s initial grid instead of being sent as a premature resize command.

Testing

  • Added regression coverage for viewport updates during startup.
  • Verified the fix against a real tmux session.

Summary by CodeRabbit

  • Bug Fixes

    • Improved session startup sizing by applying the latest available viewport dimensions when creating a native client.
    • Preserved size updates received before startup and used them during the initial refresh.
    • Prevented initial refresh and list requests from racing control-channel setup.
    • Synchronized the active terminal viewport when reconnecting or returning to the app.
  • Tests

    • Added coverage for viewport updates received before session startup.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 34ea252b-c7cf-4012-ba07-bd4b456d6cd6

📥 Commits

Reviewing files that changed from the base of the PR and between a936168 and 8ee287f.

📒 Files selected for processing (1)
  • RemuxApp/Sources/App/RemuxRootModel.swift

📝 Walkthrough

Walkthrough

The app now preserves viewport claims made before tmux client creation. Startup uses the latest stored size for the native client and initial refresh. Active-session lifecycle updates claim the selected viewport before discovery work.

Changes

Viewport-aware startup

Layer / File(s) Summary
Defer and apply viewport state
RemuxApp/Sources/Tmux/TmuxSessionController.swift, RemuxApp/Sources/Tmux/TmuxSessionLink.swift
The controller caches pre-start sizes and applies the latest valid size during startup. The startup documentation describes control-channel-first initialization.
Claim active session viewport
RemuxApp/Sources/App/RemuxRootModel.swift
The model claims the selected session viewport when the runtime connects or the app becomes active.
Validate queued viewport startup
RemuxAppTests/TmuxSessionControllerClientSizeTests.swift
The test verifies that queued size claims emit no early commands and that the latest size is used before topology data is requested.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 8ee28

The change retains startup viewport updates until the tmux client is ready, preventing premature resize failures; no actionable merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant RemuxRootModel
  participant TmuxSessionController
  participant NativeClient
  RemuxRootModel->>TmuxSessionController: claim selected active viewport
  TmuxSessionController->>TmuxSessionController: store clientSize before client creation
  RemuxRootModel->>TmuxSessionController: start session
  TmuxSessionController->>NativeClient: create client with latest clientSize
  TmuxSessionController->>NativeClient: refresh viewport
Loading

Possibly related PRs

  • h3nock/remux#21: Both modify active terminal and session lifecycle behavior in RemuxRootModel.swift.
  • h3nock/remux#49: Both modify TmuxSessionController viewport handling and related tests.
  • h3nock/remux#62: Both extend viewport-claim handling across RemuxRootModel and TmuxSessionController.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing the tmux startup resize failure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tmux-startup-resize

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.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploying remux with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8ee287f
Status: ✅  Deploy successful!
Preview URL: https://2e0b5ba0.remux-agx.pages.dev
Branch Preview URL: https://fix-tmux-startup-resize.remux-agx.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploying getremux with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8ee287f
Status: ✅  Deploy successful!
Preview URL: https://43f39360.getremux.pages.dev
Branch Preview URL: https://fix-tmux-startup-resize.getremux.pages.dev

View logs

@h3nock
h3nock marked this pull request as ready for review August 14, 2026 07:24

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a936168c18

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +763 to +765
guard client != nil else {
clientSize = nextSize
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retain the pre-start viewport claim

When the selected viewport changes while transport.start is still awaiting, TmuxScreenModel calls this method with claimActiveViewport: true, but this branch records only the size and discards the claim. After start, no topology handler restores that intent, so unlike the already-started path—which queues both the refresh and active-window claim—the selected client can remain unclaimed until a later input or action, leaving a multi-client session at the wrong active-window grid during initial display. Preserve the pending claim and submit it once topology becomes available.

Useful? React with 👍 / 👎.

@h3nock
h3nock merged commit 4cf572c into main Aug 14, 2026
6 checks passed
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