pi-odd-worktree 2.0.0 → 3.0.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.
- package/README.md +54 -311
- package/extensions/odd-worktree-tools.ts +4149 -2447
- package/lib/bash-activity.js +1164 -0
- package/lib/bash-design.js +684 -0
- package/lib/bash-destructive.js +559 -0
- package/lib/bash-frame.js +205 -0
- package/lib/card-content.js +23 -0
- package/lib/card-style.js +175 -0
- package/lib/checkout-facts.js +30 -70
- package/lib/codegraph-card-preview.js +628 -0
- package/lib/codegraph-card.js +515 -0
- package/lib/codegraph-compaction.js +76 -0
- package/lib/codegraph-daemon.js +246 -0
- package/lib/codegraph-edit-sync.js +182 -0
- package/lib/codegraph-guard-target.js +337 -0
- package/lib/codegraph-guard.js +211 -0
- package/lib/codegraph-index.js +1020 -0
- package/lib/codegraph-lock.js +607 -0
- package/lib/codegraph-mcp-config.js +134 -0
- package/lib/codegraph-mcp.js +123 -0
- package/lib/codegraph-paths.js +69 -0
- package/lib/codegraph-prompt/explore.md +11 -0
- package/lib/codegraph-prompt/fix.md +6 -0
- package/lib/codegraph-prompt/generic.md +8 -0
- package/lib/codegraph-prompt/judge.md +9 -0
- package/lib/codegraph-prompt/orchestrator.md +17 -0
- package/lib/codegraph-prompt/verify.md +10 -0
- package/lib/codegraph-prompt/worker.md +7 -0
- package/lib/codegraph-role.js +55 -0
- package/lib/codegraph-rules.js +146 -0
- package/lib/codegraph-session.js +303 -383
- package/lib/codegraph-warmup.js +139 -0
- package/lib/file-card-markdown.js +141 -0
- package/lib/file-card-resolver.js +245 -0
- package/lib/file-card.js +659 -0
- package/lib/files-index.js +387 -0
- package/lib/files-insert.js +81 -0
- package/lib/files-orders.js +326 -0
- package/lib/files-picker-view.js +1416 -0
- package/lib/files-preview.js +338 -0
- package/lib/files-scope-detail.js +171 -0
- package/lib/files-scope-view.js +507 -0
- package/lib/gh-issues.js +308 -14
- package/lib/issue-preview.js +26 -7
- package/lib/issues-bash-mutation.js +206 -0
- package/lib/issues-cache-store.js +261 -0
- package/lib/issues-section.js +710 -0
- package/lib/issues-view.js +649 -52
- package/lib/odd-prompt/odd-worktrees.md +21 -0
- package/lib/odd-worktrees-prompt.js +10 -28
- package/lib/related-issues-cache.js +210 -0
- package/lib/shell-card.js +825 -0
- package/lib/skill-odd-card.js +183 -0
- package/lib/tui-paint.js +4 -5
- package/lib/warp-create-panel.js +538 -250
- package/lib/warp-create-picker.js +56 -9
- package/lib/warp-delete-confirm.js +19 -28
- package/lib/warp-selector-view.js +160 -82
- package/lib/which-command.js +90 -0
- package/lib/worktree-card.js +267 -897
- package/lib/worktree-cards.js +383 -0
- package/lib/worktree-create.js +287 -0
- package/lib/worktree-git.js +3 -3
- package/lib/worktree-guard.js +548 -0
- package/lib/worktree-hooks.js +421 -711
- package/lib/worktree-list.js +120 -0
- package/lib/worktree-registry.js +162 -879
- package/lib/{worktree-close-herdr.js → worktree-remove.js} +9 -11
- package/lib/worktree-setup-runner.js +376 -0
- package/lib/worktree-setup.js +140 -0
- package/lib/worktree-warp-busy.js +462 -85
- package/lib/worktree-warp-sessions.js +1 -2
- package/package.json +2 -2
- package/tools/bash-activity.test.js +1419 -0
- package/tools/bash-design.test.js +1091 -0
- package/tools/bash-destructive.test.js +139 -0
- package/tools/card-content.test.js +44 -0
- package/tools/card-style.test.js +298 -0
- package/tools/codegraph-card-preview.test.js +254 -0
- package/tools/codegraph-card.test.js +1080 -0
- package/tools/codegraph-compaction.test.js +378 -0
- package/tools/codegraph-daemon.test.js +248 -0
- package/tools/codegraph-edit-sync.test.js +295 -0
- package/tools/codegraph-guard-target.test.js +174 -0
- package/tools/codegraph-guard.test.js +238 -0
- package/tools/codegraph-index.test.js +1948 -0
- package/tools/codegraph-lock.test.js +932 -0
- package/tools/codegraph-mcp-config.test.js +181 -0
- package/tools/codegraph-mcp.test.js +194 -0
- package/tools/codegraph-paths.test.js +44 -0
- package/tools/codegraph-role.test.js +30 -0
- package/tools/codegraph-rules.test.js +250 -0
- package/tools/codegraph-session.test.js +660 -391
- package/tools/codegraph-warmup.test.js +316 -0
- package/tools/commands.test.js +510 -31
- package/tools/file-card-markdown.test.js +188 -0
- package/tools/file-card.test.js +1289 -0
- package/tools/files-bridge.test.js +575 -0
- package/tools/files-command.test.js +610 -0
- package/tools/files-index.test.js +473 -0
- package/tools/files-insert.test.js +139 -0
- package/tools/files-orders.test.js +597 -0
- package/tools/files-picker-view.test.js +1871 -0
- package/tools/files-preview.test.js +452 -0
- package/tools/files-scope-detail.test.js +264 -0
- package/tools/files-scope-view.test.js +614 -0
- package/tools/fixtures/card-codegraph-outputs.js +110 -0
- package/tools/fixtures/codegraph-cli-stub.js +16 -0
- package/tools/fixtures/codegraph-init-process.js +28 -0
- package/tools/fixtures/codegraph-lock-worker.js +117 -0
- package/tools/fixtures/daemon-fake.js +98 -0
- package/tools/fixtures/daemon-mcp-server.js +39 -0
- package/tools/fixtures/daemon-warmup-worker.js +12 -0
- package/tools/fixtures/load-extension.js +136 -3
- package/tools/gh-issues-feedback.test.js +31 -7
- package/tools/gh-issues.test.js +391 -1
- package/tools/issue-preview.test.js +44 -7
- package/tools/issues-bash-mutation.test.js +101 -0
- package/tools/issues-cache-store.test.js +222 -0
- package/tools/issues-command.test.js +1512 -66
- package/tools/issues-open-guard.test.js +1096 -0
- package/tools/issues-section.test.js +4195 -0
- package/tools/issues-seed-query-regression.test.js +67 -0
- package/tools/issues-view.test.js +1489 -60
- package/tools/odd-worktrees-prompt.test.js +98 -65
- package/tools/package-surface.test.js +431 -36
- package/tools/related-issues-cache.test.js +324 -0
- package/tools/shell-card.test.js +834 -0
- package/tools/skill-odd-card.test.js +200 -0
- package/tools/t5-session-identity.test.js +44 -22
- package/tools/warp-busy-guard.test.js +2569 -308
- package/tools/warp-create-panel.test.js +499 -74
- package/tools/warp-create-picker.test.js +101 -5
- package/tools/warp-delete-confirm.test.js +49 -15
- package/tools/warp-empty-session.test.js +0 -1
- package/tools/warp-fallback-regression.test.js +533 -0
- package/tools/warp-selector-view.test.js +460 -196
- package/tools/which-command.test.js +126 -0
- package/tools/worktree-card.test.js +551 -0
- package/tools/worktree-cards.test.js +845 -0
- package/tools/worktree-changes.test.js +4 -5
- package/tools/worktree-create.test.js +489 -0
- package/tools/worktree-guard.test.js +823 -0
- package/tools/worktree-hooks.test.js +905 -0
- package/tools/worktree-list.test.js +170 -0
- package/tools/worktree-registry.test.js +89 -230
- package/tools/worktree-remove-async.test.js +318 -0
- package/tools/worktree-setup-runner.test.js +276 -0
- package/tools/worktree-setup.test.js +140 -0
- package/tools/worktree-tools.test.js +477 -93
- package/lib/codegraph-commands.js +0 -165
- package/lib/odd-prompt/odd-worktrees.with-codegraph.md +0 -19
- package/lib/odd-prompt/odd-worktrees.without-codegraph.md +0 -15
- package/lib/worktree-model-result.js +0 -291
- package/tools/codegraph-commands.test.js +0 -371
- package/tools/herdr-free-create.test.js +0 -161
- package/tools/worktree-close-herdr-async.test.js +0 -204
- package/tools/worktree-odd-migration.test.js +0 -224
- package/tools/worktree-registry-cache.test.js +0 -163
- package/tools/worktree-registry-odd.test.js +0 -231
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// T7 (S9, S14, S17) and T10 (S20, S27): the `/files` command driven through the
|
|
3
|
+
// registered handler and the fake host. The interactive panels themselves have
|
|
4
|
+
// their own suites (tools/files-picker-view.test.js,
|
|
5
|
+
// tools/files-scope-view.test.js); what this file proves is the COMMAND: that it
|
|
6
|
+
// is registered with the other four, that a host without an overlay gets one
|
|
7
|
+
// honest line instead of a throw, and that it wires the landed modules — the two
|
|
8
|
+
// scope lists from Git and the ownership rule, the picker with its
|
|
9
|
+
// `loadEntries`/`loadPreview`/`highlight`/`languageForPath` seams, the insertion
|
|
10
|
+
// form through `pasteToEditor`, and the editor handoff that stops the terminal,
|
|
11
|
+
// forces one full repaint on the close path and disposes its view (S14, S27).
|
|
12
|
+
const { test, describe, after } = require('node:test');
|
|
13
|
+
const assert = require('node:assert/strict');
|
|
14
|
+
const fs = require('node:fs');
|
|
15
|
+
const os = require('node:os');
|
|
16
|
+
const path = require('node:path');
|
|
17
|
+
const { pathToFileURL } = require('node:url');
|
|
18
|
+
const { spawnSync } = require('node:child_process');
|
|
19
|
+
const { LIB_DIR, loadExtension, stubbedSource } = require('./fixtures/load-extension.js');
|
|
20
|
+
|
|
21
|
+
const scratch = [];
|
|
22
|
+
function track(dir) {
|
|
23
|
+
scratch.push(dir);
|
|
24
|
+
return dir;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const savedEnv = { ...process.env };
|
|
28
|
+
after(() => {
|
|
29
|
+
for (const key of Object.keys(process.env)) {
|
|
30
|
+
if (!(key in savedEnv)) delete process.env[key];
|
|
31
|
+
}
|
|
32
|
+
for (const [key, value] of Object.entries(savedEnv)) process.env[key] = value;
|
|
33
|
+
for (const dir of scratch) {
|
|
34
|
+
try { fs.rmSync(dir, { recursive: true, force: true }); } catch { /* best effort */ }
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function git(cwd, args) {
|
|
39
|
+
const out = spawnSync('git', args, { cwd, encoding: 'utf8' });
|
|
40
|
+
if (out.status !== 0) throw new Error(`git ${args.join(' ')} failed: ${out.stderr}`);
|
|
41
|
+
return out.stdout.trim();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A real repository: `main`, one commit and one tracked file. */
|
|
45
|
+
function makeRepo() {
|
|
46
|
+
const dir = track(fs.mkdtempSync(path.join(os.tmpdir(), 'odd-files-repo-')));
|
|
47
|
+
git(dir, ['init', '-b', 'main']);
|
|
48
|
+
git(dir, ['config', 'user.email', 'test@example.test']);
|
|
49
|
+
git(dir, ['config', 'user.name', 'Test']);
|
|
50
|
+
fs.writeFileSync(path.join(dir, 'a.js'), 'const x = 1;\n');
|
|
51
|
+
fs.writeFileSync(path.join(dir, 'README.md'), '# fixture\n');
|
|
52
|
+
git(dir, ['add', 'a.js', 'README.md']);
|
|
53
|
+
git(dir, ['commit', '-m', 'init']);
|
|
54
|
+
return fs.realpathSync(dir);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** One checkout this package owns, at the canonical directory, one file short of committed. */
|
|
58
|
+
function addOwnedWorktree(repo, odd, branch) {
|
|
59
|
+
const parent = path.dirname(repo);
|
|
60
|
+
const target = path.join(parent, `${path.basename(repo)}-worktrees`, odd);
|
|
61
|
+
git(repo, ['worktree', 'add', '-b', branch, target, 'main']);
|
|
62
|
+
fs.writeFileSync(path.join(target, 'x.js'), 'const y = 2;\n');
|
|
63
|
+
return fs.realpathSync(target);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* S20: a checkout Git knows that this package never created, so it is on the `a`
|
|
68
|
+
* list and not on the registered one. Its parent is realpath'd first, so the path
|
|
69
|
+
* Git records is the path the picker paints.
|
|
70
|
+
*/
|
|
71
|
+
function addLooseWorktree(repo, name, branch) {
|
|
72
|
+
const parent = track(fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'odd-files-loose-wt-'))));
|
|
73
|
+
const target = path.join(parent, name);
|
|
74
|
+
git(repo, ['worktree', 'add', '-b', branch, target, 'main']);
|
|
75
|
+
fs.writeFileSync(path.join(target, 'loose.js'), 'const loose = 1;\n');
|
|
76
|
+
return target;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ---- the fake host -------------------------------------------------------
|
|
80
|
+
//
|
|
81
|
+
// One extension instance per load, because `setFilesTuiLoader` and
|
|
82
|
+
// `setFilesAgentLoader` are that instance's own seams (the same shape the other
|
|
83
|
+
// panels' tests use). `custom` mounts the factory exactly like Pi does: the
|
|
84
|
+
// component is built synchronously and the answer resolves the overlay promise.
|
|
85
|
+
async function loadFilesExtension(pi = {}) {
|
|
86
|
+
process.env.GENTLE_WORKTREE_LIB_DIR = LIB_DIR;
|
|
87
|
+
const dir = track(fs.mkdtempSync(path.join(os.tmpdir(), 'odd-files-ext-')));
|
|
88
|
+
const copy = path.join(dir, 'odd-worktree-tools.mjs');
|
|
89
|
+
fs.writeFileSync(copy, stubbedSource());
|
|
90
|
+
const mod = await import(pathToFileURL(copy).href);
|
|
91
|
+
const commands = new Map();
|
|
92
|
+
const fakeHost = {
|
|
93
|
+
registerCommand: (name, handler) => { commands.set(name, handler); },
|
|
94
|
+
registerTool: () => {},
|
|
95
|
+
registerMessageRenderer: () => {},
|
|
96
|
+
on: () => {},
|
|
97
|
+
...pi,
|
|
98
|
+
};
|
|
99
|
+
mod.default(fakeHost);
|
|
100
|
+
return { mod, commands };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const theme = { fg: (_role, text) => text, bg: (_role, text) => text, bold: (text) => text };
|
|
104
|
+
|
|
105
|
+
function stripAnsi(text) {
|
|
106
|
+
return String(text).replace(/\x1b\[[0-9;]*m/g, '');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The mount host: records every `custom` call (its options and its component) and
|
|
111
|
+
* every terminal event the handoff causes, so a test can tell what the command
|
|
112
|
+
* asked for and what it repainted.
|
|
113
|
+
*/
|
|
114
|
+
function mountHost({ rows = 40 } = {}) {
|
|
115
|
+
const mounts = [];
|
|
116
|
+
const events = [];
|
|
117
|
+
const renders = [];
|
|
118
|
+
const pasted = [];
|
|
119
|
+
const notifications = [];
|
|
120
|
+
const tui = {
|
|
121
|
+
terminal: { rows },
|
|
122
|
+
stopped: false,
|
|
123
|
+
stop() { tui.stopped = true; events.push('stop'); },
|
|
124
|
+
start() { tui.stopped = false; events.push('start'); },
|
|
125
|
+
// Pi records the request even while stopped: `requestRender(true)` resets the
|
|
126
|
+
// written-frame state at once and defers only the paint, which is how the
|
|
127
|
+
// next frame after `start()` rewrites every cell (S27). `renders` keeps the
|
|
128
|
+
// terminal state each request was made in, so a test can tell whether the
|
|
129
|
+
// paint was asked for while the terminal was still ours.
|
|
130
|
+
requestRender(force) {
|
|
131
|
+
renders.push({ force: force === true, stopped: tui.stopped });
|
|
132
|
+
events.push(force === true ? 'render:force' : 'render');
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
const ui = {
|
|
136
|
+
notify: (text, level) => { notifications.push([level, text]); },
|
|
137
|
+
pasteToEditor: (text) => { pasted.push(text); },
|
|
138
|
+
custom: (factory, options) => new Promise((resolve) => {
|
|
139
|
+
const component = factory(tui, theme, {}, (value) => resolve(value));
|
|
140
|
+
mounts.push({ options, component });
|
|
141
|
+
}),
|
|
142
|
+
};
|
|
143
|
+
return { tui, mounts, events, renders, pasted, notifications, ui };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The session ctx. `registeredRoots` are the worktrees this session registered
|
|
148
|
+
* through the host's `session_worktree_register` tool: the host appends one
|
|
149
|
+
* custom entry per registration, which is the only durable record of them
|
|
150
|
+
* (S35), so the double carries the same shape instead of a seam of its own.
|
|
151
|
+
*/
|
|
152
|
+
function ctxFor(repo, ui, options = {}) {
|
|
153
|
+
const sessionId = options.sessionId === undefined ? 'thread-1' : options.sessionId;
|
|
154
|
+
const registeredRoots = Array.isArray(options.registeredRoots) ? options.registeredRoots : [];
|
|
155
|
+
return {
|
|
156
|
+
cwd: repo,
|
|
157
|
+
hasUI: true,
|
|
158
|
+
mode: 'tui',
|
|
159
|
+
sessionManager: {
|
|
160
|
+
getSessionId: () => sessionId,
|
|
161
|
+
getEntries: () => registeredRoots.map((root) => ({
|
|
162
|
+
type: 'custom',
|
|
163
|
+
customType: 'gentle-pi.session-worktree/v1',
|
|
164
|
+
data: { sessionId, root, evidence: 'session:tool' },
|
|
165
|
+
})),
|
|
166
|
+
},
|
|
167
|
+
ui,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async function waitFor(predicate, label) {
|
|
172
|
+
const deadline = Date.now() + 20_000;
|
|
173
|
+
while (Date.now() < deadline) {
|
|
174
|
+
if (predicate()) return;
|
|
175
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
176
|
+
}
|
|
177
|
+
throw new Error(`timed out waiting for ${label}`);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const rowsOf = (component, width = 120) => component.render(width).map((line) => stripAnsi(line));
|
|
181
|
+
const textOf = (component, width = 120) => rowsOf(component, width).join('\n');
|
|
182
|
+
// A scope row reads `│ ▸ <label> [±n files] │`; counting them is how a
|
|
183
|
+
// duplicated `main` row would be caught. The detail line and the footer share the
|
|
184
|
+
// frame but never reduce to a label plus a count cell.
|
|
185
|
+
const scopeLabels = (component) => rowsOf(component)
|
|
186
|
+
.filter((row) => row.startsWith('│ ') && row.endsWith(' │'))
|
|
187
|
+
.map((row) => row.slice(2, -2).replace(/\s+/g, ' ').trimStart().replace(/^▸ /, '').trim());
|
|
188
|
+
const scopeRowCount = (component, label) => scopeLabels(component)
|
|
189
|
+
.filter((row) => row === label
|
|
190
|
+
|| (row.startsWith(`${label} ±`) && /^±\d+ files?$/.test(row.slice(label.length + 1)))).length;
|
|
191
|
+
|
|
192
|
+
// The ANSI-aware helpers the panel measures with; key matching falls back to the
|
|
193
|
+
// view's own spelled sequences, which is what a host without `matchesKey` has.
|
|
194
|
+
function visibleWidthOf(value) {
|
|
195
|
+
return [...stripAnsi(value)].length;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const helpers = {
|
|
199
|
+
visibleWidth: visibleWidthOf,
|
|
200
|
+
truncateToWidth: (value, width, ellipsis = '') => {
|
|
201
|
+
const text = stripAnsi(value);
|
|
202
|
+
if (width <= 0) return '';
|
|
203
|
+
const chars = [...text];
|
|
204
|
+
if (chars.length <= width) return value;
|
|
205
|
+
const mark = [...String(ellipsis)];
|
|
206
|
+
return `${chars.slice(0, Math.max(0, width - mark.length)).join('')}${mark.join('')}`;
|
|
207
|
+
},
|
|
208
|
+
// ANSI-aware: a line that already fits keeps its escapes, which is what the
|
|
209
|
+
// coloured preview depends on. A longer one is split on visible cells.
|
|
210
|
+
wrapTextWithAnsi: (value, width) => {
|
|
211
|
+
if (width <= 0) return [String(value)];
|
|
212
|
+
if (visibleWidthOf(value) <= width) return [String(value)];
|
|
213
|
+
const chars = [...stripAnsi(value)];
|
|
214
|
+
const rows = [];
|
|
215
|
+
while (chars.length > width) rows.push(chars.splice(0, width).join(''));
|
|
216
|
+
rows.push(chars.join(''));
|
|
217
|
+
return rows;
|
|
218
|
+
},
|
|
219
|
+
isKeyRelease: () => false,
|
|
220
|
+
// What Pi's own matcher does for the keys this test drives: a raw sequence
|
|
221
|
+
// becomes a name. Without it the panels only see the names themselves.
|
|
222
|
+
matchesKey: (data, name) => {
|
|
223
|
+
const RAW = {
|
|
224
|
+
'\u001b[A': 'up', '\u001b[B': 'down', '\r': 'enter', '\n': 'enter',
|
|
225
|
+
'\u001b': 'escape', '\t': 'tab', '\u0005': 'ctrl+e', '\u000f': 'ctrl+o',
|
|
226
|
+
'\u0015': 'ctrl+u', '\u000a': 'ctrl+j',
|
|
227
|
+
};
|
|
228
|
+
return data === name || RAW[data] === name;
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
const GREEN = '\u001b[32m';
|
|
233
|
+
|
|
234
|
+
// Pi's own pair, faked: a `.js` file is coloured and every other name is not.
|
|
235
|
+
const agentStub = {
|
|
236
|
+
highlightCode: (code, language) => {
|
|
237
|
+
const lines = String(code).split('\n');
|
|
238
|
+
return language === 'javascript' ? lines.map((line) => `${GREEN}${line}\u001b[39m`) : lines;
|
|
239
|
+
},
|
|
240
|
+
getLanguageFromPath: (filePath) => (filePath.endsWith('.js') ? 'javascript' : undefined),
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
describe('/files registration (S17)', () => {
|
|
244
|
+
test('the file picker is registered beside the other three panels', async () => {
|
|
245
|
+
const { commands } = await loadExtension({});
|
|
246
|
+
assert.deepEqual([...commands.keys()].sort(), ['files', 'issues', 'odd', 'warp']);
|
|
247
|
+
const files = commands.get('files');
|
|
248
|
+
assert.equal(typeof files.handler, 'function', 'the command carries its handler');
|
|
249
|
+
assert.ok(files.description.includes('files'), 'the description says what it browses');
|
|
250
|
+
assert.ok(files.description.includes('ctrl+e'), 'and how a file opens in the editor');
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
test('the command reads the seven landed files modules and nothing of its own', () => {
|
|
254
|
+
const source = stubbedSource();
|
|
255
|
+
assert.ok(source.includes('pi.registerCommand(\'files\''), 'the command is registered');
|
|
256
|
+
assert.ok(source.includes('function registerFilesCommand'), 'its registration is a named step');
|
|
257
|
+
for (const module of [
|
|
258
|
+
'files-index.js',
|
|
259
|
+
'files-insert.js',
|
|
260
|
+
'files-scope-detail.js',
|
|
261
|
+
'files-scope-view.js',
|
|
262
|
+
'files-picker-view.js',
|
|
263
|
+
]) {
|
|
264
|
+
assert.ok(source.includes(`libRequire('${module}')`), `${module} is required by the wiring`);
|
|
265
|
+
}
|
|
266
|
+
// The row builder and the preview pane are composed BY the views, so the
|
|
267
|
+
// command must own no copy of their rules.
|
|
268
|
+
assert.equal(/function (buildRows|nextOrder|previewRows)\b/.test(source), false, 'the wiring reimplements no view rule');
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
describe('a host without an overlay (S17)', () => {
|
|
273
|
+
test('says so in one honest line and returns', async () => {
|
|
274
|
+
const { commands } = await loadExtension({});
|
|
275
|
+
const notifications = [];
|
|
276
|
+
const ctx = { cwd: os.tmpdir(), ui: { notify: (text, level) => notifications.push([level, text]) } };
|
|
277
|
+
await commands.get('files').handler('', ctx);
|
|
278
|
+
assert.deepEqual(notifications, [['info', 'files: the file picker needs an interactive session with overlay support']]);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
test('a host with no UI at all, and one whose UI throws, never throws into the host', async () => {
|
|
282
|
+
const { commands } = await loadExtension({});
|
|
283
|
+
await commands.get('files').handler('', { cwd: os.tmpdir() });
|
|
284
|
+
const hostile = {
|
|
285
|
+
cwd: os.tmpdir(),
|
|
286
|
+
ui: {
|
|
287
|
+
notify: () => { throw new Error('dead UI'); },
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
await commands.get('files').handler('', hostile);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
test('an argument is refused instead of opening the picker', async () => {
|
|
294
|
+
const { commands } = await loadExtension({});
|
|
295
|
+
const notifications = [];
|
|
296
|
+
const ctx = { cwd: os.tmpdir(), ui: { notify: (text, level) => notifications.push([level, text]) } };
|
|
297
|
+
await commands.get('files').handler('nope', ctx);
|
|
298
|
+
assert.deepEqual(notifications, [['error', 'Unknown option "nope". Use /files with no argument.']]);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
test('outside a Git repository the package’s own sentence lands', async () => {
|
|
302
|
+
const { commands } = await loadExtension({});
|
|
303
|
+
const loose = track(fs.mkdtempSync(path.join(os.tmpdir(), 'odd-files-loose-')));
|
|
304
|
+
const host = mountHost();
|
|
305
|
+
await commands.get('files').handler('', ctxFor(loose, host.ui));
|
|
306
|
+
assert.deepEqual(host.mounts, [], 'no overlay is mounted over nothing');
|
|
307
|
+
assert.deepEqual(host.notifications, [['info', `not a git repository: ${fs.realpathSync(loose)}; run 'git init' first`]]);
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
describe('one checkout: the scope step still opens (S20, S7/S8)', () => {
|
|
312
|
+
test('the step offers the session checkout alone, and Enter pastes its `@` reference', async () => {
|
|
313
|
+
const repo = makeRepo();
|
|
314
|
+
const { commands } = await loadFilesExtension();
|
|
315
|
+
const host = mountHost();
|
|
316
|
+
// The overlay resolves `ctx.ui.custom` only when it settles, so the handler is
|
|
317
|
+
// started and driven, never awaited before the panel answers.
|
|
318
|
+
const running = commands.get('files').handler('', ctxFor(repo, host.ui));
|
|
319
|
+
|
|
320
|
+
await waitFor(() => host.mounts.length >= 1, 'the scope mount');
|
|
321
|
+
assert.equal(host.mounts.length, 1, 'the step opens even when there is nothing else to choose (S20)');
|
|
322
|
+
assert.deepEqual(host.mounts[0].options, {
|
|
323
|
+
overlay: true,
|
|
324
|
+
overlayOptions: { anchor: 'center', width: '70%', minWidth: 60, maxHeight: '85%' },
|
|
325
|
+
}, 'the step is its own smaller card');
|
|
326
|
+
const step = host.mounts[0].component;
|
|
327
|
+
const stepRows = textOf(step);
|
|
328
|
+
assert.ok(stepRows.includes('main'), 'the session checkout is the row');
|
|
329
|
+
assert.ok(!stepRows.includes('±'), 'a clean checkout paints no count');
|
|
330
|
+
assert.ok(stepRows.includes('a all'), 'the footer names the list `a` switches to (S20)');
|
|
331
|
+
|
|
332
|
+
step.handleInput('enter');
|
|
333
|
+
|
|
334
|
+
await waitFor(() => host.mounts.length >= 2, 'the picker mount');
|
|
335
|
+
assert.deepEqual(host.mounts[1].options, {
|
|
336
|
+
overlay: true,
|
|
337
|
+
overlayOptions: { anchor: 'center', width: '85%', minWidth: 76, maxHeight: '100%' },
|
|
338
|
+
}, 'the picker takes the terminal width S15 needs');
|
|
339
|
+
|
|
340
|
+
const picker = host.mounts[1].component;
|
|
341
|
+
await waitFor(() => textOf(picker).includes('a.js'), 'the listing');
|
|
342
|
+
// The order footer and the one-option-per-key legend are the view's; the
|
|
343
|
+
// command only has to hand it a listing to paint.
|
|
344
|
+
// S33 (round L11) renamed the flat order `modified` to `files`; the footer
|
|
345
|
+
// token is the view's, and this line only proves the wiring gave it a listing.
|
|
346
|
+
assert.ok(textOf(picker).includes('files'), 'the default order paints');
|
|
347
|
+
|
|
348
|
+
// The default `files` order puts changed files first and sorts the clean
|
|
349
|
+
// ones by path, so the highlight opens on README.md, not on a.js.
|
|
350
|
+
picker.handleInput('\r');
|
|
351
|
+
assert.deepEqual(host.pasted, ['@README.md'], 'the session checkout keeps the `@` form');
|
|
352
|
+
assert.deepEqual(host.notifications, [], 'inserting never notifies');
|
|
353
|
+
await running;
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
describe('the `a` list of every worktree (S20)', () => {
|
|
358
|
+
test('`a` offers a worktree this package never registered, and it is browsable', async () => {
|
|
359
|
+
const repo = makeRepo();
|
|
360
|
+
const loose = addLooseWorktree(repo, 'loose', 'feat/loose');
|
|
361
|
+
const { mod, commands } = await loadFilesExtension();
|
|
362
|
+
mod.setFilesTuiLoader(async () => helpers);
|
|
363
|
+
const host = mountHost();
|
|
364
|
+
const running = commands.get('files').handler('', ctxFor(repo, host.ui));
|
|
365
|
+
|
|
366
|
+
await waitFor(() => host.mounts.length >= 1, 'the scope mount');
|
|
367
|
+
const step = host.mounts[0].component;
|
|
368
|
+
assert.ok(!textOf(step).includes('loose · feat/loose'), 'the registered list does not carry it');
|
|
369
|
+
assert.ok(textOf(step).includes('a all'));
|
|
370
|
+
|
|
371
|
+
step.handleInput('a');
|
|
372
|
+
const widened = textOf(step);
|
|
373
|
+
assert.ok(widened.includes('loose · feat/loose'), 'Git\'s own listing offers it under the same label');
|
|
374
|
+
assert.ok(widened.includes('a registered'), 'and the footer names the way back');
|
|
375
|
+
|
|
376
|
+
step.handleInput('\u001b[B');
|
|
377
|
+
step.handleInput('\r');
|
|
378
|
+
|
|
379
|
+
await waitFor(() => host.mounts.length >= 2, 'the picker over the loose checkout');
|
|
380
|
+
const picker = host.mounts[1].component;
|
|
381
|
+
await waitFor(() => textOf(picker).includes('loose.js'), 'the loose checkout listing');
|
|
382
|
+
assert.ok(textOf(picker).includes(loose), 'the picker lists the checkout the step answered');
|
|
383
|
+
|
|
384
|
+
const disposeOnce = picker.dispose.bind(picker);
|
|
385
|
+
let disposed = 0;
|
|
386
|
+
picker.dispose = () => { disposed += 1; disposeOnce(); };
|
|
387
|
+
picker.handleInput('\u001b');
|
|
388
|
+
await running;
|
|
389
|
+
assert.equal(disposed, 1, 'a close that never reached the editor still disposes its view (S27)');
|
|
390
|
+
});
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
describe('the default scope list is the session’s (S35)', () => {
|
|
394
|
+
test('main, the session checkout and the registered worktrees; an unregistered ODD worktree needs `a`', async () => {
|
|
395
|
+
const repo = makeRepo();
|
|
396
|
+
const registered = addOwnedWorktree(repo, 'registered-one', 'feat/reg');
|
|
397
|
+
addOwnedWorktree(repo, 'owned-only', 'feat/only');
|
|
398
|
+
const { mod, commands } = await loadFilesExtension();
|
|
399
|
+
mod.setFilesTuiLoader(async () => helpers);
|
|
400
|
+
const host = mountHost();
|
|
401
|
+
const running = commands.get('files').handler('', ctxFor(repo, host.ui, { registeredRoots: [registered] }));
|
|
402
|
+
|
|
403
|
+
await waitFor(() => host.mounts.length >= 1, 'the scope mount');
|
|
404
|
+
const step = host.mounts[0].component;
|
|
405
|
+
assert.ok(textOf(step).includes('main'), 'the principal checkout leads');
|
|
406
|
+
assert.ok(textOf(step).includes('registered-one · feat/reg'), 'the session’s registration is a default row');
|
|
407
|
+
assert.ok(textOf(step).includes('±1 file'), 'and it keeps its uncommitted count');
|
|
408
|
+
assert.ok(!textOf(step).includes('owned-only · feat/only'),
|
|
409
|
+
'an ODD worktree this session never registered is not a default row');
|
|
410
|
+
assert.ok(textOf(step).includes('a all'), 'the footer names the list `a` switches to');
|
|
411
|
+
assert.equal(scopeRowCount(step, 'main'), 1, '`main` is one row');
|
|
412
|
+
|
|
413
|
+
step.handleInput('a');
|
|
414
|
+
assert.ok(textOf(step).includes('owned-only · feat/only'), '`a` is what shows every worktree Git reports');
|
|
415
|
+
assert.ok(textOf(step).includes('registered-one · feat/reg'), 'and it still carries the registered one');
|
|
416
|
+
assert.ok(textOf(step).includes('a registered'), 'the footer names the way back');
|
|
417
|
+
assert.equal(scopeRowCount(step, 'main'), 1, '`main` is never duplicated on the wider list');
|
|
418
|
+
|
|
419
|
+
step.handleInput('a');
|
|
420
|
+
assert.ok(!textOf(step).includes('owned-only · feat/only'), 'the key switches back to the session’s list');
|
|
421
|
+
assert.ok(textOf(step).includes('registered-one · feat/reg'));
|
|
422
|
+
|
|
423
|
+
// The step answers the scope object the picker then browses.
|
|
424
|
+
step.handleInput('\u001b[B');
|
|
425
|
+
step.handleInput('\r');
|
|
426
|
+
await waitFor(() => host.mounts.length >= 2, 'the picker over the registered worktree');
|
|
427
|
+
const picker = host.mounts[1].component;
|
|
428
|
+
await waitFor(() => textOf(picker).includes('x.js'), 'the registered worktree’s listing');
|
|
429
|
+
assert.ok(textOf(picker).includes(registered), 'the picker lists the checkout the step answered');
|
|
430
|
+
picker.handleInput('\u001b');
|
|
431
|
+
await running;
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
test('a session that registered nothing sees `main` alone, and `a` still works', async () => {
|
|
435
|
+
const repo = makeRepo();
|
|
436
|
+
addOwnedWorktree(repo, 'owned-only', 'feat/only');
|
|
437
|
+
const { mod, commands } = await loadFilesExtension();
|
|
438
|
+
mod.setFilesTuiLoader(async () => helpers);
|
|
439
|
+
const host = mountHost();
|
|
440
|
+
const running = commands.get('files').handler('', ctxFor(repo, host.ui));
|
|
441
|
+
|
|
442
|
+
await waitFor(() => host.mounts.length >= 1, 'the scope mount');
|
|
443
|
+
const step = host.mounts[0].component;
|
|
444
|
+
assert.equal(scopeRowCount(step, 'main'), 1, 'the session checkout IS `main`, so it is one row');
|
|
445
|
+
assert.ok(!textOf(step).includes('owned-only · feat/only'), 'no registration, no default row for it');
|
|
446
|
+
assert.ok(textOf(step).includes('a all'));
|
|
447
|
+
|
|
448
|
+
step.handleInput('a');
|
|
449
|
+
assert.ok(textOf(step).includes('owned-only · feat/only'), 'the wider list still works with nothing registered');
|
|
450
|
+
assert.ok(textOf(step).includes('a registered'));
|
|
451
|
+
step.handleInput('a');
|
|
452
|
+
assert.ok(!textOf(step).includes('owned-only · feat/only'), 'and the way back is the one row');
|
|
453
|
+
assert.equal(scopeRowCount(step, 'main'), 1);
|
|
454
|
+
|
|
455
|
+
step.handleInput('\u001b');
|
|
456
|
+
await running;
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
test('a session sitting in another worktree carries it, once, without registering anything', async () => {
|
|
460
|
+
const repo = makeRepo();
|
|
461
|
+
const mine = addOwnedWorktree(repo, 'mine', 'feat/mine');
|
|
462
|
+
addOwnedWorktree(repo, 'other', 'feat/other');
|
|
463
|
+
const { mod, commands } = await loadFilesExtension();
|
|
464
|
+
mod.setFilesTuiLoader(async () => helpers);
|
|
465
|
+
const host = mountHost();
|
|
466
|
+
const running = commands.get('files').handler('', ctxFor(mine, host.ui));
|
|
467
|
+
|
|
468
|
+
await waitFor(() => host.mounts.length >= 1, 'the scope mount');
|
|
469
|
+
const step = host.mounts[0].component;
|
|
470
|
+
assert.ok(textOf(step).includes('main'), '`main` leads from any checkout');
|
|
471
|
+
assert.equal(scopeRowCount(step, 'mine · feat/mine'), 1, 'the session’s own checkout is one row');
|
|
472
|
+
assert.ok(!textOf(step).includes('other · feat/other'), 'a worktree the session neither sits in nor registered is not');
|
|
473
|
+
|
|
474
|
+
step.handleInput('a');
|
|
475
|
+
assert.ok(textOf(step).includes('other · feat/other'), '`a` reports every worktree of the clone');
|
|
476
|
+
assert.equal(scopeRowCount(step, 'mine · feat/mine'), 1, 'and the session checkout is still one row');
|
|
477
|
+
assert.equal(scopeRowCount(step, 'main'), 1);
|
|
478
|
+
step.handleInput('\u001b');
|
|
479
|
+
await running;
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
describe('several checkouts: the scope step (S9)', () => {
|
|
484
|
+
test('main first with the worktree’s count and detail, then the picker over the chosen checkout', async () => {
|
|
485
|
+
const repo = makeRepo();
|
|
486
|
+
const worktree = addOwnedWorktree(repo, 'pick-me', 'feat/pick');
|
|
487
|
+
const { mod, commands } = await loadFilesExtension();
|
|
488
|
+
mod.setFilesTuiLoader(async () => helpers);
|
|
489
|
+
const host = mountHost();
|
|
490
|
+
// S35: the default list carries the worktrees THIS SESSION registered, so the
|
|
491
|
+
// checkout is registered here exactly as `worktree_create` registers it; the
|
|
492
|
+
// `a` list (every worktree Git reports) has its own case below.
|
|
493
|
+
const running = commands.get('files').handler('', ctxFor(repo, host.ui, { registeredRoots: [worktree] }));
|
|
494
|
+
|
|
495
|
+
await waitFor(() => host.mounts.length >= 1, 'the scope mount');
|
|
496
|
+
const scopeMount = host.mounts[0];
|
|
497
|
+
assert.deepEqual(scopeMount.options, {
|
|
498
|
+
overlay: true,
|
|
499
|
+
overlayOptions: { anchor: 'center', width: '70%', minWidth: 60, maxHeight: '85%' },
|
|
500
|
+
}, 'the step is its own smaller card');
|
|
501
|
+
const scopeRows = textOf(scopeMount.component);
|
|
502
|
+
assert.ok(scopeRows.includes('main'), 'the principal checkout leads');
|
|
503
|
+
assert.ok(scopeRows.includes('pick-me · feat/pick'), 'the worktree names its ODD and its branch');
|
|
504
|
+
assert.ok(scopeRows.includes('±1 file'), 'its uncommitted count is read from Git');
|
|
505
|
+
assert.ok(scopeRows.includes('init'), 'the detail line leads with the last commit subject');
|
|
506
|
+
assert.ok(scopeRows.indexOf('main') < scopeRows.indexOf('pick-me'), 'main keeps the first row');
|
|
507
|
+
|
|
508
|
+
// Down selects the worktree, Enter opens it.
|
|
509
|
+
scopeMount.component.handleInput('\u001b[B');
|
|
510
|
+
scopeMount.component.handleInput('\r');
|
|
511
|
+
|
|
512
|
+
await waitFor(() => host.mounts.length >= 2, 'the picker over the chosen scope');
|
|
513
|
+
const picker = host.mounts[1].component;
|
|
514
|
+
await waitFor(() => textOf(picker).includes('x.js'), 'the worktree listing');
|
|
515
|
+
assert.ok(textOf(picker).includes(worktree), 'the picker names the scope it lists');
|
|
516
|
+
|
|
517
|
+
picker.handleInput('\r');
|
|
518
|
+
assert.deepEqual(host.pasted, [path.join(worktree, 'x.js')], 'another checkout travels as its real absolute path');
|
|
519
|
+
assert.deepEqual(host.notifications, []);
|
|
520
|
+
await running;
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
test('esc closes the step without opening a picker', async () => {
|
|
524
|
+
const repo = makeRepo();
|
|
525
|
+
addOwnedWorktree(repo, 'pick-me', 'feat/pick');
|
|
526
|
+
const { mod, commands } = await loadFilesExtension();
|
|
527
|
+
mod.setFilesTuiLoader(async () => helpers);
|
|
528
|
+
const host = mountHost();
|
|
529
|
+
const running = commands.get('files').handler('', ctxFor(repo, host.ui));
|
|
530
|
+
await waitFor(() => host.mounts.length >= 1, 'the scope mount');
|
|
531
|
+
host.mounts[0].component.handleInput('\u001b');
|
|
532
|
+
await running;
|
|
533
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
534
|
+
assert.equal(host.mounts.length, 1, 'nothing else is mounted');
|
|
535
|
+
assert.deepEqual(host.pasted, []);
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
describe('the preview and the editor (S12, S14)', () => {
|
|
540
|
+
test('the injected highlighter reaches the pane through the command’s own seams (S12)', async () => {
|
|
541
|
+
const repo = makeRepo();
|
|
542
|
+
const { mod, commands } = await loadFilesExtension();
|
|
543
|
+
mod.setFilesTuiLoader(async () => helpers);
|
|
544
|
+
mod.setFilesAgentLoader(async () => agentStub);
|
|
545
|
+
const host = mountHost();
|
|
546
|
+
const running = commands.get('files').handler('', ctxFor(repo, host.ui));
|
|
547
|
+
await waitFor(() => host.mounts.length >= 1, 'the scope mount');
|
|
548
|
+
host.mounts[0].component.handleInput('enter');
|
|
549
|
+
await waitFor(() => host.mounts.length >= 2, 'the picker mount');
|
|
550
|
+
const picker = host.mounts[1].component;
|
|
551
|
+
const painted = () => picker.render(120).join('\n');
|
|
552
|
+
await waitFor(() => textOf(picker).includes('a.js'), 'the listing');
|
|
553
|
+
// The highlight follows the HIGHLIGHTED row: the order opens on README.md,
|
|
554
|
+
// which names no language, so the file with the language is selected first.
|
|
555
|
+
assert.equal(painted().includes(GREEN), false, 'a language-less file stays plain');
|
|
556
|
+
picker.handleInput('\u001b[B');
|
|
557
|
+
await waitFor(() => painted().includes(GREEN), 'the coloured preview');
|
|
558
|
+
assert.ok(stripAnsi(painted()).includes('const x = 1;'), 'the file text is the preview');
|
|
559
|
+
picker.handleInput('\u001b');
|
|
560
|
+
await running;
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
test('ctrl+e settles the overlay on a live terminal, then stops it for the editor, and disposes once it returns (S27)', async () => {
|
|
564
|
+
const repo = makeRepo();
|
|
565
|
+
delete process.env.VISUAL;
|
|
566
|
+
delete process.env.EDITOR;
|
|
567
|
+
const { mod, commands } = await loadFilesExtension();
|
|
568
|
+
mod.setFilesTuiLoader(async () => helpers);
|
|
569
|
+
const host = mountHost();
|
|
570
|
+
const running = commands.get('files').handler('', ctxFor(repo, host.ui));
|
|
571
|
+
await waitFor(() => host.mounts.length >= 1, 'the scope mount');
|
|
572
|
+
host.mounts[0].component.handleInput('enter');
|
|
573
|
+
await waitFor(() => host.mounts.length >= 2, 'the picker mount');
|
|
574
|
+
const picker = host.mounts[1].component;
|
|
575
|
+
await waitFor(() => textOf(picker).includes('a.js'), 'the listing');
|
|
576
|
+
|
|
577
|
+
// The view the command constructed is the component the host was handed, so
|
|
578
|
+
// its `dispose` calls are observable on the very object the factory returned.
|
|
579
|
+
const disposeOnce = picker.dispose.bind(picker);
|
|
580
|
+
let disposed = 0;
|
|
581
|
+
picker.dispose = () => { disposed += 1; disposeOnce(); };
|
|
582
|
+
|
|
583
|
+
host.events.length = 0;
|
|
584
|
+
host.renders.length = 0;
|
|
585
|
+
picker.handleInput('\u0005');
|
|
586
|
+
// The reference's order: the overlay settles and the forced close repaint
|
|
587
|
+
// lands while the terminal is STILL ours; only then is it stopped for the
|
|
588
|
+
// editor. `ctl+e` records the path in `onOpen`, it never spawns from there.
|
|
589
|
+
assert.deepEqual(host.events, ['render:force'], 'the close path repaints BEFORE anything stops the terminal');
|
|
590
|
+
assert.deepEqual(host.renders, [{ force: true, stopped: false }], 'and that repaint is the forced one, on a live terminal');
|
|
591
|
+
assert.equal(host.tui.stopped, false, 'the terminal is still ours when the overlay settles');
|
|
592
|
+
|
|
593
|
+
await waitFor(() => host.events.includes('start'), 'the terminal resumed after the editor step');
|
|
594
|
+
assert.equal(host.tui.stopped, false);
|
|
595
|
+
assert.deepEqual(host.events, ['render:force', 'stop', 'start', 'render:force'],
|
|
596
|
+
'stop arrives after the settle, and the resume repaint is the second forced one');
|
|
597
|
+
assert.deepEqual(host.renders, [
|
|
598
|
+
{ force: true, stopped: false },
|
|
599
|
+
{ force: true, stopped: false },
|
|
600
|
+
], 'the resume repaint is asked for once the terminal is back');
|
|
601
|
+
await waitFor(() => disposed === 1, 'the view disposed once the handoff returned');
|
|
602
|
+
await running;
|
|
603
|
+
assert.equal(disposed, 1, 'disposed exactly once');
|
|
604
|
+
assert.deepEqual(host.notifications, [[
|
|
605
|
+
'warning',
|
|
606
|
+
'files: no editor configured: set $VISUAL or $EDITOR to open documents outside Pi',
|
|
607
|
+
]]);
|
|
608
|
+
assert.deepEqual(host.pasted, [], 'opening a file pastes nothing');
|
|
609
|
+
});
|
|
610
|
+
});
|