pi-polish 0.1.13 → 0.1.15

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.
@@ -45,7 +45,7 @@ export default function (pi: ExtensionAPI) {
45
45
  if (!(child instanceof Markdown) || (child as any).defaultTextStyle !== undefined || (child as any)[patched]) continue;
46
46
  const render = child.render.bind(child);
47
47
  child.render = (width: number) => {
48
- const lines: string[] = render(width);
48
+ const lines = [...render(width)];
49
49
  const first = lines.findIndex((l) => l.replace(/\x1b\[[0-9;]*m/g, "").trim());
50
50
  if (first >= 0) lines[first] = markFirstLine(lines[first], REPLY);
51
51
  return lines;
@@ -361,6 +361,7 @@ function withBackground(line: string, spans: Span[], on: string, off: string): s
361
361
  class DiffView implements Component {
362
362
  private highlighted: string[];
363
363
  private palette: Palette;
364
+ private cachedRender?: { width: number; lines: string[] };
364
365
 
365
366
  constructor(
366
367
  private lines: string[],
@@ -403,6 +404,8 @@ class DiffView implements Component {
403
404
  }
404
405
 
405
406
  render(width: number): string[] {
407
+ if (this.cachedRender?.width === width) return this.cachedRender.lines;
408
+
406
409
  const { addedBg, removedBg, addedGutter, removedGutter } = this.palette;
407
410
  const out = this.lines.map((line, i) => {
408
411
  const sign = line[0];
@@ -419,10 +422,13 @@ class DiffView implements Component {
419
422
  return `${bg}${text.replace(/\x1b\[0?m/g, (m) => m + bg)}${pad}${BG_RESET}`;
420
423
  });
421
424
  if (this.footer) out.push(truncateToWidth(this.footer, width));
425
+ this.cachedRender = { width, lines: out };
422
426
  return out;
423
427
  }
424
428
 
425
- invalidate(): void {}
429
+ invalidate(): void {
430
+ this.cachedRender = undefined;
431
+ }
426
432
  }
427
433
 
428
434
  function lineCount(n: number): string {
@@ -631,8 +637,9 @@ export default function (pi: ExtensionAPI) {
631
637
  const pulse = secs % 2 ? "dim" : "accent";
632
638
  const head = theme.fg(pulse, `${MARK} `) + theme.fg("toolTitle", `${summary(group, true)}…`) + theme.fg("dim", ` · ${secs}s`) + failNote;
633
639
  const latest = active.latest ? [theme.fg("dim", ` ${active.latest}`)] : [];
634
- // pi-background marks commands that ctrl+b can move to the background
635
- const movable = (globalThis as any)[Symbol.for("pi-background.movable")]?.has(active.id) ? [theme.fg("dim", " (ctrl+b to run in background)")] : [];
640
+ // pi-background marks commands that its shortcut (ctrl+b unless set otherwise) can move to the background
641
+ const moveKey = (globalThis as any)[Symbol.for("pi-background.moveKey")]?.() ?? "ctrl+b";
642
+ const movable = (globalThis as any)[Symbol.for("pi-background.movable")]?.has(active.id) ? [theme.fg("dim", ` (${moveKey} to run in background)`)] : [];
636
643
  return oneLine([head, theme.fg("dim", ` └ ${active.label}`), ...latest, ...movable]);
637
644
  }
638
645
  // Finished rows go quiet, like Claude Code's: dim text, with a red ● only when something failed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-polish",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "license": "MIT",
5
5
  "author": "Thomas van Dongen",
6
6
  "type": "module",