Skip to content

Ignore the daemon's dummy initial frame when sizing the PTY#505

Merged
dakra merged 1 commit into
mainfrom
fix/504-daemon-dummy-frame
Jul 2, 2026
Merged

Ignore the daemon's dummy initial frame when sizing the PTY#505
dakra merged 1 commit into
mainfrom
fix/504-daemon-dummy-frame

Conversation

@dakra

@dakra dakra commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Problem

With an Emacs daemon + client frame, killing the buffer that was selected when M-x ghostel was started (e.g. *scratch*) resets the PTY to 79x22 (issue #504).

The daemon keeps an invisible ~80x24 initial frame whose sole window shows *scratch*. Killing that buffer substitutes the ghostel buffer into that window. Both ghostel's own resize path (ghostel--windows with all-frames) and core's window--adjust-process-windows collect windows across all frames, so window-adjust-process-window-size-smallest clamps the PTY to the dummy window's 79x22 body.

Note that frame-visible-p and terminal-live-p are both t on the dummy frame, so visibility can't be used as a filter; the reliable test is (and (daemonp) (eq frame terminal-frame))Vterminal_frame is assigned exactly once at startup, so client tty frames are never affected.

Fix

  • ghostel--daemon-dummy-frame-p: identifies the dummy frame.
  • ghostel--windows now skips windows on it — fixes the clamp in ghostel--adjust-size and keeps ghostel--get-render-window/anchoring off the dummy frame.
  • ghostel--adjust-process-window-size drops dummy-frame windows and delegates to the standard sizing function; installed as the process's adjust-window-size-function on both PTY spawn sites (ghostel--spawn-pty, ghostel-compile). The previous (process-put proc 'adjust-window-size-function nil) was a no-op — core falls back to the global window-adjust-process-window-size-function on a nil property, so core was resizing the elisp PTY with an unfiltered all-frames window list.

If the buffer is shown only in the dummy frame, the window list is empty and the sizing function returns nil, leaving the PTY size alone.

Verification

  • 3 new ERT tests (elisp group).
  • Live daemon repro (daemon + 200x50 tty client): PTY stays 47x199 after killing *scratch* (was 22x79), stty size confirms; normal window resizes still track on both the native-PTY and elisp-PTY (ghostel-use-native-pty nil) paths.

For the record: eat exhibits the identical bug (verified live), and core's window--process-window-list walks all frames, so this is arguably also an upstream Emacs issue.

Fixes #504

Killing the buffer shown in the Emacs daemon's invisible 80x24
initial frame substitutes the ghostel buffer into its sole window,
and `window-adjust-process-window-size-smallest' then clamped the
terminal to that dummy window (79x22).

Filter such windows out of `ghostel--windows' so the window-size
hook (`ghostel--adjust-size') never sees them, and set the
processes' `adjust-window-size-function' to `ignore': a nil
property does not opt out of core's `window--adjust-process-windows'
(it falls back to the global default), which kept resizing the
Emacs-path PTY from an unfiltered all-frames window list, overwriting
the winsize the Zig renderer syncs on resize.

Fixes #504
@dakra
dakra force-pushed the fix/504-daemon-dummy-frame branch from ccdf6a9 to 109ed0d Compare July 2, 2026 22:27
@dakra
dakra merged commit 109ed0d into main Jul 2, 2026
24 checks passed
@dakra
dakra deleted the fix/504-daemon-dummy-frame branch July 2, 2026 22:31
@dakra
dakra temporarily deployed to github-pages July 2, 2026 22:31 — with GitHub Actions Inactive
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.

PTY columns reset after killing the buffer that was selected when Ghostel was started in daemon/client frame

2 participants