- commit
- c654778
- parent
- 758a137
- author
- Eric Bower
- date
- 2026-04-25 21:08:53 -0400 EDT
fix(run): ignore DA queries when no terminal client connected `run` is not a real terminal client, it just tails the output and cannot respond to shell QA queries so we have a special flag that ignores read-only clients
1 files changed,
+9,
-6
+9,
-6
1@@ -539,6 +539,7 @@ const Daemon = struct {
2 cwd: []const u8 = "",
3 has_pty_output: bool = false,
4 has_had_client: bool = false,
5+ has_terminal_client: bool = false, // true only after a real attach (.Init received)
6 created_at: u64, // unix timestamp (ns)
7 is_task_mode: bool = false, // flag for when session is run as a task
8 task_exit_code: ?u8 = null, // null = running or n/a, set when task completes
9@@ -943,6 +944,7 @@ const Daemon = struct {
10
11 // Mark that we've had a client init, so subsequent clients get terminal state
12 self.has_had_client = true;
13+ self.has_terminal_client = true;
14
15 std.log.debug("init resize rows={d} cols={d}", .{ resize.rows, resize.cols });
16 }
17@@ -2408,12 +2410,13 @@ fn daemonLoop(daemon: *Daemon, server_sock_fd: i32, pty_fd: i32) !void {
18 try vt_stream.nextSlice(buf[0..n]);
19 daemon.has_pty_output = true;
20
21- // When no clients are attached, respond to terminal
22- // queries (e.g. DA1/DA2) on behalf of the terminal.
23- // This prevents shells like from fish from waiting 2s
24- // and then sending a no DA query response warning because
25- // there's no client terminal to respond to the query.
26- if (daemon.clients.items.len == 0 and
27+ // When no real terminal client has attached yet, respond to
28+ // terminal queries (e.g. DA1/DA2) on behalf of the terminal.
29+ // This prevents fish from waiting 10s for unanswered queries.
30+ // `has_terminal_client` is only set when a client sends .Init
31+ // (a real zmx attach), not when a `zmx run` tail-only client
32+ // connects.
33+ if (!daemon.has_terminal_client and
34 daemon.pty_write_buf.items.len < Daemon.PTY_WRITE_BUF_MAX)
35 {
36 util.respondToDeviceAttributes(daemon.alloc, &daemon.pty_write_buf, buf[0..n]);