pi-odd-worktree 3.12.0 → 3.12.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.
@@ -1197,6 +1197,22 @@ function createIssuesView(options = {}) {
1197
1197
  });
1198
1198
  }
1199
1199
 
1200
+ // S10a (cross-bucket): every bucket stores its OWN copy of a row, so one write
1201
+ // that closed an issue closed it in every bucket that lists it. Marking only
1202
+ // the bucket on screen left the others painting the pre-write row — and the
1203
+ // pre-write count that row honored — until the reader happened to visit them.
1204
+ // The row keeps its new state where each bucket stores it, so the open-only
1205
+ // filter and every count follow it at once, and `invalidateLoadedPages` still
1206
+ // makes the next visit read GitHub's own answer.
1207
+ function markIssueStateEverywhere(number, nextState) {
1208
+ pages.forEach((page) => {
1209
+ if (!Array.isArray(page.issues)) return;
1210
+ page.issues.forEach((row) => {
1211
+ if (numOf(row) === number) row.state = nextState;
1212
+ });
1213
+ });
1214
+ }
1215
+
1200
1216
  // S21 (T17): a save that changed the VIEWER's own assignment changed which
1201
1217
  // bucket holds the issue, and the answer says so (`self`). Only `assigned`
1202
1218
  // moves: `mine` is authorship and `involved` excludes the viewer's own
@@ -2350,10 +2366,11 @@ function createIssuesView(options = {}) {
2350
2366
  result = { ok: false, error: (err && err.message) || 'action failed' };
2351
2367
  }
2352
2368
  settleSave(result, () => {
2353
- // S10a: the list is open-only, so a closed issue leaves it at once. The
2354
- // row keeps its new state where it is stored, and the open-only filter
2355
- // and every count follow it.
2356
- row.state = 'closed';
2369
+ // S10a: the list is open-only, so a closed issue leaves EVERY bucket that
2370
+ // lists it at once — not only the one on screen. The row keeps its new
2371
+ // state where it is stored, and the open-only filter and every count
2372
+ // follow it.
2373
+ markIssueStateEverywhere(number, 'closed');
2357
2374
  const cached = details.get(number);
2358
2375
  if (cached && cached.issue) cached.issue = { ...cached.issue, state: 'closed' };
2359
2376
  state.mode = 'list';
@@ -215,7 +215,9 @@ function messageCardHeading(customType, body) {
215
215
  /**
216
216
  * The rows of one message card, for one width, rebuilt on every pass: the heading, the whole
217
217
  * body — with no preview budget and no content level in sight — and the closing rule. `floatRows`
218
- * decides the style once, here, from the host's own setting.
218
+ * decides the style once, here, from the host's own setting, and takes the card's identity role so
219
+ * the WHOLE closed box wears it: the top rule alone would leave the sides and the closing rule the
220
+ * theme's plain `border`, a frame that changes colour halfway down the card.
219
221
  */
220
222
  function messageCardRows(customType, lines, paint, metrics, width) {
221
223
  const body = messageCardBody(lines, customType);
@@ -227,7 +229,7 @@ function messageCardRows(customType, lines, paint, metrics, width) {
227
229
  // instruction the agent must read, whatever the conversation's content level says.
228
230
  body: cardBodyRows(body, heading.tone, paint, inner, { expanded: true }, metrics),
229
231
  bottom: cardBottom(heading.tone, paint, inner, undefined, metrics),
230
- }));
232
+ }), heading.railRole);
231
233
  }
232
234
 
