- commit
- 3379edc
- parent
- f6b9539
- author
- Eric Bower
- date
- 2025-10-15 18:15:51 -0400 EDT
fix: properly clear terminal after detach
1 files changed,
+13,
-2
+13,
-2
1@@ -328,13 +328,15 @@ fn readCallback(
2
3 if (std.mem.eql(u8, parsed.value.payload.status, "ok")) {
4 cleanupClientFdFile(ctx);
5- _ = posix.write(posix.STDERR_FILENO, "\r\nDetached from session\r\n") catch {};
6+ writeDetachCleanup();
7+ _ = posix.write(posix.STDERR_FILENO, "Detached from session\r\n") catch {};
8 return cleanup(ctx, completion);
9 }
10 },
11 .detach_notification => {
12 cleanupClientFdFile(ctx);
13- _ = posix.write(posix.STDERR_FILENO, "\r\nDetached from session (external request)\r\n") catch {};
14+ writeDetachCleanup();
15+ _ = posix.write(posix.STDERR_FILENO, "Detached from session (external request)\r\n") catch {};
16 return cleanup(ctx, completion);
17 },
18 .kill_notification => {
19@@ -400,6 +402,15 @@ fn cleanupClientFdFile(ctx: *Context) void {
20 std.fs.cwd().deleteFile(client_fd_path) catch {};
21 }
22
23+fn writeDetachCleanup() void {
24+ // Clear screen artifacts before showing detach message:
25+ // \x1b[2J - Clear entire screen
26+ // \x1b[H - Move cursor to home position (1,1)
27+ // \x1b[?25h - Show cursor
28+ // \x1b[0m - Reset all text attributes (colors, styles)
29+ _ = posix.write(posix.STDERR_FILENO, "\x1b[2J\x1b[H\x1b[?25h\x1b[0m") catch {};
30+}
31+
32 fn sendDetachRequest(ctx: *Context) void {
33 const request_payload = protocol.DetachSessionRequest{ .session_name = ctx.session_name };
34 var out: std.io.Writer.Allocating = .init(ctx.allocator);