repos / zmx

session persistence for terminal processes
git clone https://github.com/neurosnap/zmx.git

commit
7fde464
parent
d9edbf0
author
Eric Bower
date
2025-10-13 12:33:35 -0400 EDT
chore: rm scrollback buffer

ghostty handles this for us
1 files changed,  +1, -9
M src/daemon.zig
+1, -9
 1@@ -54,7 +54,6 @@ const PtyWriteContext = struct {
 2 const Session = struct {
 3     name: []const u8,
 4     pty_master_fd: std.posix.fd_t,
 5-    buffer: std.ArrayList(u8),
 6     child_pid: std.posix.pid_t,
 7     allocator: std.mem.Allocator,
 8     pty_read_buffer: [4096]u8,
 9@@ -72,7 +71,6 @@ const Session = struct {
10 
11     fn deinit(self: *Session) void {
12         self.allocator.free(self.name);
13-        self.buffer.deinit(self.allocator);
14         self.vt.deinit(self.allocator);
15         self.vt_stream.deinit();
16         self.attached_clients.deinit();
17@@ -591,7 +589,7 @@ fn handleAttachSession(ctx: *ServerContext, client: *Client, session_name: []con
18     }
19 
20     // If reattaching, send the scrollback buffer as binary frame
21-    if (is_reattach and session.buffer.items.len > 0) {
22+    if (is_reattach) {
23         const buffer_slice = try session.vt.plainStringUnwrapped(client.allocator);
24         defer client.allocator.free(buffer_slice);
25 
26@@ -838,11 +836,6 @@ fn readPtyCallback(
27 
28         const valid_data = data[0..valid_len];
29 
30-        // Store PTY output in buffer for session restore
31-        session.buffer.appendSlice(session.allocator, valid_data) catch |err| {
32-            std.debug.print("Buffer append error: {s}\n", .{@errorName(err)});
33-        };
34-
35         // Build a sanitized buffer that only includes bytes we can safely send
36         var sanitized_buf = std.ArrayList(u8).initCapacity(session.allocator, valid_len) catch return .disarm;
37         defer sanitized_buf.deinit(session.allocator);
38@@ -1078,7 +1071,6 @@ fn createSession(allocator: std.mem.Allocator, session_name: []const u8) !*Sessi
39     session.* = .{
40         .name = try allocator.dupe(u8, session_name),
41         .pty_master_fd = @intCast(master_fd),
42-        .buffer = try std.ArrayList(u8).initCapacity(allocator, 0),
43         .child_pid = pid,
44         .allocator = allocator,
45         .pty_read_buffer = undefined,