pi-odd-worktree 3.13.0 → 3.15.0

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.
@@ -0,0 +1,196 @@
1
+ 'use strict';
2
+ // S5/S7/S8 (opencode-usage-alert): the `Alert` page of `/gentle:customize`. It carries one
3
+ // Off/On pair PER provider the peak registry declares, in the registry's declaration order,
4
+ // under each provider's own setting label (`Deepseek peak`, then `Claude peak`). Each line
5
+ // reads and writes the boolean `lib/alert-mode.js` owns for that provider id, and a
6
+ // successful change applies to the RUNNING session at once — no `/reload`, so nothing says
7
+ // "restart". Pure over the injected bridge and callbacks; nothing here loads the extension.
8
+ const { test, describe } = require('node:test');
9
+ const assert = require('node:assert/strict');
10
+
11
+ const alertMode = require('../lib/alert-mode.js');
12
+ const alertRows = require('../lib/alert-rows.js');
13
+ const { PROVIDERS } = require('../lib/peak-providers.js');
14
+
15
+ // A bridge whose `createStore` keeps one in-memory file per plugin id, like the real one.
16
+ function fakeBridge(initial = {}) {
17
+ const files = new Map(Object.entries(initial));
18
+ const writes = [];
19
+ const createStore = (id) => ({
20
+ get: (key, fallback) => (files.get(id)?.[key] !== undefined ? files.get(id)[key] : fallback),
21
+ set: (key, value) => {
22
+ files.set(id, { ...(files.get(id) ?? {}), [key]: value });
23
+ writes.push([id, key, value]);
24
+ },
25
+ });
26
+ return { api: { createStore }, files, writes };
27
+ }
28
+
29
+ // The rows of one provider's pair: Off first, then On, both under the provider's setting.
30
+ function pairOf(rows, setting) {
31
+ return rows.filter((row) => row.choice.setting === setting);
32
+ }
33
+
34
+ function stored(value = {}) {
35
+ return fakeBridge({ 'odd-worktree': { alerts: { peaks: value } } });
36
+ }
37
+
38
+ function provider(api, hooks = {}) {
39
+ const calls = { notify: [], onChange: [] };
40
+ const rows = alertRows.alertRowsProvider({
41
+ api,
42
+ notify: (text) => {
43
+ calls.notify.push(text);
44
+ if (hooks.notify) hooks.notify(text);
45
+ },
46
+ onChange: () => {
47
+ calls.onChange.push(true);
48
+ if (hooks.onChange) hooks.onChange();
49
+ },
50
+ });
51
+ return { provider: rows, calls, rows: (ctx = {}) => rows.rows(ctx) };
52
+ }
53
+
54
+ describe('the Alert page', () => {
55
+ test('is one provider, named, on a page of its own, placed right after Notifications', () => {
56
+ const { provider: page } = provider(fakeBridge().api);
57
+ assert.deepEqual(Object.keys(page).sort(), ['category', 'categoryPlacement', 'id', 'rows']);
58
+ assert.equal(page.id, 'odd-worktree.alert.peak');
59
+ assert.equal(page.category, 'Alert');
60
+ assert.deepEqual(page.categoryPlacement, { after: 'Notifications' });
61
+ });
62
+
63
+ test('carries exactly one Off/On pair per registry entry, in declaration order, with its own label', () => {
64
+ const { rows } = provider(fakeBridge().api);
65
+ const built = rows();
66
+ assert.equal(PROVIDERS.length > 0, true, 'the registry declares at least one provider');
67
+ assert.deepEqual(
68
+ built.map((row) => [row.choice.setting, row.choice.value]),
69
+ PROVIDERS.flatMap((entry) => [[entry.setting, 'Off'], [entry.setting, 'On']]),
70
+ );
71
+ // The registry's documented shape: DeepSeek first, Claude second, each under its setting.
72
+ assert.deepEqual(PROVIDERS.map((entry) => entry.id), ['deepseek', 'claude']);
73
+ assert.deepEqual(PROVIDERS.map((entry) => entry.setting), ['Deepseek peak', 'Claude peak']);
74
+ for (const row of built) {
75
+ assert.equal(row.category, 'Alert');
76
+ assert.equal(typeof row.label, 'function');
77
+ assert.equal(typeof row.action, 'function');
78
+ }
79
+ });
80
+
81
+ test('labels each pair with its provider\'s setting, not with a fixed name', () => {
82
+ const built = provider(fakeBridge().api).rows();
83
+ for (const entry of PROVIDERS) {
84
+ const pair = pairOf(built, entry.setting);
85
+ assert.equal(pair.length, 2, entry.setting);
86
+ assert.deepEqual(pair.map((row) => row.choice.value), ['Off', 'On'], entry.setting);
87
+ for (const row of pair) assert.equal(row.label(), entry.setting);
88
+ }
89
+ });
90
+ });
91
+
92
+ describe('the current value', () => {
93
+ test('is Off for every provider on a first run, and follows each provider\'s own switch', () => {
94
+ const fresh = provider(fakeBridge().api).rows();
95
+ for (const entry of PROVIDERS) {
96
+ assert.deepEqual(pairOf(fresh, entry.setting).map((row) => row.choice.current()), [true, false], entry.setting);
97
+ }
98
+ for (const entry of PROVIDERS) {
99
+ const built = provider(stored({ [entry.id]: true }).api).rows();
100
+ const pair = pairOf(built, entry.setting);
101
+ assert.deepEqual(pair.map((row) => row.choice.current()), [false, true], entry.setting);
102
+ // Every other provider is untouched by that one provider's value.
103
+ for (const sibling of PROVIDERS.filter((other) => other.id !== entry.id)) {
104
+ assert.deepEqual(
105
+ pairOf(built, sibling.setting).map((row) => row.choice.current()),
106
+ [true, false],
107
+ `${entry.id} vs ${sibling.id}`,
108
+ );
109
+ }
110
+ }
111
+ });
112
+
113
+ test('is read live: a value changed between two builds is reflected', () => {
114
+ const bridge = fakeBridge();
115
+ const { rows } = provider(bridge.api);
116
+ const target = PROVIDERS[0];
117
+ const sibling = PROVIDERS[1];
118
+ assert.deepEqual(pairOf(rows(), target.setting).map((row) => row.choice.current()), [true, false]);
119
+ alertMode.writePeakAlert(bridge.api, target.id, true);
120
+ assert.deepEqual(pairOf(rows(), target.setting).map((row) => row.choice.current()), [false, true]);
121
+ assert.deepEqual(pairOf(rows(), sibling.setting).map((row) => row.choice.current()), [true, false]);
122
+ alertMode.writePeakAlert(bridge.api, target.id, false);
123
+ assert.deepEqual(pairOf(rows(), target.setting).map((row) => row.choice.current()), [true, false]);
124
+ });
125
+ });
126
+
127
+ describe('choosing a value', () => {
128
+ test('persists that provider\'s id, then applies it to the running session once', async () => {
129
+ const bridge = fakeBridge();
130
+ const { rows, calls } = provider(bridge.api);
131
+ const target = PROVIDERS[0];
132
+ await pairOf(rows(), target.setting)[1].action();
133
+ assert.deepEqual(bridge.files.get('odd-worktree'), { alerts: { peaks: { [target.id]: true } } });
134
+ assert.equal(calls.onChange.length, 1);
135
+ assert.equal(alertMode.readPeakAlert(bridge.api, target.id), true);
136
+ await pairOf(rows(), target.setting)[0].action();
137
+ assert.deepEqual(bridge.files.get('odd-worktree'), { alerts: { peaks: { [target.id]: false } } });
138
+ assert.equal(calls.onChange.length, 2);
139
+ assert.equal(alertMode.readPeakAlert(bridge.api, target.id), false);
140
+ });
141
+
142
+ test('a second provider\'s line writes only its own id and leaves its siblings alone', async () => {
143
+ const bridge = stored({});
144
+ const { rows, calls } = provider(bridge.api);
145
+ await pairOf(rows(), PROVIDERS[0].setting)[1].action();
146
+ await pairOf(rows(), PROVIDERS[1].setting)[1].action();
147
+ assert.deepEqual(bridge.files.get('odd-worktree'), {
148
+ alerts: { peaks: { [PROVIDERS[0].id]: true, [PROVIDERS[1].id]: true } },
149
+ });
150
+ assert.equal(calls.onChange.length, 2);
151
+ await pairOf(rows(), PROVIDERS[0].setting)[0].action();
152
+ assert.equal(alertMode.readPeakAlert(bridge.api, PROVIDERS[0].id), false);
153
+ assert.equal(alertMode.readPeakAlert(bridge.api, PROVIDERS[1].id), true);
154
+ });
155
+
156
+ test('keeps the other keys of the store', async () => {
157
+ const bridge = fakeBridge({ 'odd-worktree': { modules: { codegraph: false } } });
158
+ await provider(bridge.api).rows()[0].action();
159
+ assert.deepEqual(bridge.files.get('odd-worktree'), {
160
+ modules: { codegraph: false },
161
+ alerts: { peaks: { [PROVIDERS[0].id]: false } },
162
+ });
163
+ });
164
+
165
+ test('says nothing: these switches need no reload, so no restart notice is printed', async () => {
166
+ const bridge = fakeBridge();
167
+ const { rows, calls } = provider(bridge.api);
168
+ for (const row of rows()) await row.action();
169
+ assert.deepEqual(calls.notify, []);
170
+ });
171
+ });
172
+
173
+ describe('a write the store refuses', () => {
174
+ test('is thrown per provider so the menu reports it, and nothing is told it changed', async () => {
175
+ const api = { createStore: () => ({ get: (_key, fallback) => fallback, set: () => { throw new Error('read-only'); } }) };
176
+ const { rows, calls } = provider(api);
177
+ for (const entry of PROVIDERS) {
178
+ const pair = pairOf(rows(), entry.setting);
179
+ await assert.rejects(async () => pair[0].action(), new RegExp(`^Error: ${entry.setting} could not be saved$`), entry.setting);
180
+ await assert.rejects(async () => pair[1].action(), new RegExp(`^Error: ${entry.setting} could not be saved$`), entry.setting);
181
+ }
182
+ assert.deepEqual(calls.onChange, []);
183
+ });
184
+
185
+ test('is thrown for a host with no store at all, and still calls nothing', async () => {
186
+ const { rows, calls } = provider(undefined);
187
+ await assert.rejects(async () => rows()[0].action(), /could not be saved$/);
188
+ assert.deepEqual(calls.onChange, []);
189
+ });
190
+
191
+ test('leaves the stored value reading Off, the way it read before the press', async () => {
192
+ const api = { createStore: () => ({ get: (_key, fallback) => fallback, set: () => { throw new Error('read-only'); } }) };
193
+ await assert.rejects(async () => provider(api).rows()[1].action(), /could not be saved$/);
194
+ assert.equal(alertMode.readPeakAlert(api, PROVIDERS[0].id), false);
195
+ });
196
+ });
@@ -620,8 +620,9 @@ describe('S8 (T6): the naming observer’s git probes', () => {
620
620
  });
