resize restored tmux panes to the current tab size - #3137
Conversation
…est client window-size. closes generalaction#2867
Greptile SummaryThis PR immediately applies the pane's current dimensions to newly observed PTY sessions and configures tmux windows to follow the latest attached client.
Confidence Score: 4/5The 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
|
| 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) { |
There was a problem hiding this 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.
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.| const setWindowSize = `tmux set-option -t ${quotedName} window-size latest 2>/dev/null || true`; | ||
| const configure = `(${enableMouse}) && (${setHistoryLimit}) && (${setWindowSize})`; |
There was a problem hiding this 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.
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!
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
updatePtySizeimmediately.also sets
window-size lateston new tmux sessions so the pane follows the current client instead of the first attach.closes #2867
test plan
pnpm --dir apps/emdash-desktop exec vitest run src/core/services/pty/api/tmux.test.ts