pi-odd-worktree 3.0.0 → 3.0.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/extensions/odd-worktree-tools.ts +39 -12
- package/lib/bash-activity.js +7 -5
- package/lib/files-picker-view.js +22 -17
- package/lib/gh-issues.js +15 -1
- package/package.json +1 -1
- package/tools/bash-activity.test.js +6 -5
- package/tools/bash-design.test.js +3 -1
- package/tools/files-command.test.js +4 -1
- package/tools/files-picker-view.test.js +23 -5
- package/tools/gh-issues.test.js +26 -0
- package/tools/issues-command.test.js +5 -1
- package/tools/issues-section.test.js +40 -0
|
@@ -6515,12 +6515,15 @@ function oddTerminalRows(hostTui) {
|
|
|
6515
6515
|
// behind nvim, so the two screens overlap), frames paint over the editor, and
|
|
6516
6516
|
// keystrokes are split between the two processes.
|
|
6517
6517
|
//
|
|
6518
|
-
// `tui.stop()` is the host's own suspend (the
|
|
6519
|
-
//
|
|
6520
|
-
//
|
|
6521
|
-
//
|
|
6522
|
-
//
|
|
6523
|
-
//
|
|
6518
|
+
// `tui.stop()` is the host's own suspend (the call Pi's interactive `!` command
|
|
6519
|
+
// makes): it restores cooked mode, shows the cursor and detaches terminal input.
|
|
6520
|
+
// It carries `preserveScreen: true`, exactly like Pi's own fullscreen suspend,
|
|
6521
|
+
// because a BARE stop on the alternate screen prints the whole last frame into
|
|
6522
|
+
// the normal buffer (pi-tui `TuiAltScreen.afterTerminalStop`) and that frame
|
|
6523
|
+
// would sit in scrollback above the editor. `tui.start()` plus a forced repaint
|
|
6524
|
+
// take the terminal back — and only after the editor has EXITED, because the
|
|
6525
|
+
// opener resolves when the child SPAWNS. So the child's exit is what the open
|
|
6526
|
+
// waits for; without it Pi would resume painting under a running nvim.
|
|
6524
6527
|
//
|
|
6525
6528
|
// The opener stays the shared `lib/open-external.js` one (fixed argv, honest
|
|
6526
6529
|
// failure result); this wrapper only adds the terminal lifecycle around it. A
|
|
@@ -6562,7 +6565,7 @@ function openExternalSuspended(hostTui, target) {
|
|
|
6562
6565
|
};
|
|
6563
6566
|
try {
|
|
6564
6567
|
if (hostTui && typeof hostTui.stop === "function") {
|
|
6565
|
-
hostTui.stop();
|
|
6568
|
+
hostTui.stop({ preserveScreen: true });
|
|
6566
6569
|
suspended = true;
|
|
6567
6570
|
}
|
|
6568
6571
|
} catch {
|
|
@@ -7594,16 +7597,23 @@ function issuesScopeDriftLine(currentName, pinnedName) {
|
|
|
7594
7597
|
return `the checkout's repository changed since this issue list loaded (now ${issuesScopeLabel(currentName)} instead of ${issuesScopeLabel(pinnedName)}); reopen /issues`;
|
|
7595
7598
|
}
|
|
7596
7599
|
|
|
7597
|
-
// The TUI hands the terminal to another
|
|
7598
|
-
// first, exactly like the odd viewer's editor open
|
|
7599
|
-
// and the overlay fight over the same stdin/renderer. `stop()` is the host's
|
|
7600
|
+
// The TUI hands the terminal to another program: a browser open must give it
|
|
7601
|
+
// up first, exactly like the odd viewer's editor open. `stop()` is the host's
|
|
7600
7602
|
// own suspend; `start()` plus a forced repaint take the terminal back once the
|
|
7601
7603
|
// child has been waited for.
|
|
7604
|
+
//
|
|
7605
|
+
// `preserveScreen: true` is part of that contract, not a detail. Pi's TUI runs
|
|
7606
|
+
// in the alternate screen, and a BARE `stop()` exits it by printing the whole
|
|
7607
|
+
// last frame into the normal buffer (pi-tui `TuiAltScreen.afterTerminalStop`),
|
|
7608
|
+
// so every `o` press stamps one copy of the sidebar into scrollback and the
|
|
7609
|
+
// open reads as a cut. Pi's own suspend passes the same option when it is in
|
|
7610
|
+
// fullscreen mode. A host that is not on the alternate screen ignores it, and a
|
|
7611
|
+
// host without `stop()` keeps the previous behaviour untouched.
|
|
7602
7612
|
function withSuspendedTerminal(hostTui, run) {
|
|
7603
7613
|
let suspended = false;
|
|
7604
7614
|
try {
|
|
7605
7615
|
if (hostTui && typeof hostTui.stop === "function") {
|
|
7606
|
-
hostTui.stop();
|
|
7616
|
+
hostTui.stop({ preserveScreen: true });
|
|
7607
7617
|
suspended = true;
|
|
7608
7618
|
}
|
|
7609
7619
|
} catch {
|
|
@@ -7756,7 +7766,14 @@ async function issuesBrowserRepoIdentity(gh, checkoutRoot, fresh) {
|
|
|
7756
7766
|
}
|
|
7757
7767
|
if (!reported || reported.ok !== true
|
|
7758
7768
|
|| typeof reported.nameWithOwner !== "string" || reported.nameWithOwner.length === 0) {
|
|
7759
|
-
return {
|
|
7769
|
+
return {
|
|
7770
|
+
ok: false,
|
|
7771
|
+
error: (reported && reported.error) || "cannot resolve this checkout's repository",
|
|
7772
|
+
// gh's own verdict when the checkout has no remote at all: nothing to
|
|
7773
|
+
// resolve FROM. The rail draws that as a state; every other caller keeps
|
|
7774
|
+
// the failure sentence it has always shown.
|
|
7775
|
+
...(reported && reported.noRemote === true ? { noRemote: true } : {}),
|
|
7776
|
+
};
|
|
7760
7777
|
}
|
|
7761
7778
|
const normalized = gh.normalizeScopeIdentity(reported.nameWithOwner, process.env);
|
|
7762
7779
|
if (!normalized || normalized.ok !== true) {
|
|
@@ -8720,6 +8737,13 @@ async function loadIssuesSidebar() {
|
|
|
8720
8737
|
resolved = { ok: false, error: issuesSidebarError(err, "cannot resolve this checkout's own repository") };
|
|
8721
8738
|
}
|
|
8722
8739
|
if (!resolved || resolved.ok !== true) {
|
|
8740
|
+
// S12 (T11) parity: a checkout with no remote at all is not a broken read
|
|
8741
|
+
// either — there is no GitHub repository to read from. Its one line is short
|
|
8742
|
+
// and gray, like the non-repository one, and the settled state keeps no
|
|
8743
|
+
// retry timer.
|
|
8744
|
+
if (resolved && resolved.noRemote === true) {
|
|
8745
|
+
return { ok: false, error: ISSUES_SIDEBAR_NOT_GITHUB, errorTone: "dim" };
|
|
8746
|
+
}
|
|
8723
8747
|
return { ok: false, error: (resolved && resolved.error) || "cannot resolve this checkout's own repository" };
|
|
8724
8748
|
}
|
|
8725
8749
|
const identity = resolved.identity;
|
|
@@ -8830,6 +8854,9 @@ async function loadIssuesSidebar() {
|
|
|
8830
8854
|
// `pi.sendUserMessage` returns void by contract, so this reports that the command
|
|
8831
8855
|
// was dispatched, never that a panel opened. Never throws.
|
|
8832
8856
|
const ISSUES_SIDEBAR_NOT_REPOSITORY = "not a git repository";
|
|
8857
|
+
// The same short-line state one step further in: the checkout IS a repository,
|
|
8858
|
+
// but it has no remote, so there is no GitHub repository to read issues from.
|
|
8859
|
+
const ISSUES_SIDEBAR_NOT_GITHUB = "not a GitHub repository";
|
|
8833
8860
|
const ISSUES_PANEL_REFUSAL_ENTRY = "odd-worktree-issues-refusal";
|
|
8834
8861
|
const ISSUES_PANEL_DISPATCH_FAILED = "the host cannot dispatch the /issues command here";
|
|
8835
8862
|
|
package/lib/bash-activity.js
CHANGED
|
@@ -65,10 +65,12 @@ const SHELL_ACTIVITIES = ['destructive', 'checking', 'formatting', 'preparing',
|
|
|
65
65
|
*
|
|
66
66
|
* A mark carries its own gap where a font may paint it wider than the host counts:
|
|
67
67
|
* U+2692 is drawn two cells wide by an emoji-fallback font while the host's width
|
|
68
|
-
* function counts it as one,
|
|
69
|
-
* own second cell
|
|
70
|
-
*
|
|
71
|
-
*
|
|
68
|
+
* function counts it as one, and that font paints a single space after it inside the
|
|
69
|
+
* glyph's own second cell, so a heading with one gap reads `⚒preparing` — the gap is
|
|
70
|
+
* swallowed. Preparing's mark therefore ends in TWO spaces: the first is the one the
|
|
71
|
+
* wide glyph eats, the second is the column the reader sees. Counted and painted width
|
|
72
|
+
* still agree (the host counts the glyph as one column plus two, the terminal paints
|
|
73
|
+
* two columns of glyph plus one visible space).
|
|
72
74
|
*/
|
|
73
75
|
const SHELL_ACTIVITY_IDENTITY = {
|
|
74
76
|
// The error role is the one slot that reads as a warning in every shipped theme,
|
|
@@ -76,7 +78,7 @@ const SHELL_ACTIVITY_IDENTITY = {
|
|
|
76
78
|
destructive: { glyph: '⚠', titleRole: 'error' },
|
|
77
79
|
checking: { glyph: '✓', titleRole: 'mdHeading' },
|
|
78
80
|
formatting: { glyph: '≋', titleRole: 'syntaxFunction' },
|
|
79
|
-
preparing: { glyph: '⚒
|
|
81
|
+
preparing: { glyph: '⚒ ', titleRole: 'syntaxFunction' },
|
|
80
82
|
publishing: { glyph: '↑', titleRole: 'success' },
|
|
81
83
|
versioning: { glyph: '⎇', titleRole: 'warning' },
|
|
82
84
|
codegraph: { glyph: '\u{F01BC}', titleRole: 'mdCode' },
|
package/lib/files-picker-view.js
CHANGED
|
@@ -44,6 +44,12 @@
|
|
|
44
44
|
// that held the file (S39), and the footer legend names the action it performs
|
|
45
45
|
// (S40).
|
|
46
46
|
//
|
|
47
|
+
// Round L22 (S43) gives `enter` back to inserting alone: it is the whole payload
|
|
48
|
+
// rule of S7 on a file row, and on a group row — never inserted, S24 and S38 stand —
|
|
49
|
+
// the Tab selection alone, so with no mark it sends nothing and the panel stays
|
|
50
|
+
// open. Folding belongs to `space` (S10, S32), `shift+space` (S39) and the click
|
|
51
|
+
// (S38) only, which is what the footer's `enter insert` has always said.
|
|
52
|
+
//
|
|
47
53
|
// The shapes it consumes are the module contracts in `odd/tasks/files-picker.md`:
|
|
48
54
|
// `loadEntries()` resolves `{ ok: true, entries } | { ok: false, message }` with
|
|
49
55
|
// entries already changed-first; `loadPreview(path)` resolves one
|
|
@@ -544,14 +550,14 @@ function createFilesPickerView(options = {}) {
|
|
|
544
550
|
}
|
|
545
551
|
|
|
546
552
|
/**
|
|
547
|
-
* space
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
*
|
|
553
|
+
* space folds a group (S10, S32). The cursor rests on a group row — every row of a
|
|
554
|
+
* tree order takes it (S38) — so the row folds itself; on a file row the group
|
|
555
|
+
* folded is the one HOLDING that file, its folder in `tree` and its extension group
|
|
556
|
+
* in `ext`. The toggled group row is then the row the cursor keeps, which is the IDE
|
|
557
|
+
* behaviour the reader asked for and a row that always paints. A file at the
|
|
558
|
+
* repository root has no folder to fold, a non-empty query holds every group open,
|
|
559
|
+
* and the flat `files` order paints no group at all, so the key is inert in all
|
|
560
|
+
* three cases. `enter` never folds (S43).
|
|
555
561
|
*/
|
|
556
562
|
function toggleFocusedGroup() {
|
|
557
563
|
if (order === FLAT_ORDER || query.length > 0) return false;
|
|
@@ -1291,13 +1297,12 @@ function createFilesPickerView(options = {}) {
|
|
|
1291
1297
|
return;
|
|
1292
1298
|
}
|
|
1293
1299
|
if (keyMatches(data, ['enter'])) {
|
|
1294
|
-
//
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
}
|
|
1300
|
+
// S43: enter is ONLY the insert key, in every order. On a file row the payload
|
|
1301
|
+
// is the Tab marks plus the focused file (S7); on a group row it is the Tab
|
|
1302
|
+
// marks alone, and `finish('insert')` sends nothing while none are marked. The
|
|
1303
|
+
// panel never folds here — folding stays on space (S10, S32), shift+space (S39)
|
|
1304
|
+
// and the click (S38).
|
|
1305
|
+
finish('insert');
|
|
1301
1306
|
return;
|
|
1302
1307
|
}
|
|
1303
1308
|
if (keyMatches(data, ['ctrl+e'])) {
|
|
@@ -1371,8 +1376,8 @@ function createFilesPickerView(options = {}) {
|
|
|
1371
1376
|
if (row !== undefined && row.kind === 'group') {
|
|
1372
1377
|
// S38: a click parks the cursor on the group row exactly as on a file row, and
|
|
1373
1378
|
// S10's fold still happens with it, so the reader lands on the row it clicked
|
|
1374
|
-
// and `space
|
|
1375
|
-
// only the focus moves then.
|
|
1379
|
+
// and `space` then has that row (S43 leaves `enter` to insert). A query holds
|
|
1380
|
+
// every group open, so only the focus moves then.
|
|
1376
1381
|
const focused = selectRow(hit.index);
|
|
1377
1382
|
if (query.length > 0) {
|
|
1378
1383
|
if (focused) repaint();
|
package/lib/gh-issues.js
CHANGED
|
@@ -759,6 +759,14 @@ async function runGh(argv, opts = {}) {
|
|
|
759
759
|
|
|
760
760
|
// Failure text for a non-zero `gh` exit: prefer stderr (where gh explains
|
|
761
761
|
// auth and resolution problems), fall back to the bare status.
|
|
762
|
+
// gh's own answer when the checkout has no remote at all: there is nothing to
|
|
763
|
+
// resolve FROM, so it cannot name a repository. It is a STATE of the checkout,
|
|
764
|
+
// not a failure of `gh` (authentication, network, a broken install), and a
|
|
765
|
+
// caller that draws states needs to tell the two apart. Matched on gh's text
|
|
766
|
+
// because that is all gh reports; an unknown wording just degrades to the
|
|
767
|
+
// failure it already was.
|
|
768
|
+
const NO_GIT_REMOTE_PATTERN = /no git remotes/i;
|
|
769
|
+
|
|
762
770
|
function exitError(outcome, what) {
|
|
763
771
|
const stderr = (outcome.stderr || '').trim();
|
|
764
772
|
if (stderr) return `${what}: ${stderr.split('\n')[0].slice(0, 500)}`;
|
|
@@ -1021,7 +1029,13 @@ async function reportedRepoName(opts = {}) {
|
|
|
1021
1029
|
// failure still prevents this gh call).
|
|
1022
1030
|
const repo = await runGh(['repo', 'view', '--json', 'nameWithOwner'], opts);
|
|
1023
1031
|
if (repo.error) return { ok: false, error: repo.error };
|
|
1024
|
-
if (repo.status !== 0)
|
|
1032
|
+
if (repo.status !== 0) {
|
|
1033
|
+
return {
|
|
1034
|
+
ok: false,
|
|
1035
|
+
error: exitError(repo, 'cannot resolve the repository'),
|
|
1036
|
+
...(NO_GIT_REMOTE_PATTERN.test(repo.stderr || '') ? { noRemote: true } : {}),
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1025
1039
|
const parsedRepo = parseJsonBody(repo.stdout, 'gh repo view');
|
|
1026
1040
|
if (!parsedRepo.ok) return parsedRepo;
|
|
1027
1041
|
const reported = parsedRepo.doc && typeof parsedRepo.doc.nameWithOwner === 'string'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-odd-worktree",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.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",
|
|
@@ -70,9 +70,10 @@ test('every activity wears its own mark and a theme role', () => {
|
|
|
70
70
|
checking: { glyph: '✓', titleRole: 'mdHeading' },
|
|
71
71
|
formatting: { glyph: '≋', titleRole: 'syntaxFunction' },
|
|
72
72
|
// U+2692 is painted two cells wide by an emoji-fallback font while the host
|
|
73
|
-
// counts it as one,
|
|
74
|
-
//
|
|
75
|
-
|
|
73
|
+
// counts it as one, and that font eats the space right after it: two gaps are
|
|
74
|
+
// what leaves one VISIBLE column (`⚒ preparing`) while the counted width still
|
|
75
|
+
// matches what the terminal paints.
|
|
76
|
+
preparing: { glyph: '⚒ ', titleRole: 'syntaxFunction' },
|
|
76
77
|
publishing: { glyph: '↑', titleRole: 'success' },
|
|
77
78
|
versioning: { glyph: '⎇', titleRole: 'warning' },
|
|
78
79
|
// The native tool's own mark, so the shell call and the tool read as one card.
|
|
@@ -98,7 +99,7 @@ test('every activity wears its own mark and a theme role', () => {
|
|
|
98
99
|
test('a mark costs one counted column, plus preparing\'s declared gap', () => {
|
|
99
100
|
for (const activity of SHELL_ACTIVITIES) {
|
|
100
101
|
const { glyph } = SHELL_ACTIVITY_IDENTITY[activity];
|
|
101
|
-
assert.equal([...glyph].length, activity === 'preparing' ?
|
|
102
|
+
assert.equal([...glyph].length, activity === 'preparing' ? 3 : 1, `${activity}: one mark, plus its own gaps`);
|
|
102
103
|
assert.equal(glyph.trimStart(), glyph, `${activity}: a mark never starts with its gap`);
|
|
103
104
|
}
|
|
104
105
|
});
|
|
@@ -106,7 +107,7 @@ test('a mark costs one counted column, plus preparing\'s declared gap', () => {
|
|
|
106
107
|
test('the host measures every mark at the width the heading assumes', { skip: visibleWidth ? false : 'requires @earendil-works/pi-tui' }, () => {
|
|
107
108
|
for (const activity of SHELL_ACTIVITIES) {
|
|
108
109
|
const { glyph } = SHELL_ACTIVITY_IDENTITY[activity];
|
|
109
|
-
assert.equal(visibleWidth(glyph), activity === 'preparing' ?
|
|
110
|
+
assert.equal(visibleWidth(glyph), activity === 'preparing' ? 3 : 1, `${activity}: one counted column plus its own gaps`);
|
|
110
111
|
}
|
|
111
112
|
});
|
|
112
113
|
|
|
@@ -37,7 +37,9 @@ describe('the heading', () => {
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
test('the other families get their own mark and word', () => {
|
|
40
|
-
|
|
40
|
+
// `preparing` keeps TWO gaps after U+2692: an emoji-fallback font paints the
|
|
41
|
+
// glyph two cells wide and eats the first space, so one gap would read `⚒preparing`.
|
|
42
|
+
const cases = [['node --test tools/*.test.js', '✓ checking'], ['rm -rf build', '⚠ destructive'], ['git commit -m wip', '⎇ versioning'], ['pnpm install', '⚒ preparing']];
|
|
41
43
|
for (const [command, heading] of cases) {
|
|
42
44
|
const [out] = applyBashActivityHeading([neon(command)], CALL);
|
|
43
45
|
assert.ok(strip(out).includes(heading), `${command} -> ${heading}`);
|
|
@@ -120,7 +120,8 @@ function mountHost({ rows = 40 } = {}) {
|
|
|
120
120
|
const tui = {
|
|
121
121
|
terminal: { rows },
|
|
122
122
|
stopped: false,
|
|
123
|
-
|
|
123
|
+
stops: [],
|
|
124
|
+
stop(options) { tui.stopped = true; events.push('stop'); tui.stops.push(options); },
|
|
124
125
|
start() { tui.stopped = false; events.push('start'); },
|
|
125
126
|
// Pi records the request even while stopped: `requestRender(true)` resets the
|
|
126
127
|
// written-frame state at once and defers only the paint, which is how the
|
|
@@ -594,6 +595,8 @@ describe('the preview and the editor (S12, S14)', () => {
|
|
|
594
595
|
assert.equal(host.tui.stopped, false);
|
|
595
596
|
assert.deepEqual(host.events, ['render:force', 'stop', 'start', 'render:force'],
|
|
596
597
|
'stop arrives after the settle, and the resume repaint is the second forced one');
|
|
598
|
+
assert.deepEqual(host.tui.stops, [{ preserveScreen: true }],
|
|
599
|
+
'the suspend preserves the screen: a bare stop stamps the whole alt-screen frame into scrollback');
|
|
597
600
|
assert.deepEqual(host.renders, [
|
|
598
601
|
{ force: true, stopped: false },
|
|
599
602
|
{ force: true, stopped: false },
|
|
@@ -848,7 +848,8 @@ describe('keys (S4)', () => {
|
|
|
848
848
|
assert.ok(!bodyText(rows).includes('util.ts'), 'every group starts collapsed');
|
|
849
849
|
assert.match(selectedRow(rows), /brand-new\.ts/);
|
|
850
850
|
// S38 replaces S24's "a click folds it without focusing it": the click parks
|
|
851
|
-
// the cursor on the group row AND folds it, so `space
|
|
851
|
+
// the cursor on the group row AND folds it, so `space` has the row (S43 leaves
|
|
852
|
+
// `enter` to insert, and only the Tab marks on a group row).
|
|
852
853
|
assert.deepEqual(view.handleMouse(mouse({ y: BODY_TOP })), { handled: true, render: true });
|
|
853
854
|
rows = rowsOf(view);
|
|
854
855
|
assert.ok(bodyText(rows).includes('cursor.ts'), 'the click opened the folder');
|
|
@@ -1231,16 +1232,29 @@ describe('every row of tree and ext takes the cursor (S38)', () => {
|
|
|
1231
1232
|
view.handleInput('home');
|
|
1232
1233
|
assert.equal(selectedName(rowsOf(view)), 'src');
|
|
1233
1234
|
const before = rowsOf(view);
|
|
1235
|
+
assert.ok(bodyText(before).includes('a.ts'), 'the folder holding the focused file is open (S30)');
|
|
1234
1236
|
const renders = calls.render;
|
|
1235
1237
|
view.handleInput('tab');
|
|
1236
1238
|
assert.deepEqual(rowsOf(view), before, 'tab changes nothing on a group row');
|
|
1237
1239
|
assert.equal(calls.render, renders, 'so it repaints nothing');
|
|
1238
1240
|
assert.ok(!bodyText(rowsOf(view)).includes(SELECTION_MARK), 'and it never marks the group');
|
|
1241
|
+
// S43: enter is only the insert key. With no Tab mark it sends nothing, keeps the
|
|
1242
|
+
// panel open and leaves the group exactly as it found it — never a fold.
|
|
1239
1243
|
view.handleInput('enter');
|
|
1240
1244
|
assert.deepEqual(calls.insert, [], 'enter on a group row inserts nothing');
|
|
1241
1245
|
assert.equal(calls.close, 0, 'and leaves the panel open');
|
|
1242
|
-
|
|
1243
|
-
assert.
|
|
1246
|
+
const after = rowsOf(view);
|
|
1247
|
+
assert.deepEqual(after, before, 'enter folds nothing and repaints nothing else');
|
|
1248
|
+
assert.ok(bodyText(after).includes('a.ts'), 'the folder under the cursor is still open');
|
|
1249
|
+
// S43: with a Tab mark the same row sends the marks alone, once, and closes.
|
|
1250
|
+
view.handleInput('down');
|
|
1251
|
+
assert.equal(selectedName(rowsOf(view)), 'a.ts');
|
|
1252
|
+
view.handleInput('tab');
|
|
1253
|
+
view.handleInput('home');
|
|
1254
|
+
assert.equal(selectedName(rowsOf(view)), 'src', 'the cursor is back on the group row');
|
|
1255
|
+
view.handleInput('enter');
|
|
1256
|
+
assert.deepEqual(calls.insert, [['src/a.ts']], 'the Tab selection alone is the payload');
|
|
1257
|
+
assert.equal(calls.close, 1, 'and the panel closes');
|
|
1244
1258
|
});
|
|
1245
1259
|
|
|
1246
1260
|
test('the preview settles on a group row and the panel stays live', async () => {
|
|
@@ -1333,11 +1347,15 @@ describe('every row of tree and ext takes the cursor (S38)', () => {
|
|
|
1333
1347
|
assert.ok(bodyText(rows).includes('a.ts'), 'the files paint again');
|
|
1334
1348
|
view.handleInput('down');
|
|
1335
1349
|
assert.equal(selectedName(rowsOf(view)), 'a.ts', 'and one step down reaches the first file');
|
|
1336
|
-
//
|
|
1350
|
+
// S43 supersedes S10's "enter also folds": the fold keys are space, shift+space
|
|
1351
|
+
// and the click, so enter on this group row changes nothing and stays open.
|
|
1337
1352
|
view.handleInput('up');
|
|
1338
1353
|
view.handleInput('enter');
|
|
1339
|
-
|
|
1354
|
+
rows = rowsOf(view);
|
|
1355
|
+
assert.ok(bodyText(rows).includes('a.ts'), 'enter leaves the folder under the cursor open');
|
|
1356
|
+
assert.equal(selectedName(rows), 'src', 'and the group row keeps the cursor');
|
|
1340
1357
|
assert.deepEqual(calls.insert, [], 'a group row never inserts');
|
|
1358
|
+
assert.equal(calls.close, 0, 'and the panel stays open');
|
|
1341
1359
|
});
|
|
1342
1360
|
});
|
|
1343
1361
|
|
package/tools/gh-issues.test.js
CHANGED
|
@@ -1190,6 +1190,32 @@ describe('fork scope (S5)', () => {
|
|
|
1190
1190
|
assert.ok(gh.calls.every((call) => call.scoped === false), 'no GH_REPO is injected');
|
|
1191
1191
|
});
|
|
1192
1192
|
|
|
1193
|
+
// gh's `no git remotes` answer is a STATE of the checkout, not a `gh` failure:
|
|
1194
|
+
// there is nothing to resolve from. `reportedRepoName` says which one it is, so
|
|
1195
|
+
// a caller that draws states never has to parse gh's sentence.
|
|
1196
|
+
test('reportedRepoName distinguishes a checkout with no remote from a gh failure', async () => {
|
|
1197
|
+
const checkout = makeCheckout({ remotes: [] });
|
|
1198
|
+
const noRemote = github();
|
|
1199
|
+
ghIssues.setGhRunner(async (bin, argv, opts) => {
|
|
1200
|
+
if (argv[0] === 'repo' && argv[1] === 'view') {
|
|
1201
|
+
return { status: 1, stdout: '', stderr: 'no git remotes found', error: null };
|
|
1202
|
+
}
|
|
1203
|
+
return noRemote.runner(bin, argv, opts);
|
|
1204
|
+
});
|
|
1205
|
+
|
|
1206
|
+
const unresolved = await ghIssues.reportedRepoName({ cwd: checkout, scope: null });
|
|
1207
|
+
assert.equal(unresolved.ok, false);
|
|
1208
|
+
assert.equal(unresolved.noRemote, true, 'the caller can tell this state apart');
|
|
1209
|
+
assert.match(String(unresolved.error), /cannot resolve the repository/, 'and the failure sentence is unchanged');
|
|
1210
|
+
|
|
1211
|
+
const broken = makeCheckout({ remotes: [['origin', 'myfork/project']] });
|
|
1212
|
+
ghIssues.setGhRunner(async () => ({ status: 1, stdout: '', stderr: 'gh: Not logged in', error: null }));
|
|
1213
|
+
const failed = await ghIssues.reportedRepoName({ cwd: broken, scope: null });
|
|
1214
|
+
assert.equal(failed.ok, false);
|
|
1215
|
+
assert.notEqual(failed.noRemote, true, 'a gh failure is never reported as a missing remote');
|
|
1216
|
+
assert.match(String(failed.error), /Not logged in/);
|
|
1217
|
+
});
|
|
1218
|
+
|
|
1193
1219
|
// A cached scope must never outlive a changed remote: the same owner/name on
|
|
1194
1220
|
// a different account is a different repository, and a write would land there.
|
|
1195
1221
|
test('a changed checkout remote is picked up before the next read and the next write', async () => {
|
|
@@ -191,12 +191,14 @@ const stubTui = {
|
|
|
191
191
|
function makeHostTui(rows = 24) {
|
|
192
192
|
const paints = [];
|
|
193
193
|
const lifecycle = [];
|
|
194
|
+
const stops = [];
|
|
194
195
|
return {
|
|
195
196
|
paints,
|
|
196
197
|
lifecycle,
|
|
198
|
+
stops,
|
|
197
199
|
tui: {
|
|
198
200
|
terminal: { rows },
|
|
199
|
-
stop: () => lifecycle.push('stop'),
|
|
201
|
+
stop: (options) => { lifecycle.push('stop'); stops.push(options); },
|
|
200
202
|
start: () => lifecycle.push('start'),
|
|
201
203
|
requestRender: (force) => { lifecycle.push('render'); paints.push(force === true); },
|
|
202
204
|
},
|
|
@@ -1202,6 +1204,8 @@ describe('/issues actions (S3,S4)', () => {
|
|
|
1202
1204
|
assert.ok(!gitCalls[0].argv.join(' ').includes('xdg-open'), 'never an invented opener');
|
|
1203
1205
|
assert.deepEqual(run.host.lifecycle, ['stop', 'start', 'render'],
|
|
1204
1206
|
'the TUI is suspended for the browser open and taken back afterwards');
|
|
1207
|
+
assert.deepEqual(run.host.stops, [{ preserveScreen: true }],
|
|
1208
|
+
'the suspend preserves the screen: a bare stop stamps the whole alt-screen frame into scrollback');
|
|
1205
1209
|
assert.deepEqual(run.host.paints, [true], 'the terminal is forced to repaint on resume');
|
|
1206
1210
|
});
|
|
1207
1211
|
|
|
@@ -1595,6 +1595,46 @@ test('S12 (T11): a session outside a repository paints one short dim line, and t
|
|
|
1595
1595
|
'the command notice keeps its own wording');
|
|
1596
1596
|
});
|
|
1597
1597
|
|
|
1598
|
+
// A checkout that IS a repository but has no remote at all is the same kind of
|
|
1599
|
+
// state one step further in: gh cannot name a repository because there is
|
|
1600
|
+
// nothing to resolve from, so the rail says it in one short gray line — never
|
|
1601
|
+
// gh's long failure sentence in the red tone — and it reads nothing.
|
|
1602
|
+
// The boundary of that state: ONLY gh's no-remote refusal becomes the gray line.
|
|
1603
|
+
// Every other failure keeps today's long error row, and an unknown wording
|
|
1604
|
+
// degrades to it instead of being read as "nothing to do here".
|
|
1605
|
+
for (const [stderr, label, tone] of [
|
|
1606
|
+
['no git remotes found\nrun git remote add origin <url> first', 'not a GitHub repository', 'dim'],
|
|
1607
|
+
['NO GIT REMOTES found', 'not a GitHub repository', 'dim'],
|
|
1608
|
+
['gh: Not logged in', 'cannot resolve the repository: gh: Not logged in', 'error'],
|
|
1609
|
+
['no remotes configured for this checkout',
|
|
1610
|
+
'cannot resolve the repository: no remotes configured for this checkout', 'error'],
|
|
1611
|
+
['', 'cannot resolve the repository: gh exited with status 1', 'error'],
|
|
1612
|
+
]) {
|
|
1613
|
+
test(`S12 (T11) parity: gh's ${JSON.stringify(stderr.split('\n')[0])} paints ${tone}`, async () => {
|
|
1614
|
+
const checkout = makeCheckout([]);
|
|
1615
|
+
const { registered } = installBridge();
|
|
1616
|
+
const loaded = await loadExtension({});
|
|
1617
|
+
ghIssues = require(path.join(LIB_DIR, 'gh-issues.js'));
|
|
1618
|
+
const calls = [];
|
|
1619
|
+
ghIssues.setGhRunner(async (bin, argv) => {
|
|
1620
|
+
calls.push({ bin, argv: argv.slice() });
|
|
1621
|
+
if (argv[0] === 'repo') return { status: 1, stdout: '', stderr, error: null };
|
|
1622
|
+
if (argv[0] === 'api' && argv[1] === 'user') return okJson('{"login":"me"}');
|
|
1623
|
+
assert.fail(`unexpected issue read: ${argv.join(' ')}`);
|
|
1624
|
+
});
|
|
1625
|
+
|
|
1626
|
+
const ctx = { cwd: checkout, ui: { notify: () => {} } };
|
|
1627
|
+
await fireSessionStart(loaded.hooks, ctx);
|
|
1628
|
+
assert.equal(registered.length, 1);
|
|
1629
|
+
const section = registered[0];
|
|
1630
|
+
const rows = await waitForRows(section, ctx);
|
|
1631
|
+
|
|
1632
|
+
assert.deepEqual(rows, [{ label, tone }], 'one row, in the role this failure earns');
|
|
1633
|
+
assert.equal(section.meta(ctx), undefined, 'and no count');
|
|
1634
|
+
assert.equal(graphqlCalls(calls).length, 0, 'and no issue read at all');
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1598
1638
|
// S13 (T11, corrected): without the `gh` CLI the rail section is NEVER ADDED —
|
|
1599
1639
|
// "/issues nunca se carga ni nunca se agrega a sidebar github sidebar". The decision
|
|
1600
1640
|
// is a LOCAL presence answer (a PATH walk; the module answers `ghCliPresent`, no
|