@pi-kaush/pi-content-layout 0.1.6 → 0.1.8
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 +15 -0
- package/README.md +8 -5
- package/package.json +1 -1
- package/src/intercom-message.ts +28 -14
- package/src/render.ts +25 -12
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- Give the submitted-prompt box an explicit right padding column inside the
|
|
6
|
+
surface, matching the one already on the left of the text, so wrapped
|
|
7
|
+
content no longer sits flush against the box's right edge.
|
|
8
|
+
|
|
9
|
+
- Reference semantic tokens for the remaining extension-colored elements:
|
|
10
|
+
the intercom sender name rides `customMessageLabel`, the submitted-prompt
|
|
11
|
+
rail rides `borderAccent`, and prompt surfaces paint with `userMessageBg`.
|
|
12
|
+
- Paint the prompt surfaces (active editor, submitted prompt) with the
|
|
13
|
+
theme's `customMessageBg` token instead of a hardcoded hex, retiring the
|
|
14
|
+
last fixed color in this package. Falls back to the legacy #071312 only
|
|
15
|
+
for theme lookalikes that cannot resolve the token.
|
|
16
|
+
- Paint the `intercom_message` frame in the bash-mode green used for `!`
|
|
17
|
+
shell-block rules, keep all text inside it muted, and render the sender
|
|
18
|
+
name in the `mdHeading` orange. All colors come from theme tokens.
|
|
19
|
+
|
|
5
20
|
- Restyle pi-intercom's inbound `intercom_message` box onto the shared
|
|
6
21
|
transcript columns (frame border on the marker column, title and body text
|
|
7
22
|
on the text column) and drop the redundant `Ctrl+O expands` title hint.
|
package/README.md
CHANGED
|
@@ -38,11 +38,14 @@ indentation in both packages together.
|
|
|
38
38
|
When [`pi-intercom`](https://www.npmjs.com/package/pi-intercom) is installed,
|
|
39
39
|
this package restyles its inbound `intercom_message` box onto the shared
|
|
40
40
|
transcript columns: the frame's left border sits on the tool-marker column
|
|
41
|
-
(the outer inset), the `From:` title and body text share the text column
|
|
42
|
-
by tool rows and Thought labels
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
(the outer inset), and the `From:` title and body text share the text column
|
|
42
|
+
used by tool rows and Thought labels. The frame borrows the bash-mode green
|
|
43
|
+
of `!` shell-block rules, all text inside stays muted, and the sender name
|
|
44
|
+
uses the `mdHeading` orange (the Thought-label hue in cobalt2 and Pi's stock
|
|
45
|
+
themes). The redundant
|
|
46
|
+
`Ctrl+O expands` title hint is dropped (the meta line inside the box keeps
|
|
47
|
+
`Ctrl+O to expand`). Content is unchanged, and expanded view keeps
|
|
48
|
+
pi-intercom's full body, attachment, and reply sections.
|
|
46
49
|
|
|
47
50
|
Pi resolves custom message renderers in extension load order (first
|
|
48
51
|
registration wins), so list this package before `pi-intercom` in `packages`
|
package/package.json
CHANGED
package/src/intercom-message.ts
CHANGED
|
@@ -55,10 +55,14 @@ class IntercomMessageComponent implements Component {
|
|
|
55
55
|
|
|
56
56
|
if (boxWidth < MIN_BOX_WIDTH) {
|
|
57
57
|
const text = truncateToWidth(`From: ${senderName}`, boxWidth, "");
|
|
58
|
-
return [margin + text + margin];
|
|
58
|
+
return [margin + this.theme.fg("muted", text) + margin];
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
// The frame borrows customMessageLabel — Pi's token for extension-message
|
|
62
|
+
// labels (orange in cobalt2) — so the border matches the sender name.
|
|
63
|
+
// Everything textual inside the frame is muted, matching tool-row summaries.
|
|
64
|
+
const border = (text: string) => this.theme.fg("customMessageLabel", text);
|
|
65
|
+
const bodyColor = (text: string) => this.theme.fg("muted", text);
|
|
62
66
|
// Columns inside the frame: │ + space + content(innerWidth) + space + │.
|
|
63
67
|
const innerWidth = boxWidth - 4;
|
|
64
68
|
|
|
@@ -69,18 +73,32 @@ class IntercomMessageComponent implements Component {
|
|
|
69
73
|
};
|
|
70
74
|
const bottomBorder = `${margin}${border(`╰${"─".repeat(boxWidth - 2)}╯`)}${margin}`;
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
// The sender name alone rides customMessageLabel — Pi's token for the
|
|
77
|
+
// label of an extension message (orange in cobalt2).
|
|
78
|
+
const titlePrefix = "From: ";
|
|
79
|
+
const title = `${titlePrefix}${senderName}${from.cwd ? ` (${from.cwd})` : ""}`;
|
|
73
80
|
const titleText = truncateToWidth(title, Math.max(1, innerWidth - 1), "");
|
|
81
|
+
const nameEnd = Math.min(
|
|
82
|
+
titleText.length,
|
|
83
|
+
titlePrefix.length + senderName.length,
|
|
84
|
+
);
|
|
85
|
+
const styledTitle =
|
|
86
|
+
bodyColor(titleText.slice(0, titlePrefix.length)) +
|
|
87
|
+
this.theme.fg(
|
|
88
|
+
"customMessageLabel",
|
|
89
|
+
titleText.slice(titlePrefix.length, nameEnd),
|
|
90
|
+
) +
|
|
91
|
+
bodyColor(titleText.slice(nameEnd));
|
|
74
92
|
const dashes = "─".repeat(
|
|
75
93
|
Math.max(1, innerWidth - visibleWidth(titleText)),
|
|
76
94
|
);
|
|
77
|
-
const topBorder = `${margin}${border("╭")} ${
|
|
95
|
+
const topBorder = `${margin}${border("╭")} ${styledTitle} ${border(dashes + "╮")}${margin}`;
|
|
78
96
|
|
|
79
97
|
const lines: string[] = [topBorder];
|
|
80
98
|
|
|
81
99
|
if (!this.expanded) {
|
|
82
100
|
this.collapsedPreview ??= this.bodyText.replace(/\s+/g, " ").trim();
|
|
83
|
-
lines.push(frameLine(
|
|
101
|
+
lines.push(frameLine(bodyColor(this.collapsedPreview)));
|
|
84
102
|
|
|
85
103
|
const meta: string[] = [];
|
|
86
104
|
if (this.details.replyCommand) {
|
|
@@ -97,7 +115,7 @@ class IntercomMessageComponent implements Component {
|
|
|
97
115
|
meta.push(`Reply to ${replyTo.slice(0, 8)}`);
|
|
98
116
|
}
|
|
99
117
|
meta.push("Ctrl+O to expand");
|
|
100
|
-
lines.push(frameLine(
|
|
118
|
+
lines.push(frameLine(bodyColor(meta.join(" · "))));
|
|
101
119
|
lines.push(bottomBorder);
|
|
102
120
|
return lines;
|
|
103
121
|
}
|
|
@@ -109,13 +127,13 @@ class IntercomMessageComponent implements Component {
|
|
|
109
127
|
};
|
|
110
128
|
}
|
|
111
129
|
for (const line of this.wrappedBody.lines) {
|
|
112
|
-
lines.push(frameLine(
|
|
130
|
+
lines.push(frameLine(bodyColor(line)));
|
|
113
131
|
}
|
|
114
132
|
|
|
115
133
|
if (this.details.replyCommand) {
|
|
116
134
|
lines.push(frameLine(""));
|
|
117
135
|
const replyLines = wrapTextWithAnsi(
|
|
118
|
-
|
|
136
|
+
bodyColor(`To reply: ${this.details.replyCommand}`),
|
|
119
137
|
innerWidth,
|
|
120
138
|
);
|
|
121
139
|
for (const line of replyLines) {
|
|
@@ -127,18 +145,14 @@ class IntercomMessageComponent implements Component {
|
|
|
127
145
|
if (attachments?.length) {
|
|
128
146
|
lines.push(frameLine(""));
|
|
129
147
|
for (const attachment of attachments) {
|
|
130
|
-
lines.push(
|
|
131
|
-
frameLine(this.theme.fg("dim", `Attachment: ${attachment.name}`)),
|
|
132
|
-
);
|
|
148
|
+
lines.push(frameLine(bodyColor(`Attachment: ${attachment.name}`)));
|
|
133
149
|
}
|
|
134
150
|
}
|
|
135
151
|
|
|
136
152
|
const replyTo = this.details.message?.replyTo;
|
|
137
153
|
if (replyTo && !this.details.message?.expectsReply) {
|
|
138
154
|
lines.push(frameLine(""));
|
|
139
|
-
lines.push(
|
|
140
|
-
frameLine(this.theme.fg("dim", `Reply to ${replyTo.slice(0, 8)}`)),
|
|
141
|
-
);
|
|
155
|
+
lines.push(frameLine(bodyColor(`Reply to ${replyTo.slice(0, 8)}`)));
|
|
142
156
|
}
|
|
143
157
|
|
|
144
158
|
lines.push(bottomBorder);
|
package/src/render.ts
CHANGED
|
@@ -6,11 +6,20 @@ export const OUTER_INSET = 2;
|
|
|
6
6
|
export const PROMPT_RAIL = "▎";
|
|
7
7
|
export const ACTIVE_SIDE_PADDING = 1;
|
|
8
8
|
|
|
9
|
-
// The prompt surface (active editor block and submitted message body)
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
|
|
9
|
+
// The prompt surface (active editor block and submitted message body) paints
|
|
10
|
+
// with the theme's userMessageBg token, so both user-input surfaces stay
|
|
11
|
+
// identical while following the active theme. userMessageBg is a required pi
|
|
12
|
+
// theme token; the legacy hex remains only as a fallback for theme lookalikes
|
|
13
|
+
// that cannot resolve it (test fakes, older hosts).
|
|
14
|
+
const PROMPT_SURFACE_BG_FALLBACK = "\x1b[48;2;7;19;18m"; // #071312
|
|
15
|
+
|
|
16
|
+
export function promptSurfaceBg(theme: Theme): string {
|
|
17
|
+
try {
|
|
18
|
+
return theme.getBgAnsi("userMessageBg");
|
|
19
|
+
} catch {
|
|
20
|
+
return PROMPT_SURFACE_BG_FALLBACK;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
14
23
|
|
|
15
24
|
const BORDER_SENTINEL = "\x1b]133;P;pi-content-layout\x07";
|
|
16
25
|
const SGR_PATTERN = /\x1b\[([0-9;]*)m/g;
|
|
@@ -158,7 +167,7 @@ function activeBlockLine(
|
|
|
158
167
|
return paintBackground(
|
|
159
168
|
`${padding}${fitLine(body, innerWidth)}${padding}`,
|
|
160
169
|
width,
|
|
161
|
-
|
|
170
|
+
promptSurfaceBg(theme),
|
|
162
171
|
);
|
|
163
172
|
}
|
|
164
173
|
|
|
@@ -235,7 +244,7 @@ export function renderSubmittedUserLines(
|
|
|
235
244
|
width: number,
|
|
236
245
|
theme: Theme,
|
|
237
246
|
inset = contentInset(width),
|
|
238
|
-
railColor: ThemeColor = "
|
|
247
|
+
railColor: ThemeColor = "borderAccent",
|
|
239
248
|
): string[] {
|
|
240
249
|
const blockWidth = width - inset * 2;
|
|
241
250
|
if (inset === 0 || blockWidth <= visibleWidth(PROMPT_RAIL)) {
|
|
@@ -244,16 +253,20 @@ export function renderSubmittedUserLines(
|
|
|
244
253
|
|
|
245
254
|
const bodyWidth = blockWidth - visibleWidth(PROMPT_RAIL);
|
|
246
255
|
const margin = " ".repeat(inset);
|
|
256
|
+
const surfaceBg = promptSurfaceBg(theme);
|
|
247
257
|
return lines.map((line) => {
|
|
248
258
|
const { controls, content } = splitLeadingSemanticControls(line);
|
|
249
|
-
const recolored = replaceBackground(content,
|
|
259
|
+
const recolored = replaceBackground(content, surfaceBg);
|
|
250
260
|
const rail = theme.fg(railColor, PROMPT_RAIL);
|
|
251
|
-
// One
|
|
252
|
-
// columns right of the rail
|
|
261
|
+
// One column of side padding inside the box on both edges, so submitted
|
|
262
|
+
// text sits two columns right of the rail and one column off the right
|
|
263
|
+
// edge — matching the active editor's side padding.
|
|
264
|
+
const padding = " ".repeat(ACTIVE_SIDE_PADDING);
|
|
265
|
+
const innerWidth = Math.max(1, bodyWidth - ACTIVE_SIDE_PADDING * 2);
|
|
253
266
|
const body = paintBackground(
|
|
254
|
-
|
|
267
|
+
`${padding}${fitLine(recolored, innerWidth)}${padding}`,
|
|
255
268
|
bodyWidth,
|
|
256
|
-
|
|
269
|
+
surfaceBg,
|
|
257
270
|
);
|
|
258
271
|
return `${controls}${margin}${rail}${body}${margin}`;
|
|
259
272
|
});
|