@tian.zuo/pi-beautify-style 0.3.0 → 0.3.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @tian.zuo/pi-beautify-style
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#224](https://github.com/TianZuo555/pi-extensions/pull/224) [`80a696e`](https://github.com/TianZuo555/pi-extensions/commit/80a696ef7704e06a0f80f34060ae4da90f2e8f8a) Thanks [@TianZuo555](https://github.com/TianZuo555)! - Support Pi 1.6 render lines in compact thinking previews, preserve codemode summary syntax colors, and keep sticky prompt markers out of Pi’s render cache.
8
+
3
9
  ## 0.3.0
4
10
 
5
11
  ### Minor Changes
@@ -401,7 +401,7 @@ export class ThinkingPreviewBlock implements Component {
401
401
  hintHovered: boolean;
402
402
  expandAction: string | undefined;
403
403
  streaming: boolean;
404
- lines: string[];
404
+ lines: readonly string[];
405
405
  }
406
406
  | undefined;
407
407
 
@@ -458,7 +458,7 @@ export class ThinkingPreviewBlock implements Component {
458
458
  this.hintHovered = hovered;
459
459
  }
460
460
 
461
- private headingLines(width: number, padding: number): string[] {
461
+ private headingLines(width: number, padding: number): readonly string[] {
462
462
  // 收起态(收尾且未展开)只留标题 + 打开提示;运行中正文自己就是入口。
463
463
  const hint = this.expanded || this.streaming ? undefined : collapsedThinkingHint();
464
464
  if (!hint) return new Text(this.heading, padding, 0).render(width);
@@ -368,6 +368,7 @@ export function installStickyPromptMarkerPatch(): StickyPatch | null {
368
368
  if (previous) previous.active = false;
369
369
  const original =
370
370
  previous && prototype.render === previous.installed ? previous.original : prototype.render;
371
+ const markedOutput = new WeakMap<readonly string[], readonly string[]>();
371
372
  const patch: StickyPatch = {
372
373
  active: true,
373
374
  original,
@@ -375,10 +376,14 @@ export function installStickyPromptMarkerPatch(): StickyPatch | null {
375
376
  const lines = original.call(this, width);
376
377
  if (!patch.active || !isToolTuiFullscreen()) return lines;
377
378
  if (!Array.isArray(lines) || lines.length === 0) return lines;
378
- // 接在行尾:行首的 OSC133 前缀保持在下游的可剥离位置。
379
- lines[0] += MESSAGE_START;
380
- lines[lines.length - 1] += MESSAGE_END;
381
- return lines;
379
+ const cached = markedOutput.get(lines);
380
+ if (cached) return cached;
381
+ // Keep Pi's cached lines intact and leave the OSC 133 prefix in place.
382
+ const marked = [...lines];
383
+ marked[0] += MESSAGE_START;
384
+ marked[marked.length - 1] += MESSAGE_END;
385
+ markedOutput.set(lines, marked);
386
+ return marked;
382
387
  },
383
388
  };
384
389
  prototype.render = patch.installed;
@@ -184,12 +184,11 @@ export function codemodeCodeLines(
184
184
  }
185
185
 
186
186
  /**
187
- * 所以包一层 `() => { … }` 再取中间那一行。失败或没着色时退回原文。
187
+ * Highlight the statement in a function body and keep its line.
188
188
  */
189
189
  export function highlightCodeSummary(summary: string): string {
190
190
  try {
191
- const lines = highlightCode(`() => { ${summary} }`, "javascript");
192
- const colored = lines[0]?.replace(/^\(\) => \{ /, "").replace(/ \}$/, "");
191
+ const [, colored] = highlightCode(`() => {\n${summary}\n}`, "javascript");
193
192
  return colored && stripAnsi(colored) === summary ? colored : summary;
194
193
  } catch {
195
194
  return summary;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tian.zuo/pi-beautify-style",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Claude Code-style TUI for the pi coding agent: tool cards, rich diffs, compact mode, footer chips, and integrations for this repo's ask-user, background-terminals, and usage extensions.",
5
5
  "type": "module",
6
6
  "keywords": [