diff --git a/crates/spaceshd/src/surface.rs b/crates/spaceshd/src/surface.rs index eb8b28a..556d04e 100644 --- a/crates/spaceshd/src/surface.rs +++ b/crates/spaceshd/src/surface.rs @@ -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));