pi-odd-worktree 3.12.4 → 3.14.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.
@@ -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);
@@ -1567,8 +1605,13 @@ test('F3 preserve: a standard single-root repository still paints plain document
1567
1605
  const pending = doOdd(e, '', ctxFor(repo, host, []));
1568
1606
  try {
1569
1607
  await waitFor(() => host.mounts.length === 1, 'the panel mounts');
1570
- assert.deepEqual(rowLabels(host.mounts[0].component), ['main-two', 'main-one'],
1571
- 'unique names keep their exact plain text, in the recency order the panel always used');
1608
+ // The fixture's mtimes are deliberately the OPPOSITE of its rank (T16 depends on that),
1609
+ // and the panel can paint the cheap mtime scan before the ranked listing lands, so the
1610
+ // frame read here has to be the settled one: wait for the rank, then assert it.
1611
+ await waitFor(() => rowLabels(host.mounts[0].component).join('|') === 'main-one|main-two',
1612
+ 'the settled frame is the ranked listing');
1613
+ assert.deepEqual(rowLabels(host.mounts[0].component), ['main-one', 'main-two'],
1614
+ 'unique names keep their exact plain text, in the rank the panel reads');
1572
1615
  } finally {
1573
1616
  await closePanel(host, pending);
1574
1617
  }
@@ -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
+ });
@@ -2472,10 +2472,19 @@ describe('createOddView grouped listing (T9: S10,S11,S13)', () => {
2472
2472
  const rowsOf = (lines) => listCells(lines)
2473
2473
  .map((cell) => cell.trim().replace(/^▸\s*/, ''))
2474
2474
  .filter((cell) => cell !== '');
2475
+ // The focused row's label. The CURSOR is the first cell after the frame's
2476
+ // `│ `, so it sits at index 1 of the pane cell, while a folded group's own
2477
+ // marker is indented past it: a folded header is not mistaken for the cursor
2478
+ // (odd-panel-groups S1 makes every group folded by default).
2475
2479
  const focusedRow = (lines) => {
2476
- const cell = listCells(lines).map((value) => value.trim()).find((value) => value.startsWith('▸'));
2477
- return cell === undefined ? null : cell.replace(/^▸\s*/, '');
2480
+ const cell = listCells(lines).find((value) => value[1] === '▸');
2481
+ return cell === undefined ? null : cell.trim().replace(/^▸\s*/, '');
2478
2482
  };
2483
+ // The list rows as LABELS, with the cursor and the fold marker removed, so a row
2484
+ // reads the same however it is drawn.
2485
+ const labelsOf = (lines) => listCells(lines)
2486
+ .map((cell) => cell.replace(/[▸▾]/g, '').trim().replace(/\s+/g, ' '))
2487
+ .filter((cell) => cell !== '');
2479
2488
  const bodyOf = (lines) => strip(lines.join('\n'));
2480
2489
  const footerOf = (lines) => strip(lines[lines.length - 2]);
2481
2490
 
@@ -2538,54 +2547,52 @@ describe('createOddView grouped listing (T9: S10,S11,S13)', () => {
2538
2547
  assert.ok(!bodyOf(groupedFrame).includes('▾'), 'and no header is painted');
2539
2548
  });
2540
2549
 
2541
- test('S10: a header row per checkout, in order, each followed by its own documents', async () => {
2542
- const view = build({ groups: [MAIN, RAIL] });
2550
+ test('S1: a header row per checkout, in order, and Enter opens each one', async () => {
2551
+ const view = build({ groups: [MAIN, RAIL], initialDoc: '/wt/main/odd/tasks/alpha.md' });
2543
2552
  await tick();
2544
- const lines = view.render(100);
2545
- assert.deepEqual(rowsOf(lines), ['▾ main', 'alpha', 'bravo', '▾ odd-rail', 'delta'],
2546
- 'the main group, its documents, then the worktree group and its documents');
2547
- assert.equal(focusedRow(lines), 'alpha', 'the first DOCUMENT is focused, not the header');
2548
- assert.match(bodyOf(lines), /body of alpha/, 'and its document is the one painted');
2549
- assert.match(bodyOf(lines), /✎ Odd · 3 documents/, 'the title counts the listed documents');
2553
+ assert.deepEqual(labelsOf(view.render(100)), ['main (2 odd)', 'alpha', 'bravo', 'odd-rail (1 odd)'],
2554
+ 'main first with its documents, then the worktree group, still folded');
2555
+ // From alpha, two steps reach the odd-rail header; Enter opens it.
2556
+ view.handleInput('down');
2557
+ view.handleInput('down');
2558
+ view.handleInput('enter');
2559
+ assert.deepEqual(labelsOf(view.render(100)), ['main (2 odd)', 'alpha', 'bravo', 'odd-rail (1 odd)', 'delta'],
2560
+ 'the opened worktree group follows main with its own document');
2550
2561
  });
2551
2562
 
2552
2563
  test('S13: a worktree group with no documents of its own is dropped', async () => {
2553
2564
  const view = build({ groups: [MAIN, RAIL, checkout('odd-fix', '/wt/odd-fix', false, [])] });
2554
2565
  await tick();
2555
2566
  const lines = view.render(100);
2556
- assert.deepEqual(rowsOf(lines), ['▾ main', 'alpha', 'bravo', '▾ odd-rail', 'delta'],
2567
+ assert.deepEqual(labelsOf(lines), ['main (2 odd)', 'odd-rail (1 odd)'],
2557
2568
  'the empty worktree contributes neither header nor rows');
2558
2569
  assert.ok(!bodyOf(lines).includes('odd-fix'), 'and it is never named');
2559
2570
  });
2560
2571
 
2561
- test('S10: Enter on a header collapses the group, hides its documents and keeps the focus on it', async () => {
2572
+ test('S10: Enter on a header opens it, Enter again closes it, and the focus stays on it', async () => {
2562
2573
  const view = build({ groups: [MAIN, RAIL] });
2563
2574
  await tick();
2564
- // Rows: [header main, alpha, bravo, header odd-rail, delta]; the mount
2565
- // focuses alpha (index 1), so two steps reach the worktree header.
2566
- for (let step = 0; step < 2; step += 1) view.handleInput('down');
2567
- assert.equal(focusedRow(view.render(100)), '▾ odd-rail', 'the premise: the header is focused');
2575
+ // The folded default paints two headers; one step reaches the worktree header.
2576
+ view.handleInput('down');
2577
+ assert.equal(focusedRow(view.render(100)), '▸ odd-rail (1 odd)', 'the premise: the folded header is focused');
2568
2578
  view.handleInput('enter');
2569
- const collapsed = view.render(100);
2570
- assert.deepEqual(rowsOf(collapsed), ['▾ main', 'alpha', 'bravo', '▸ odd-rail'],
2571
- 'the header stays and its documents are gone');
2572
- assert.equal(focusedRow(collapsed), '▸ odd-rail', 'the focus stays on the header');
2573
- assert.equal(view.state.index, 3, 'and so does its row');
2574
- assert.ok(!bodyOf(collapsed).includes('delta'), 'the collapsed documents are hidden');
2579
+ const opened = view.render(100);
2580
+ assert.deepEqual(labelsOf(opened), ['main (2 odd)', 'odd-rail (1 odd)', 'delta'], 'its document appears');
2581
+ assert.equal(focusedRow(opened), '▾ odd-rail (1 odd)', 'and the focus stays on the header');
2582
+ assert.equal(view.state.index, 1, 'which is still its row');
2575
2583
  view.handleInput('enter');
2576
- assert.deepEqual(rowsOf(view.render(100)), ['▾ main', 'alpha', 'bravo', '▾ odd-rail', 'delta'],
2577
- 'Enter again reopens it');
2584
+ assert.deepEqual(labelsOf(view.render(100)), ['main (2 odd)', 'odd-rail (1 odd)'], 'Enter again closes it');
2578
2585
  });
2579
2586
 
2580
2587
  test('Enter on a document keeps today\'s no-op: nothing folds and nothing moves', async () => {
2581
- const view = build({ groups: [MAIN, RAIL] });
2588
+ const view = build({ groups: [MAIN, RAIL], initialDoc: '/wt/main/odd/tasks/alpha.md' });
2582
2589
  await tick();
2583
2590
  view.handleInput('down');
2584
2591
  const before = view.render(100);
2585
2592
  assert.equal(focusedRow(before), 'bravo', 'the premise: a document is focused');
2586
2593
  view.handleInput('enter');
2587
2594
  const after = view.render(100);
2588
- assert.deepEqual(rowsOf(after), rowsOf(before), 'no group folded around the focused document');
2595
+ assert.deepEqual(labelsOf(after), labelsOf(before), 'no group folded around the focused document');
2589
2596
  assert.equal(view.state.index, 2, 'and the selection did not move');
2590
2597
  });
2591
2598
 
@@ -2663,12 +2670,15 @@ describe('createOddView grouped listing (T9: S10,S11,S13)', () => {
2663
2670
  });
2664
2671
 
2665
2672
  test('S11: the reloaded grouping re-applies the selection when the document is still there', async () => {
2666
- const view = build({ groups: [MAIN, RAIL], onToggleAll: () => {} });
2673
+ const view = build({
2674
+ groups: [MAIN, RAIL],
2675
+ initialDoc: '/wt/odd-rail/odd/tasks/delta.md',
2676
+ onToggleAll: () => {},
2677
+ });
2667
2678
  await tick();
2668
- for (let step = 0; step < 3; step += 1) view.handleInput('down');
2669
2679
  assert.equal(focusedRow(view.render(100)), 'delta', 'the premise: delta is the document being read');
2670
2680
  // The caller answered the `a` toggle with every worktree: delta is still
2671
- // there, in a different place of a longer listing.
2681
+ // there, in a longer listing, and its group is still the one open.
2672
2682
  view.applyGroups([
2673
2683
  MAIN,
2674
2684
  checkout('odd-rail', '/wt/odd-rail', false, [
@@ -2678,7 +2688,7 @@ describe('createOddView grouped listing (T9: S10,S11,S13)', () => {
2678
2688
  ]);
2679
2689
  await tick();
2680
2690
  const lines = view.render(100);
2681
- assert.deepEqual(rowsOf(lines), ['▾ main', 'alpha', 'bravo', '▾ odd-rail', 'zulu', 'delta']);
2691
+ assert.deepEqual(labelsOf(lines), ['main (2 odd)', 'odd-rail (2 odd)', 'zulu', 'delta']);
2682
2692
  assert.equal(focusedRow(lines), 'delta', 'the reader keeps the SAME document');
2683
2693
  assert.match(bodyOf(lines), /body of delta/, 'and its pane is still the one being read');
2684
2694
  });
@@ -2705,10 +2715,88 @@ describe('createOddView grouped listing (T9: S10,S11,S13)', () => {
2705
2715
  await tick();
2706
2716
  const lines = view.render(100);
2707
2717
  assert.equal(focusedRow(lines), 'delta', 'the highlight is on the requested document row');
2708
- assert.equal(view.state.index, 3, 'across the group it lives in');
2718
+ assert.equal(view.state.index, 2, 'across the group it lives in, which is the only one open');
2709
2719
  assert.match(bodyOf(lines), /body of delta/, 'the right pane starts on the requested document');
2710
2720
  assert.equal(view.state.scroll, 0, 'and at the top of it');
2711
2721
  });
2722
+
2723
+ // -------------------------------------------------------------------------
2724
+ // odd-panel-groups (S1-S5): the panel OPENS folded, expands the ONE group the
2725
+ // requested ODD lives in, aligns a document's text with its group's text and
2726
+ // counts every group and the whole listing.
2727
+ // -------------------------------------------------------------------------
2728
+ test('S1: every group opens folded, with no document row painted', async () => {
2729
+ const view = build({ groups: [MAIN, RAIL] });
2730
+ await tick();
2731
+ const lines = view.render(100);
2732
+ assert.deepEqual(labelsOf(lines), ['main (2 odd)', 'odd-rail (1 odd)'],
2733
+ 'the two headers and nothing under them');
2734
+ assert.equal(view.state.index, 0, 'the cursor opens on the first header');
2735
+ assert.equal(listCells(lines)[0][1], '▸', 'drawn as the focused row');
2736
+ assert.match(bodyOf(lines), /enter opens this group/, 'and the pane says how to open one');
2737
+ });
2738
+
2739
+ test('S2: the requested document expands its OWN group only, and is selected', async () => {
2740
+ const view = build({ groups: [MAIN, RAIL], initialDoc: '/wt/odd-rail/odd/tasks/delta.md' });
2741
+ await tick();
2742
+ const lines = view.render(100);
2743
+ assert.deepEqual(labelsOf(lines), ['main (2 odd)', 'odd-rail (1 odd)', 'delta'],
2744
+ 'main stays folded; the group of the requested ODD is the only one open');
2745
+ assert.equal(focusedRow(lines), 'delta', 'and its document is the selection');
2746
+ assert.match(bodyOf(lines), /body of delta/, 'the pane is on it');
2747
+ });
2748
+
2749
+ test('S2: a request for a document of main expands main and leaves the worktree folded', async () => {
2750
+ const view = build({ groups: [MAIN, RAIL], initialDoc: '/wt/main/odd/tasks/bravo.md' });
2751
+ await tick();
2752
+ const lines = view.render(100);
2753
+ assert.deepEqual(labelsOf(lines), ['main (2 odd)', 'alpha', 'bravo', 'odd-rail (1 odd)'],
2754
+ 'main is open, the worktree group stays closed');
2755
+ assert.equal(focusedRow(lines), 'bravo');
2756
+ });
2757
+
2758
+ test('S1: Enter opens the focused group and closes it again', async () => {
2759
+ const view = build({ groups: [MAIN, RAIL] });
2760
+ await tick();
2761
+ view.handleInput('enter');
2762
+ assert.deepEqual(labelsOf(view.render(100)), ['main (2 odd)', 'alpha', 'bravo', 'odd-rail (1 odd)'],
2763
+ 'Enter on the folded header opens that group only');
2764
+ view.handleInput('enter');
2765
+ assert.deepEqual(labelsOf(view.render(100)), ['main (2 odd)', 'odd-rail (1 odd)'],
2766
+ 'Enter again closes it');
2767
+ });
2768
+
2769
+ test('S3: a document reads at the column its group name starts at', async () => {
2770
+ const view = build({ groups: [MAIN, RAIL], initialDoc: '/wt/main/odd/tasks/alpha.md' });
2771
+ await tick();
2772
+ const cells = listCells(view.render(100));
2773
+ const header = cells.find((cell) => cell.includes('main (2 odd)'));
2774
+ const child = cells.find((cell) => cell.includes('alpha'));
2775
+ assert.ok(header !== undefined && child !== undefined, 'both rows are painted');
2776
+ assert.equal(child.indexOf('alpha'), header.indexOf('main'),
2777
+ 'the document starts at the column the group name starts at');
2778
+ assert.ok(header.indexOf('main') > 2, 'and the disclosure marker keeps a column of its own');
2779
+ });
2780
+
2781
+ test('S4/S5: each header carries its count and the title sums every group', async () => {
2782
+ const view = build({ groups: [MAIN, RAIL], initialDoc: '/wt/main/odd/tasks/alpha.md' });
2783
+ await tick();
2784
+ const text = bodyOf(view.render(100));
2785
+ assert.match(text, /▾ main \(2 odd\)/, 'the main group names how many it lists');
2786
+ assert.match(text, /▸ odd-rail \(1 odd\)/, 'and so does the folded worktree group');
2787
+ assert.match(text, /✎ Odd · 3 documents/, '2 of main + 1 of the worktree = 3, never 2');
2788
+ });
2789
+
2790
+ test('S4: a group with one document says `1 odd`, never `1 odds`', async () => {
2791
+ const view = build({
2792
+ groups: [checkout('main', '/wt/main', true, [groupDoc('alpha')]), RAIL],
2793
+ initialDoc: '/wt/main/odd/tasks/alpha.md',
2794
+ });
2795
+ await tick();
2796
+ const text = bodyOf(view.render(100));
2797
+ assert.match(text, /▾ main \(1 odd\)/);
2798
+ assert.ok(!text.includes('odds'), 'the count is `odd` at every size');
2799
+ });
2712
2800
  });
2713
2801
 
2714
2802
  // ---------------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
- // S4 surface: the standalone package always registers /warp, /odd, /files
3
- // and /issues plus the TWO agent worktree tools (S3/S4: `worktree_delete` and
2
+ // S4 surface: the standalone package always registers /warp, /odd, /files,
3
+ // /issues and /identity plus the TWO agent worktree tools (S3/S4: `worktree_delete` and
4
4
  // `worktree_warp` are not registered, so `/warp` is the only front that moves
5
5
  // the session and the panel's ctrl+d the only one that removes a checkout),
6
6
  // loads in plain Pi with git as its only external dependency, and ships none of
@@ -13,9 +13,10 @@
13
13
  // worktree↔issue association.
14
14
  //
15
15
  // The bash activity is not a preference here: it is a design on gentle-shell-bridge's
16
- // own `Card activity` line, so the shipped surface is exactly five commands, two tools, TWO
16
+ // own `Card activity` line, so the shipped surface is exactly six commands, two tools, TWO
17
17
  // sidebar sections, one tools design and the one `Cards` row group the two file-card
18
- // switches carry.
18
+ // switches carry. `/identity` is the name the person stores for their own prompt card and
19
+ // the orchestrator prompt: transversal like `/files`, so no module switch gates it.
19
20
  //
20
21
  // Everything here reads the observable surface: the registered command and
21
22
  // tool objects, the manifest, the files on disk. No internal state is read.
@@ -85,11 +86,11 @@ describe('manifest', () => {
85
86
  });
86
87
 
87
88
  describe('registration', () => {
88
- test('registers /warp, /odd, /files, /issues, /prs and the two worktree tools', async () => {
89
+ test('registers /warp, /odd, /files, /issues, /prs, /identity and the two worktree tools', async () => {
89
90
  delete process.env.GENTLE_WORKTREE_THREAD;
90
91
  const { commands, tools, messageRenderers } = await loadExtension({});
91
92
  const registered = [...commands.keys()].sort();
92
- assert.deepEqual(registered, ['files', 'issues', 'odd', 'prs', 'warp'], 'the command list is exactly the five panels');
93
+ assert.deepEqual(registered, ['files', 'identity', 'issues', 'odd', 'prs', 'warp'], 'the command list is exactly the six panels');
93
94
  assert.deepEqual([...tools.keys()].sort(), ['worktree_create', 'worktree_list'], 'exactly two agent tools');
94
95
  assert.deepEqual([...messageRenderers.keys()], ['worktree-warp']);
95
96
  });