pi-odd-worktree 3.7.0 → 3.7.2

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.
@@ -434,6 +434,10 @@ const LEADING_CHROME = new Set([' ', '│', '▎', '|', '┃', '║']);
434
434
  // The closing run is dropped only while it CLEARS a state, because a frame cell's own paint starts
435
435
  // there too (`\u001b[32m│`) and is the host's to keep.
436
436
  const TRAILING_SGR = /(?:\u001b\[[0-9;]*m)+$/u;
437
+ // A row whose first cell is the host's frame rule, and the skip marker the host draws between hunks:
438
+ // neither is the rest of a wrapped diff line.
439
+ const WRAP_BREAK_CELLS = new Set(['╭', '╰', '╮', '╯', '─']);
440
+ const SKIP_MARKER = /^\.\.\./u;
437
441
  const SGR_CLEARS = new Set(['0', '22', '23', '24', '25', '27', '28', '29', '39', '49', '55', '59']);
438
442
 
439
443
  /** Whether one SGR escape CLEARS a state rather than opening one. */
@@ -547,11 +551,14 @@ function recolourDiffRow(row, spec) {
547
551
  const paintedCode = code === '' ? '' : highlightRow(code, 'muted', spec.language, spec.seam, spec.theme);
548
552
  return `${before}${paint(spec.theme, 'muted', token)}${paintedCode}${after}`;
549
553
  }
550
- const match = ADDED.exec(rest) ?? REMOVED.exec(rest) ?? CONTEXT.exec(rest);
554
+ // The number's trailing space is the row's padding when the row states no code of its own (the host
555
+ // flushed it before a word wider than the row), so the row is read with that space restored.
556
+ const probe = `${rest} `;
557
+ const match = ADDED.exec(probe) ?? REMOVED.exec(probe) ?? CONTEXT.exec(probe);
551
558
  if (match === null) return row;
552
559
  // `undefined` marks a context row, whose marker is a space and already part of the row's chrome.
553
- const added = ADDED.test(rest);
554
- const role = added ? 'toolDiffAdded' : REMOVED.test(rest) ? 'toolDiffRemoved' : undefined;
560
+ const added = ADDED.test(probe);
561
+ const role = added ? 'toolDiffAdded' : REMOVED.test(probe) ? 'toolDiffRemoved' : undefined;
555
562
  const gutter = role === undefined ? match[1] : `${rest[0]}${match[1]}`;
556
563
  const head = `${gutter}${DIVIDER_RUN}`;
557
564
  const headColumns = textColumns(head);
@@ -564,8 +571,14 @@ function recolourDiffRow(row, spec) {
564
571
  // A row this design already divided wears the rule right after its number: read it back, so the
565
572
  // second pass rebuilds the same row instead of adding a second divider (S14).
566
573
  const code = tailText.startsWith(DIVIDER_TAIL) ? tailText.slice(DIVIDER_TAIL.length) : tailText;
567
- const clipped = headColumns + textColumns(code) > room;
568
- const shown = clipped ? clipPlain(code, room - headColumns) : code;
574
+ // S15: a line the host wrapped states the rest of it on rows this design drops. The row is drawn
575
+ // from the WHOLE line, so it fills its width like the write pane's and ends in the ellipsis that
576
+ // pane writes for a line that did not fit.
577
+ const whole = joinWrapped(code, rest, spec.rest ?? [], room);
578
+ const base = whole;
579
+ const overflow = headColumns + textColumns(base) > room;
580
+ const clipped = overflow;
581
+ const shown = overflow ? clipPlain(base, room - headColumns) : base;
569
582
  let body;
570
583
  if (role !== undefined) {
571
584
  body = paint(spec.theme, role, `${head}${shown}`);
@@ -593,17 +606,179 @@ function highlightRow(code, fallback, language, seam, theme) {
593
606
  return paint(theme, fallback === 'muted' ? 'text' : fallback, code);
594
607
  }
595
608
 
609
+ /** Whether a row states a numbered diff line (a hunk header and a skip marker state none). */
610
+ function statesLine(row) {
611
+ const chars = visibleChars(row);
612
+ const start = diffStart(chars);
613
+ if (start < 0) return false;
614
+ const rest = chars.slice(start).map((entry) => entry.char).join('');
615
+ return !HUNK.test(rest) && (ADDED.test(rest) || REMOVED.test(rest) || CONTEXT.test(rest));
616
+ }
617
+
618
+ /**
619
+ * Whether a row is the REST of a diff line the host wrapped: text with no number, at the row's own
620
+ * left column. A blank band row, a frame rule, a skip marker and the host's expand hint are the
621
+ * host's own rows and never the rest of a line.
622
+ */
623
+ function wrappedRest(row) {
624
+ if (typeof row !== 'string' || statesLine(row)) return undefined;
625
+ const chars = visibleChars(row);
626
+ const first = chars.findIndex((entry) => !LEADING_CHROME.has(entry.char));
627
+ const last = contentLast(chars);
628
+ if (first < 0 || last < first) return undefined;
629
+ if (WRAP_BREAK_CELLS.has(chars[first].char)) return undefined;
630
+ const text = chars.slice(first, last + 1).map((entry) => entry.char).join('');
631
+ return HUNK.test(text) || SKIP_MARKER.test(text) || EXPAND_HINT.test(plainOf(row)) ? undefined : text;
632
+ }
633
+
634
+ /**
635
+ * The code of a wrapped diff line put back together: the numbered row's code and the rows the host
636
+ * wrapped it onto. The host broke each row at a space it then ate, or — for a word longer than the
637
+ * width — through the word, which leaves the row FULL and with no space to break at. `room` is the
638
+ * width the host wrapped at.
639
+ */
640
+ function joinWrapped(code, rowText, rest, room) {
641
+ let whole = code;
642
+ let previous = rowText;
643
+ let previousCode = code;
644
+ for (const piece of rest) {
645
+ const hardBreak = textColumns(previous) >= room && !previousCode.trim().includes(' ');
646
+ // A numbered row with no code of its own (the host flushed it before a word wider than the row)
647
+ // has nothing to separate the rest from.
648
+ whole += `${hardBreak || whole === '' ? '' : ' '}${piece}`;
649
+ previous = piece;
650
+ previousCode = piece;
651
+ }
652
+ return whole;
653
+ }
654
+
655
+ // ---- the edit heading: what the call changed ----
656
+
657
+ // The heading the host draws for an `edit`: its frame cells, an optional icon, the tool and the path.
658
+ const EDIT_HEADING = /^[╭─\s▎│]*(?:✎\s*)?edit\s+\S+/u;
659
+ // The most cells the line comparison may fill; a bigger block is counted without one.
660
+ const MAX_DIFF_CELLS = 4_000_000;
661
+
662
+ function textLines(text) {
663
+ return text === '' ? [] : text.split('\n');
664
+ }
665
+
666
+ /** How many lines of `before` a change to `after` deletes and adds, by the longest common subsequence. */
667
+ function lineDelta(before, after) {
668
+ const a = textLines(before);
669
+ const b = textLines(after);
670
+ let head = 0;
671
+ while (head < a.length && head < b.length && a[head] === b[head]) head += 1;
672
+ let tail = 0;
673
+ while (tail < a.length - head && tail < b.length - head && a[a.length - 1 - tail] === b[b.length - 1 - tail]) tail += 1;
674
+ const left = a.slice(head, a.length - tail);
675
+ const right = b.slice(head, b.length - tail);
676
+ if (left.length === 0 || right.length === 0 || left.length * right.length > MAX_DIFF_CELLS) {
677
+ return { added: right.length, removed: left.length };
678
+ }
679
+ let previous = new Array(right.length + 1).fill(0);
680
+ for (let i = 1; i <= left.length; i += 1) {
681
+ const current = new Array(right.length + 1).fill(0);
682
+ for (let j = 1; j <= right.length; j += 1) {
683
+ current[j] = left[i - 1] === right[j - 1] ? previous[j - 1] + 1 : Math.max(previous[j], current[j - 1]);
684
+ }
685
+ previous = current;
686
+ }
687
+ const common = previous[right.length];
688
+ return { added: right.length - common, removed: left.length - common };
689
+ }
690
+
691
+ /** The `(+added · -removed)` an edit call states, or `undefined` when it changes no line. A zero is not written. */
692
+ function changeCount(args) {
693
+ if (args === null || typeof args !== 'object') return undefined;
694
+ const edits = Array.isArray(args.edits) ? [...args.edits] : [];
695
+ if (typeof args.oldText === 'string' && typeof args.newText === 'string') edits.push(args);
696
+ let added = 0;
697
+ let removed = 0;
698
+ for (const entry of edits) {
699
+ if (entry === null || typeof entry !== 'object') continue;
700
+ if (typeof entry.oldText !== 'string' || typeof entry.newText !== 'string') continue;
701
+ const delta = lineDelta(entry.oldText, entry.newText);
702
+ added += delta.added;
703
+ removed += delta.removed;
704
+ }
705
+ const parts = [added > 0 ? `+${added}` : '', removed > 0 ? `-${removed}` : ''].filter((part) => part !== '');
706
+ return parts.length === 0 ? undefined : `(${parts.join(' · ')})`;
707
+ }
708
+
709
+ /** The SGR escapes in force at the end of `text`: every one since the last full reset. */
710
+ function sgrInForce(text) {
711
+ let state = [];
712
+ for (const escape of text.matchAll(/\u001b\[([0-9;]*)m/gu)) {
713
+ if (escape[1] === '' || escape[1] === '0') state = [];
714
+ else state.push(escape[0]);
715
+ }
716
+ return state.join('');
717
+ }
718
+
719
+ /**
720
+ * The host's heading row with `count` written after the path, in the `muted` role. The columns come
721
+ * out of the rule (or the padding) that follows the path, so the row keeps its width and the frame
722
+ * does not move; a heading with no room for it, or whose filler carries a paint of its own, is the
723
+ * host's. A heading that already wears a count has no filler right after its path, so it is a no-op.
724
+ */
725
+ function headingWithCount(row, count, theme) {
726
+ const chars = visibleChars(row);
727
+ const matched = EDIT_HEADING.exec(chars.map((entry) => entry.char).join(''));
728
+ if (matched === null) return row;
729
+ const end = Array.from(matched[0]).length;
730
+ let filler = 0;
731
+ while (end + filler < chars.length && (chars[end + filler].char === ' ' || chars[end + filler].char === '─')) filler += 1;
732
+ const need = textColumns(count) + 1;
733
+ if (chars[end]?.char !== ' ' || filler < need + 3) return row;
734
+ const from = chars[end + 1].raw;
735
+ const to = chars[end + 1 + need].raw;
736
+ if (row.slice(from, to).includes('\u001b')) return row;
737
+ const at = chars[end].raw;
738
+ const before = row.slice(0, at);
739
+ return `${before} ${paint(theme, 'muted', count)}${sgrInForce(before)}${row.slice(at, from)}${row.slice(to)}`;
740
+ }
741
+
596
742
  /**
597
743
  * Every row of an `edit` card, recoloured and divided. Idempotent (S8b/S14): each row is read as its
598
744
  * PLAIN text and rebuilt from it, divider included, so a row already wearing this drawing states the
599
745
  * same visible characters and comes back byte for byte — never with a second copy of an escape, a
600
746
  * reset or the divider.
747
+ *
748
+ * S15: the host wraps a long diff line onto rows that carry no number and no gutter, which would
749
+ * draw at the frame's left column with no divider. This design draws ONE row per line, like the
750
+ * write pane: the rows after a numbered one that are the rest of its line are dropped, and that row
751
+ * ends in `…`. A row that fit is never marked.
601
752
  */
602
753
  function editRows(lines, render, ctx, seam) {
603
754
  const language = languageOf(callPath(render?.args), seam);
604
- return lines.map((row) => (typeof row === 'string'
605
- ? recolourDiffRow(row, { theme: ctx.theme, language, seam })
606
- : String(row)));
755
+ const count = render?.isError === true ? undefined : changeCount(render?.args);
756
+ let headed = count === undefined;
757
+ const out = [];
758
+ let index = 0;
759
+ while (index < lines.length) {
760
+ const row = lines[index];
761
+ index += 1;
762
+ if (typeof row !== 'string') {
763
+ out.push(String(row));
764
+ continue;
765
+ }
766
+ if (!headed && statesLine(row)) headed = true;
767
+ if (!headed && EDIT_HEADING.test(plainOf(row))) {
768
+ headed = true;
769
+ out.push(headingWithCount(row, count, ctx.theme));
770
+ continue;
771
+ }
772
+ const rest = [];
773
+ if (render?.isError !== true && statesLine(row)) {
774
+ while (index < lines.length && wrappedRest(lines[index]) !== undefined) {
775
+ rest.push(wrappedRest(lines[index]));
776
+ index += 1;
777
+ }
778
+ }
779
+ out.push(recolourDiffRow(row, { theme: ctx.theme, language, seam, rest }));
780
+ }
781
+ return out;
607
782
  }
608
783
 
609
784
  // ---- the design's entry point ----
package/lib/jobs-card.js CHANGED
@@ -43,14 +43,17 @@ const { cardText } = require('./codegraph-card-preview.js');
43
43
  /** The four tools this card owns, in the order the bridge's `Card tags` line declares them. */
44
44
  const JOB_TOOLS = Object.freeze(['bash_background', 'monitor', 'job_stop', 'job_list']);
45
45
 
46
- // Each tool's mark, its label and the theme role the heading wears. The two job tools share one
47
- // mark and one role, so a `monitor` and a `bash_background` read as the same family the report
48
- // card states, while their words say which TOOL ran what the report is about.
46
+ // Each tool's mark, its label, the theme role the heading wears and the role the call's own text
47
+ // wears. The two job tools share one mark and one role, so a `monitor` and a `bash_background` read
48
+ // as the same family the report card states, while their words say which TOOL ran what the report is
49
+ // about. `subtitleRole` is the INPUT the call carries — its label, its command, its job id — which is
50
+ // muted on the two bash tools so the role colour stays on the frame and the name, and stays `accent`
51
+ // on the two the human did not ask to change.
49
52
  const IDENTITY = Object.freeze({
50
- bash_background: { glyph: '⧗', title: 'bash background', titleRole: 'bashMode' },
51
- monitor: { glyph: '⧗', title: 'bash monitor', titleRole: 'bashMode' },
52
- job_stop: { glyph: '■', title: 'stop', titleRole: 'warning' },
53
- job_list: { glyph: '≡', title: 'jobs', titleRole: 'syntaxFunction' },
53
+ bash_background: { glyph: '⧗', title: 'bash background', titleRole: 'bashMode', subtitleRole: 'muted' },
54
+ monitor: { glyph: '⧗', title: 'bash monitor', titleRole: 'bashMode', subtitleRole: 'muted' },
55
+ job_stop: { glyph: '■', title: 'stop', titleRole: 'warning', subtitleRole: 'accent' },
56
+ job_list: { glyph: '≡', title: 'jobs', titleRole: 'syntaxFunction', subtitleRole: 'accent' },
54
57
  });
55
58
 
56
59
  const SUBTITLE_ROLE = 'accent';
@@ -97,7 +100,7 @@ function jobCardHeading(tool, args) {
97
100
  subtitle,
98
101
  collapsed: subtitle,
99
102
  labelBold: true,
100
- subtitleSegments: [{ text: subtitle, role: SUBTITLE_ROLE }],
103
+ subtitleSegments: [{ text: subtitle, role: identity.subtitleRole ?? SUBTITLE_ROLE }],
101
104
  };
102
105
  }
103
106
 
@@ -94,14 +94,16 @@ const MIN_PAINT_WIDTH = 6;
94
94
  // The attribution name every bridge surface of this package registers under (`lib/bash-design.js`).
95
95
  const PLUGIN_NAME = 'Odd worktree';
96
96
 
97
- // Each card's mark, title, tone, registration id and the label the bridge asks every registration
98
- // for. The label is not shown: a following design contributes no value to the customize menu, and
99
- // neither `default` nor `native` may be used as one. The id is identity, never shown either.
97
+ // Each card's mark, title, tone, the theme role its frame and name wear, registration id and the
98
+ // label the bridge asks every registration for. The label is not shown: a following design
99
+ // contributes no value to the customize menu, and neither `default` nor `native` may be used as one.
100
+ // The id is identity, never shown either.
100
101
  const IDENTITY = Object.freeze({
101
102
  [EXPLORATION_TYPE]: {
102
103
  glyph: '⌕',
103
104
  title: 'Exploration budget',
104
105
  tone: CARD_TONE.INFO,
106
+ titleRole: 'accent',
105
107
  id: 'odd-worktree.exploration-budget-card',
106
108
  label: 'card',
107
109
  description: 'draws the exploration budget alert as a card, in the style the shell has chosen',
@@ -109,7 +111,11 @@ const IDENTITY = Object.freeze({
109
111
  [VERIFIER_TYPE]: {
110
112
  glyph: '⚑',
111
113
  title: 'Verifier reminder',
112
- tone: CARD_TONE.WARNING,
114
+ // A REMINDER, not an alert: nothing failed and nothing is running, so the card is
115
+ // informational and wears the theme's accent like the budget card — not the amber that a
116
+ // warning tone owns the WHOLE box with (`TONE_OWNS_BOX`), which would override the identity role.
117
+ tone: CARD_TONE.INFO,
118
+ titleRole: 'accent',
113
119
  id: 'odd-worktree.verifier-settle-reminder-card',
114
120
  label: 'card',
115
121
  description: 'draws the verifier reminder as a card, in the style the shell has chosen',
@@ -192,6 +198,11 @@ function messageCardHeading(customType, body) {
192
198
  glyph: identity.glyph,
193
199
  title: identity.title,
194
200
  tone: identity.tone,
201
+ // The mark, the name AND the closed box wear one theme role, exactly as the job cards do: an
202
+ // informational card would otherwise keep the theme's plain `border` frame and read as if it had
203
+ // no role at all. The detail stays the substrate's muted subtitle, and the body stays `text`.
204
+ titleRole: identity.titleRole,
205
+ railRole: identity.titleRole,
195
206
  // The label is bolded inside the card's own role, exactly as the file and job cards do.
196
207
  labelBold: true,
197
208
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-odd-worktree",
3
- "version": "3.7.0",
3
+ "version": "3.7.2",
4
4
  "description": "Pi package for odd-worktree: the Git worktree tools a Pi session uses (create and list the checkouts the agent works in), the /warp worktree panel, the /odd ODD viewer, and the /issues GitHub issue reader. Needs only Pi and git: no companion app, no extra service.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -756,3 +756,152 @@ describe('the shape of the contract (S5)', () => {
756
756
  assert.doesNotThrow(() => diffColorDesign(seamFor().seam).apply(rows, callCtx({ render: { args } })));
757
757
  });
758
758
  });
759
+
760
+ describe('a diff line the host wrapped is ONE row ending in an ellipsis, as the write pane draws it (S15)', () => {
761
+ const ctx = () => ({ tool: 'edit', part: 'call', width: WIDTH, theme, render: { args: { path: 'lib/app.js' } } });
762
+ // The host's `Text` breaks a long diff line at the width: the first row states the number, every
763
+ // other row is the rest of the SAME line, at the row's own left column with no number.
764
+ const INNER = WIDTH - 4;
765
+ const hostWrap = (marker, number, code) => {
766
+ // Word wrap; a word longer than the row is broken through, which fills the row.
767
+ const rows = [];
768
+ let current = '';
769
+ for (let word of `${marker}${number} ${code}`.split(' ')) {
770
+ if (current !== '' && textLength(`${current} ${word}`) > INNER) {
771
+ rows.push(current);
772
+ current = '';
773
+ }
774
+ while (textLength(word) > INNER) {
775
+ if (current !== '') rows.push(current);
776
+ rows.push(word.slice(0, INNER));
777
+ current = '';
778
+ word = word.slice(INNER);
779
+ }
780
+ current = current === '' ? word : `${current} ${word}`;
781
+ }
782
+ rows.push(current);
783
+ return rows.map((row) => `│ ${row.padEnd(INNER)} │`);
784
+ };
785
+ const textLength = (text) => Array.from(text).length;
786
+ const LONG = 'const mentions = source.split(newline).filter((line) => !/oddModules/.test(line) && /codegraph/i.test(line))';
787
+
788
+ test('an added line: the rest rows are dropped and the one row keeps its width, divider and role', () => {
789
+ const wrapped = hostWrap('+', '233', LONG);
790
+ assert.ok(wrapped.length >= 2, 'the host did wrap this line');
791
+ const rows = diffColorDesign(seamFor().seam).apply(wrapped, ctx());
792
+ assert.equal(rows.length, 1, `the wrapped remainder is not drawn as stray rows: ${rows.map(unpaint).join('\n')}`);
793
+ assert.equal(cols(rows[0]), WIDTH, 'the row keeps the width the host gave it');
794
+ const plain = unpaint(rows[0]);
795
+ assert.match(plain, /^│ \+233 │ const mentions = .*…\s*│$/u, plain);
796
+ assert.match(rows[0], /<toolDiffAdded>\+233 │ .*…<\/toolDiffAdded>/u, 'the whole row still wears the role');
797
+ assert.equal((plain.match(/│/gu) ?? []).length, 3, `two frame cells and ONE divider: ${plain}`);
798
+ });
799
+
800
+ test('a removed and a context line behave the same, and the rows around them are untouched', () => {
801
+ const rows = diffColorDesign(seamFor().seam).apply([
802
+ `│ ${'@@ -230,3 +230,3 @@'.padEnd(INNER)} │`,
803
+ ...hostWrap('-', '232', LONG),
804
+ ...hostWrap(' ', '234', LONG),
805
+ `│ ${'+235 const next = 1;'.padEnd(INNER)} │`,
806
+ ], ctx());
807
+ const plain = rows.map(unpaint);
808
+ assert.equal(plain.length, 4, plain.join('\n'));
809
+ assert.match(plain[1], /^│ -232 │ const mentions = .*…\s*│$/u);
810
+ assert.match(plain[2], /^│ +234 │ const mentions = .*…\s*│$/u);
811
+ assert.match(plain[3], /^│ \+235 │ const next = 1;\s*│$/u, 'a line that fit is not marked');
812
+ for (const row of rows) assert.equal(cols(row), WIDTH);
813
+ });
814
+
815
+ test('a word longer than the width is cut the same way, and nothing wraps past the frame', () => {
816
+ const rows = diffColorDesign(seamFor().seam).apply(hostWrap('+', '9', 'x'.repeat(130)), ctx());
817
+ assert.equal(rows.length, 1);
818
+ assert.equal(cols(rows[0]), WIDTH);
819
+ assert.match(unpaint(rows[0]), /^│ \+9 │ x+…\s*│$/u);
820
+ });
821
+
822
+ test('painted twice is the same rows', () => {
823
+ const design = diffColorDesign(seamFor().seam);
824
+ const once = design.apply(hostWrap('+', '233', LONG), ctx());
825
+ assert.deepEqual(design.apply(once, ctx()), once);
826
+ });
827
+
828
+ test('only the rest of a line is dropped: a skip marker, the closing rule and a hint stay', () => {
829
+ const rows = [
830
+ ...hostWrap('+', '233', LONG),
831
+ '│ ... │',
832
+ '╰──────────────────────────────────────────────────────────╯',
833
+ 'ctrl+o to expand',
834
+ ];
835
+ const plain = diffColorDesign(seamFor().seam).apply(rows, ctx()).map(unpaint);
836
+ assert.equal(plain.length, 4, plain.join('\n'));
837
+ assert.equal(plain[1], rows[hostWrap('+', '233', LONG).length]);
838
+ assert.equal(plain[2], rows.at(-2));
839
+ assert.equal(plain[3], 'ctrl+o to expand');
840
+ });
841
+ });
842
+
843
+ describe('the edit heading states what the call changed, as the write heading states its lines (S16)', () => {
844
+ const heading = '╭─ ✎ edit lib/app.js ─────────────────────────────────────╮';
845
+ const withHint = '╭─ ✎ edit lib/app.js ──────────────── ctrl+o to collapse ─╮';
846
+ const run = (rows, edits, extra = {}) => diffColorDesign(seamFor().seam).apply(rows, {
847
+ tool: 'edit',
848
+ part: 'call',
849
+ width: WIDTH,
850
+ theme,
851
+ render: { args: { path: 'lib/app.js', edits }, ...extra },
852
+ });
853
+ const edit = (oldText, newText) => ({ oldText, newText });
854
+
855
+ test('added and removed lines follow the path, muted, and the row keeps its width', () => {
856
+ const [row] = run([withHint], [edit('a\nb', 'a\nc\nd')]);
857
+ assert.equal(cols(row), cols(withHint), 'the rule gave the columns, the frame did not move');
858
+ assert.match(row, /edit lib\/app\.js <muted>\(\+2 · -1\)<\/muted> ─+ ctrl\+o to collapse ─╮$/u, row);
859
+ });
860
+
861
+ test('a count of zero is not written, and nothing changed writes nothing', () => {
862
+ assert.match(run([heading], [edit('a', 'a\nb\nc')])[0], /<muted>\(\+2\)<\/muted>/u);
863
+ assert.match(run([heading], [edit('a\nb', 'a')])[0], /<muted>\(-1\)<\/muted>/u);
864
+ assert.equal(run([heading], [edit('same', 'same')])[0], heading);
865
+ });
866
+
867
+ test('every edit of the call counts, and the legacy single oldText/newText call too', () => {
868
+ assert.match(run([heading], [edit('a', 'b'), edit('x\ny', 'x')])[0], /\(\+1 · -2\)/u);
869
+ const legacy = diffColorDesign(seamFor().seam).apply([heading], {
870
+ tool: 'edit', part: 'call', width: WIDTH, theme, render: { args: { path: 'lib/app.js', oldText: 'a', newText: 'b\nc' } },
871
+ });
872
+ assert.match(legacy[0], /\(\+2 · -1\)/u);
873
+ });
874
+
875
+ test('a line only counts when the call really changes it', () => {
876
+ const [row] = run([heading], [edit('keep\nold\nkeep too', 'keep\nnew\nkeep too')]);
877
+ assert.match(row, /\(\+1 · -1\)/u, row);
878
+ });
879
+
880
+ test('float and unframed headings carry the count too', () => {
881
+ const float = ' ▎ ✎ edit lib/app.js ctrl+o to expand ';
882
+ assert.match(run([float], [edit('a', 'b')])[0], /edit lib\/app\.js <muted>\(\+1 · -1\)<\/muted> +ctrl\+o to expand/u);
883
+ assert.equal(cols(run([float], [edit('a', 'b')])[0]), cols(float));
884
+ const bare = `edit lib/app.js${' '.repeat(40)}`;
885
+ assert.match(run([bare], [edit('a', 'b')])[0], /^edit lib\/app\.js <muted>\(\+1 · -1\)<\/muted> +$/u);
886
+ });
887
+
888
+ test('no room, no args, a failed call or the body rows: the host\'s rows come back', () => {
889
+ const tight = '╭─ ✎ edit lib/app.js ─╮';
890
+ assert.deepEqual(run([tight], [edit('a', 'b')]), [tight]);
891
+ assert.deepEqual(run([heading], undefined), [heading]);
892
+ assert.deepEqual(run([heading], [edit('a', 'b')], { isError: true }), [heading]);
893
+ const body = ['│ -1 edit lib/app.js ────────────────────────────────────── │'];
894
+ assert.equal(unpaint(run(body, [edit('a', 'b')])[0]).includes('(+1 · -1)'), false);
895
+ });
896
+
897
+ test('painted twice is the same row', () => {
898
+ const once = run([withHint], [edit('a', 'b')]);
899
+ assert.deepEqual(run(once, [edit('a', 'b')]), once);
900
+ });
901
+
902
+ test('the colour the heading was drawn in is picked up again after the count', () => {
903
+ const painted = `\u001b[34m${withHint}\u001b[39m`;
904
+ const [row] = run([painted], [edit('a', 'b')]);
905
+ assert.ok(row.includes('</muted>\u001b[34m'), row);
906
+ });
907
+ });
@@ -193,6 +193,18 @@ test('both job tools wear one mark and one role, so a monitor reads as a backgro
193
193
  assert.match(unpaint(monitor), /⧗ bash monitor ·/u);
194
194
  });
195
195
 
196
+ test('the two bash tools keep the role on the frame and the name, and mute the input text', () => {
197
+ publishBridge(ACTIVITY);
198
+ const resolver = jobsResolver();
199
+ const background = callRows(resolver, 'bash_background', { command: COMMAND, label: LABEL }, taggedTheme)[0];
200
+ const monitor = callRows(resolver, 'monitor', { command: COMMAND, label: LABEL, timeout_seconds: 60 }, taggedTheme)[0];
201
+ for (const row of [background, monitor]) {
202
+ assert.ok(row.includes('<bashMode>'), 'the frame and the mark keep the identity role');
203
+ assert.ok(row.includes('<muted>'), 'the input text — the label — is muted');
204
+ assert.ok(!row.includes('<accent>'), 'and it is not the accent the other two tools keep');
205
+ }
206
+ });
207
+
196
208
  test('expanded, the whole command is stated below the heading, every line of it', () => {
197
209
  publishBridge(ACTIVITY);
198
210
  const rows = callRows(jobsResolver(), 'bash_background', { command: 'sleep 20\n\ngh run list --repo acme/api', label: LABEL }, plainTheme, 70, { isPartial: false, expanded: true }).map(unpaint);
@@ -457,16 +457,20 @@ test('a mid-session flip repaints a card already on screen, in both directions',
457
457
 
458
458
  // ---- the palette (S5) ----
459
459
 
460
- test('each card wears its own tone: info for the budget, warning for the reminder', () => {
460
+ test('both cards are informational and wear the accent on the frame and the name', () => {
461
461
  const outcome = registered();
462
462
  const budget = designFor(outcome, EXPLORATION).apply(plainBody(EXPLORATION, STARTED), { width: 70, customType: EXPLORATION, theme: taggedTheme, render: { expanded: false, outputPad: 1, message: {} } });
463
- // INFO: the rounded frame keeps the theme's plain border role while the name carries the accent.
463
+ // Both cards name ONE theme role for the frame and the name, so an informational card is never the
464
+ // theme's plain border with no colour of its own: `accent` for the budget.
464
465
  assert.ok(budget[0].includes('<accent>⌕</accent>'), budget[0]);
465
- assert.ok(budget[0].includes('<border>╭'), 'the frame keeps the plain border role');
466
+ assert.ok(budget[0].includes('<accent>╭'), 'the frame wears the identity role, not the plain border');
467
+ assert.ok(budget[0].includes('<muted>'), 'the detail stays the muted subtitle');
466
468
  const reminder = designFor(outcome, VERIFIER).apply(plainBody(VERIFIER, VERIFIER_TEXT), { width: 70, customType: VERIFIER, theme: taggedTheme, render: { expanded: false, outputPad: 1, message: {} } });
467
- // WARNING owns the box: frame and name both carry the warning role.
468
- assert.ok(reminder[0].includes('<warning>⚑</warning>'), reminder[0]);
469
- assert.ok(reminder[0].includes('<warning>╭'), 'the frame carries the tone');
469
+ // A reminder is not an alert: it wears the same accent, never the amber a warning tone owns the
470
+ // whole box with.
471
+ assert.ok(reminder[0].includes('<accent>⚑</accent>'), reminder[0]);
472
+ assert.ok(reminder[0].includes('<accent>╭'), 'the frame wears the identity role');
473
+ assert.ok(!reminder[0].includes('<warning>'), 'nothing on a reminder card is painted as a warning');
470
474
  });
471
475
 
472
476
  test('every row fits the width the host asked for, at narrow and wide terminals, in both styles', () => {