@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 +2 -1
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/intercom-message.ts +36 -27
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
|
-
-
|
|
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
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
|
-
|
|
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]!;
|
package/src/intercom-message.ts
CHANGED
|
@@ -94,41 +94,52 @@ class IntercomMessageComponent implements Component {
|
|
|
94
94
|
);
|
|
95
95
|
const topBorder = `${margin}${border("╭")} ${styledTitle} ${border(dashes + "╮")}${margin}`;
|
|
96
96
|
|
|
97
|
-
const
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
130
|
-
|
|
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
|
}
|