@pi-kaush/pi-content-layout 0.1.17 → 0.1.19

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
@@ -7,7 +7,8 @@
7
7
  Pi's leading `Spacer(1)`, so the frame butted against the entry above
8
8
  (most visibly a collapsed tool-call group) whenever `pi-intercom` loads
9
9
  before this package.
10
- - Align native `ThemedText` system notices with the transcript inset. Cache-miss notices gain a `✗` marker and omit `~` before the estimated cost, preserving Pi's cause labels, token counts, warning color, and detection logic.
10
+ - Show Pi's bare `Warning: …` and `Error: …` rows, and native cache-miss notices, as a glyph on the message edge (the tool-rail column) with a hanging indent: `!` for warnings, `✗` for errors. The label is dropped, the estimated cost loses its `~`, and Pi's text and theme color (bronze warnings, red errors) are preserved. Cache-miss notices now use `!` and sit on the edge instead of indented with `✗`.
11
+ - Fix a stacking glyph: Pi's `Text` returns the same cached line array on every render, and the notice rewrite edited that array in place, so each repaint prepended another `!` or `✗` and shoved the row out of its inset. The rewrite now edits a copy, with a regression test that renders repeatedly.
11
12
 
12
13
  - Restyle the `intercom_message` box even when `pi-intercom` wins Pi's first-registration-wins renderer lookup: a chat-container hook replaces the box Pi built with this package's frame, so the surface no longer depends on `packages` order. The renderer registration stays as the cheaper path when this package loads first.
13
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-kaush/pi-content-layout",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "Inset Pi's conversation surface and style active and submitted prompts as matching blocks.",
5
5
  "license": "MIT",
6
6
  "author": "Kaushik Gopal",
package/src/index.ts CHANGED
@@ -293,7 +293,8 @@ function noticePresentation(
293
293
  }
294
294
 
295
295
  function renderNotice(notice: NoticePresentation, width: number): string[] {
296
- const lines = notice.body.render(width);
296
+ // Text caches and returns its own array; copy before editing a line.
297
+ const lines = [...notice.body.render(width)];
297
298
  const first = lines.findIndex((line) => stripTerminalSequences(line).trim());
298
299
  if (first < 0) return lines;
299
300
  const line = lines[first]!;
@@ -94,41 +94,52 @@ class IntercomMessageComponent implements Component {
94
94
  );
95
95
  const topBorder = `${margin}${border("╭")} ${styledTitle} ${border(dashes + "╮")}${margin}`;
96
96
 
97
- const lines: string[] = [topBorder];
97
+ const contentLines = this.expanded
98
+ ? this.renderExpanded(innerWidth, frameLine, bodyColor)
99
+ : this.renderCollapsed(frameLine, bodyColor);
100
+ return [topBorder, ...contentLines, bottomBorder];
101
+ }
98
102
 
99
- if (!this.expanded) {
100
- this.collapsedPreview ??= this.bodyText.replace(/\s+/g, " ").trim();
101
- lines.push(frameLine(bodyColor(this.collapsedPreview)));
103
+ private renderCollapsed(
104
+ frameLine: (content: string) => string,
105
+ bodyColor: (text: string) => string,
106
+ ): string[] {
107
+ this.collapsedPreview ??= this.bodyText.replace(/\s+/g, " ").trim();
108
+ const lines = [frameLine(bodyColor(this.collapsedPreview))];
102
109
 
103
- const meta: string[] = [];
104
- if (this.details.replyCommand) {
105
- meta.push(`To reply: ${this.details.replyCommand}`);
106
- }
107
- const attachments = this.details.message?.content?.attachments;
108
- if (attachments?.length) {
109
- meta.push(
110
- `${attachments.length} attachment${attachments.length === 1 ? "" : "s"}`,
111
- );
112
- }
113
- const replyTo = this.details.message?.replyTo;
114
- if (replyTo && !this.details.message?.expectsReply) {
115
- meta.push(`Reply to ${replyTo.slice(0, 8)}`);
116
- }
117
- meta.push("Ctrl+O to expand");
118
- lines.push(frameLine(bodyColor(meta.join(" · "))));
119
- lines.push(bottomBorder);
120
- return lines;
110
+ const meta: string[] = [];
111
+ if (this.details.replyCommand) {
112
+ meta.push(`To reply: ${this.details.replyCommand}`);
113
+ }
114
+ const attachments = this.details.message?.content?.attachments;
115
+ if (attachments?.length) {
116
+ meta.push(
117
+ `${attachments.length} attachment${attachments.length === 1 ? "" : "s"}`,
118
+ );
121
119
  }
120
+ const replyTo = this.details.message?.replyTo;
121
+ if (replyTo && !this.details.message?.expectsReply) {
122
+ meta.push(`Reply to ${replyTo.slice(0, 8)}`);
123
+ }
124
+ meta.push("Ctrl+O to expand");
125
+ lines.push(frameLine(bodyColor(meta.join(" · "))));
126
+ return lines;
127
+ }
122
128
 
129
+ private renderExpanded(
130
+ innerWidth: number,
131
+ frameLine: (content: string) => string,
132
+ bodyColor: (text: string) => string,
133
+ ): string[] {
123
134
  if (this.wrappedBody?.width !== innerWidth) {
124
135
  this.wrappedBody = {
125
136
  width: innerWidth,
126
137
  lines: wrapTextWithAnsi(this.bodyText, innerWidth),
127
138
  };
128
139
  }
129
- for (const line of this.wrappedBody.lines) {
130
- lines.push(frameLine(bodyColor(line)));
131
- }
140
+ const lines = this.wrappedBody.lines.map((line) =>
141
+ frameLine(bodyColor(line)),
142
+ );
132
143
 
133
144
  if (this.details.replyCommand) {
134
145
  lines.push(frameLine(""));
@@ -154,8 +165,6 @@ class IntercomMessageComponent implements Component {
154
165
  lines.push(frameLine(""));
155
166
  lines.push(frameLine(bodyColor(`Reply to ${replyTo.slice(0, 8)}`)));
156
167
  }
157
-
158
- lines.push(bottomBorder);
159
168
  return lines;
160
169
  }
161
170
  }