Skip to content

Commit 777b19c

Browse files
committed
fix(admin): thread the ASCII glyph opt-in into the overlay styler (issue #54)
PI_DISPATCH_ASCII=1 flipped panel.mjs' glyph table but not the overlay's own frame glyphs, the half-ASCII gap the dashboard comment deferred with 'lands when the view PR settles'. This is that PR settling: makeStyler now receives { ascii } from the same resolved paths the setGlyphs funnel reads, so the frame and the panel primitives degrade together. The opt-in stays per styler instance on purpose, because setGlyphs must not restyle overlays behind a styler's back (the recorded style.mjs rationale is unchanged). Byte-identical without the opt-in, pinned by test. Signed-off-by: Rob Boerman <robboerman@live.nl>
1 parent f47b535 commit 777b19c

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

admin/src/dashboard.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ export function makeDashboard({
175175
deps = createDashboardDeps(paths),
176176
}: any = {}) {
177177
// The overlay-only color styler, bound to pi's injected theme (null in tests -> plain, same geometry).
178-
const styler = makeStyler(theme);
178+
// The ascii opt-in rides the same resolved paths as panel.mjs' setGlyphs funnel, so PI_DISPATCH_ASCII=1
179+
// degrades the overlay frame and the panel primitives TOGETHER -- half-ASCII output was the pending gap
180+
// the old comment here deferred (issue #54's works-in-ASCII acceptance is what landed it).
181+
const styler = makeStyler(theme, { ascii: paths?.asciiGlyphs === true });
179182
let snapshot: any = null;
180183
let fetching = false;
181184
let disposed = false;

admin/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,8 @@ async function dispatch(pi: ExtensionAPI, args: string, ctx: any): Promise<void>
816816
const paths = resolvePaths(process.env);
817817
// Glyph posture BEFORE any rendering: every /dispatch surface (the overlay, the costs view's sparkline)
818818
// draws through panel.mjs' active table, and this is the one funnel all subcommands pass through. The
819-
// dashboard's own styler keeps its default for now -- its `ascii` opt-in lands when the view PR settles.
819+
// dashboard's own styler opts in per instance (makeStyler's `ascii`, threaded from these same paths in
820+
// makeDashboard), so PI_DISPATCH_ASCII now flips the overlay frame too, not only panel.mjs (issue #54).
820821
setGlyphs(paths.asciiGlyphs);
821822

822823
// Drain the deployment pointer's retained one-line notice (a broken or newer pointer file) into the

admin/test/dashboard.test.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@ test("with a theme, the framed LIST is colored (ANSI present) but every line sti
9393
assert.match(stripAnsi(lines.join("\n")), /PAUSED/, "plain content survives under the color");
9494
});
9595

96+
test("paths.asciiGlyphs threads into the overlay styler: the frame degrades with the panel, together", async () => {
97+
// PI_DISPATCH_ASCII used to flip panel.mjs' table but not the overlay's own frame glyphs -- the
98+
// half-ASCII gap the old dashboard comment deferred. The opt-in is per styler instance on purpose
99+
// (setGlyphs must not restyle overlays behind a styler's back), so the thread is paths -> makeStyler.
100+
const comp = makeDashboard({ paths: { asciiGlyphs: true }, done() {}, tui: fakeTui(), intervalMs: 100000, deps: cannedDeps() });
101+
await flush();
102+
const ascii = comp.render(80);
103+
await comp.dispose();
104+
assert.ok(ascii[0].startsWith("+"), "ascii corners frame the overlay");
105+
const joined = ascii.join("\n");
106+
assert.ok(!joined.includes("┌") && !joined.includes("│") && !joined.includes("├"), "no frame box-drawing glyph leaks through the ascii overlay");
107+
108+
const comp2 = makeDashboard({ paths: {}, done() {}, tui: fakeTui(), intervalMs: 100000, deps: cannedDeps() });
109+
await flush();
110+
const box = comp2.render(80);
111+
await comp2.dispose();
112+
assert.ok(box[0].startsWith("┌"), "no opt-in keeps the box-drawing default, byte-identically");
113+
});
114+
96115
test("before the first fetch resolves it renders a loading panel, not a crash", () => {
97116
// A fetch that never resolves: the panel must still render (from the null snapshot) synchronously.
98117
const comp = makeDashboard({

0 commit comments

Comments
 (0)