@agfpd/iapeer 0.4.60 → 0.4.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/supervisor/daemon.ts +22 -2
package/package.json
CHANGED
package/src/supervisor/daemon.ts
CHANGED
|
@@ -450,17 +450,37 @@ export function runSupervisorDaemon(opts: SupervisorDaemonOptions): void {
|
|
|
450
450
|
// and a busy child's tick cadence has quiet gaps — the stability loop returns in such a gap
|
|
451
451
|
// BEFORE the redraw arrives (proven by the repro byte log: the \x1b[NA redraw came as frame #2,
|
|
452
452
|
// after the snapshot), which re-creates the dup exactly.
|
|
453
|
-
const awaitSeqBump = async (timeoutMs: number): Promise<
|
|
453
|
+
const awaitSeqBump = async (timeoutMs: number): Promise<boolean> => {
|
|
454
454
|
const seq = writeSeq
|
|
455
455
|
const deadline = Date.now() + timeoutMs
|
|
456
456
|
while (writeSeq === seq && Date.now() < deadline) await Bun.sleep(15)
|
|
457
|
+
return writeSeq !== seq // true = the child actually emitted its SIGWINCH redraw (vs a silent child)
|
|
457
458
|
}
|
|
458
459
|
const firstAttach = async (s: { write(b: Buffer): number }, c: number, r: number): Promise<void> => {
|
|
459
460
|
await awaitModelParsedStable()
|
|
461
|
+
// ORPHAN-SCROLLBACK on a shrinking attach (Артур welcome-attach corruption, 04.07 — live repro):
|
|
462
|
+
// the model is hosted at HOST 220x50; a real terminal attaches NARROWER (e.g. 120x30). applyGeometry
|
|
463
|
+
// REFLOWS the model (220→120): every wide line rewraps TALLER, and with fewer rows the TOP of the
|
|
464
|
+
// pre-resize viewport SPILLS into scrollback. The child's SIGWINCH redraw repaints only the VIEWPORT
|
|
465
|
+
// (a relative-cursor TUI can't reach scrollback), so the spilled rows linger as stale, reflow-wrapped
|
|
466
|
+
// orphans ABOVE the clean repaint — the "two frames overlaid + left-clipped" screenshot. This is a
|
|
467
|
+
// DIFFERENT artifact from the 0.4.59 viewport-dup (that stacked inside the viewport; this is scrollback).
|
|
468
|
+
const preBaseY = xterm.buffer.active.baseY // committed scrollback history depth BEFORE the resize
|
|
460
469
|
if (c !== cols || r !== rows) {
|
|
461
470
|
applyGeometry(c, r) // model + child together — one honest SIGWINCH, BEFORE the snapshot
|
|
462
|
-
await awaitSeqBump(SIGWINCH_REDRAW_WAIT_MS) // the redraw wave ARRIVES (or the child has none)
|
|
471
|
+
const redrew = await awaitSeqBump(SIGWINCH_REDRAW_WAIT_MS) // the redraw wave ARRIVES (or the child has none)
|
|
463
472
|
await awaitModelParsedStable() // …then drain it to stability (bounded, В25 cap)
|
|
473
|
+
// Erase the orphan scrollback ONLY when it is PROVABLY 100% orphan: preBaseY===0 means there was NO
|
|
474
|
+
// committed history — the ENTIRE pre-resize screen was the child's dynamic tree, which the redraw has
|
|
475
|
+
// now fully repainted into the viewport, so every post-resize scrollback row is a redundant spilled
|
|
476
|
+
// copy. Erase it server-side (ESC[3J on the MODEL → serialize then carries only the clean viewport;
|
|
477
|
+
// no clear reaches the client's native scrollback). GUARDED on an actual redraw (a silent child keeps
|
|
478
|
+
// its only copy) and on new scrollback existing. preBaseY>0 (real scroll-up history) is left intact:
|
|
479
|
+
// the history/dynamic-tree seam lives inside the child's renderer and can't be derived here, so we
|
|
480
|
+
// never risk dropping real history — that narrower case is a separate follow-up.
|
|
481
|
+
if (redrew && preBaseY === 0 && xterm.buffer.active.baseY > 0) {
|
|
482
|
+
await new Promise<void>(res => xterm.write('\x1b[3J', () => res())) // eraseScrollback + parse barrier
|
|
483
|
+
}
|
|
464
484
|
}
|
|
465
485
|
sendSnapshot(s) // serialize the post-redraw model → send → lift gate (synchronous, no interleave)
|
|
466
486
|
}
|