Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion darknode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
18 changes: 10 additions & 8 deletions lib/cli/compact-anim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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 };
11 changes: 6 additions & 5 deletions test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })));
}

Expand Down
Loading