621
621
 
622
622
  // PRESERVE: the filter above must not stop the naming it filters FOR. A write
623
- // of an `odd/tasks/*.md` document still names the session after that document
624
- // and its branch — the behaviour the observer existed for.
623
+ // of an `odd/tasks/*.md` document still names the session after that document —
624
+ // the behaviour the observer existed for — and the name is the ODD's OWN file name
625
+ // (not the heading inside it, and with no branch suffix).
625
626
  test('a write of an odd/tasks document still names the session', async () => {
626
627
  const repo = makeRepo();
627
628
  const created = await tools.get('worktree_create').execute(
@@ -647,7 +648,7 @@ describe('S8 (T6): the naming observer’s git probes', () => {
647
648
  const out = handler({ toolName: 'write', input: { path: documentPath }, toolResults: [] }, ctx);
648
649
  if (out && typeof out.then === 'function') await out;
649
650
  }
650
- assert.equal(name, 'Named session @ feat/named', 'the write still names the session after its document');
651
+ assert.equal(name, 'Named', 'the write still names the session after its document');
651
652
  });
652
653
 
653
654
  test('a checkout created moments ago is still seen by the next naming step', async () => { const repo = makeRepo();
@@ -291,15 +291,23 @@ describe('the grouped listing the panel draws (S10, S13)', () => {
291
291
  pending.catch(() => {});
292
292
  await waitFor(() => host.mounts.length === 1, 'the panel mounts');
293
293
 
294
- const text = frameText(host.mounts[0].component);
294
+ const component = host.mounts[0].component;
295
+ const text = frameText(component);
295
296
  // S10/S13: main always carries every ODD of main; a registered worktree
296
- // carries only what it has that main does not.
297
- assert.match(text, /\u25be main/, 'main is a group of its own');
298
- assert.match(text, /\u25be wt-a/, 'the registered worktree is a group');
299
- assert.match(text, /a-only/);
297
+ // carries only what it has that main does not — and, per odd-panel-groups
298
+ // S1, both arrive FOLDED with their count.
299
+ assert.match(text, /\u25b8 main \(2 odd\)/, 'main is a folded group of its own');
300
+ assert.match(text, /\u25b8 wt-a \(1 odd\)/, 'the registered worktree is a folded group');
301
+ assert.ok(!text.includes('a-only'), `a folded group shows no document\n${text}`);
300
302
  assert.ok(!text.includes('wt-b'), `an unregistered worktree is not a group\n${text}`);
301
303
  assert.ok(!text.includes('b-only'), `nor is one of its documents listed\n${text}`);
302
304
  assert.match(text, /3 documents/, 'main’s two plus the worktree’s one');
305
+ // Opening the worktree group shows the document that belongs to it.
306
+ component.handleInput('down');
307
+ component.handleInput('enter');
308
+ const opened = frameText(component);
309
+ assert.match(opened, /\u25be wt-a \(1 odd\)/, 'Enter opens that group');
310
+ assert.match(opened, /a-only/, 'and its own document under it');
303
311
 
304
312
  // The unregistered checkout was never asked anything: no worktree listing
305
313
  // of its own, no merge-base, no diff, no status.
@@ -374,7 +382,13 @@ describe('the grouped listing the panel draws (S10, S13)', () => {
374
382
  await waitFor(() => frameText(component).includes('wt-b'), 'the second group is drawn');
375
383
  assert.equal(observed.listing().length, 1, 'one grouped reload, one worktree listing');
376
384
  assert.match(frameText(component), /a session only/, 'the hint follows the mode');
377
- assert.match(frameText(component), /\u25be wt-b/);
385
+ // S1: the group the reload just added arrives folded; opening it is what
386
+ // reveals its document.
387
+ assert.match(frameText(component), /\u25b8 wt-b \(1 odd\)/);
388
+ component.handleInput('down');
389
+ component.handleInput('down');
390
+ component.handleInput('enter');
391
+ assert.match(frameText(component), /\u25be wt-b \(1 odd\)/, 'Enter opens the new group');
378
392
  assert.match(frameText(component), /b-only/);
379
393
 
380
394
  // `a` again: back to the session's registered set only.
@@ -385,7 +399,7 @@ describe('the grouped listing the panel draws (S10, S13)', () => {
385
399
  'the registered reload never asks an unregistered worktree anything');
386
400
  assert.equal(observed.listing().length, 1, 'and it re-enumerates the checkouts once');
387
401
  assert.match(frameText(component), /a all worktrees/, 'the hint returns with the mode');
388
- assert.match(frameText(component), /\u25be wt-a/);
402
+ assert.match(frameText(component), /\u25b8 wt-a \(1 odd\)/);
389
403
 
390
404
  await closePanel(host, pending);
391
405
  } finally {
@@ -733,11 +747,13 @@ describe('T6 verifier regressions (S11, S13, D2)', () => {
733
747
  try {
734
748
  await waitFor(() => host.mounts.length === 1, 'mount');
735
749
  const view = host.mounts[0].component;
736
- assert.doesNotMatch(frameText(view), /t6-outside-odd/);
750
+ // odd-panel-groups S1: groups are folded, so the witness of a scope is its
751
+ // GROUP HEADER, which is drawn either way.
752
+ assert.doesNotMatch(frameText(view), /wt-t6-outside \(1 odd\)/);
737
753
  view.handleInput('a');
738
754
  // An owned worktree's delta is a witness that this was not just the pre-reload frame.
739
- await waitFor(() => frameText(view).includes('t6-witness-odd'), 'all-mode reload');
740
- assert.match(frameText(view), /t6-outside-odd/);
755
+ await waitFor(() => /wt-t6-witness \(1 odd\)/.test(frameText(view)), 'all-mode reload');
756
+ assert.match(frameText(view), /wt-t6-outside \(1 odd\)/);
741
757
  } finally {
742
758
  await closePanel(host, pending);
743
759
  }
@@ -800,12 +816,13 @@ describe('T6 verifier regressions (S11, S13, D2)', () => {
800
816
  await waitFor(() => host.mounts.length === 1, 'mount');
801
817
  await waitForRankedListing(observed, [repo]);
802
818
  const view = host.mounts[0].component;
803
- assert.doesNotMatch(frameText(view), /new-t6-odd/);
819
+ // odd-panel-groups S1: the group arrives folded, so its HEADER is the witness.
820
+ assert.doesNotMatch(frameText(view), /wt-t6-new-registration \(1 odd\)/);
804
821
  roots.push(linked);
805
822
  observed.clear();
806
823
  view.handleInput('r');
807
824
  await waitForRankedListing(observed, [repo]);
808
- assert.match(frameText(view), /new-t6-odd/);
825
+ assert.match(frameText(view), /wt-t6-new-registration \(1 odd\)/);
809
826
  } finally {
810
827
  observed.restore();
811
828
  await closePanel(host, pending);
@@ -865,10 +882,10 @@ test('T6 independent: while an all-mode read is held the hint still matches the
865
882
  delayed.arm();
866
883
  v.handleInput('a');
867
884
  await waitFor(() => delayed.pending.length === 1, 'held all-mode read');
868
- assert.doesNotMatch(frameText(v), /visible-in-all/);
885
+ assert.doesNotMatch(frameText(v), /held-all \(1 odd\)/);
869
886
  assert.match(frameText(v), /a all worktrees/);
870
887
  delayed.pending[0].resolve(await delayed.real(delayed.pending[0].input));
871
- await waitFor(() => frameText(v).includes('visible-in-all'), 'all-mode result');
888
+ await waitFor(() => frameText(v).includes('held-all (1 odd)'), 'all-mode result');
872
889
  assert.match(frameText(v), /a session only/);
873
890
  } finally {
874
891
  for (const read of delayed.pending) read.resolve([]);
@@ -900,7 +917,10 @@ test('T6 independent: a late initial rank cannot replace a newer all-mode listin
900
917
  const v = host.mounts[0].component;
901
918
  writeTask(repo, 'late-main', '# Added while ranking\n');
902
919
  v.handleInput('a');
903
- await waitFor(() => /all-witness/.test(frameText(v)) && /late-main/.test(frameText(v)), 'new all-mode frame');
920
+ await waitFor(
921
+ () => /rank-witness \(1 odd\)/.test(frameText(v)) && /main \(3 odd\)/.test(frameText(v)),
922
+ 'new all-mode frame',
923
+ );
904
924
  const before = frameText(v);
905
925
  release();
906
926
  await new Promise(resolve => setImmediate(resolve));
@@ -946,7 +966,7 @@ test('T6 round 4: latest r publishes the hint with the pending a scope (S11)', a
946
966
  v.handleInput('r');
947
967
  await waitFor(() => d.pending.length === 2, 'both requests held');
948
968
  d.pending[1].resolve(await d.real(d.pending[1].input));
949
- await waitFor(() => /all-witness/.test(frameText(v)), 'latest r result');
969
+ await waitFor(() => /linked \(1 odd\)/.test(frameText(v)), 'latest r result');
950
970
  assert.match(frameText(v), /a session only/);
951
971
  } finally {
952
972
  for (const read of d.pending) read.resolve(null);
@@ -973,7 +993,7 @@ test('T6 round 4: a failed all-worktree Git read keeps drawn rows and hint (S11/
973
993
  await waitForRankedListing(observed, [repo]);
974
994
  const v = host.mounts[0].component;
975
995
  const before = frameText(v);
976
- assert.match(before, /session-witness/);
996
+ assert.match(before, /registered \(1 odd\)/);
977
997
  g.runArgvAsync = (bin, args, opts) => args.includes('worktree') && args.includes('list')
978
998
  ? (failedRead = run(bin, ['worktree', 'list', '--t6-invalid-option'], opts))
979
999
  : run(bin, args, opts);
@@ -1100,24 +1120,24 @@ test('T6 round 4: every release order leaves the latest applied load (S11/S13/D2
1100
1120
  await waitFor(() => {
1101
1121
  const text = frameText(view);
1102
1122
  return expectedAll
1103
- ? /other-only/.test(text) && /a session only/.test(text)
1104
- : !/other-only/.test(text) && /a all worktrees/.test(text);
1123
+ ? /other \(1 odd\)/.test(text) && /a session only/.test(text)
1124
+ : !/other \(1 odd\)/.test(text) && /a all worktrees/.test(text);
1105
1125
  }, `${label}: ${kind} applied`);
1106
1126
  } else {
1107
1127
  await new Promise((resolve) => setImmediate(resolve));
1108
1128
  assert.equal(frameText(view), before, `${label}: the superseded ${kind} changed nothing`);
1109
1129
  }
1110
1130
  const text = frameText(view);
1111
- assert.equal(/other-only/.test(text), expectedAll,
1131
+ assert.equal(/other \(1 odd\)/.test(text), expectedAll,
1112
1132
  `${label}: the drawn rows follow the latest applied load`);
1113
1133
  assert.match(text, expectedAll ? /a session only/ : /a all worktrees/,
1114
1134
  `${label}: the hint describes that same applied load`);
1115
- assert.match(text, /registered-only/, `${label}: the session delta is drawn in both modes`);
1135
+ assert.match(text, /registered \(1 odd\)/, `${label}: the session delta is drawn in both modes`);
1116
1136
  releases += 1;
1117
1137
  }
1118
1138
  await new Promise((resolve) => setImmediate(resolve));
1119
1139
  const settled = frameText(view);
1120
- assert.equal(/other-only/.test(settled), expectedAll, `${label}: nothing stale lands afterwards`);
1140
+ assert.equal(/other \(1 odd\)/.test(settled), expectedAll, `${label}: nothing stale lands afterwards`);
1121
1141
  assert.match(settled, expectedAll ? /a session only/ : /a all worktrees/, `${label}: the final hint`);
1122
1142
  } finally {
1123
1143
  for (const read of deferred.pending) read.resolve(sessionModel);
@@ -1186,8 +1206,10 @@ function perms(plan) {
1186
1206
  // outside one only in the all-worktrees mode, and the hint names that mode.
1187
1207
  function markFrame(v, all) {
1188
1208
  const text = frameText(v);
1189
- assert.match(text, /registered-witness/);
1190
- assert.equal(text.includes('outside-witness'), all, text);
1209
+ // odd-panel-groups S1: every group is folded, so the scope is read from the group
1210
+ // HEADERS, which are painted whether a group is open or closed.
1211
+ assert.match(text, /registered \(1 odd\)/);
1212
+ assert.equal(/elsewhere \(1 odd\)/.test(text), all, text);
1191
1213
  assert.ok(text.includes(all ? 'a session only' : 'a all worktrees'), text);
1192
1214
  }
1193
1215
 
@@ -1505,12 +1527,21 @@ const listCells = (component) => renderedRows(component)
1505
1527
  .filter((line) => /^\u2502/.test(line))
1506
1528
  .map((line) => (line.split('\u2502')[1] || ''))
1507
1529
  .filter((cell) => cell.trim() !== '' && !/^\u203a|^\u2191/.test(cell.trim()));
1530
+ // A row's label with the CURSOR and the group's own fold marker removed, so a row
1531
+ // reads the same however it is drawn (odd-panel-groups S1 folds every group, so a
1532
+ // marker is present on rows that are not focused at all).
1533
+ const cellLabel = (cell) => cell.trim()
1534
+ .replace(/^[\u25b8\u25be]\s*/, '')
1535
+ .replace(/^[\u25b8\u25be]\s*/, '')
1536
+ .replace(/\s+/g, ' ');
1508
1537
  const rowLabels = (component) => listCells(component)
1509
- .map((cell) => cell.trim().replace(/^\u25b8\s*/, ''))
1538
+ .map(cellLabel)
1510
1539
  .filter((cell) => cell !== '');
1540
+ // The CURSOR is the first cell after the frame's `\u2502 `, so it sits at index 1 of
1541
+ // the pane cell while a folded group's marker is indented past it.
1511
1542
  const focusedLabel = (component) => {
1512
- const cell = listCells(component).map((value) => value.trim()).find((value) => value.startsWith('\u25b8'));
1513
- return cell === undefined ? null : cell.replace(/^\u25b8\s*/, '');
1543
+ const cell = listCells(component).find((value) => value[1] === '\u25b8');
1544
+ return cell === undefined ? null : cellLabel(cell);
1514
1545
  };
1515
1546
  async function focusRow(component, label) {
1516
1547
  let guard = 0;
@@ -1546,14 +1577,21 @@ test('F3: two registered checkouts sharing a basename paint two different labels
1546
1577
  const v = host.mounts[0].component;
1547
1578
  const text = frameText(v);
1548
1579
  t.diagnostic(`labels: ${JSON.stringify(rowLabels(v))}`);
1549
- const painted = rowLabels(v).filter((label) => label.startsWith('collision'));
1550
- assert.equal(painted.length, 2, `both copies are listed\n${text}`);
1551
- assert.notEqual(painted[0], painted[1], 'the two rows read differently');
1552
- assert.deepEqual(painted.slice().sort(), [labelOf(a), labelOf(b)].sort(),
1553
- 'and they are the labels the ONE listing derived');
1580
+ // odd-panel-groups S1: both groups arrive FOLDED, so their own headers are the
1581
+ // rows that must tell them apart.
1582
+ const headers = rowLabels(v).filter((label) => label.includes('same checkout'));
1583
+ assert.equal(headers.length, 2, `both groups are listed\n${text}`);
1584
+ assert.notEqual(headers[0], headers[1], 'the two headers read differently');
1585
+ assert.deepEqual(headers.slice().sort(), [
1586
+ 'a/same checkout (1 odd)',
1587
+ 'b/same checkout (1 odd)',
1588
+ ], 'each is qualified with the directory that tells it apart');
1554
1589
  for (const [root, body] of [[a, /First copy/], [b, /Second copy/]]) {
1590
+ const parent = path.basename(path.dirname(root));
1591
+ await focusRow(v, `${parent}/same checkout (1 odd)`);
1592
+ v.handleInput('enter');
1555
1593
  await focusRow(v, labelOf(root));
1556
- assert.match(frameText(v), body, `${path.basename(path.dirname(root))}: its own body is open`);
1594
+ assert.match(frameText(v), body, `${parent}: its own body is open`);
1557
1595
  }
1558
1596
  } finally {
1559
1597
  await closePanel(host, pending);
@@ -4,8 +4,8 @@
4
4
  // Contract under test, through the public surface only:
5
5
  // - the section is the `ODD` card, labelled `odd`, visible by default, and it
6
6
  // carries `placement: { after: "agents" }` so the host puts it right after the
7
- // native AGENTS rail part (S1); it carries no `meta`, because nothing asked for
8
- // a header count;
7
+ // native AGENTS rail part (S1), and its heading carries the count — `N odd` — as
8
+ // `meta`, the way the CHANGES card reads `1 file` (S7 of odd-panel-groups);
9
9
  // - the rows are the ODDs `load()` resolved, in THAT order (the walk and the
10
10
  // dedupe belong to the caller), at most FOUR of them (S2); more than four adds
11
11
  // ONE fifth row reading `N more`, dim and inert, while exactly four paint four
@@ -140,9 +140,9 @@ test('S1: the section is the ODD card, placed right after the native AGENTS part
140
140
  'the placement is exactly what puts the card after the AGENTS part');
141
141
  assert.deepEqual(Object.keys(handle.section.placement), ['after']);
142
142
  assert.equal(typeof handle.section.lines, 'function', 'the host draws the card through lines()');
143
- assert.equal('meta' in handle.section, false, 'nothing asked for a header count, so there is no meta');
143
+ assert.equal(typeof handle.section.meta, 'function', 'the heading draws its `N odd` through meta()');
144
144
  assert.deepEqual(Object.keys(handle.section).sort(),
145
- ['defaultVisible', 'id', 'lines', 'placement', 'rowLabel', 'title'],
145
+ ['defaultVisible', 'id', 'lines', 'meta', 'placement', 'rowLabel', 'title'],
146
146
  'the section is exactly the shape the bridge registers');
147
147
  assert.equal(typeof handle.invalidate, 'function', 'the session boundary has its seam');
148
148
  });
@@ -562,3 +562,65 @@ test('S1: the empty line is a state, not a failure: another frame inside the TTL
562
562
  assert.deepEqual(handle.section.lines({}).map((row) => row.label), ['alpha', 'beta', 'gamma', 'delta'],
563
563
  'a list replaces the empty line, and its rows keep their own shape');
564
564
  });
565
+
566
+ // ---------------------------------------------------------------------------
567
+ // S7 (odd-panel-groups): the heading carries the count, like the CHANGES card's
568
+ // `1 file` — `N odd`, lowercase and in the host's muted role.
569
+ // ---------------------------------------------------------------------------
570
+
571
+ test('S7: the heading answers `N odd`, and nothing before a read', async () => {
572
+ const items = [oddItem('alpha', 'main'), oddItem('beta', 'wt-a'), oddItem('gamma', 'main')];
573
+ const handle = createOddRailSection({
574
+ load: async () => items,
575
+ open: () => {},
576
+ schedule: () => {},
577
+ });
578
+
579
+ assert.equal(handle.section.meta({}), undefined, 'no read yet: no count is invented');
580
+ await handle.refresh();
581
+ assert.equal(handle.section.meta({}), '3 odd', 'the count is every ODD the rows are made of');
582
+ assert.equal(typeof handle.section.meta, 'function', 'the host draws it through meta()');
583
+ });
584
+
585
+ test('S7: one ODD and an empty list both read as a lowercase count', async () => {
586
+ const one = createOddRailSection({ load: async () => [oddItem('alpha', 'main')], open: () => {}, schedule: () => {} });
587
+ await one.refresh();
588
+ assert.equal(one.section.meta({}), '1 odd', 'the singular number keeps the same word');
589
+
590
+ const none = createOddRailSection({ load: async () => [], open: () => {}, schedule: () => {} });
591
+ await none.refresh();
592
+ assert.equal(none.section.meta({}), '0 odd', 'an empty section still counts nothing honestly');
593
+ });
594
+
595
+ test('S7: the count is every loaded ODD, not only the four the card can draw', async () => {
596
+ const items = Array.from({ length: 9 }, (_, index) => oddItem(`odd-${index}`, index === 0 ? 'main' : 'wt'));
597
+ const handle = createOddRailSection({ load: async () => items, open: () => {}, schedule: () => {} });
598
+ await handle.refresh();
599
+ assert.equal(handle.section.meta({}), '9 odd', 'the cap on DRAWN rows never caps the count');
600
+ });
601
+
602
+ test('S7: a stale list says so, and a failed first read answers no count', async () => {
603
+ let fail = false;
604
+ const items = [oddItem('alpha', 'main'), oddItem('beta', 'wt-a')];
605
+ const handle = createOddRailSection({ load: async () => { if (fail) throw new Error('read failed'); return items; }, open: () => {}, schedule: () => {} });
606
+ await handle.refresh();
607
+ assert.equal(handle.section.meta({}), '2 odd');
608
+ fail = true;
609
+ await handle.refresh();
610
+ assert.equal(handle.section.meta({}), '2 odd · stale', 'the rows on screen are not live, and the count says so');
611
+
612
+ const broken = createOddRailSection({ load: async () => { throw new Error('read failed'); }, open: () => {}, schedule: () => {} });
613
+ await broken.refresh();
614
+ assert.equal(broken.section.meta({}), undefined, 'no successful read, no count');
615
+ });
616
+
617
+ test('S7: the heading only READS the snapshot — it never starts a load', async () => {
618
+ let reads = 0;
619
+ const handle = createOddRailSection({
620
+ load: async () => { reads += 1; return [oddItem('alpha', 'main')]; },
621
+ open: () => {},
622
+ schedule: () => {},
623
+ });
624
+ assert.equal(handle.section.meta({}), undefined);
625
+ assert.equal(reads, 0, 'a collapsed card draws its heading alone and pays no read for it');
626
+ });