╭ changed ────────╮ │src/serve_ssh.zig│ ╰─────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────╮ │251 defer if (terminal_maybe) |*terminal| terminal.deinit(); │ │252 │ │253 // initial render — user sees the page immediately │ │254 - if (terminal_maybe) |*terminal| _ = try terminal.render(&nav.root); │ │254 + if (terminal_maybe) |*terminal| { │ │255 + try terminal.queryBackground(); │ │256 + _ = try terminal.render(&nav.root); │ │257 + } │ │258 │ │259 // event loop. nextEvent blocks until something interesting arrives;│ │260 // for each event, rebuild the widget tree and re-render so the user│ ╰─────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────╮ │299 } │ │300 } │ │301 │ │299 - try ui_session.applyAndWritePending(io, allocator, &repo); │ │300 - │ │302 // pick up data written by other handles so the next navigation│ │303 // builds its page from a current moment │ │304 try ui_session.reloadMoment(allocator, &repo); │ ╰────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────╮ │305 │ │305 - // reconcile navigation: forward to a new page, or back on escape │ │306 - try nav.sync(allocator, &ui_session); │ │306 + // reconcile navigation: forward to a new page, or back on escape. │ │307 + // the terminal background can change at any time, so recheck it on each page│ │308 + if (try nav.sync(allocator, &ui_session)) { │ │309 + if (terminal_maybe) |*terminal| try terminal.queryBackground(); │ │310 + } │ │311 │ │312 // the quit button (on the quit tab) asks the host to tear down │ │313 if (ui_session.quit_requested) break :event_loop; │ ╰──────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────╮ │320 } │ │321 } │ │322 │ │319 -// only a lone ESC needs a deadline; longer CSI/SS3 fragments must remain │ │320 -// buffered until complete. a timeout leaves partial SSH packets in the reader. │ │323 +// only ambiguous input (a lone ESC or ESC ]) needs a deadline; longer │ │324 +// fragments must remain buffered until complete. a timeout leaves partial SSH │ │325 +// packets in the reader. │ │326 pub fn nextTuiEvent(sess: *ssh.SessionCtx, terminal: ?*StreamTerminal) !?ssh.Event {│ │327 if (terminal) |t| { │ │323 - if (t.parser.esc_len == 1) { │ │328 + if (t.parser.isAmbiguous()) { │ │329 sess.conn.read_timeout = escape_timeout.toDeadline(sess.conn.io); │ │330 defer sess.conn.read_timeout = .none; │ │331 return sess.nextEvent() catch |err| switch (err) { │ ╰─────────────────────────────────────────────────────────────────────────────────────────╯