pi-autosuggestions 0.3.1 → 0.3.3

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.
@@ -1 +1 @@
1
- {".":"0.3.1"}
1
+ {".":"0.3.3"}
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.3](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.3.2...pi-autosuggestions-v0.3.3) (2026-09-04)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * force white blinking bar cursor in terminals with themed cursors ([20a3a24](https://github.com/0xPlayerOne/pi-autosuggestions/commit/20a3a2499cad2ec3a83e1c8d1edd0c96b6d6a2ee))
9
+
10
+ ## [0.3.2](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.3.1...pi-autosuggestions-v0.3.2) (2026-09-04)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * use the terminal's native blinking bar cursor ([2abf68b](https://github.com/0xPlayerOne/pi-autosuggestions/commit/2abf68b1f226c9b62ec2c9cdebeb3375601de632))
16
+
3
17
  ## [0.3.1](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.3.0...pi-autosuggestions-v0.3.1) (2026-09-04)
4
18
 
5
19
 
package/README.md CHANGED
@@ -84,11 +84,19 @@ In bash mode (`!command`), a second strategy completes **filesystem paths**:
84
84
  zero or one option → ghost, with history winning over paths
85
85
  - Works for `!!` hidden commands and any bash argument, not just `cd`
86
86
 
87
- ### Beam cursor
88
-
89
- The block cursor becomes a thin blinking vertical bar (`▏`, ~2 Hz) that stays
90
- solid while you type. On ghost rows the cursor rides the suggestion's first
91
- character, zsh-autosuggestions style.
87
+ ### Native blinking bar cursor
88
+
89
+ The editor's fake block cursor is replaced by your terminal's **native blinking
90
+ bar cursor** — the same behavior as Apple Terminal's bar style: it overlays the
91
+ cell edge without ever covering the character, blinks on its own, and pauses
92
+ blinking while you type. On ghost rows the bar rides the suggestion's first
93
+ character. The extension forces the cursor **white** (OSC 12) and requests the
94
+ blinking-bar shape (DECSCUSR `CSI 5 q`) so it doesn't inherit the terminal
95
+ theme's cursor color; both are restored to your terminal's defaults when pi
96
+ exits. If blinking stays off (e.g. Warp), check the terminal's own cursor-blink
97
+ setting (Warp: Settings → Appearance → Cursor → Blinking).
98
+ A software beam cursor is kept as a fallback if the hardware cursor is
99
+ unavailable.
92
100
 
93
101
  ## Attribution
94
102
 
@@ -52,9 +52,6 @@ class BashInlineEditor extends CustomEditor {
52
52
  private ghost: Ghost | null = null;
53
53
  private ghostToken = 0;
54
54
  private ghostAbort?: AbortController;
55
- private cursorOn = true;
56
- private lastInputAt = 0;
57
- private blinkTimer?: ReturnType<typeof setInterval>;
58
55
  /** Submitted prompts, oldest first — the zsh-autosuggestions history strategy. */
59
56
  private promptHistory: string[] = [];
60
57
  /** Set by Escape; keeps the ghost dismissed until the next text edit. */
@@ -62,7 +59,15 @@ class BashInlineEditor extends CustomEditor {
62
59
 
63
60
  constructor(tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager) {
64
61
  super(tui, theme, keybindings);
65
- this.startBlink();
62
+ // Native terminal cursor = the Apple-Terminal-style blinking bar: it
63
+ // draws over the glyph's cell edge without covering the character.
64
+ // - DECSCUSR 5 q: blinking bar shape (Warp honors this).
65
+ // - OSC 12: force the cursor color white — terminals like Warp paint
66
+ // the native cursor with the theme's color (often blue), which we
67
+ // don't control from the theme.
68
+ tui.setShowHardwareCursor(true);
69
+ tui.terminal.write("\x1b]12;#ffffff\x1b\\");
70
+ tui.terminal.write("\x1b[5 q");
66
71
  // Wrap onChange so programmatic text changes (paste, undo, history,
67
72
  // setText) also refresh the inline suggestion.
68
73
  let external: ((text: string) => void) | undefined;
@@ -117,9 +122,6 @@ class BashInlineEditor extends CustomEditor {
117
122
  }
118
123
 
119
124
  handleInput(data: string): void {
120
- // Solid cursor while typing; blinking resumes after the idle window.
121
- this.lastInputAt = Date.now();
122
- this.cursorOn = true;
123
125
  // Accept keys while a ghost suggestion is showing and the cursor sits
124
126
  // at end of line (zsh-autosuggestions widget semantics):
125
127
  // right → accept the whole suggestion
@@ -181,54 +183,62 @@ class BashInlineEditor extends CustomEditor {
181
183
  return out;
182
184
  }
183
185
  const head = row.slice(0, match.index);
186
+ const ch = match[1] || " ";
187
+ if (this.tui.getShowHardwareCursor()) {
188
+ // Native terminal cursor mode: strip the fake block so the real
189
+ // blinking bar is the only cursor. It overlays the cell edge
190
+ // without covering the character, and it rides the first ghost
191
+ // character on suggestion rows.
192
+ const ghost = this.activeGhost();
193
+ if (!ghost) {
194
+ // Empty cursor cell: the native bar blinks there, nothing covered.
195
+ out[rowIdx] = head + ch + row.slice(match.index + match[0].length);
196
+ return out;
197
+ }
198
+ // The ghost starts AT the cursor cell so the native bar overlays
199
+ // its first character (Apple Terminal bar-cursor behavior) instead
200
+ // of sitting in a gap cell.
201
+ const remainder = ghost.suggestion.slice(ghost.typed.length);
202
+ const pad = / *$/.exec(row.slice(match.index + match[0].length))?.[0].length ?? 0;
203
+ const avail = pad + 1;
204
+ let used = 0;
205
+ const ghostCells: string[] = [];
206
+ for (const g of [...remainder]) {
207
+ const w = visibleWidth(g);
208
+ if (used + w > avail) {
209
+ break;
210
+ }
211
+ ghostCells.push(`${DIM}${g}${RESET}`);
212
+ used += w;
213
+ }
214
+ out[rowIdx] = head + ghostCells.join("") + " ".repeat(Math.max(0, pad - used + 1));
215
+ return out;
216
+ }
184
217
  const ghost = this.activeGhost();
185
218
  if (ghost) {
186
- // Base row layout: text + cursor cell + padding. Drop the cursor
187
- // cell (frees 1 col) and render ghost chars into the padding.
219
+ // Fallback (software blink): ghost chars fill the padding.
188
220
  const remainder = ghost.suggestion.slice(ghost.typed.length);
189
221
  const pad = / *$/.exec(row.slice(match.index + match[0].length))?.[0].length ?? 0;
190
222
  const avail = pad + 1;
191
223
  let used = 0;
192
- const cells: string[] = [];
193
- for (const ch of [...remainder]) {
194
- const w = visibleWidth(ch);
224
+ const ghostCells: string[] = [];
225
+ for (const g of [...remainder]) {
226
+ const w = visibleWidth(g);
195
227
  if (used + w > avail) {
196
228
  break;
197
229
  }
198
- // Blink "on": first suggestion char is bright (acts as the cursor)
199
- cells.push(used === 0 && this.cursorOn ? `\x1b[1m${ch}${RESET}` : `${DIM}${ch}${RESET}`);
230
+ ghostCells.push(`${DIM}${g}${RESET}`);
200
231
  used += w;
201
232
  }
202
- out[rowIdx] = head + cells.join("") + " ".repeat(Math.max(0, pad - used + 1));
233
+ out[rowIdx] = head + BEAM + ghostCells.join("") + " ".repeat(Math.max(0, pad - used));
203
234
  return out;
204
235
  }
205
- const ch = match[1] || " ";
206
- // The beam only replaces empty cells — over a letter it would black
207
- // the character out every other blink. Cursor over a letter instead
208
- // renders that letter underlined while visible (zsh bar cursors draw
209
- // the bar in the same cell; a terminal grid can't, so underline wins).
210
- const cursorCell = this.cursorOn ? (ch === " " ? BEAM : `\x1b[4m${ch}${RESET}`) : ch;
211
- out[rowIdx] = head + cursorCell + row.slice(match.index + match[0].length);
236
+ out[rowIdx] = head + BEAM + row.slice(match.index + match[0].length);
212
237
  return out;
213
238
  }
214
239
 
215
240
  // --- internals ---
216
241
 
217
- /** Toggle the beam cursor while focused; solid briefly after keystrokes. */
218
- private startBlink(): void {
219
- if (this.blinkTimer) {
220
- return;
221
- }
222
- this.blinkTimer = setInterval(() => {
223
- if (!this.focused) {
224
- return;
225
- }
226
- const idle = Date.now() - this.lastInputAt > SOLID_AFTER_INPUT_MS;
227
- this.cursorOn = idle ? !this.cursorOn : true;
228
- this.tui.requestRender();
229
- }, BLINK_INTERVAL_MS);
230
- }
231
-
232
242
  private inBashMode(): boolean {
233
243
  return this.getText().trimStart().startsWith("!");
234
244
  }
@@ -529,4 +539,13 @@ export default function (pi: ExtensionAPI): void {
529
539
  pi.on("session_start", (_event, ctx) => {
530
540
  ctx.ui.setEditorComponent((tui, theme, keybindings) => new BashInlineEditor(tui, theme, keybindings));
531
541
  });
542
+ // Restore the terminal's own cursor color and shape when pi exits so the
543
+ // shell afterwards isn't left with our forced white bar.
544
+ process.on("exit", () => {
545
+ try {
546
+ process.stdout.write("\x1b]104;12\x1b\\\x1b[0 q");
547
+ } catch {
548
+ // terminal gone — nothing to restore
549
+ }
550
+ });
532
551
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-autosuggestions",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "zsh-autosuggestions-style ghost completions for the pi coding agent — history-based inline suggestions, path completion in bash mode, blinking beam cursor",
5
5
  "keywords": [
6
6
  "pi-package",