szn

Bug 421 — Grid.copyVisibleFrom indexes both rings by physical slot — clock-mode background output rotates the source start_index and welds rows to the wrong content

421. Grid.copyVisibleFrom indexes both rings by physical slot — clock-mode background output rotates the source start_index and welds rows to the wrong content

Severity: LOW Status: ✅ RESOLVED

const dest_line = &self.lines.items[r];
const src_line = &source.lines.items[r];   // physical index on BOTH rings

Correct only while self.start_index == source.start_index. The clock-mode saved grid is a clone (start_index preserved at clone time), but PTY feeding during clock mode is not gated: live scrollUp rotates the live ring and rewrites other physical slots. Each clock tick re-runs copyVisibleFrom(live_grid) (server.zig:2893) and starts copying physical row r of the live ring — which is now a different logical row — into the overlay, wrong rows and wrapped flags included.

Fix: index the source logically: source.lines.items[(source.start_index + r) % source.lines.items.len].