@phenx-inc/ctlsurf 0.1.8 → 0.1.9

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.
@@ -3647,7 +3647,7 @@ var ConversationBridge = class {
3647
3647
  inputBuffer = "";
3648
3648
  // Virtual terminal for processing escape sequences into rendered text
3649
3649
  terminal;
3650
- lastSnapshotLines = 0;
3650
+ lastSnapshot = "";
3651
3651
  pendingWrites = 0;
3652
3652
  constructor() {
3653
3653
  this.terminal = new import_headless.Terminal({ cols: 120, rows: 50, scrollback: 1e4 });
@@ -3657,7 +3657,7 @@ var ConversationBridge = class {
3657
3657
  }
3658
3658
  startSession() {
3659
3659
  this.terminal.reset();
3660
- this.lastSnapshotLines = 0;
3660
+ this.lastSnapshot = "";
3661
3661
  this.pendingWrites = 0;
3662
3662
  this.inputBuffer = "";
3663
3663
  this.sessionActive = true;
@@ -3706,18 +3706,23 @@ var ConversationBridge = class {
3706
3706
  return;
3707
3707
  }
3708
3708
  const buf = this.terminal.buffer.active;
3709
- const totalLines = buf.baseY + buf.cursorY + 1;
3710
- if (totalLines <= this.lastSnapshotLines) return;
3711
- const newLines = [];
3712
- for (let i = this.lastSnapshotLines; i < totalLines; i++) {
3709
+ const totalLines = buf.baseY + this.terminal.rows;
3710
+ const allLines = [];
3711
+ for (let i = 0; i < totalLines; i++) {
3713
3712
  const line = buf.getLine(i);
3714
3713
  if (line) {
3715
- newLines.push(line.translateToString(true));
3714
+ allLines.push(line.translateToString(true));
3716
3715
  }
3717
3716
  }
3718
- this.lastSnapshotLines = totalLines;
3719
- const content = newLines.join("\n");
3720
- const cleaned = content.replace(/\n{3,}/g, "\n\n").trim();
3717
+ const currentSnapshot = allLines.join("\n");
3718
+ let newContent;
3719
+ if (currentSnapshot.startsWith(this.lastSnapshot)) {
3720
+ newContent = currentSnapshot.slice(this.lastSnapshot.length);
3721
+ } else {
3722
+ newContent = currentSnapshot;
3723
+ }
3724
+ this.lastSnapshot = currentSnapshot;
3725
+ const cleaned = newContent.replace(/\n{3,}/g, "\n\n").trim();
3721
3726
  if (cleaned.length === 0) return;
3722
3727
  this.sendEntry("terminal_output", cleaned);
3723
3728
  }