- commit
- 53dacdc
- parent
- 98c58c7
- author
- Eric Bower
- date
- 2025-12-02 19:56:59 -0500 EST
fix: dont use alt screen on attach The problem is that the client switches to the alternate screen buffer on attach, which doesn't have scrollback. When ghostty replays content, it goes into the alt screen where scrollback doesn't accumulate. The alternate screen buffer (\x1b[?1049h) never has scrollback - that's by design in terminals. To get scrollback working properly we now stay on main screen and clear on detach.
1 files changed,
+3,
-8
+3,
-8
1@@ -385,12 +385,12 @@ fn attach(daemon: *Daemon) !void {
2 var orig_termios: c.termios = undefined;
3 _ = c.tcgetattr(posix.STDIN_FILENO, &orig_termios);
4
5- // restore stdin fd to its original state and exit alternate buffer after exiting.
6+ // restore stdin fd to its original state after exiting.
7 // Use TCSAFLUSH to discard any unread input, preventing stale input after detach.
8 defer {
9 _ = c.tcsetattr(posix.STDIN_FILENO, c.TCSAFLUSH, &orig_termios);
10- // Restore normal buffer and show cursor
11- const restore_seq = "\x1b[?25h\x1b[?1049l";
12+ // Clear screen and show cursor on detach
13+ const restore_seq = "\x1b[?25h\x1b[2J\x1b[H";
14 _ = posix.write(posix.STDOUT_FILENO, restore_seq) catch {};
15 }
16
17@@ -410,11 +410,6 @@ fn attach(daemon: *Daemon) !void {
18
19 _ = c.tcsetattr(posix.STDIN_FILENO, c.TCSANOW, &raw_termios);
20
21- // Switch to alternate screen buffer and home cursor
22- // This prevents session output from polluting the terminal after detach
23- const alt_buffer_seq = "\x1b[?1049h\x1b[H";
24- _ = try posix.write(posix.STDOUT_FILENO, alt_buffer_seq);
25-
26 try clientLoop(daemon.cfg, client_sock);
27 }
28