From b1072a160995cbd9d70c79e52b6741f0397118cb Mon Sep 17 00:00:00 2001 From: Darknode-Official Date: Wed, 11 Nov 2026 07:35:39 -0800 Subject: [PATCH] Condenser bar: stop its glyphs overlapping The squeeze bar's jaws and core (triangles and a diamond) render wider than one cell in common terminal fonts and spill over the bar. Use box-drawing cells, which terminals draw to fit one cell exactly, for the live bar and the done marker, and test that the bar only uses those. --- darknode.js | 2 +- lib/cli/compact-anim.js | 18 ++++++++++-------- test/run.js | 11 ++++++----- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/darknode.js b/darknode.js index 5c1a37c..7471736 100755 --- a/darknode.js +++ b/darknode.js @@ -3372,7 +3372,7 @@ function nexusTui(engine, cwd, nexusMd, autoResume, launch) { // short one-line notice stays an indented dim line. The rail is the same 2 columns the old // indent used, so wrap/clip widths are unchanged. if (m.role === "compacted") { - L.push(CompactAnim.doneRow({ before: m.before, auto: m.auto, hasSummary: !!m.summary, expanded, colors: { cyan, gray, bold, dim, mag } })); // the condenser's closed frame ▸◆◂ + L.push(CompactAnim.doneRow({ before: m.before, auto: m.auto, hasSummary: !!m.summary, expanded, colors: { cyan, gray, bold, dim, mag } })); // the condenser's closed frame ┣╋┫ if (expanded && m.summary) for (const ln of wrap(m.summary)) L.push(mag("┃ ") + gray(ln)); L.push(""); continue; } diff --git a/lib/cli/compact-anim.js b/lib/cli/compact-anim.js index 4ea89e7..1696c24 100644 --- a/lib/cli/compact-anim.js +++ b/lib/cli/compact-anim.js @@ -6,7 +6,7 @@ // over and over, while a counter shows the context being folded down. // // ⧉ Condensing conversation 12s · ↓ 1.2k tokens · esc to interrupt -// ·······▸━━━━━◆━━━━━◂······· 48.2k tokens → folding +// ·······┣━━━━━╋━━━━━┫······· 48.2k tokens → folding // // Pure + deterministic: the frame is a function of (now - start), colors are // injected, so tests can assert exact frames. @@ -25,8 +25,10 @@ function fmtSec(s) { s = Math.max(0, s | 0); return s < 60 ? s + "s" : Math.floo // The squeeze bar for a given elapsed time: `w` cells (odd widths center // cleanly). The two jaws close from the edges toward the middle over CYCLE_MS; -// cells outside the jaws are dim dots, the jaws are ▸/◂, the squeezed span is a -// heavy rule, and the center is a ◆ core. Returns { plain, colored }. +// Only box-drawing cells and a middle dot: terminals draw those to fit one +// cell exactly, while shapes like a diamond or triangle spill into neighbours. +// cells outside the jaws are dim dots, the jaws are ┣/┫, the squeezed span is a +// heavy rule, and the center is a ╋ core. Returns { plain, colored }. function squeezeBar(elapsedMs, w, t) { t = t || theme(); w = Math.max(7, w | 0); @@ -38,9 +40,9 @@ function squeezeBar(elapsedMs, w, t) { const d = Math.abs(i - mid); const left = i < mid; let ch, paint; - if (d < 0.6) { ch = "◆"; paint = (s) => t.bold(t.mag(s)); } // the core - else if (i === reach && left) { ch = "▸"; paint = t.cyan; } // left jaw - else if (i === w - 1 - reach && !left) { ch = "◂"; paint = t.cyan; } // right jaw + if (d < 0.6) { ch = "╋"; paint = (s) => t.bold(t.mag(s)); } // the core + else if (i === reach && left) { ch = "┣"; paint = t.cyan; } // left jaw + else if (i === w - 1 - reach && !left) { ch = "┫"; paint = t.cyan; } // right jaw else if ((left && i > reach) || (!left && i < w - 1 - reach)) { ch = "━"; paint = (s) => t.cyan(s); } // squeezed span else { ch = "·"; paint = t.dim; } // already folded away plain += ch; colored += paint(ch); @@ -66,13 +68,13 @@ function compactRows(o) { } // doneRow(o) -> string (the marker left in the transcript once compaction is -// done: the squeeze's final, fully-closed frame "▸◆◂" + what was folded). +// done: the squeeze's final, fully-closed frame "┣╋┫" + what was folded). // o: { before, auto, hasSummary, expanded, colors } function doneRow(o) { o = o || {}; const t = theme(o.colors); const what = o.before ? (o.auto ? "auto-condensed " : "condensed ") + fmtK(o.before) + " tokens of conversation" : (o.auto ? "auto-condensed the conversation" : "conversation condensed"); - return t.cyan("▸") + t.bold(t.mag("◆")) + t.cyan("◂") + " " + t.gray(what) + (o.hasSummary ? t.gray(" · ctrl+o " + (o.expanded ? "hides" : "shows") + " the summary") : ""); + return t.cyan("┣") + t.bold(t.mag("╋")) + t.cyan("┫") + " " + t.gray(what) + (o.hasSummary ? t.gray(" · ctrl+o " + (o.expanded ? "hides" : "shows") + " the summary") : ""); } module.exports = { compactRows, squeezeBar, doneRow, CYCLE_MS }; diff --git a/test/run.js b/test/run.js index 8cfa21d..8efef6e 100644 --- a/test/run.js +++ b/test/run.js @@ -3463,18 +3463,19 @@ ok("shouldCheck: first launch runs; throttled within 4h; runs after", shouldChec { const CA = require("../lib/cli/compact-anim"); const f0 = CA.squeezeBar(0, 21).plain, fEnd = CA.squeezeBar(CA.CYCLE_MS - 10, 21).plain; - ok("the core ◆ sits dead center", f0[10] === "◆" && fEnd[10] === "◆"); - ok("jaws start at the edges", f0[0] === "▸" && f0[20] === "◂"); - ok("jaws close in on the core over the cycle", fEnd.indexOf("▸") > f0.indexOf("▸") && fEnd.indexOf("◂") < f0.indexOf("◂")); - ok("folded-away cells become dots", /^·+▸/.test(fEnd)); + ok("the core ╋ sits dead center", f0[10] === "╋" && fEnd[10] === "╋"); + ok("jaws start at the edges", f0[0] === "┣" && f0[20] === "┫"); + ok("jaws close in on the core over the cycle", fEnd.indexOf("┣") > f0.indexOf("┣") && fEnd.indexOf("┫") < f0.indexOf("┫")); + ok("folded-away cells become dots", /^·+┣/.test(fEnd)); ok("the bar loops (frame at one full cycle == frame 0)", CA.squeezeBar(CA.CYCLE_MS, 21).plain === f0); ok("bar width is honored", CA.squeezeBar(700, 15).plain.length === 15); + ok("every bar cell is a box-drawing char or a dot, so nothing spills over its neighbours", [0, 300, 700, 1200, 1590].every((ms) => /^[\u2500-\u257F\u00B7]+$/.test(CA.squeezeBar(ms, 21).plain)) && /^[\u2500-\u257F]{3} /.test(CA.doneRow({ before: 1 }))); const rows = CA.compactRows({ now: 13000, start: 1000, tok: 1234, before: 48200, width: 80 }); ok("title says Condensing conversation with elapsed + tokens + esc", /Condensing conversation/.test(rows[0]) && /12s/.test(rows[0]) && /1\.2k tokens/.test(rows[0]) && /esc to interrupt/.test(rows[0])); ok("bar row shows the context being folded", /48\.2k tokens → folding/.test(rows[1])); ok("rows stay within the width", rows.every((r) => r.length <= 80)); ok("a narrow terminal still renders", CA.compactRows({ now: 5, start: 0, width: 24 }).every((r) => typeof r === "string")); - ok("done marker is the closed frame + folded size", /^▸◆◂ condensed 48\.2k tokens/.test(CA.doneRow({ before: 48200 }))); + ok("done marker is the closed frame + folded size", /^┣╋┫ condensed 48\.2k tokens/.test(CA.doneRow({ before: 48200 }))); ok("done marker notes auto + the summary toggle", /auto-condensed/.test(CA.doneRow({ before: 1, auto: true })) && /ctrl\+o shows the summary/.test(CA.doneRow({ hasSummary: true })) && /hides/.test(CA.doneRow({ hasSummary: true, expanded: true }))); }