@xynogen/pix-pretty 1.18.3 → 1.18.4
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/package.json +1 -1
- package/src/gate-overlay.test.ts +41 -0
- package/src/gate-overlay.ts +2 -2
package/package.json
CHANGED
package/src/gate-overlay.test.ts
CHANGED
|
@@ -158,6 +158,7 @@ describe("showOverlay — confirm mode", () => {
|
|
|
158
158
|
title: "SSH FILE TRANSFER",
|
|
159
159
|
body: [
|
|
160
160
|
"Intent: Copy a release artifact",
|
|
161
|
+
"Command: scp app.tar.gz host:/tmp",
|
|
161
162
|
"Host: deploy@example.com",
|
|
162
163
|
"Direction: Download",
|
|
163
164
|
"From: /srv/releases/app.tar.gz",
|
|
@@ -170,6 +171,8 @@ describe("showOverlay — confirm mode", () => {
|
|
|
170
171
|
},
|
|
171
172
|
);
|
|
172
173
|
const joined = captured.join("\n");
|
|
174
|
+
expect(joined).toContain("<dim>Intent:</dim> <text>Copy a release artifact</text>");
|
|
175
|
+
expect(joined).toContain("<dim>Command:</dim> <dim>scp app.tar.gz host:/tmp</dim>");
|
|
173
176
|
expect(joined).toContain("<dim>Host:</dim> <accent>deploy@example.com</accent>");
|
|
174
177
|
expect(joined).toContain("<dim>Direction:</dim> <warning>Download</warning>");
|
|
175
178
|
expect(joined).toContain("<dim>From:</dim> <text>/srv/releases/app.tar.gz</text>");
|
|
@@ -178,6 +181,44 @@ describe("showOverlay — confirm mode", () => {
|
|
|
178
181
|
expect(joined).toContain("<dim>Auth:</dim> <success>SSH key (no password)</success>");
|
|
179
182
|
});
|
|
180
183
|
|
|
184
|
+
// Regression guard (readability fix, pix-pretty 1.18.4): Intent:/Command:
|
|
185
|
+
// lines must go through the label/value colour map — a <dim> label plus a
|
|
186
|
+
// semantic value — never a bare bright value with the label stripped off.
|
|
187
|
+
// Pre-1.18.4 they were sliced and dumped as bright <text> with no label,
|
|
188
|
+
// which was hard to read on the modal background. Command value must be <dim>.
|
|
189
|
+
test("Intent/Command body lines keep a dim label and never drop it", async () => {
|
|
190
|
+
const coloredTheme = {
|
|
191
|
+
fg: (color: string, text: string) => `<${color}>${text}</${color}>`,
|
|
192
|
+
bg: (_color: string, text: string) => text,
|
|
193
|
+
bold: (text: string) => text,
|
|
194
|
+
};
|
|
195
|
+
let captured: string[] = [];
|
|
196
|
+
await showOverlay(
|
|
197
|
+
makeUI(
|
|
198
|
+
(comp) => {
|
|
199
|
+
captured = comp.render(100);
|
|
200
|
+
comp.handleInput(ENTER);
|
|
201
|
+
},
|
|
202
|
+
undefined,
|
|
203
|
+
coloredTheme,
|
|
204
|
+
),
|
|
205
|
+
{
|
|
206
|
+
mode: "sudo",
|
|
207
|
+
title: "ROOT COMMAND REQUEST",
|
|
208
|
+
accent: "error",
|
|
209
|
+
body: ["Intent: install a package", "Command: apt install foo"],
|
|
210
|
+
timeoutMs: 0,
|
|
211
|
+
},
|
|
212
|
+
);
|
|
213
|
+
const joined = captured.join("\n");
|
|
214
|
+
// Command label + value both dim; intent value stays readable text but is
|
|
215
|
+
// always prefixed by a dim label (never a bare label-less value).
|
|
216
|
+
expect(joined).toContain("<dim>Command:</dim> <dim>apt install foo</dim>");
|
|
217
|
+
expect(joined).toContain("<dim>Intent:</dim> <text>install a package</text>");
|
|
218
|
+
// The pre-1.18.4 bug: label stripped, value dumped bright with no dim label.
|
|
219
|
+
expect(joined).not.toContain("<text>apt install foo</text>"); // command value is dim, not text
|
|
220
|
+
});
|
|
221
|
+
|
|
181
222
|
test("wraps a long body command instead of truncating it", async () => {
|
|
182
223
|
// A command far wider than any modal width — must survive in full, wrapped.
|
|
183
224
|
const longCmd = `echo ${"pix-gate-installed-or-linked ".repeat(8)}done`;
|
package/src/gate-overlay.ts
CHANGED
|
@@ -176,8 +176,6 @@ function buildSections(opts: {
|
|
|
176
176
|
const inner = width - 4; // CHROME = 2 border + 2 padding
|
|
177
177
|
const header = [theme.fg(accent, theme.bold(config.title))];
|
|
178
178
|
const body = (config.body ?? []).map((line) => {
|
|
179
|
-
if (line.startsWith("Intent:")) return theme.fg("text", line.slice(7).trimStart());
|
|
180
|
-
if (line.startsWith("Command:")) return theme.fg("text", line.slice(8).trimStart());
|
|
181
179
|
if (line.startsWith("Warning:")) return theme.fg("warning", line);
|
|
182
180
|
if (line.startsWith("(") && line.endsWith(")")) return theme.fg("muted", line);
|
|
183
181
|
|
|
@@ -186,6 +184,8 @@ function buildSections(opts: {
|
|
|
186
184
|
const label = line.slice(0, separator + 1);
|
|
187
185
|
const value = line.slice(separator + 1).trimStart();
|
|
188
186
|
const valueColors: Record<string, string> = {
|
|
187
|
+
"Intent:": "text",
|
|
188
|
+
"Command:": "dim",
|
|
189
189
|
"Host:": "accent",
|
|
190
190
|
"Direction:": "warning",
|
|
191
191
|
"From:": "text",
|