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::Attach { reply }) => { let _ = reply.send(bcast.subscribe()); }
Some(SurfaceMsg::AttachSnapshot { reply }) => { Some(SurfaceMsg::AttachSnapshot { reply }) => {
// Flush pending into the grid first so the snapshot is current, // Subscribe-then-snapshot is atomic within this actor turn (no await,
// but DO NOT broadcast here; subscribe before any further output. // no flush can interleave). Any not-yet-flushed `pending` stays in
if !pending.is_empty() { // `pending` and is delivered to ALL subscribers — including this new
grid.feed(&pending); // one — exactly once by the normal 6ms/16KiB flush path. It is NOT in
let _ = bcast.send(std::mem::take(&mut pending)); // this snapshot. Broadcasting here would double-render on reattach.
flush_deadline = None;
}
let sub = bcast.subscribe(); let sub = bcast.subscribe();
let snap = snapshot_ansi(&grid); let snap = snapshot_ansi(&grid);
let _ = reply.send((snap, sub)); let _ = reply.send((snap, sub));