caroushell 0.1.29 → 0.1.30

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.
Files changed (2) hide show
  1. package/dist/terminal.js +17 -37
  2. package/package.json +2 -2
package/dist/terminal.js CHANGED
@@ -22,8 +22,6 @@ class Terminal {
22
22
  this.cursorRow = 0;
23
23
  this.cursorCol = 0;
24
24
  this.writesDisabled = false;
25
- this.pendingBlock = null;
26
- this.renderScheduled = false;
27
25
  }
28
26
  disableWrites() {
29
27
  this.writesDisabled = true;
@@ -72,63 +70,47 @@ class Terminal {
72
70
  write(text) {
73
71
  if (!this.canWrite())
74
72
  return;
75
- this.flushPendingRender();
76
73
  this.out.write(text);
77
74
  }
78
75
  hideCursor() {
79
- this.write("\x1b[?25l");
76
+ if (!this.canWrite())
77
+ return;
78
+ this.out.write("\x1b[?25l");
80
79
  }
81
80
  showCursor() {
82
- this.write("\x1b[?25h");
83
- }
84
- // Render a block of lines by clearing previous block (if any) and writing fresh
85
- renderBlock(lines, cursorRow, cursorCol) {
86
81
  if (!this.canWrite())
87
82
  return;
88
- this.pendingBlock = {
89
- lines: [...lines],
90
- cursorRow,
91
- cursorCol,
92
- };
93
- if (this.renderScheduled)
94
- return;
95
- this.renderScheduled = true;
96
- queueMicrotask(() => this.flushPendingRender());
83
+ this.out.write("\x1b[?25h");
97
84
  }
98
- flushPendingRender() {
99
- if (!this.pendingBlock) {
100
- this.renderScheduled = false;
101
- return;
102
- }
103
- const pending = this.pendingBlock;
104
- this.pendingBlock = null;
105
- this.renderScheduled = false;
85
+ // Render a block of lines by clearing previous block (if any) and writing fresh
86
+ renderBlock(lines, cursorRow, cursorCol) {
106
87
  if (!this.canWrite())
107
88
  return;
108
89
  this.withCork(() => {
90
+ this.hideCursor();
109
91
  this.moveCursorToTopOfBlock();
110
92
  if (this.activeRows > 0) {
111
93
  readline_1.default.cursorTo(this.out, 0);
112
94
  readline_1.default.clearScreenDown(this.out);
113
95
  }
114
- for (let i = 0; i < pending.lines.length; i++) {
115
- this.out.write(pending.lines[i]);
116
- if (i < pending.lines.length - 1)
96
+ for (let i = 0; i < lines.length; i++) {
97
+ this.out.write(lines[i]);
98
+ if (i < lines.length - 1)
117
99
  this.out.write("\n");
118
100
  }
119
- this.activeRows = pending.lines.length;
101
+ this.activeRows = lines.length;
120
102
  this.cursorRow = Math.max(0, this.activeRows - 1);
121
- const lastLine = pending.lines[this.cursorRow] || "";
103
+ const lastLine = lines[this.cursorRow] || "";
122
104
  this.cursorCol = lastLine.length;
123
- const needsPosition = typeof pending.cursorRow === "number" ||
124
- typeof pending.cursorCol === "number";
105
+ const needsPosition = typeof cursorRow === "number" || typeof cursorCol === "number";
125
106
  if (needsPosition) {
126
- const targetRow = typeof pending.cursorRow === "number"
127
- ? Math.min(Math.max(pending.cursorRow, 0), Math.max(0, this.activeRows - 1))
107
+ const targetRow = typeof cursorRow === "number"
108
+ ? Math.min(Math.max(cursorRow, 0), Math.max(0, this.activeRows - 1))
128
109
  : this.cursorRow;
129
- const targetCol = Math.max(0, pending.cursorCol ?? this.cursorCol);
110
+ const targetCol = Math.max(0, cursorCol ?? this.cursorCol);
130
111
  this.moveCursorTo(targetRow, targetCol);
131
112
  }
113
+ this.showCursor();
132
114
  });
133
115
  }
134
116
  moveCursorTo(lineIndex, column) {
@@ -149,8 +131,6 @@ class Terminal {
149
131
  // When we have printed arbitrary output that is not managed by renderBlock,
150
132
  // reset internal line tracking so the next render starts fresh.
151
133
  resetBlockTracking() {
152
- this.pendingBlock = null;
153
- this.renderScheduled = false;
154
134
  this.activeRows = 0;
155
135
  this.cursorRow = 0;
156
136
  this.cursorCol = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caroushell",
3
- "version": "0.1.29",
3
+ "version": "0.1.30",
4
4
  "description": "Terminal carousel that suggests commands from history, config, and AI.",
5
5
  "type": "commonjs",
6
6
  "main": "dist/main.js",
@@ -18,7 +18,7 @@
18
18
  "prepare": "npm run build",
19
19
  "start": "node dist/main.js",
20
20
  "test": "node --import tsx --test tests/*.ts",
21
- "test:generate": "tsx src/test-generate.ts",
21
+ "test:ai-generate": "tsx src/test-generate.ts",
22
22
  "lint": "eslint . --ext .ts",
23
23
  "release": "tsx scripts/release.ts"
24
24
  },