fix(daemon): remove pending broadcast on attach to prevent reattach double-render

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-09 20:33:11 +07:00
parent 62e86a1c97
commit 77dfc69bd9
+5 -7
View File
@@ -63,13 +63,11 @@ pub fn spawn_surface(
}
Some(SurfaceMsg::Attach { reply }) => { let _ = reply.send(bcast.subscribe()); }
Some(SurfaceMsg::AttachSnapshot { reply }) => {
// Flush pending into the grid first so the snapshot is current,
// but DO NOT broadcast here; subscribe before any further output.
if !pending.is_empty() {
grid.feed(&pending);
let _ = bcast.send(std::mem::take(&mut pending));
flush_deadline = None;
}
// Subscribe-then-snapshot is atomic within this actor turn (no await,
// no flush can interleave). Any not-yet-flushed `pending` stays in
// `pending` and is delivered to ALL subscribers — including this new
// one — exactly once by the normal 6ms/16KiB flush path. It is NOT in
// this snapshot. Broadcasting here would double-render on reattach.
let sub = bcast.subscribe();
let snap = snapshot_ansi(&grid);
let _ = reply.send((snap, sub));