Skip to content

resize restored tmux panes to the current tab size - #3137

Open
thedhruvhegde wants to merge 1 commit into
generalaction:mainfrom
thedhruvhegde:fix/tmux-restore-full-width
Open

resize restored tmux panes to the current tab size#3137
thedhruvhegde wants to merge 1 commit into
generalaction:mainfrom
thedhruvhegde:fix/tmux-restore-full-width

Conversation

@thedhruvhegde

@thedhruvhegde thedhruvhegde commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

summary

restored sessions skipped the first resize until a later calibration, so tmux often stayed at a leftover width (e.g. ~80 cols). new sessions now get updatePtySize immediately.

also sets window-size latest on new tmux sessions so the pane follows the current client instead of the first attach.

closes #2867

test plan

  • restore a tmux tab after shrinking/growing the window and confirm the pane fills the tab
  • new session still sizes correctly on first attach
  • pnpm --dir apps/emdash-desktop exec vitest run src/core/services/pty/api/tmux.test.ts

@greptile-apps

greptile-apps Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR immediately applies the pane's current dimensions to newly observed PTY sessions and configures tmux windows to follow the latest attached client.

  • The active-session path is resized during initial calibration.
  • Background restored sessions can still miss the resize when their frontend PTY is registered after the session-list effect.
  • The new tmux command construction lacks focused regression coverage.

Confidence Score: 4/5

The PR should not merge until restored background sessions are reliably resized after their frontend PTY becomes available.

The active restored-session path is repaired by calibration, but a background session can be recorded before registration and then receive no backend resize when activated, leaving tmux at stale dimensions until an unrelated resize event.

Files Needing Attention: apps/emdash-desktop/src/core/features/terminals/browser/pty/use-pty-pane-resize.ts, packages/core/src/services/pty/api/tmux.ts

Important Files Changed

Filename Overview
apps/emdash-desktop/src/core/features/terminals/browser/pty/use-pty-pane-resize.ts Sends dimensions before calibration for newly added sessions, but does not retry sessions whose frontend PTY registers after the effect.
packages/core/src/services/pty/api/tmux.ts Configures tmux sessions with window-size latest; the generated command is not directly tested.
Prompt To Fix All With AI
### Issue 1
apps/emdash-desktop/src/core/features/terminals/browser/pty/use-pty-pane-resize.ts:208
When a background restored session is added before its asynchronously created `FrontendPty` is registered, this effect records the ID but silently skips `resizeBackend`. Later activation only resizes the xterm grid, and an already-calibrated pane does not schedule another backend resize when its cell metrics are unchanged. The restored tmux session therefore remains at its stale dimensions until an unrelated pane or font change.

### Issue 2
packages/core/src/services/pty/api/tmux.ts:13-14
The focused `tmux.test.ts` named in the test plan does not exercise `buildTmuxShellLine`, so the new `window-size latest` command has no regression coverage. Add a command-construction assertion, including an escaped session name, to prevent future changes from silently removing or corrupting this configuration.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "resize restored tmux panes to the curren..." | Re-trigger Greptile

sessionsRef.current = sessionIds;
const dims = controllerDimsBoxRef.current!.get();
if (dims && added.length > 0 && hasCalibratedRef.current) {
if (dims && added.length > 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 When a background restored session is added before its asynchronously created FrontendPty is registered, this effect records the ID but silently skips resizeBackend. Later activation only resizes the xterm grid, and an already-calibrated pane does not schedule another backend resize when its cell metrics are unchanged. The restored tmux session therefore remains at its stale dimensions until an unrelated pane or font change.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/emdash-desktop/src/core/features/terminals/browser/pty/use-pty-pane-resize.ts
Line: 208

Comment:
When a background restored session is added before its asynchronously created `FrontendPty` is registered, this effect records the ID but silently skips `resizeBackend`. Later activation only resizes the xterm grid, and an already-calibrated pane does not schedule another backend resize when its cell metrics are unchanged. The restored tmux session therefore remains at its stale dimensions until an unrelated pane or font change.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +13 to +14
const setWindowSize = `tmux set-option -t ${quotedName} window-size latest 2>/dev/null || true`;
const configure = `(${enableMouse}) && (${setHistoryLimit}) && (${setWindowSize})`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 The focused tmux.test.ts named in the test plan does not exercise buildTmuxShellLine, so the new window-size latest command has no regression coverage. Add a command-construction assertion, including an escaped session name, to prevent future changes from silently removing or corrupting this configuration.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/src/services/pty/api/tmux.ts
Line: 13-14

Comment:
The focused `tmux.test.ts` named in the test plan does not exercise `buildTmuxShellLine`, so the new `window-size latest` command has no regression coverage. Add a command-construction assertion, including an escaped session name, to prevent future changes from silently removing or corrupting this configuration.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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.

[bug]: Restored tmux tab does not use full pane width until manually resized

1 participant