233
235
  /**
package/lib/prs-view.js CHANGED
@@ -931,6 +931,22 @@ function createPrsView(options = {}) {
931
931
  });
932
932
  }
933
933
 
934
+ // S10a (cross-bucket): every bucket stores its OWN copy of a row, so a close
935
+ // GitHub accepted closed the pull request in every bucket that lists it.
936
+ // Marking only the bucket on screen left the others painting the pre-write row
937
+ // — and the pre-write count that row honored — until the reader happened to
938
+ // visit them. The row keeps its new state where each bucket stores it, so the
939
+ // open-only filter and every count follow it at once, and
940
+ // `invalidateLoadedPages` still makes the next visit read GitHub's answer.
941
+ function markPullRequestStateEverywhere(number, nextState) {
942
+ pages.forEach((page) => {
943
+ if (!Array.isArray(page.rows)) return;
944
+ page.rows.forEach((row) => {
945
+ if (numOf(row) === number) row.state = nextState;
946
+ });
947
+ });
948
+ }
949
+
934
950
  function listTitle(row) {
935
951
  return String((row && row.title) || '');
936
952
  }
@@ -2259,8 +2275,9 @@ function createPrsView(options = {}) {
2259
2275
  notOpen: `pull request #${number} is not open; it cannot be closed`,
2260
2276
  });
2261
2277
  settleCaptured(gate.then((verdict) => (verdict.ok === true ? runSeam(closePull, number) : verdict)), () => {
2262
- const closed = filteredRows().find((candidate) => numOf(candidate) === number);
2263
- if (closed) closed.state = 'closed';
2278
+ // S10a: a closed pull request leaves EVERY bucket that lists it at once,
2279
+ // not only the one on screen.
2280
+ markPullRequestStateEverywhere(number, 'closed');
2264
2281
  const cached = details.get(number);
2265
2282
  if (cached && cached.pullRequest) cached.pullRequest = { ...cached.pullRequest, state: 'closed' };
2266
2283
  state.mode = 'list';
@@ -2315,8 +2332,9 @@ function createPrsView(options = {}) {
2315
2332
  }
2316
2333
  return runSeam(merge, number, payload);
2317
2334
  }), () => {
2318
- const target = filteredRows().find((candidate) => numOf(candidate) === number);
2319
- if (target) target.state = 'closed';
2335
+ // S10a: a merged pull request is a closed one, so it leaves every bucket
2336
+ // that lists it — the same cross-bucket rule the close follows.
2337
+ markPullRequestStateEverywhere(number, 'closed');
2320
2338
  mergeDraft = null;
2321
2339
  state.mode = 'list';
2322
2340
  actionError = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-odd-worktree",
3
- "version": "3.12.0",
3
+ "version": "3.12.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",
@@ -143,6 +143,7 @@ function makeView(opts = {}) {
143
143
  loadIssue: opts.loadIssue,
144
144
  loadPages: opts.loadPages,
145
145
  loadIssuePage: opts.loadIssuePage,
146
+ prefetchBuckets: opts.prefetchBuckets,
146
147
  loadLabels: opts.loadLabels,
147
148
  loadAssignees: opts.loadAssignees,
148
149
  assigned: opts.assigned,
@@ -3517,6 +3518,51 @@ describe('issues view pending writes and comment caret (S10/S11)', () => {
3517
3518
  assert.match(leftColumn(view, 100), /issue title 2/, 'the remaining open issue stays listed');
3518
3519
  });
3519
3520
 
3521
+ test('a close drops the issue from every bucket that lists it, not only the one on screen (S10a)', async () => {
3522
+ // The interactive host prefetches every tab, so each bucket stores its OWN
3523
+ // copy of the same issue. One close on GitHub closes it in all of them, and
3524
+ // a bucket that still paints its pre-write copy — and its pre-write count —
3525
+ // until the reader happens to visit it is showing the reader a lie.
3526
+ const closed = new Set();
3527
+ const buckets = {
3528
+ mine: [issue(1), issue(2)],
3529
+ assigned: [issue(1), issue(3), issue(4), issue(5)],
3530
+ involved: [],
3531
+ };
3532
+ const idOf = { p0: 'mine', p1: 'assigned', p2: 'involved' };
3533
+ const { view } = makeView({
3534
+ pages: [
3535
+ { id: 'p0', label: 'My issues' },
3536
+ { id: 'p1', label: 'Assigned' },
3537
+ { id: 'p2', label: 'Involved' },
3538
+ ],
3539
+ prefetchBuckets: true,
3540
+ loadIssuePage: (request) => pageResult(
3541
+ (buckets[idOf[request.bucketId]] || []).filter((row) => !closed.has(row.number)),
3542
+ ),
3543
+ loadIssue: (n) => ({ ok: true, issue: issue(n, { permissions: EDITABLE }), comments: [] }),
3544
+ actions: { setState: (number) => { closed.add(number); return { ok: true }; } },
3545
+ });
3546
+ await tick();
3547
+ assert.match(strip(view.render(100).join('\n')), /Assigned \(4\)/, 'the fixture lists #1 in both buckets');
3548
+ view.handleInput('x');
3549
+ view.handleInput('enter');
3550
+ await tick();
3551
+ const tabs = strip(view.render(100).join('\n'));
3552
+ assert.match(tabs, /My issues \(1\)/, 'the bucket on screen drops it at once');
3553
+ assert.match(tabs, /Assigned \(3\)/, 'the other bucket that lists it follows without waiting for a visit');
3554
+ // Walking to that bucket never paints the closed issue again: not while its
3555
+ // own read is in flight, and not after the answer lands.
3556
+ view.handleInput('right');
3557
+ const whileReading = leftColumn(view, 100);
3558
+ assert.ok(!whileReading.includes('issue title 1'), 'the stale copy is gone before the read lands');
3559
+ assert.match(whileReading, /issue title 3/, 'the open rows of that bucket stay painted meanwhile');
3560
+ await tick();
3561
+ const settled = leftColumn(view, 100);
3562
+ assert.ok(!settled.includes('issue title 1'), 'the fresh answer agrees with the local edit');
3563
+ assert.match(settled, /issue title 5/);
3564
+ });
3565
+
3520
3566
  test('a failed save keeps the draft and its error, and the view is usable again', async () => {
3521
3567
  const gate = deferred();
3522
3568
  const calls = [];
@@ -504,6 +504,34 @@ test('both cards are informational and wear the accent on the frame and the name
504
504
  assert.ok(!reminder[0].includes('<warning>'), 'nothing on a reminder card is painted as a warning');
505
505
  });
506
506
 
507
+ test('the whole closed box wears the identity role: the sides and the closing rule too', () => {
508
+ const outcome = registered();
509
+ // The card names ONE role for its box (`accent`, S5), and the substrate paints the box — the top
510
+ // rule, every body row's two sides and the closing rule — in that role. Only the top rule wearing
511
+ // it leaves the frame brighter at the heading and dimmer around the body, which reads as a colour
512
+ // that stops halfway down the card.
513
+ const budget = designFor(outcome, EXPLORATION).apply(plainBody(EXPLORATION, STARTED), { width: 70, customType: EXPLORATION, theme: taggedTheme, render: { expanded: false, outputPad: 1, message: {} } });
514
+ assert.ok(budget.length >= 4, 'a heading, at least one body row and the closing rule');
515
+ for (const row of budget) {
516
+ assert.ok(!row.includes('<border>'), `no cell of the frame falls back to the plain border: ${row}`);
517
+ }
518
+ assert.ok(budget[0].includes('<accent>╭'), budget[0]);
519
+ assert.ok(budget[0].includes('<accent>╮'), budget[0]);
520
+ for (const row of budget.slice(1, -1)) {
521
+ assert.ok(row.startsWith('<accent>│</accent>'), `the left side wears the identity role: ${row}`);
522
+ assert.ok(row.endsWith('<accent>│</accent>'), `the right side wears the identity role: ${row}`);
523
+ }
524
+ assert.ok(budget[budget.length - 1].startsWith('<accent>╰'), 'the closing rule wears the identity role');
525
+ assert.ok(budget[budget.length - 1].endsWith('╯</accent>'), budget[budget.length - 1]);
526
+ // The same rule in float, where the box is two rails and no corner: nothing may fall back either.
527
+ globalThis[CARD_STYLE_SLOT] = CARD_STYLE.FLOAT;
528
+ const float = designFor(outcome, VERIFIER).apply(plainBody(VERIFIER, VERIFIER_TEXT), { width: 70, customType: VERIFIER, theme: { fg: taggedTheme.fg, bg: bandTheme.bg }, render: { expanded: false, outputPad: 1, message: {} } });
529
+ for (const row of float) assert.ok(!row.includes('<border>'), `no float rail falls back to the plain border: ${row}`);
530
+ assert.ok(float[0].includes('<accent>▎'), 'the float heading band wears the identity role');
531
+ assert.ok(float[float.length - 1].includes('<accent>▎'), 'so does the closing row');
532
+ assert.ok(!float.join('\n').includes('<warning>'), 'a reminder is still no warning');
533
+ });
534
+
507
535
  test('every row fits the width the host asked for, at narrow and wide terminals, in both styles', () => {
508
536
  const outcome = registered();
509
537
  for (const style of [CARD_STYLE.NEON, CARD_STYLE.FLOAT]) {
@@ -1805,3 +1805,85 @@ describe('S6: a move over a linked issue number highlights it', () => {
1805
1805
  'a move onto the separator clears the hover');
1806
1806
  });
1807
1807
  });
1808
+
1809
+ // ---------------------------------------------------------------------------
1810
+ // S10a: a write that closed a pull request closed it in EVERY bucket that lists
1811
+ // it, so no bucket keeps painting the pre-write row or its pre-write count until
1812
+ // the reader happens to visit it.
1813
+ // ---------------------------------------------------------------------------
1814
+ describe('prs view close reaches every bucket (S10a)', () => {
1815
+ test('a close drops the pull request from every bucket that lists it, not only the one on screen', async () => {
1816
+ const closed = new Set();
1817
+ const buckets = {
1818
+ mine: [pullRequest(87), pullRequest(88)],
1819
+ review: [pullRequest(87), pullRequest(89), pullRequest(90)],
1820
+ involved: [],
1821
+ };
1822
+ const { view } = makeView({
1823
+ prefetchBuckets: true,
1824
+ loadPullRequestPage: (request) => {
1825
+ const rows = (buckets[request.bucketId] || []).filter((row) => !closed.has(row.number));
1826
+ return { ok: true, rows, totalCount: rows.length, hasMore: false, cursor: null };
1827
+ },
1828
+ loadPullRequest: (number) => ({
1829
+ ok: true,
1830
+ pullRequest: pullRequest(number, { permissions: EDITABLE }),
1831
+ comments: [],
1832
+ }),
1833
+ actions: { close: (number) => { closed.add(number); return { ok: true }; } },
1834
+ });
1835
+ await tick();
1836
+ assert.match(strip(view.render(150).join('\n')), /Needs My Review \(3\)/, 'the fixture lists #87 in both buckets');
1837
+ view.handleInput('x');
1838
+ view.handleInput('enter');
1839
+ await tick();
1840
+ const tabs = strip(view.render(150).join('\n'));
1841
+ assert.match(tabs, /My Pull Request \(1\)/, 'the bucket on screen drops it at once');
1842
+ assert.match(tabs, /Needs My Review \(2\)/, 'the other bucket that lists it follows without waiting for a visit');
1843
+ // Walking to that bucket never paints the closed pull request again: not
1844
+ // while its own read is in flight, and not after the answer lands.
1845
+ view.handleInput('tab');
1846
+ const whileReading = leftOf(view, 150);
1847
+ assert.ok(!whileReading.includes('pull request 87'), 'the stale copy is gone before the read lands');
1848
+ assert.match(whileReading, /pull request 89/, 'the open rows of that bucket stay painted meanwhile');
1849
+ await tick();
1850
+ const settled = leftOf(view, 150);
1851
+ assert.ok(!settled.includes('pull request 87'), 'the fresh answer agrees with the local edit');
1852
+ assert.match(settled, /pull request 90/);
1853
+ });
1854
+
1855
+ test('a merge drops the pull request from every bucket that lists it, not only the one on screen', async () => {
1856
+ const closed = new Set();
1857
+ const buckets = {
1858
+ mine: [pullRequest(87), pullRequest(88)],
1859
+ review: [pullRequest(87), pullRequest(89), pullRequest(90)],
1860
+ involved: [],
1861
+ };
1862
+ const { view } = makeView({
1863
+ prefetchBuckets: true,
1864
+ loadPullRequestPage: (request) => {
1865
+ const rows = (buckets[request.bucketId] || []).filter((row) => !closed.has(row.number));
1866
+ return { ok: true, rows, totalCount: rows.length, hasMore: false, cursor: null };
1867
+ },
1868
+ loadPullRequest: (number) => ({
1869
+ ok: true,
1870
+ pullRequest: pullRequest(number, { permissions: EDITABLE }),
1871
+ comments: [],
1872
+ }),
1873
+ actions: { merge: (number) => { closed.add(number); return { ok: true }; } },
1874
+ });
1875
+ await tick();
1876
+ assert.match(strip(view.render(150).join('\n')), /Needs My Review \(3\)/, 'the fixture lists #87 in both buckets');
1877
+ view.handleInput('m');
1878
+ view.handleInput('ctrl+s');
1879
+ await tick();
1880
+ const tabs = strip(view.render(150).join('\n'));
1881
+ assert.match(tabs, /My Pull Request \(1\)/, 'the bucket on screen drops it at once');
1882
+ assert.match(tabs, /Needs My Review \(2\)/, 'the other bucket that lists it follows without waiting for a visit');
1883
+ view.handleInput('tab');
1884
+ const whileReading = leftOf(view, 150);
1885
+ assert.ok(!whileReading.includes('pull request 87'), 'the stale copy is gone before the read lands');
1886
+ await tick();
1887
+ assert.ok(!leftOf(view, 150).includes('pull request 87'), 'the fresh answer agrees with the local edit');
1888
+ });
1889
+ });