wtagent 0.2.1 → 0.2.2

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": "wtagent",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Turn your own web AI session into a local tool-using agent.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -198,7 +198,17 @@ export class ShellChatInput {
198
198
  const outputStream = this.outputStream;
199
199
  const previousRaw = inputStream.isRaw;
200
200
  const decoder = new StringDecoder("utf8");
201
- const columns = () => Math.max(10, Number(inputStream.columns) || 80);
201
+ // Terminal width lives on the TTY *output* stream; process.stdin.columns is
202
+ // undefined, so reading it always fell back to 80 — wrapping CJK input after
203
+ // ~40 chars and, worse, making the editor's multi-line row model disagree
204
+ // with the terminal's real wrapping (arrow-key redraws then duplicated the
205
+ // input up the screen). Prefer the output stream's live column count.
206
+ const columns = () => Math.max(
207
+ 10,
208
+ Number(outputStream.columns)
209
+ || Number(inputStream.columns)
210
+ || 80,
211
+ );
202
212
 
203
213
  let buffer = []; // flat code-point buffer; "\n" chars are real line breaks
204
214
  let cursor = 0;
@@ -507,8 +517,14 @@ export class ShellChatInput {
507
517
  ranges.push({ start: 0, end: 0 });
508
518
  }
509
519
 
510
- if (linesDrawn > 1) {
511
- outputStream.write(`\x1b[${linesDrawn - 1}A`);
520
+ // The previous render left the physical cursor on row `cursorRow`, which
521
+ // is NOT always the last drawn row: arrowing left/up into an earlier
522
+ // wrapped row leaves it higher. Move up by that actual row to reach the
523
+ // top — using `linesDrawn - 1` here overshoots whenever the cursor sits
524
+ // above the bottom row, drifting the whole block up the screen on every
525
+ // keystroke (duplicating wrapped lines). Mirror of finishLine()'s move.
526
+ if (cursorRow > 0) {
527
+ outputStream.write(`\x1b[${cursorRow}A`);
512
528
  }
513
529
  outputStream.write("\r");
514
530
  for (let index = 0; index < rendered.length; index += 1) {