@causyne/agent 1.20.107 → 1.20.108

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@causyne/agent",
3
- "version": "1.20.107",
3
+ "version": "1.20.108",
4
4
  "description": "Agentic AI for software, tools, and computer workflows",
5
5
  "main": "bin/causyne.js",
6
6
  "type": "module",
package/src/tui/prompt.js CHANGED
@@ -401,7 +401,7 @@ export class ChatPrompt {
401
401
  renderer.onPlanChange = (plan) => {
402
402
  if (this.surface) this.surface.sidebarPlan = plan;
403
403
  this.scheduleDraw();
404
- return this.surface && sidebarVisible(this.surface.width) ? 'sidebar' : undefined;
404
+ return this.surface && sidebarVisible(this.surface.width, false, this.surface.env) ? 'sidebar' : undefined;
405
405
  };
406
406
  }
407
407
 
@@ -470,7 +470,7 @@ export class ChatPrompt {
470
470
 
471
471
  /** Persistent checklist shown outside the chat transcript. */
472
472
  planRows(width) {
473
- if (this.surface && sidebarVisible(this.surface.width)) return [];
473
+ if (this.surface && sidebarVisible(this.surface.width, false, this.surface.env)) return [];
474
474
  const plan = this.renderer && Array.isArray(this.renderer.latestPlan) ? this.renderer.latestPlan : [];
475
475
  if (plan.length === 0) return [];
476
476
  const completed = plan.filter(item => item.status === 'completed').length;
@@ -482,8 +482,15 @@ export class ChatPrompt {
482
482
  return [summary, ''];
483
483
  }
484
484
  const rows = [`${bold(paint('accent', 'implementation plan'))} ${dim(`${completed}/${plan.length}`)}`];
485
+ // When the sidebar is absent, keep the active task visible instead of
486
+ // permanently showing the first five (often already completed) steps.
485
487
  const limit = Math.min(plan.length, 5);
486
- for (const item of plan.slice(0, limit)) {
488
+ const active = plan.findIndex(item => item.status === 'in_progress');
489
+ const pending = plan.findIndex(item => item.status !== 'completed');
490
+ const focus = active >= 0 ? active : pending >= 0 ? pending : plan.length - 1;
491
+ const start = Math.max(0, Math.min(focus - 1, plan.length - limit));
492
+ if (start > 0) rows.push(` ${dim(`${GLYPHS.ellipsis} ${start} earlier`)}`);
493
+ for (const item of plan.slice(start, start + limit)) {
487
494
  const mark = item.status === 'completed'
488
495
  ? paint('success', GLYPHS.check)
489
496
  : item.status === 'in_progress'
@@ -491,7 +498,8 @@ export class ChatPrompt {
491
498
  : paint('muted', GLYPHS.dot);
492
499
  rows.push(` ${mark} ${truncate(safeDisplay(item.text || item.step || ''), Math.max(8, width - 5), GLYPHS.ellipsis)}`);
493
500
  }
494
- if (plan.length > limit) rows.push(` ${dim(`${GLYPHS.ellipsis} ${plan.length - limit} more`)}`);
501
+ const remaining = plan.length - start - limit;
502
+ if (remaining > 0) rows.push(` ${dim(`${GLYPHS.ellipsis} ${remaining} later`)}`);
495
503
  rows.push('');
496
504
  return rows;
497
505
  }
package/src/tui/stage.js CHANGED
@@ -225,6 +225,21 @@ export class Stage {
225
225
  this.write(`\x1b[${delta}B`);
226
226
  this.cursor = target;
227
227
  }
228
+ /**
229
+ * Recover the reserved band's physical anchor after a terminal reflow.
230
+ * A width change can soft-wrap old screen rows before the next repaint.
231
+ * Cursor-down clamps at the screen bottom without emitting a newline or
232
+ * addressing an absolute row, preserving native terminal scrollback.
233
+ */
234
+ reanchor() {
235
+ if (!this.reserved)
236
+ return false;
237
+ this.write('\x1b[999B\r');
238
+ this.cursor = this.height - 1;
239
+ this.caret = { row: this.cursor, col: 0, hideCursor: Boolean(this.caret.hideCursor) };
240
+ this.invalidate();
241
+ return true;
242
+ }
228
243
  /**
229
244
  * Repaint the band. Rows that did not change cost nothing.
230
245
  *
package/src/tui/stage.ts CHANGED
@@ -244,6 +244,21 @@ export class Stage {
244
244
  this.cursor = target;
245
245
  }
246
246
 
247
+ /**
248
+ * Recover the reserved band's physical anchor after a terminal reflow.
249
+ * A width change can soft-wrap old screen rows before the next repaint.
250
+ * Cursor-down clamps at the screen bottom without emitting a newline or
251
+ * addressing an absolute row, preserving native terminal scrollback.
252
+ */
253
+ reanchor(): boolean {
254
+ if (!this.reserved) return false;
255
+ this.write('\x1b[999B\r');
256
+ this.cursor = this.height - 1;
257
+ this.caret = { row: this.cursor, col: 0, hideCursor: Boolean(this.caret.hideCursor) };
258
+ this.invalidate();
259
+ return true;
260
+ }
261
+
247
262
  /**
248
263
  * Repaint the band. Rows that did not change cost nothing.
249
264
  *
@@ -186,6 +186,7 @@ export class StageSurface {
186
186
  this.env = env;
187
187
 
188
188
  this.stage = new Stage({ out, env });
189
+ this.lastColumns = this.stage.width();
189
190
  this.transcript = new Transcript({
190
191
  onEvict: (rows) => this.absorbEvicted(rows),
191
192
  onChange: () => this.handleChange()
@@ -680,9 +681,15 @@ export class StageSurface {
680
681
  // obsolete sidebar columns behind during the 160-column breakpoint.
681
682
  // The existing rows are already reserved: repaint them in place with
682
683
  // their new width, clearing trailing cells through Stage.paint().
684
+ const columns = this.stage.width();
683
685
  if (!this.stage.reserved || next !== this.stage.maxHeight) {
684
686
  this.stage.resize(next, 1);
687
+ } else if (columns !== this.lastColumns && !this.detached) {
688
+ // macOS Terminal may physically reflow rows when the sidebar appears
689
+ // or disappears. The old caret row is then no longer a reliable anchor.
690
+ this.stage.reanchor();
685
691
  }
692
+ this.lastColumns = columns;
686
693
  this.stage.invalidate();
687
694
  // Re-derive from the new geometry: growing the viewport lowers maxScrollTop,
688
695
  // and leaving scrollTop above it would read as "the user scrolled away".
@@ -827,9 +834,9 @@ export class StageSurface {
827
834
  this.out.write(mouseHoverTracking(true, this.env));
828
835
  this.mouseCaptured = true;
829
836
  this.detached = false;
830
- // Every row the diff remembers is stale — the terminal has scrolled under
831
- // us. Redraw the whole band rather than trusting a single cached row.
832
- this.stage.invalidate();
837
+ // After native scrollback, the former physical cursor location is unknown.
838
+ // Return to the screen bottom before repainting any transcript rows.
839
+ this.stage.reanchor();
833
840
  return true;
834
841
  }
835
842
  }