pi-odd-worktree 2.1.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 -319
- package/extensions/odd-worktree-tools.ts +4145 -2529
- 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 -712
- 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 +2565 -309
- 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 +419 -199
- 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
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
// valid confirmation) and `done(null)` cancels (Esc). Selection is
|
|
24
24
|
// tracked by item id, so it survives filtering and paging.
|
|
25
25
|
|
|
26
|
-
const path = require('node:path');
|
|
27
26
|
// S11: the ONE palette every reader and panel shares decides which theme role
|
|
28
27
|
// paints each kind of token (key, title, description, count, label, value,
|
|
29
28
|
// border, error), so a footer KEY is always distinguishable from the words
|
|
@@ -34,13 +33,29 @@ const palette = require('./tui-paint.js');
|
|
|
34
33
|
const MULTI_SELECT_PAGE_SIZE_DEFAULT = 8;
|
|
35
34
|
const MULTI_SELECT_MAX_HEIGHT = 24;
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
// S11 (T8, warp-queue-boundary): the pending-changes question is the ONE prompt
|
|
37
|
+
// in this package that writes files into another checkout, so it owns two
|
|
38
|
+
// protections of its own. The NON-destructive answer is the one focused when the
|
|
39
|
+
// panel opens, and every input event arriving inside a SHORT grace window after
|
|
40
|
+
// the component is created is DROPPED: a buffered or double-tapped Enter — the
|
|
41
|
+
// one that submitted the command, or one meant to queue a follow-up message
|
|
42
|
+
// while the session streams — can then never answer a question the human did
|
|
43
|
+
// not see. Esc still cancels and Enter still confirms, as soon as the keypress
|
|
44
|
+
// is one the human could have made after seeing the panel.
|
|
45
|
+
const COPY_QUESTION_INPUT_GRACE_MS = 400;
|
|
46
|
+
const COPY_QUESTION_ITEMS = ['YES COPY', 'NO COPY'];
|
|
47
|
+
const COPY_QUESTION_SAFE_ANSWER = 'NO COPY';
|
|
48
|
+
|
|
49
|
+
// The picker options the copy question passes, in ONE place: both fronts that
|
|
50
|
+
// ask it (the /warp front and the create flow) and the tests read the same
|
|
51
|
+
// wiring. The visible item order is unchanged (`YES COPY` stays first); only the
|
|
52
|
+
// OPENING focus and the input grace window differ from the other pickers.
|
|
53
|
+
function copyQuestionOptions() {
|
|
54
|
+
return {
|
|
55
|
+
items: COPY_QUESTION_ITEMS.slice(),
|
|
56
|
+
initialSelected: COPY_QUESTION_SAFE_ANSWER,
|
|
57
|
+
inputGraceMs: COPY_QUESTION_INPUT_GRACE_MS,
|
|
58
|
+
};
|
|
44
59
|
}
|
|
45
60
|
|
|
46
61
|
// Slice the (already filtered) rows into pages, clamping the requested
|
|
@@ -745,6 +760,11 @@ function createTextInput({ title, placeholder, initial, helpers, hostTui, theme,
|
|
|
745
760
|
// Enter confirms the focused data row, Tab goes Back with `{ back: true }`
|
|
746
761
|
// keeping the kept value, Esc cancels with `done(null)`. Completion
|
|
747
762
|
// fires exactly once; hostile dimensions render nothing.
|
|
763
|
+
// `inputGraceMs` (default 0, so every other picker is unchanged) DROPS every
|
|
764
|
+
// input event that arrives within that many milliseconds of the component being
|
|
765
|
+
// created; the measured clock is `now` (default `Date.now`), injectable so a
|
|
766
|
+
// test never sleeps. The copy question passes a short window and the safe
|
|
767
|
+
// answer, so a stray Enter cannot answer it.
|
|
748
768
|
// Warp-selector extension (no unrelated redesign): `canDelete` is an
|
|
749
769
|
// opt-in predicate `(index, item) => boolean` — when it reports the
|
|
750
770
|
// focused row deletable, raw Ctrl+D (`\\x04` via the installed matcher
|
|
@@ -755,7 +775,7 @@ function createTextInput({ title, placeholder, initial, helpers, hostTui, theme,
|
|
|
755
775
|
// else) and `showTab: false` hides the Tab hint and ignores Tab (the
|
|
756
776
|
// top-level warp selector has no previous field). Defaults preserve the
|
|
757
777
|
// type panel byte-identically.
|
|
758
|
-
function createSingleSelect({ title, items, getId, getLabel, helpers, hostTui, theme, rowsAvailable, initialSelected, canDelete, confirmLabel, showTab, done }) {
|
|
778
|
+
function createSingleSelect({ title, items, getId, getLabel, helpers, hostTui, theme, rowsAvailable, initialSelected, canDelete, confirmLabel, showTab, inputGraceMs, now, done }) {
|
|
759
779
|
const rows = Array.isArray(items) ? items.slice() : [];
|
|
760
780
|
const idOf = typeof getId === 'function' ? getId : (item) => (item && typeof item === 'object' && 'id' in item ? item.id : String(item));
|
|
761
781
|
const labelOf = typeof getLabel === 'function' ? getLabel : (item) => String((item && typeof item === 'object' && 'label' in item ? item.label : item) ?? '');
|
|
@@ -771,6 +791,25 @@ function createSingleSelect({ title, items, getId, getLabel, helpers, hostTui, t
|
|
|
771
791
|
const at = rows.findIndex((item) => idOf(item) === initialSelected);
|
|
772
792
|
if (at >= 0) state.cursor = at;
|
|
773
793
|
}
|
|
794
|
+
// S11: the construction timestamp and the clock that decides the grace window.
|
|
795
|
+
// No timer is armed and nothing is deferred: every event is measured against
|
|
796
|
+
// the moment the component was CREATED, so the panel simply ignores whatever
|
|
797
|
+
// was already buffered. A throwing or unusable clock never suppresses input
|
|
798
|
+
// forever — it reads as "past the window".
|
|
799
|
+
const graceMs = Number.isFinite(inputGraceMs) && inputGraceMs > 0 ? inputGraceMs : 0;
|
|
800
|
+
const clock = typeof now === 'function' ? now : () => Date.now();
|
|
801
|
+
const createdAt = clock();
|
|
802
|
+
function insideGraceWindow() {
|
|
803
|
+
if (graceMs <= 0) return false;
|
|
804
|
+
let at;
|
|
805
|
+
try {
|
|
806
|
+
at = Number(clock());
|
|
807
|
+
} catch {
|
|
808
|
+
return false;
|
|
809
|
+
}
|
|
810
|
+
if (!Number.isFinite(at) || !Number.isFinite(createdAt)) return false;
|
|
811
|
+
return at - createdAt < graceMs;
|
|
812
|
+
}
|
|
774
813
|
function availableRows() {
|
|
775
814
|
try {
|
|
776
815
|
if (typeof rowsAvailable === 'function') {
|
|
@@ -834,6 +873,10 @@ function createSingleSelect({ title, items, getId, getLabel, helpers, hostTui, t
|
|
|
834
873
|
}
|
|
835
874
|
function handleInput(data) {
|
|
836
875
|
if (settled) return;
|
|
876
|
+
// S11: an event that arrives inside the grace window is DROPPED whole — it
|
|
877
|
+
// neither answers, nor cancels, nor moves the cursor, so a keystroke the
|
|
878
|
+
// human made before the panel could be seen leaves no trace on it.
|
|
879
|
+
if (insideGraceWindow()) return;
|
|
837
880
|
if (isKeyRelease(helpers, data)) return;
|
|
838
881
|
// Ctrl+D deletes the focused row ONLY when the opt-in predicate says
|
|
839
882
|
// so (warp selector: eligible worktree rows). On a protected row
|
|
@@ -899,6 +942,10 @@ function createSingleSelect({ title, items, getId, getLabel, helpers, hostTui, t
|
|
|
899
942
|
|
|
900
943
|
module.exports = {
|
|
901
944
|
MULTI_SELECT_PAGE_SIZE_DEFAULT,
|
|
945
|
+
COPY_QUESTION_INPUT_GRACE_MS,
|
|
946
|
+
COPY_QUESTION_ITEMS,
|
|
947
|
+
COPY_QUESTION_SAFE_ANSWER,
|
|
948
|
+
copyQuestionOptions,
|
|
902
949
|
paginate,
|
|
903
950
|
createMultiSelect,
|
|
904
951
|
createSingleSelect,
|
|
@@ -34,9 +34,11 @@
|
|
|
34
34
|
// identical while the work is different, so the counts alone would
|
|
35
35
|
// authorize deleting something the human never saw.
|
|
36
36
|
// - `ignored`, the files git ignores (build output, `.env`, `node_modules/`…).
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
// the
|
|
37
|
+
// A2 used to name them in the question; the human's objection was that they
|
|
38
|
+
// are untracked, ignored files and announcing them is noise, so the reading
|
|
39
|
+
// stays — the path list and its fingerprint are the safety net the
|
|
40
|
+
// post-answer comparison uses — and the question no longer discloses them.
|
|
41
|
+
// They are still deleted with the checkout, and nothing warns about them.
|
|
40
42
|
|
|
41
43
|
const crypto = require('node:crypto');
|
|
42
44
|
const os = require('node:os');
|
|
@@ -56,8 +58,9 @@ const MAX_FINGERPRINT_BYTES = 32 * 1024 * 1024;
|
|
|
56
58
|
// One bounded read buffer, reused for every hashed file. Nothing else about a
|
|
57
59
|
// file's size reaches memory: the bytes are hashed as they arrive.
|
|
58
60
|
const READ_CHUNK_BYTES = 64 * 1024;
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
+
// The ignored-file reading keeps a few sample paths: they are no longer
|
|
62
|
+
// disclosed in the question (A2 amendment), but the reading is what the
|
|
63
|
+
// post-answer comparison and the moved-facts report use.
|
|
61
64
|
const IGNORED_SAMPLES = 3;
|
|
62
65
|
|
|
63
66
|
function optionalRequire(name) {
|
|
@@ -372,25 +375,13 @@ function changesLine(changes) {
|
|
|
372
375
|
return ` Uncommitted changes: unknown (${reason}).`;
|
|
373
376
|
}
|
|
374
377
|
|
|
375
|
-
// A2: ignored files are deleted with the checkout while the working
|
|
376
|
-
// clean,
|
|
377
|
-
//
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
const samples = Array.isArray(ignored.samples) ? ignored.samples.filter((entry) => typeof entry === 'string' && entry.length > 0) : [];
|
|
383
|
-
const named = samples.join(', ');
|
|
384
|
-
const more = files > samples.length ? `, +${files - samples.length} more` : '';
|
|
385
|
-
return ` Ignored files (deleted with the checkout): ${named}${more}.`;
|
|
386
|
-
}
|
|
387
|
-
if (ignored.status === 'none') return '';
|
|
388
|
-
const reason = typeof ignored.reason === 'string' && ignored.reason.length > 0
|
|
389
|
-
? ignored.reason
|
|
390
|
-
: 'the ignored-file listing failed';
|
|
391
|
-
return ` Ignored files: unknown (${reason}).`;
|
|
392
|
-
}
|
|
393
|
-
|
|
378
|
+
// A2 (amended): ignored files are deleted with the checkout while the working
|
|
379
|
+
// tree reads clean, and the human asked that the question stop naming them —
|
|
380
|
+
// they are untracked, ignored files, so announcing them is noise. The READING
|
|
381
|
+
// stays (`readIgnored`), and `warpDeleteEvidenceKey` still carries it, so an
|
|
382
|
+
// ignored file that appears between the answer and the removal still refuses
|
|
383
|
+
// the deletion; only the body line is gone. Nothing warns about those paths any
|
|
384
|
+
// more, which is the accepted consequence of this change.
|
|
394
385
|
function aheadLine(aheadMain) {
|
|
395
386
|
if (!aheadMain || typeof aheadMain !== 'object') return ' Commits ahead of main: unknown.';
|
|
396
387
|
if (aheadMain.status === 'ahead') return ` Commits ahead of main: ${aheadMain.ahead}.`;
|
|
@@ -438,7 +429,8 @@ function warpDeleteEvidenceKey(evidence) {
|
|
|
438
429
|
|
|
439
430
|
// Build the dialog for one checkout. `force: true` only on POSITIVE evidence
|
|
440
431
|
// of pending changes, so the shared close is never forced on a checkout the
|
|
441
|
-
// evidence cannot vouch for.
|
|
432
|
+
// evidence cannot vouch for. The title states what the dialog IS — a
|
|
433
|
+
// confirmation — and the facts stay below it in the body.
|
|
442
434
|
function warpDeletePrompt(target, evidence) {
|
|
443
435
|
const entry = target && typeof target === 'object' ? target : {};
|
|
444
436
|
const name = typeof entry.name === 'string' ? entry.name : String(entry.name ?? '');
|
|
@@ -447,10 +439,9 @@ function warpDeletePrompt(target, evidence) {
|
|
|
447
439
|
const read = evidence && typeof evidence === 'object' ? evidence : {};
|
|
448
440
|
const body = `Delete worktree checkout at ${checkoutPath} for branch '${branch}'? This removes the checkout but keeps the branch.`
|
|
449
441
|
+ changesLine(read.changes)
|
|
450
|
-
+ aheadLine(read.aheadMain)
|
|
451
|
-
+ ignoredLine(read.ignored);
|
|
442
|
+
+ aheadLine(read.aheadMain);
|
|
452
443
|
return {
|
|
453
|
-
title: `
|
|
444
|
+
title: `Confirm delete: worktree '${name}'`,
|
|
454
445
|
body,
|
|
455
446
|
force: !!(read.changes && read.changes.status === 'dirty'),
|
|
456
447
|
};
|
|
@@ -103,19 +103,17 @@
|
|
|
103
103
|
// discloses, the refusals and the removal. So a keypress
|
|
104
104
|
// can never remove anything on its own, and this view needs
|
|
105
105
|
// no permission mode.
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
// there steps back one level to the panel.
|
|
106
|
+
// S20: the extended list is a KEY, not a row — `a` opens it,
|
|
107
|
+
// and no `view all worktrees` row exists to select.
|
|
109
108
|
//
|
|
110
109
|
// Keys, exactly (S5 + docs/keys.md): `↑`/`↓` and `j`/`k` move, `enter`
|
|
111
|
-
// chooses
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
// list, `r` reloads, `esc`/`ctrl+c` close from the panel
|
|
110
|
+
// chooses, `c` opens the create flow, `ctrl+d` asks to delete the focused
|
|
111
|
+
// checkout, `a` opens the extended
|
|
112
|
+
// list (S14: never `v`), `r` reloads, `esc`/`ctrl+c` close from the panel
|
|
115
113
|
// or step back from the list. S1/S4: `e` (edit) is
|
|
116
114
|
// deliberately NOT a binding and no legend names it; `ctrl+d` is offered on
|
|
117
|
-
// the focused checkout row and
|
|
118
|
-
// checkout). S9 keeps the footer
|
|
115
|
+
// the focused checkout row, and only there — every row the cursor can reach
|
|
116
|
+
// is a real checkout (S20). S9 keeps the footer
|
|
119
117
|
// shortcuts and binds no
|
|
120
118
|
// `?` help overlay: the footer already names every key. `↑`/`↓` are
|
|
121
119
|
// never repurposed for ahead/behind: both numbers ride the facts line. In the
|
|
@@ -137,17 +135,25 @@
|
|
|
137
135
|
// receiving issues and ODD documents, so neither an id, a name nor a count of
|
|
138
136
|
// them is rendered anywhere in this component.
|
|
139
137
|
//
|
|
140
|
-
// Layout (S3/S4, pinned top to bottom):
|
|
141
|
-
// panel 7 fixed rows — top rule
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
//
|
|
138
|
+
// Layout (S3/S4/S15/S16/S19/S20, pinned top to bottom):
|
|
139
|
+
// panel 7 fixed rows — top rule carrying the heading `Warp · n worktrees`
|
|
140
|
+
// (n = the checkouts the panel's listing holds, S16), the CURRENT
|
|
141
|
+
// checkout's detail line, the FOCUSED checkout's detail line (S19:
|
|
142
|
+
// the block is the two detail lines alone — no name line), a blank
|
|
143
|
+
// row, the list, a second blank row, the one-row key legend and the
|
|
144
|
+
// bottom rule — plus a SCROLLABLE list BLOCK of seven lines (S15,
|
|
145
|
+
// corrected by L19/L20): five checkout rows when both `↑ n more` and
|
|
146
|
+
// `↓ n more` are drawn, six when only one is, seven when nothing is
|
|
147
|
+
// hidden. Both are fixed
|
|
148
|
+
// text OUTSIDE the selection space, so the cursor never lands on
|
|
149
|
+
// them and neither line exists when its count is zero. The height is
|
|
150
|
+
// the
|
|
148
151
|
// content's own height, clamped by `rowsAvailable`, so the frame
|
|
149
|
-
// always fills it exactly.
|
|
150
|
-
//
|
|
152
|
+
// always fills it exactly. With nothing to list, one
|
|
153
|
+
// `(no other worktrees)` row takes the window's place.
|
|
154
|
+
// list 5 fixed rows — top rule carrying `Warp · all n worktrees` (S20: n
|
|
155
|
+
// is the panel's rows PLUS the checkouts outside
|
|
156
|
+
// `<repo-name>-worktrees/`), the filter row (never selectable), a
|
|
151
157
|
// page of every OTHER checkout (the current one is never a
|
|
152
158
|
// destination, so it is not a row here either), the page indicator
|
|
153
159
|
// and the key footer, the bottom rule. When nothing is left to
|
|
@@ -175,12 +181,14 @@ function paintKind(theme, kind, text) {
|
|
|
175
181
|
}
|
|
176
182
|
|
|
177
183
|
const MIN_WIDTH = 24;
|
|
178
|
-
//
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
//
|
|
182
|
-
|
|
183
|
-
//
|
|
184
|
+
// S15 (L20): the panel's list BLOCK is seven lines, and the `↑ n more` /
|
|
185
|
+
// `↓ n more` lines are drawn out of that same budget: both drawn leaves five
|
|
186
|
+
// checkout rows, one drawn leaves six, and with nothing hidden the block holds
|
|
187
|
+
// seven checkouts (or every one of them, when there are fewer).
|
|
188
|
+
const LIST_BLOCK_LINES = 7;
|
|
189
|
+
// top rule + the current checkout's detail + the focused checkout's detail +
|
|
190
|
+
// blank + blank above the legend + the legend + bottom rule (S19). The list
|
|
191
|
+
// block comes on top of these.
|
|
184
192
|
const POPUP_FIXED_ROWS = 7;
|
|
185
193
|
// The panel needs its fixed rows plus one list row to be readable at all.
|
|
186
194
|
const POPUP_MIN_HEIGHT = POPUP_FIXED_ROWS + 1;
|
|
@@ -203,7 +211,7 @@ const POPUP_KEYS = [
|
|
|
203
211
|
{ key: 'enter', text: 'enter choose', short: 'enter', priority: 60 },
|
|
204
212
|
{ key: 'c', text: 'c create', short: 'c create', priority: 50 },
|
|
205
213
|
{ key: 'ctrl+d', text: 'ctrl+d delete', short: 'ctrl+d', priority: 40 },
|
|
206
|
-
{ key: '
|
|
214
|
+
{ key: 'a', text: 'a all', short: 'a all', priority: 30 },
|
|
207
215
|
{ key: 'r', text: 'r reload', short: 'r reload', priority: 20 },
|
|
208
216
|
{ key: 'esc', text: 'esc close', short: 'esc close', priority: 80 },
|
|
209
217
|
];
|
|
@@ -336,6 +344,26 @@ function basename(target) {
|
|
|
336
344
|
return parts.length > 0 ? parts[parts.length - 1] : String(target);
|
|
337
345
|
}
|
|
338
346
|
|
|
347
|
+
// S20: the checkouts this package created live under
|
|
348
|
+
// `<repo-name>-worktrees/<odd>`, so an entry lives in the selector's own
|
|
349
|
+
// LISTING when it is the principal checkout (which stands beside that
|
|
350
|
+
// directory) or when its parent directory is a `…-worktrees` root. Git may
|
|
351
|
+
// also know worktrees outside it: those are the ones the panel's listing does
|
|
352
|
+
// not hold, only the extended list offers, and the ones that make the `a`
|
|
353
|
+
// token appear in the legend.
|
|
354
|
+
function inListing(entry) {
|
|
355
|
+
if (entry.isPrincipal === true) return true;
|
|
356
|
+
const parts = String(entry.path).split(/[\\/]/).filter((part) => part.length > 0);
|
|
357
|
+
parts.pop();
|
|
358
|
+
const parent = parts.length > 0 ? parts[parts.length - 1] : '';
|
|
359
|
+
return /-worktrees$/.test(parent);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// S16: the heading's count, with the same plural rule the list footer uses.
|
|
363
|
+
function worktreeCount(total) {
|
|
364
|
+
return `${total} ${total === 1 ? 'worktree' : 'worktrees'}`;
|
|
365
|
+
}
|
|
366
|
+
|
|
339
367
|
// Epoch ms for a timestamp in any of the forms a caller may supply: a finite
|
|
340
368
|
// number, a Date, or an ISO string. Null when it is not a readable timestamp
|
|
341
369
|
// (S9: an unreadable value is never a zero).
|
|
@@ -665,6 +693,19 @@ function createWarpSelectorView(options = {}) {
|
|
|
665
693
|
return checkouts.filter((entry) => !isCurrent(entry));
|
|
666
694
|
}
|
|
667
695
|
|
|
696
|
+
// S20: the panel lists what this package created — its own LISTING, the
|
|
697
|
+
// principal included — while the extended list adds the worktrees Git knows
|
|
698
|
+
// outside `<repo-name>-worktrees/`. The `a` token is advertised only when
|
|
699
|
+
// such a checkout exists, because only then does the extended list hold
|
|
700
|
+
// anything the panel does not.
|
|
701
|
+
function listed() {
|
|
702
|
+
return others().filter((entry) => inListing(entry));
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function hasOutside() {
|
|
706
|
+
return others().some((entry) => !inListing(entry));
|
|
707
|
+
}
|
|
708
|
+
|
|
668
709
|
// The identity of one path: the canonical spelling when the caller supplied
|
|
669
710
|
// a reader, the path itself otherwise. A reader that throws or answers
|
|
670
711
|
// nothing leaves the spelling as the identity instead of breaking a frame.
|
|
@@ -709,33 +750,71 @@ function createWarpSelectorView(options = {}) {
|
|
|
709
750
|
return `${marker}${entry.name}${desc ? ` · ${desc}` : ''}`;
|
|
710
751
|
}
|
|
711
752
|
|
|
712
|
-
//
|
|
713
|
-
//
|
|
714
|
-
//
|
|
715
|
-
//
|
|
753
|
+
// S15/S20: the panel's list area is a BUDGET of seven lines (L20) shared
|
|
754
|
+
// with the `↑ n more` / `↓ n more` lines: the window follows the selection
|
|
755
|
+
// one row at a time, the two lines are fixed text outside the selection
|
|
756
|
+
// space, and a short panel caps the budget at the rows the host offers, so
|
|
757
|
+
// the frame never overflows.
|
|
758
|
+
function windowStart(cursor, visible, total) {
|
|
759
|
+
if (total <= visible) return 0;
|
|
760
|
+
if (cursor < visible) return 0;
|
|
761
|
+
return Math.min(cursor - visible + 1, Math.max(0, total - visible));
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
// The visible rows, the window's start and the two hidden counts, solved
|
|
765
|
+
// together: the number of lines the block draws depends on where the window
|
|
766
|
+
// sits, and the window's size depends on how many lines it draws.
|
|
767
|
+
function listWindow(total, cursor, budget) {
|
|
768
|
+
if (total === 0 || budget <= 0) return { start: 0, visible: 0, up: 0, down: 0 };
|
|
769
|
+
// Too short for a row and a count line: the rows take the whole budget, so
|
|
770
|
+
// the frame stays inside the rows the host offers.
|
|
771
|
+
if (budget < 3) {
|
|
772
|
+
const visible = Math.min(budget, total);
|
|
773
|
+
return { start: windowStart(cursor, visible, total), visible, up: 0, down: 0 };
|
|
774
|
+
}
|
|
775
|
+
let visible = Math.min(budget, total);
|
|
776
|
+
for (let step = 0; step < 4; step += 1) {
|
|
777
|
+
const start = windowStart(cursor, visible, total);
|
|
778
|
+
const lines = (start > 0 ? 1 : 0) + (start + visible < total ? 1 : 0);
|
|
779
|
+
const next = Math.max(1, Math.min(total, budget - lines));
|
|
780
|
+
if (next === visible) break;
|
|
781
|
+
visible = next;
|
|
782
|
+
}
|
|
783
|
+
const start = windowStart(cursor, visible, total);
|
|
784
|
+
return {
|
|
785
|
+
start,
|
|
786
|
+
visible,
|
|
787
|
+
up: start,
|
|
788
|
+
down: Math.max(0, total - (start + visible)),
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
|
|
716
792
|
function popupPlan(maxRows) {
|
|
717
|
-
const list =
|
|
793
|
+
const list = listed();
|
|
794
|
+
const total = list.length;
|
|
718
795
|
const area = Math.max(0, maxRows - POPUP_FIXED_ROWS);
|
|
719
|
-
if (
|
|
720
|
-
// One muted row explains the empty
|
|
721
|
-
return { list, shown: [],
|
|
796
|
+
if (total === 0) {
|
|
797
|
+
// One muted row explains the empty listing inside the frame.
|
|
798
|
+
return { list, start: 0, shown: [], up: 0, down: 0, height: POPUP_FIXED_ROWS + 1 };
|
|
722
799
|
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
800
|
+
const cursor = Math.min(Math.max(0, state.cursor), total - 1);
|
|
801
|
+
const budget = Math.min(LIST_BLOCK_LINES, area);
|
|
802
|
+
const window = listWindow(total, cursor, budget);
|
|
803
|
+
return {
|
|
804
|
+
list,
|
|
805
|
+
start: window.start,
|
|
806
|
+
shown: list.slice(window.start, window.start + window.visible),
|
|
807
|
+
up: window.up,
|
|
808
|
+
down: window.down,
|
|
809
|
+
height: POPUP_FIXED_ROWS + window.visible + (window.up > 0 ? 1 : 0) + (window.down > 0 ? 1 : 0),
|
|
810
|
+
};
|
|
730
811
|
}
|
|
731
812
|
|
|
732
|
-
//
|
|
733
|
-
//
|
|
813
|
+
// S20: the panel's rows are exactly the checkouts its listing holds — there
|
|
814
|
+
// is no `view all worktrees` row to select any more, so the cursor only ever
|
|
815
|
+
// lands on a real checkout.
|
|
734
816
|
function popupItems(plan) {
|
|
735
|
-
|
|
736
|
-
for (const entry of plan.shown) items.push({ kind: 'checkout', checkout: entry });
|
|
737
|
-
if (plan.viewAll) items.push({ kind: 'viewall' });
|
|
738
|
-
return items;
|
|
817
|
+
return plan.list.map((entry) => ({ kind: 'checkout', checkout: entry }));
|
|
739
818
|
}
|
|
740
819
|
|
|
741
820
|
function popupItemsNow() {
|
|
@@ -770,12 +849,12 @@ function createWarpSelectorView(options = {}) {
|
|
|
770
849
|
return factsTextFor(currentPath);
|
|
771
850
|
}
|
|
772
851
|
|
|
773
|
-
//
|
|
774
|
-
//
|
|
852
|
+
// S19: the row the cursor sits on, or an empty line when nothing is listed
|
|
853
|
+
// (the list area already says why). The selection only ever lands on a real
|
|
854
|
+
// checkout (S20), so this line always describes one.
|
|
775
855
|
function factsRowText() {
|
|
776
856
|
const item = focusedPopupItem();
|
|
777
857
|
if (!item) return '';
|
|
778
|
-
if (item.kind === 'viewall') return 'every worktree, searchable';
|
|
779
858
|
return factsTextFor(item.checkout.path);
|
|
780
859
|
}
|
|
781
860
|
|
|
@@ -939,18 +1018,13 @@ function createWarpSelectorView(options = {}) {
|
|
|
939
1018
|
function choosePopup() {
|
|
940
1019
|
const item = focusedPopupItem();
|
|
941
1020
|
if (!item) return;
|
|
942
|
-
if (item.kind === 'viewall') {
|
|
943
|
-
openList();
|
|
944
|
-
return;
|
|
945
|
-
}
|
|
946
1021
|
finish({ warp: item.checkout.path });
|
|
947
1022
|
}
|
|
948
1023
|
|
|
949
1024
|
// S4: `ctrl+d` NAMES the checkout to delete and nothing else. The marker
|
|
950
1025
|
// carries the focused path, so the extension re-resolves it against a fresh
|
|
951
1026
|
// listing and asks its own question; nothing here reads a permission mode,
|
|
952
|
-
// inspects changes or removes anything.
|
|
953
|
-
// it resolves nothing.
|
|
1027
|
+
// inspects changes or removes anything.
|
|
954
1028
|
function askDelete(item) {
|
|
955
1029
|
if (!item || item.kind !== 'checkout') return;
|
|
956
1030
|
finish({ delete: item.checkout.path });
|
|
@@ -998,7 +1072,7 @@ function createWarpSelectorView(options = {}) {
|
|
|
998
1072
|
askDeletePopup();
|
|
999
1073
|
return;
|
|
1000
1074
|
}
|
|
1001
|
-
if (keyText(helpers, data, ['
|
|
1075
|
+
if (keyText(helpers, data, ['a'])) {
|
|
1002
1076
|
openList();
|
|
1003
1077
|
return;
|
|
1004
1078
|
}
|
|
@@ -1127,11 +1201,14 @@ function createWarpSelectorView(options = {}) {
|
|
|
1127
1201
|
return `${border('│')} ${body} ${border('│')}`;
|
|
1128
1202
|
}
|
|
1129
1203
|
|
|
1130
|
-
// The panel legend's tokens: the offer row
|
|
1131
|
-
//
|
|
1132
|
-
//
|
|
1133
|
-
|
|
1134
|
-
|
|
1204
|
+
// The panel legend's tokens: S20 dropped the offer row, so the `a` token is
|
|
1205
|
+
// a KEY for the extended list and it appears only when that list holds a
|
|
1206
|
+
// checkout the panel's listing does not (one outside
|
|
1207
|
+
// `<repo-name>-worktrees/`). S1/S4: no capability token is conditional any
|
|
1208
|
+
// more — the delete key and its predicate left with the worktree
|
|
1209
|
+
// association.
|
|
1210
|
+
function popupLegend() {
|
|
1211
|
+
return hasOutside() ? POPUP_KEYS.slice() : POPUP_KEYS.filter((entry) => entry.key !== 'a');
|
|
1135
1212
|
}
|
|
1136
1213
|
|
|
1137
1214
|
// S2/S11: the footer legend renders through the frame row, so it is
|
|
@@ -1141,9 +1218,12 @@ function createWarpSelectorView(options = {}) {
|
|
|
1141
1218
|
return frameRow(width, palette.legendRow(theme, entries, Math.max(1, width - 4), (text) => measure(helpers, text)), null);
|
|
1142
1219
|
}
|
|
1143
1220
|
|
|
1144
|
-
// S3/S4: the panel renders exactly `plan.height` rows
|
|
1145
|
-
//
|
|
1146
|
-
//
|
|
1221
|
+
// S3/S4/S15/S16/S19: the panel renders exactly `plan.height` rows — the
|
|
1222
|
+
// heading with its checkout count, the two detail lines (S19: no name line),
|
|
1223
|
+
// the blank row, the scrollable window with its hidden-count lines, the
|
|
1224
|
+
// second blank row, the legend and the bottom rule — so a host that anchors
|
|
1225
|
+
// it at the bottom of the terminal gets a frame with no loose lines inside
|
|
1226
|
+
// or below it.
|
|
1147
1227
|
function renderPopup(width, maxRows) {
|
|
1148
1228
|
const plan = popupPlan(maxRows);
|
|
1149
1229
|
const items = popupItems(plan);
|
|
@@ -1151,31 +1231,27 @@ function createWarpSelectorView(options = {}) {
|
|
|
1151
1231
|
if (state.cursor < 0) state.cursor = 0;
|
|
1152
1232
|
const focused = items[state.cursor];
|
|
1153
1233
|
|
|
1154
|
-
const lines = [frameTop(width,
|
|
1155
|
-
lines.push(frameRow(width, current ? current.name : '(unknown checkout)', 'value'));
|
|
1234
|
+
const lines = [frameTop(width, `Warp · ${worktreeCount(plan.list.length)}`)];
|
|
1156
1235
|
lines.push(frameRow(width, currentFactsText(), 'count'));
|
|
1236
|
+
lines.push(frameRow(width, factsRowText(), 'count'));
|
|
1157
1237
|
lines.push(frameRow(width, ''));
|
|
1158
1238
|
|
|
1159
1239
|
if (plan.list.length === 0) {
|
|
1160
1240
|
lines.push(frameRow(width, '(no other worktrees)', 'count'));
|
|
1161
1241
|
} else {
|
|
1242
|
+
// S15: the hidden-count lines are text, not rows: they take their own
|
|
1243
|
+
// lines only while there is something to announce, and the window never
|
|
1244
|
+
// reserves a line it does not draw.
|
|
1245
|
+
if (plan.up > 0) lines.push(frameRow(width, `↑ ${plan.up} more`, 'count'));
|
|
1162
1246
|
for (const entry of plan.shown) {
|
|
1163
|
-
const isFocused = !!(focused && focused.
|
|
1247
|
+
const isFocused = !!(focused && focused.checkout.path === entry.path);
|
|
1164
1248
|
lines.push(frameRow(width, rowText(entry, isFocused ? '▸ ' : ' '), null, isFocused));
|
|
1165
1249
|
}
|
|
1166
|
-
if (plan.
|
|
1167
|
-
lines.push(frameRow(
|
|
1168
|
-
width,
|
|
1169
|
-
`${focused && focused.kind === 'viewall' ? '▸ ' : ' '}view all worktrees`,
|
|
1170
|
-
'value',
|
|
1171
|
-
!!(focused && focused.kind === 'viewall'),
|
|
1172
|
-
));
|
|
1173
|
-
}
|
|
1250
|
+
if (plan.down > 0) lines.push(frameRow(width, `↓ ${plan.down} more`, 'count'));
|
|
1174
1251
|
}
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
lines.push(legendRow(width, popupLegend(plan)));
|
|
1252
|
+
// S19: the blank row above the keybindings.
|
|
1253
|
+
lines.push(frameRow(width, ''));
|
|
1254
|
+
lines.push(legendRow(width, popupLegend()));
|
|
1179
1255
|
lines.push(frameBottom(width));
|
|
1180
1256
|
return lines;
|
|
1181
1257
|
}
|
|
@@ -1206,7 +1282,9 @@ function createWarpSelectorView(options = {}) {
|
|
|
1206
1282
|
});
|
|
1207
1283
|
}
|
|
1208
1284
|
const filterText = filterLine();
|
|
1209
|
-
|
|
1285
|
+
// S16/S20: the heading counts what this list holds — the panel's rows plus
|
|
1286
|
+
// the checkouts outside `<repo-name>-worktrees/` — from the same listing.
|
|
1287
|
+
const lines = [frameTop(width, `Warp · all ${worktreeCount(others().length)}`)];
|
|
1210
1288
|
lines.push(frameRow(width, filterText, state.filterOpen ? null : 'count', state.filterOpen));
|
|
1211
1289
|
for (let row = 0; row < plan.pageSize; row += 1) {
|
|
1212
1290
|
const entry = rowTexts[row];
|
|
@@ -1257,7 +1335,7 @@ module.exports = {
|
|
|
1257
1335
|
createWarpSelectorView,
|
|
1258
1336
|
formatFactsLine,
|
|
1259
1337
|
MIN_WIDTH,
|
|
1260
|
-
|
|
1338
|
+
LIST_BLOCK_LINES,
|
|
1261
1339
|
POPUP_MIN_HEIGHT,
|
|
1262
1340
|
LIST_MIN_HEIGHT,
|
|
1263
1341
|
POPUP_FIXED_ROWS,
|