pi-odd-worktree 3.11.2 → 3.12.1
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.
- package/README.md +6 -4
- package/extensions/odd-worktree-tools.ts +1175 -39
- package/lib/issues-view.js +21 -4
- package/lib/odd-group.js +655 -0
- package/lib/odd-listing.js +349 -0
- package/lib/odd-rail-model.js +150 -0
- package/lib/odd-rail-section.js +453 -0
- package/lib/odd-session.js +231 -0
- package/lib/odd-view.js +500 -46
- package/lib/prs-view.js +22 -4
- package/package.json +1 -1
- package/tools/commands.test.js +58 -0
- package/tools/issues-command.test.js +13 -2
- package/tools/issues-open-guard.test.js +7 -1
- package/tools/issues-section.test.js +11 -2
- package/tools/issues-view.test.js +46 -0
- package/tools/odd-group.test.js +950 -0
- package/tools/odd-listing.test.js +504 -0
- package/tools/odd-panel-wiring.test.js +1868 -0
- package/tools/odd-rail-model.test.js +184 -0
- package/tools/odd-rail-section.test.js +524 -0
- package/tools/odd-rail-wiring.test.js +572 -0
- package/tools/odd-session-wiring.test.js +419 -0
- package/tools/odd-session.test.js +282 -0
- package/tools/odd-view.test.js +407 -1
- package/tools/package-surface.test.js +22 -6
- package/tools/prs-command.test.js +1 -1
- package/tools/prs-view.test.js +82 -0
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
|
-
|
|
2263
|
-
|
|
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
|
-
|
|
2319
|
-
|
|
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.
|
|
3
|
+
"version": "3.12.1",
|
|
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",
|
package/tools/commands.test.js
CHANGED
|
@@ -488,6 +488,64 @@ describe('/odd', () => {
|
|
|
488
488
|
await commands.get('odd').handler('nope', makeCtx(makeRepo()));
|
|
489
489
|
assert.deepEqual(notifications, [['error', 'Unknown option "nope". Use /odd.']]);
|
|
490
490
|
});
|
|
491
|
+
|
|
492
|
+
// S6 (T4): ONE optional target. An absolute `odd/tasks/*.md` and a bare ODD
|
|
493
|
+
// name that the scan knows are opened instead of refused; every other shape
|
|
494
|
+
// keeps the sentence above, verbatim. There is no overlay here (the ctx offers
|
|
495
|
+
// no `custom`), so an accepted target is observable as the absence of that
|
|
496
|
+
// sentence and the degraded menu's own one muted line.
|
|
497
|
+
test('an absolute target directly under odd/tasks is accepted', async () => {
|
|
498
|
+
const repo = makeRepo();
|
|
499
|
+
const target = path.join(repo, 'odd', 'tasks', 'feature.md');
|
|
500
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
501
|
+
fs.writeFileSync(target, '# Feature\n');
|
|
502
|
+
notifications.length = 0;
|
|
503
|
+
await commands.get('odd').handler(target, makeCtx(repo));
|
|
504
|
+
assert.deepEqual(notifications, [
|
|
505
|
+
['info', 'odd: 1 document(s) under odd/tasks/ (the viewer needs an interactive session)'],
|
|
506
|
+
]);
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
test('a bare ODD name that exists is accepted', async () => {
|
|
510
|
+
const repo = makeRepo();
|
|
511
|
+
fs.mkdirSync(path.join(repo, 'odd', 'tasks'), { recursive: true });
|
|
512
|
+
fs.writeFileSync(path.join(repo, 'odd', 'tasks', 'feature.md'), '# Feature\n');
|
|
513
|
+
notifications.length = 0;
|
|
514
|
+
await commands.get('odd').handler('feature', makeCtx(repo));
|
|
515
|
+
assert.deepEqual(notifications, [
|
|
516
|
+
['info', 'odd: 1 document(s) under odd/tasks/ (the viewer needs an interactive session)'],
|
|
517
|
+
]);
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
test('every shape that is not a target keeps the refusal verbatim', async () => {
|
|
521
|
+
const repo = makeRepo();
|
|
522
|
+
const tasks = path.join(repo, 'odd', 'tasks');
|
|
523
|
+
fs.mkdirSync(path.join(tasks, 'nested'), { recursive: true });
|
|
524
|
+
fs.writeFileSync(path.join(tasks, 'feature.md'), '# Feature\n');
|
|
525
|
+
fs.writeFileSync(path.join(tasks, 'nested', 'deep.md'), '# Deep\n');
|
|
526
|
+
fs.writeFileSync(path.join(tasks, 'notes.txt'), 'notes\n');
|
|
527
|
+
fs.writeFileSync(path.join(tasks, '.hidden.md'), '# Hidden\n');
|
|
528
|
+
const refused = [
|
|
529
|
+
// a flag is never a target
|
|
530
|
+
'--nope',
|
|
531
|
+
// a name the scan does not know
|
|
532
|
+
'missing-odd',
|
|
533
|
+
// relative, nested, another extension, a dotfile, a missing document
|
|
534
|
+
'odd/tasks/feature.md',
|
|
535
|
+
path.join(tasks, 'nested', 'deep.md'),
|
|
536
|
+
path.join(tasks, 'notes.txt'),
|
|
537
|
+
path.join(tasks, '.hidden.md'),
|
|
538
|
+
path.join(tasks, 'absent.md'),
|
|
539
|
+
// a real `.md` outside an `odd/tasks` directory
|
|
540
|
+
path.join(repo, 'README.md'),
|
|
541
|
+
path.join(repo, 'odd', 'README.md'),
|
|
542
|
+
];
|
|
543
|
+
for (const raw of refused) {
|
|
544
|
+
notifications.length = 0;
|
|
545
|
+
await commands.get('odd').handler(raw, makeCtx(repo));
|
|
546
|
+
assert.deepEqual(notifications, [['error', `Unknown option "${raw}". Use /odd.`]], raw);
|
|
547
|
+
}
|
|
548
|
+
});
|
|
491
549
|
});
|
|
492
550
|
|
|
493
551
|
// ---------------------------------------------------------------------------
|
|
@@ -1935,7 +1935,13 @@ describe('/issues opens from the rail cache (S8/T4)', () => {
|
|
|
1935
1935
|
schema: 'gentle-shell-bridge/api',
|
|
1936
1936
|
version: 1,
|
|
1937
1937
|
registerRows: () => {},
|
|
1938
|
-
|
|
1938
|
+
// T5 of odd-rail-section: the bridge carries TWO sections now, so this double
|
|
1939
|
+
// records the `GITHUB` one it is about. Every registration still receives a
|
|
1940
|
+
// disposer, so the `ODD` rail registers alongside rather than being refused.
|
|
1941
|
+
registerSection: (section) => {
|
|
1942
|
+
if (section && section.id === 'odd-worktree.issues') registered.push(section);
|
|
1943
|
+
return () => {};
|
|
1944
|
+
},
|
|
1939
1945
|
createStore: () => ({}),
|
|
1940
1946
|
requestRepaint: () => {},
|
|
1941
1947
|
};
|
|
@@ -2560,7 +2566,12 @@ describe('/issues reflects a self-assignment on the panel and the rail (S21/T17)
|
|
|
2560
2566
|
schema: 'gentle-shell-bridge/api',
|
|
2561
2567
|
version: 1,
|
|
2562
2568
|
registerRows: () => {},
|
|
2563
|
-
|
|
2569
|
+
// T5 of odd-rail-section: record the `GITHUB` section this case is about; the
|
|
2570
|
+
// `ODD` rail registers on the same double and is simply not what is read here.
|
|
2571
|
+
registerSection: (section) => {
|
|
2572
|
+
if (section && section.id === 'odd-worktree.issues') registered.push(section);
|
|
2573
|
+
return () => {};
|
|
2574
|
+
},
|
|
2564
2575
|
createStore: () => ({}),
|
|
2565
2576
|
requestRepaint: () => {},
|
|
2566
2577
|
};
|
|
@@ -287,7 +287,13 @@ function installBridge() {
|
|
|
287
287
|
schema: 'gentle-shell-bridge/api',
|
|
288
288
|
version: 1,
|
|
289
289
|
registerRows: () => {},
|
|
290
|
-
|
|
290
|
+
// T5 of odd-rail-section: the bridge carries TWO sections now, so this double
|
|
291
|
+
// records the `GITHUB` one it is about. Every registration still receives a
|
|
292
|
+
// disposer, so the `ODD` rail registers alongside rather than being refused.
|
|
293
|
+
registerSection: (section) => {
|
|
294
|
+
if (section && section.id === 'odd-worktree.issues') registered.push(section);
|
|
295
|
+
return () => {};
|
|
296
|
+
},
|
|
291
297
|
createStore: () => ({}),
|
|
292
298
|
requestRepaint: () => { repaints.push(1); },
|
|
293
299
|
};
|
|
@@ -1477,8 +1477,17 @@ function installBridge() {
|
|
|
1477
1477
|
version: 1,
|
|
1478
1478
|
registerRows: () => {},
|
|
1479
1479
|
registerSection: (section) => {
|
|
1480
|
-
|
|
1481
|
-
|
|
1480
|
+
// T5 of odd-rail-section: the bridge now carries TWO sidebar sections — this
|
|
1481
|
+
// package's `GITHUB` one and its `ODD` one — so a double that recorded every
|
|
1482
|
+
// registration would answer "two sections" to a suite that asserts exactly one
|
|
1483
|
+
// and would hand back the ODD rail wherever it reads the recorded section.
|
|
1484
|
+
// Only what this suite is about is recorded; every registration still receives
|
|
1485
|
+
// its own disposer, so the ODD rail registers and unregisters alongside.
|
|
1486
|
+
if (section && section.id === 'odd-worktree.issues') {
|
|
1487
|
+
registered.push(section);
|
|
1488
|
+
return () => { if (section && section.id === 'odd-worktree.issues') released.push(section); };
|
|
1489
|
+
}
|
|
1490
|
+
return () => {};
|
|
1482
1491
|
},
|
|
1483
1492
|
createStore: () => ({}),
|
|
1484
1493
|
requestRepaint: () => { repaints.push(1); },
|
|
@@ -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 = [];
|