pi-odd-worktree 3.11.0 → 3.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions/odd-worktree-tools.ts +111 -40
- package/lib/gh-prs.js +4 -1
- package/lib/issue-preview.js +53 -10
- package/lib/issues-view.js +55 -21
- package/lib/pr-preview.js +36 -5
- package/lib/prs-view.js +398 -65
- package/lib/user-prompt-card.js +68 -10
- package/package.json +1 -1
- package/tools/gh-prs.test.js +5 -1
- package/tools/issue-preview.test.js +113 -0
- package/tools/issues-command.test.js +8 -5
- package/tools/issues-view.test.js +130 -0
- package/tools/pr-preview.test.js +134 -0
- package/tools/prs-command.test.js +49 -0
- package/tools/prs-view.test.js +350 -5
- package/tools/user-prompt-card.test.js +173 -6
|
@@ -7742,36 +7742,6 @@ function issuesScopeDriftLine(currentName, pinnedName, command = "/issues") {
|
|
|
7742
7742
|
// open reads as a cut. Pi's own suspend passes the same option when it is in
|
|
7743
7743
|
// fullscreen mode. A host that is not on the alternate screen ignores it, and a
|
|
7744
7744
|
// host without `stop()` keeps the previous behaviour untouched.
|
|
7745
|
-
function withSuspendedTerminal(hostTui, run) {
|
|
7746
|
-
let suspended = false;
|
|
7747
|
-
try {
|
|
7748
|
-
if (hostTui && typeof hostTui.stop === "function") {
|
|
7749
|
-
hostTui.stop({ preserveScreen: true });
|
|
7750
|
-
suspended = true;
|
|
7751
|
-
}
|
|
7752
|
-
} catch {
|
|
7753
|
-
suspended = false;
|
|
7754
|
-
}
|
|
7755
|
-
const resume = () => {
|
|
7756
|
-
if (!suspended) return;
|
|
7757
|
-
suspended = false;
|
|
7758
|
-
try {
|
|
7759
|
-
if (hostTui && typeof hostTui.start === "function") hostTui.start();
|
|
7760
|
-
} catch {
|
|
7761
|
-
// A host that cannot restart still gets the repaint attempt below.
|
|
7762
|
-
}
|
|
7763
|
-
try {
|
|
7764
|
-
if (hostTui && typeof hostTui.requestRender === "function") hostTui.requestRender(true);
|
|
7765
|
-
} catch {
|
|
7766
|
-
// A repaint failure never breaks the open.
|
|
7767
|
-
}
|
|
7768
|
-
};
|
|
7769
|
-
return Promise.resolve()
|
|
7770
|
-
.then(run)
|
|
7771
|
-
.catch((err) => ({ ok: false, error: (err && err.message) || "open failed" }))
|
|
7772
|
-
.finally(resume);
|
|
7773
|
-
}
|
|
7774
|
-
|
|
7775
7745
|
// The `o`-key browser opener: `gh issue view <n> --web` through the file's own
|
|
7776
7746
|
// fixed-argv runner (never a shell, never xdg-open). `-R <owner/name>` is the
|
|
7777
7747
|
// repository the LIST was loaded from, bound when the list loads and passed at
|
|
@@ -7801,7 +7771,13 @@ function githubItemOpenInBrowser(hostTui, cwd, kind, number, pinnedIdentity) {
|
|
|
7801
7771
|
}
|
|
7802
7772
|
const bin = gh && typeof gh.ghBinary === "function" ? gh.ghBinary({}) : "gh";
|
|
7803
7773
|
const argv = [label, "view", String(number), "--web", "-R", normalized.identity];
|
|
7804
|
-
|
|
7774
|
+
// The child runs on pipes and never touches the terminal, so the host TUI is
|
|
7775
|
+
// NOT suspended for it: stopping and restarting Pi's renderer to open a URL
|
|
7776
|
+
// left the screen on the plain shell, repainting nothing (the reported bug,
|
|
7777
|
+
// and why this is a plain bounded read now). Opening a browser is not an
|
|
7778
|
+
// interactive child; `lib/open-external.js` stays the one opener that
|
|
7779
|
+
// suspends, because an editor really does need the terminal.
|
|
7780
|
+
return (async () => {
|
|
7805
7781
|
const res = await git.runArgvAsync(bin, argv, { cwd, timeoutMs: 30000 });
|
|
7806
7782
|
if (!res) return { ok: false, error: `cannot open ${label} #${number} in the browser` };
|
|
7807
7783
|
if (res.error) return { ok: false, error: res.error };
|
|
@@ -7810,7 +7786,7 @@ function githubItemOpenInBrowser(hostTui, cwd, kind, number, pinnedIdentity) {
|
|
|
7810
7786
|
return { ok: false, error: stderr || `cannot open ${label} #${number} in the browser (gh exited with status ${res.status})` };
|
|
7811
7787
|
}
|
|
7812
7788
|
return { ok: true };
|
|
7813
|
-
});
|
|
7789
|
+
})();
|
|
7814
7790
|
} catch (err) {
|
|
7815
7791
|
return Promise.resolve({ ok: false, error: (err && err.message) || `cannot open ${label} #${number} in the browser` });
|
|
7816
7792
|
}
|
|
@@ -8308,7 +8284,7 @@ async function openIssuesPanel(rawArgs, ctx, releaseOpen, resolvedCheckoutRoot,
|
|
|
8308
8284
|
|
|
8309
8285
|
// The four buckets the reader's tabs and its lazy `g` view name. The client
|
|
8310
8286
|
// derives the search qualifier from the bucket id (`author:@me`,
|
|
8311
|
-
// `review-requested:@me`, `involves:@me`) and reads the repository's own
|
|
8287
|
+
// `review-requested:@me`, `involves:@me -author:@me`) and reads the repository's own
|
|
8312
8288
|
// pull-request connection for an unfiltered `all`, exactly like the issues
|
|
8313
8289
|
// client. `lazy` keeps `all` out of the tab bar, the tab cycle and the prefetch.
|
|
8314
8290
|
const PRS_INTERACTIVE_BUCKETS = [
|
|
@@ -8392,6 +8368,32 @@ async function loadStoredRailPullRequests(identity) {
|
|
|
8392
8368
|
return prsRailStoredEntry;
|
|
8393
8369
|
}
|
|
8394
8370
|
|
|
8371
|
+
// S1/S8 (T22): `/issues` paints its first frame from the rail's in-process cache
|
|
8372
|
+
// (`issuesSidebarCachedPages`), and `/prs` must open just as fast. The rail's
|
|
8373
|
+
// pull-request read and the stored-entry load both land in the same in-memory
|
|
8374
|
+
// pair, so this reader is synchronous — no child, no disk read on the open path —
|
|
8375
|
+
// and it answers only for the identity the panel just PROVED, never for another
|
|
8376
|
+
// repository's rows. A bucket with no rows seeds nothing, so every page keeps
|
|
8377
|
+
// exactly the behaviour it had before this seed existed.
|
|
8378
|
+
function prsRailCachedPages(identity) {
|
|
8379
|
+
if (typeof identity !== "string" || identity.length === 0) return null;
|
|
8380
|
+
if (prsRailStaleIdentities.has(identity)) return null;
|
|
8381
|
+
if (prsRailStoredIdentity !== identity) return null;
|
|
8382
|
+
const entry = prsRailStoredEntry;
|
|
8383
|
+
if (!entry || typeof entry !== "object") return null;
|
|
8384
|
+
const counts = storedRailCounts(entry);
|
|
8385
|
+
const pages = new Map();
|
|
8386
|
+
for (const id of ["mine", "review"]) {
|
|
8387
|
+
const rows = Array.isArray(entry[id]) ? entry[id] : [];
|
|
8388
|
+
if (rows.length === 0) continue;
|
|
8389
|
+
const total = counts && Number.isFinite(Number(counts[id])) ? Number(counts[id]) : rows.length;
|
|
8390
|
+
// A total below its own rows is not a count: the store already refuses one,
|
|
8391
|
+
// and this reader never invents one either.
|
|
8392
|
+
pages.set(id, { rows, total: total >= rows.length ? total : rows.length });
|
|
8393
|
+
}
|
|
8394
|
+
return pages.size === 0 ? null : pages;
|
|
8395
|
+
}
|
|
8396
|
+
|
|
8395
8397
|
// T10b (S4, D15): the bucket totals a stored entry carries, or `null` when it
|
|
8396
8398
|
// carries none. The store already dropped every total it could not prove (one
|
|
8397
8399
|
// below its own rows, one that is not a count), so what arrives here is exactly
|
|
@@ -8874,6 +8876,30 @@ async function openPrsPanel(rawArgs, ctx, releaseOpen, resolvedCheckoutRoot, pi)
|
|
|
8874
8876
|
if (pinned.ok !== true) return pinned;
|
|
8875
8877
|
return await prs.listAssignableUsers(pinned.args);
|
|
8876
8878
|
};
|
|
8879
|
+
// T20: the linked-issues editor's candidate list. It asks the ISSUE client's
|
|
8880
|
+
// search page for the pinned repository's open issues, hottest-updated first,
|
|
8881
|
+
// one bounded cursor page at a time — the view never imports a client file.
|
|
8882
|
+
// `getIssuePage` already pins `repo:<pinned> is:issue is:open` and the
|
|
8883
|
+
// `sort:updated-desc` order, and answers one row cursor per issue, so the
|
|
8884
|
+
// continuation is the last row's own cursor.
|
|
8885
|
+
const loadIssueCandidates = (request = {}) => {
|
|
8886
|
+
const after = request.after == null || request.after === "" ? null : String(request.after);
|
|
8887
|
+
const asked = Number(request.pageSize);
|
|
8888
|
+
const pageSize = Number.isFinite(asked) ? Math.min(PRS_PAGE_MAX, Math.max(1, Math.floor(asked))) : PRS_PAGE_MAX;
|
|
8889
|
+
return issuesWrapFailure((async () => {
|
|
8890
|
+
const pinned = await pinnedReadArgs();
|
|
8891
|
+
if (pinned.ok !== true) return pinned;
|
|
8892
|
+
const page = await issues.getIssuePage({ query: "", after, first: pageSize }, pinned.args);
|
|
8893
|
+
if (!page || page.ok !== true) {
|
|
8894
|
+
return { ok: false, error: (page && page.error) || "cannot read the repository's open issues" };
|
|
8895
|
+
}
|
|
8896
|
+
const source = Array.isArray(page.issues) ? page.issues : [];
|
|
8897
|
+
const rows = source.map((row) => ({ number: row.number, title: row.title, state: row.state }));
|
|
8898
|
+
const last = source[source.length - 1];
|
|
8899
|
+
const cursor = last && typeof last.cursor === "string" && last.cursor !== "" ? last.cursor : null;
|
|
8900
|
+
return { ok: true, rows, hasMore: page.hasNextPage === true && cursor !== null, cursor };
|
|
8901
|
+
})(), "cannot read the repository's open issues");
|
|
8902
|
+
};
|
|
8877
8903
|
const helpersPromise = Promise.resolve()
|
|
8878
8904
|
.then(() => issuesTuiLoader())
|
|
8879
8905
|
.catch(() => null);
|
|
@@ -8889,6 +8915,9 @@ async function openPrsPanel(rawArgs, ctx, releaseOpen, resolvedCheckoutRoot, pi)
|
|
|
8889
8915
|
}
|
|
8890
8916
|
return;
|
|
8891
8917
|
}
|
|
8918
|
+
// T22: the identity this open PROVED is the only key that may seed the first
|
|
8919
|
+
// frame, read once so every page of this mount comes from the same entry.
|
|
8920
|
+
const seededPrsPages = pinnedRepo && pinnedRepo.ok === true ? prsRailCachedPages(pinnedRepo.identity) : null;
|
|
8892
8921
|
// The overlay factory's own host object is what the browser opener suspends.
|
|
8893
8922
|
let hostTuiRef = null;
|
|
8894
8923
|
// S6: the panel's own close, captured from the host's factory, so a cross-panel
|
|
@@ -8953,12 +8982,24 @@ async function openPrsPanel(rawArgs, ctx, releaseOpen, resolvedCheckoutRoot, pi)
|
|
|
8953
8982
|
}
|
|
8954
8983
|
};
|
|
8955
8984
|
return libRequire("prs-view.js").createPrsView({
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
|
|
8985
|
+
// S8/T22: a bucket the rail already read (or the store answers) is
|
|
8986
|
+
// seeded, so the first frame paints its rows instead of `loading…`.
|
|
8987
|
+
// The seed is never the last word: the mount still reads the visible
|
|
8988
|
+
// bucket and every seeded page carries no `loaded` stamp, so its first
|
|
8989
|
+
// activation reads it and `r` re-reads the one on screen.
|
|
8990
|
+
pages: PRS_INTERACTIVE_BUCKETS.map((spec) => {
|
|
8991
|
+
const seeded = seededPrsPages === null ? null : seededPrsPages.get(spec.id);
|
|
8992
|
+
if (!seeded) {
|
|
8993
|
+
return { id: spec.id, label: spec.label, rows: null, lazy: spec.lazy === true };
|
|
8994
|
+
}
|
|
8995
|
+
return {
|
|
8996
|
+
id: spec.id,
|
|
8997
|
+
label: spec.label,
|
|
8998
|
+
rows: seeded.rows,
|
|
8999
|
+
total: seeded.total,
|
|
9000
|
+
lazy: spec.lazy === true,
|
|
9001
|
+
};
|
|
9002
|
+
}),
|
|
8962
9003
|
loadPullRequestPage,
|
|
8963
9004
|
// S1/T4: a numbered open starts on the bucket the rail's click named,
|
|
8964
9005
|
// with that pull request pending selection; the command already
|
|
@@ -8968,6 +9009,7 @@ async function openPrsPanel(rawArgs, ctx, releaseOpen, resolvedCheckoutRoot, pi)
|
|
|
8968
9009
|
: { initialPullRequest, ...(hintedBucket === null ? {} : { initialBucket: hintedBucket }) }),
|
|
8969
9010
|
loadLabels,
|
|
8970
9011
|
loadAssignees,
|
|
9012
|
+
loadIssueCandidates,
|
|
8971
9013
|
prefetchBuckets: true,
|
|
8972
9014
|
// `includeMetadata` is what carries the permissions, the merge methods
|
|
8973
9015
|
// and the linked issues into the pane: without it the view sees no
|
|
@@ -10136,7 +10178,11 @@ function installUserPromptCard() {
|
|
|
10136
10178
|
// The measurement seam is asked on every paint (the TUI package may load late), and
|
|
10137
10179
|
// the card reads Pi's own live theme from its process-wide slot, like every other
|
|
10138
10180
|
// surface that paints outside a host render call.
|
|
10139
|
-
lib.installUserPromptCard({ component, metrics: () => resolveWorktreeToolCardMetrics() });
|
|
10181
|
+
const outcome = lib.installUserPromptCard({ component, metrics: () => resolveWorktreeToolCardMetrics() });
|
|
10182
|
+
// S2 (prompt-card-fix): a transcript RESTORED from history was built before this import
|
|
10183
|
+
// resolved, so the prompts already on screen keep Pi's rows until something unrelated
|
|
10184
|
+
// repaints them. One request per install — never per paint — is what gives them the card.
|
|
10185
|
+
requestPromptCardRepaint(outcome);
|
|
10140
10186
|
})
|
|
10141
10187
|
.catch(() => {
|
|
10142
10188
|
// A host without the class keeps Pi's own prompt rows (S6).
|
|
@@ -10147,6 +10193,31 @@ function installUserPromptCard() {
|
|
|
10147
10193
|
});
|
|
10148
10194
|
}
|
|
10149
10195
|
|
|
10196
|
+
/**
|
|
10197
|
+
* S2 (prompt-card-fix): the ONE repaint a successful install asks for.
|
|
10198
|
+
*
|
|
10199
|
+
* A session restored from history builds its whole transcript before the deferred host import
|
|
10200
|
+
* above resolves, so the prompts already on screen keep Pi's rows until something unrelated
|
|
10201
|
+
* repaints. The bridge's published `requestRepaint` is the only repaint this package may ask
|
|
10202
|
+
* for, and it is OPTIONAL (`gentle-shell-bridge` publishes it; an older bridge, or none, does
|
|
10203
|
+
* not): absent member, no request. The request is made per INSTALL, never per paint, and only
|
|
10204
|
+
* for an install that actually happened in a session that is still live — a refused install, a
|
|
10205
|
+
* closed session and a bridge without the member all ask nothing. Its answer is irrelevant to
|
|
10206
|
+
* the card, so the result is ignored and a throw is swallowed.
|
|
10207
|
+
*/
|
|
10208
|
+
function requestPromptCardRepaint(outcome) {
|
|
10209
|
+
if (outcome === null || typeof outcome !== "object" || outcome.installed !== true) return;
|
|
10210
|
+
if (!userPromptCardSessionLive) return;
|
|
10211
|
+
try {
|
|
10212
|
+
const resolver = libRequire("file-card-resolver.js");
|
|
10213
|
+
const api = resolver && typeof resolver.bridgeApi === "function" ? resolver.bridgeApi() : undefined;
|
|
10214
|
+
if (api === undefined || typeof api.requestRepaint !== "function") return;
|
|
10215
|
+
api.requestRepaint();
|
|
10216
|
+
} catch {
|
|
10217
|
+
// A bridge that refuses its own repaint never breaks the install it belongs to.
|
|
10218
|
+
}
|
|
10219
|
+
}
|
|
10220
|
+
|
|
10150
10221
|
/**
|
|
10151
10222
|
* The prompt card's session boundary — registered ONCE per load, by whichever path can first arm
|
|
10152
10223
|
* an install: the factory when a bridge is already published, the ready subscription, or the gate
|
package/lib/gh-prs.js
CHANGED
|
@@ -86,10 +86,13 @@ const PERMITTED_ROLES = ['TRIAGE', 'WRITE', 'MAINTAIN', 'ADMIN'];
|
|
|
86
86
|
const MERGE_ROLES = ['WRITE', 'MAINTAIN', 'ADMIN'];
|
|
87
87
|
|
|
88
88
|
// The three S1 buckets, as the repository-search qualifier each one asks for.
|
|
89
|
+
// `involved` excludes authorship exactly as the issues reader does: GitHub's
|
|
90
|
+
// `involves:@me` includes the pull requests you opened, and a bucket named for
|
|
91
|
+
// the ones you take part in must not repeat your own list.
|
|
89
92
|
const BUCKET_QUALIFIERS = {
|
|
90
93
|
mine: 'author:@me',
|
|
91
94
|
review: 'review-requested:@me',
|
|
92
|
-
involved: 'involves:@me',
|
|
95
|
+
involved: 'involves:@me -author:@me',
|
|
93
96
|
};
|
|
94
97
|
|
|
95
98
|
// The row of a list, and the head of the pane: the issue row's keys plus the
|
package/lib/issue-preview.js
CHANGED
|
@@ -41,6 +41,17 @@
|
|
|
41
41
|
// that appears in the title, the body or a comment
|
|
42
42
|
// carry none, so a click can never open the whole line.
|
|
43
43
|
// Without a collector nothing changes.
|
|
44
|
+
// `hover` the linked PR number the pointer is over, if any. That
|
|
45
|
+
// one `#N` token is painted in the hover role the rail
|
|
46
|
+
// gives a hovered row; nothing else, and no range moves.
|
|
47
|
+
// The caller passes what the SAME hit test as the click
|
|
48
|
+
// answered, so the two can never disagree.
|
|
49
|
+
//
|
|
50
|
+
// The pane's blocks are separated by the full-width rule the ODD reader already
|
|
51
|
+
// draws (`lib/odd-markdown.js` paints `'─'.repeat(width)`, here in the muted
|
|
52
|
+
// role): the metadata block from the body, the body from the comments and each
|
|
53
|
+
// comment from the next. No rule precedes the first row, none follows the last,
|
|
54
|
+
// and a block the issue does not have adds none.
|
|
44
55
|
//
|
|
45
56
|
// S23: the wrap is memoized. A repaint at an unchanged width used to re-wrap
|
|
46
57
|
// the whole body and every comment of the issue on screen; the memo is keyed
|
|
@@ -71,6 +82,17 @@ const { ROLES: PALETTE_ROLES } = require('./tui-paint.js');
|
|
|
71
82
|
// surface that injects its own `paint` still resolves the ROLE (never a colour)
|
|
72
83
|
// through its own theme.
|
|
73
84
|
const TITLE_ROLE = PALETTE_ROLES.title;
|
|
85
|
+
// The role a hovered click target takes. It is the rail's own choice for a
|
|
86
|
+
// hovered row (`lib/files-scope-view.js` paints it with the palette `key`), so a
|
|
87
|
+
// linked number highlights exactly like every other clickable row of the panel.
|
|
88
|
+
const HOVER_ROLE = PALETTE_ROLES.key;
|
|
89
|
+
|
|
90
|
+
// The horizontal rule the ODD reader draws between its blocks, as wide as the
|
|
91
|
+
// pane and in the muted role. One helper, so every boundary of both reading
|
|
92
|
+
// panes draws the same characters.
|
|
93
|
+
function ruleRow(width, paint) {
|
|
94
|
+
return paint('muted', '─'.repeat(Math.max(1, Math.floor(Number(width) || 1))));
|
|
95
|
+
}
|
|
74
96
|
|
|
75
97
|
function labelName(label) {
|
|
76
98
|
if (typeof label === 'string') return label;
|
|
@@ -211,20 +233,24 @@ function bold(text) {
|
|
|
211
233
|
// S6/D29: a token that is PART of a longer reference (`owner/repo#N`, the shape
|
|
212
234
|
// a link of another repository is painted in) is not a bare `#N` and is skipped,
|
|
213
235
|
// so a foreign number can never become a click target of this repository's PR.
|
|
214
|
-
function appendLinkedRanges(rows, numbers,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
236
|
+
function appendLinkedRanges(rows, firstLine, numbers, target, hover, hoverPaint) {
|
|
237
|
+
// Only the rows this relation produced: the collector's array may hold the
|
|
238
|
+
// metadata rows before them, and a range may never point outside its own row.
|
|
239
|
+
for (let at = 0; firstLine + at < rows.length; at += 1) {
|
|
240
|
+
const text = String(rows[firstLine + at] ?? '');
|
|
241
|
+
// The spans of the hovered token on this row, collected first so a painted
|
|
242
|
+
// (longer) row never moves the columns of a later match.
|
|
243
|
+
const hovered = [];
|
|
218
244
|
const pattern = /#(\d+)/g;
|
|
219
245
|
let match = pattern.exec(text);
|
|
220
246
|
while (match !== null) {
|
|
221
247
|
const before = match.index > 0 ? text[match.index - 1] : '';
|
|
222
248
|
const number = Number(match[1]);
|
|
223
|
-
if (/[A-Za-z0-9_/.-]/.test(before)) {
|
|
249
|
+
if (/[A-Za-z0-9_/.-]/.test(before) || !numbers.includes(number)) {
|
|
224
250
|
match = pattern.exec(text);
|
|
225
251
|
continue;
|
|
226
252
|
}
|
|
227
|
-
if (
|
|
253
|
+
if (Array.isArray(target)) {
|
|
228
254
|
target.push({
|
|
229
255
|
kind: 'pullRequest',
|
|
230
256
|
number,
|
|
@@ -233,8 +259,19 @@ function appendLinkedRanges(rows, numbers, firstLine, target) {
|
|
|
233
259
|
end: match.index + match[0].length,
|
|
234
260
|
});
|
|
235
261
|
}
|
|
262
|
+
if (typeof hoverPaint === 'function' && number === hover) {
|
|
263
|
+
hovered.push({ start: match.index, end: match.index + match[0].length });
|
|
264
|
+
}
|
|
236
265
|
match = pattern.exec(text);
|
|
237
266
|
}
|
|
267
|
+
if (hovered.length === 0) continue;
|
|
268
|
+
let row = text;
|
|
269
|
+
// Right to left, so an earlier span keeps the columns it was found at.
|
|
270
|
+
for (let span = hovered.length - 1; span >= 0; span -= 1) {
|
|
271
|
+
const { start, end } = hovered[span];
|
|
272
|
+
row = `${row.slice(0, start)}${hoverPaint(row.slice(start, end))}${row.slice(end)}`;
|
|
273
|
+
}
|
|
274
|
+
rows[firstLine + at] = row;
|
|
238
275
|
}
|
|
239
276
|
}
|
|
240
277
|
|
|
@@ -257,6 +294,9 @@ function issueDetailLines(detail, comments, options = {}) {
|
|
|
257
294
|
const nowMs = Number.isFinite(settings.now) ? settings.now : Date.now();
|
|
258
295
|
// S6: the caller's optional click-range collector (see the contract above).
|
|
259
296
|
const ranges = Array.isArray(settings.ranges) ? settings.ranges : null;
|
|
297
|
+
// The pointer's target: the linked number it is over, if any.
|
|
298
|
+
const hover = Number.isInteger(settings.hover) && settings.hover > 0 ? settings.hover : null;
|
|
299
|
+
const hoverPaint = hover === null ? null : (text) => emphasize(paint(HOVER_ROLE, text));
|
|
260
300
|
|
|
261
301
|
const lines = [];
|
|
262
302
|
// S13: the title asks for the shared title role, and keeps its emphasis.
|
|
@@ -332,17 +372,20 @@ function issueDetailLines(detail, comments, options = {}) {
|
|
|
332
372
|
// callers that gate on them (the permissions fail closed on `metadataError`).
|
|
333
373
|
|
|
334
374
|
const out = [];
|
|
335
|
-
lines.push('');
|
|
336
375
|
for (let at = 0; at < lines.length; at += 1) {
|
|
337
376
|
const rows = wrap(lines[at]);
|
|
377
|
+
const base = out.length;
|
|
378
|
+
out.push(...rows);
|
|
338
379
|
// S6: the relation row is the ONLY source of click ranges, and they are
|
|
339
380
|
// reported against the rows `wrap` produced, so a wrapped list maps right.
|
|
340
|
-
if (at === linkedRowAt) appendLinkedRanges(
|
|
341
|
-
out.push(...rows);
|
|
381
|
+
if (at === linkedRowAt) appendLinkedRanges(out, base, linkedPrs, ranges, hover, hoverPaint);
|
|
342
382
|
}
|
|
383
|
+
// The metadata block ends here, and the body follows behind ONE full-width
|
|
384
|
+
// rule; the comments and every comment-to-comment boundary get the same one.
|
|
385
|
+
out.push(ruleRow(width, paint));
|
|
343
386
|
out.push(...wrap(entry.body || '(no description)'));
|
|
344
387
|
list.forEach((comment, at) => {
|
|
345
|
-
out.push(
|
|
388
|
+
out.push(ruleRow(width, paint));
|
|
346
389
|
out.push(paint('border', `─ ${commentAuthor(comment)} · ${relativeTime(comment.createdAt, nowMs)} ─`));
|
|
347
390
|
const body = typeof comment.body === 'string' ? comment.body : '';
|
|
348
391
|
out.push(...wrap(body));
|
package/lib/issues-view.js
CHANGED
|
@@ -651,6 +651,13 @@ function createIssuesView(options = {}) {
|
|
|
651
651
|
// scroll offset included. `null` until a full frame painted (and after an
|
|
652
652
|
// early state frame, which carries no pane at all).
|
|
653
653
|
let pointerFrame = null;
|
|
654
|
+
// S6: the linked number the pointer is over, if any. It is set from the SAME
|
|
655
|
+
// hit test a click uses, so the pane can never highlight a cell it would not
|
|
656
|
+
// open, and it is cleared by a move that lands nowhere. `hoverIssue` is the
|
|
657
|
+
// item that pane painted, so navigating to another issue cannot leave a
|
|
658
|
+
// highlight behind on a number the pointer never visited there.
|
|
659
|
+
let hoverNumber = null;
|
|
660
|
+
let hoverIssue = null;
|
|
654
661
|
// The interactive reader wants every tab's data at open (S13/S15 round 3):
|
|
655
662
|
// switching must never refetch and no tab may sit at a false zero.
|
|
656
663
|
const prefetchBuckets = Boolean(options) && options.prefetchBuckets === true;
|
|
@@ -1478,7 +1485,7 @@ function createIssuesView(options = {}) {
|
|
|
1478
1485
|
};
|
|
1479
1486
|
}
|
|
1480
1487
|
|
|
1481
|
-
function detailLines(row, width, ranges = null) {
|
|
1488
|
+
function detailLines(row, width, ranges = null, hover = null) {
|
|
1482
1489
|
const entry = ensureDetail(row);
|
|
1483
1490
|
if (!entry) return [paint(theme, 'muted', '(no issue selected)')];
|
|
1484
1491
|
if (entry.status === 'error') return [paint(theme, 'error', `unreadable: ${entry.error}`)];
|
|
@@ -1509,6 +1516,9 @@ function createIssuesView(options = {}) {
|
|
|
1509
1516
|
// printed, against the rows it returned (the pane's own scroll window is
|
|
1510
1517
|
// applied by `handleMouse`).
|
|
1511
1518
|
ranges,
|
|
1519
|
+
// S6: the hovered number is that same formatter's target, so the painted
|
|
1520
|
+
// highlight and the clickable cell are one answer.
|
|
1521
|
+
hover,
|
|
1512
1522
|
});
|
|
1513
1523
|
}
|
|
1514
1524
|
|
|
@@ -1743,7 +1753,8 @@ function createIssuesView(options = {}) {
|
|
|
1743
1753
|
}
|
|
1744
1754
|
} else {
|
|
1745
1755
|
linkRanges = [];
|
|
1746
|
-
|
|
1756
|
+
const paneHover = hoverIssue !== null && hoverIssue === numOf(focused) ? hoverNumber : null;
|
|
1757
|
+
rightSource = detailLines(focused, rightWidth, linkRanges, paneHover);
|
|
1747
1758
|
}
|
|
1748
1759
|
clampScroll(rightSource.length);
|
|
1749
1760
|
const visible = rightSource.slice(state.scroll, state.scroll + bodyRows);
|
|
@@ -2877,7 +2888,11 @@ function createIssuesView(options = {}) {
|
|
|
2877
2888
|
}
|
|
2878
2889
|
}
|
|
2879
2890
|
|
|
2880
|
-
function invalidate() {
|
|
2891
|
+
function invalidate() {
|
|
2892
|
+
pointerFrame = null;
|
|
2893
|
+
hoverNumber = null;
|
|
2894
|
+
hoverIssue = null;
|
|
2895
|
+
}
|
|
2881
2896
|
|
|
2882
2897
|
// S7 (prs): `enter` in list mode is the insert key. It formats the selected
|
|
2883
2898
|
// issue as `ISSUE #N` and hands it to the host's own insertion seam, then
|
|
@@ -2898,30 +2913,49 @@ function createIssuesView(options = {}) {
|
|
|
2898
2913
|
close();
|
|
2899
2914
|
}
|
|
2900
2915
|
|
|
2901
|
-
// S6 (prs):
|
|
2902
|
-
//
|
|
2903
|
-
//
|
|
2904
|
-
//
|
|
2905
|
-
//
|
|
2906
|
-
|
|
2907
|
-
// a click on a link in a host with no `openLinked` seam does nothing.
|
|
2908
|
-
function handleMouse(event) {
|
|
2909
|
-
if (!active) return undefined;
|
|
2916
|
+
// S6 (prs): the ONE hit test both the click and the hover answer with. The
|
|
2917
|
+
// geometry is the frame `render` last composed — the pane's columns, the body
|
|
2918
|
+
// row, and the scroll offset that decides which pane line that row shows — so
|
|
2919
|
+
// a scrolled pane maps correctly, and a number can never be hoverable without
|
|
2920
|
+
// being clickable (or the other way round).
|
|
2921
|
+
function hitRange(event) {
|
|
2910
2922
|
const frame = pointerFrame;
|
|
2911
|
-
if (!frame) return
|
|
2912
|
-
if (event
|
|
2913
|
-
if (event.type !== 'click' || event.button !== 'left') return undefined;
|
|
2914
|
-
if (event.width !== frame.width || event.height !== frame.height) return undefined;
|
|
2923
|
+
if (!frame || event === null || typeof event !== 'object') return null;
|
|
2924
|
+
if (event.width !== frame.width || event.height !== frame.height) return null;
|
|
2915
2925
|
const x = Math.floor(Number(event.x));
|
|
2916
2926
|
const y = Math.floor(Number(event.y));
|
|
2917
|
-
if (!Number.isFinite(x) || !Number.isFinite(y)) return
|
|
2927
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return null;
|
|
2918
2928
|
const row = y - frame.bodyTop;
|
|
2919
|
-
if (row < 0 || row >= frame.bodyRows) return
|
|
2920
|
-
if (x < frame.paneStart || x >= frame.paneEnd) return
|
|
2929
|
+
if (row < 0 || row >= frame.bodyRows) return null;
|
|
2930
|
+
if (x < frame.paneStart || x >= frame.paneEnd) return null;
|
|
2921
2931
|
const column = x - frame.paneStart;
|
|
2922
2932
|
const line = frame.scroll + row;
|
|
2923
|
-
|
|
2924
|
-
&& column >= candidate.start && column < candidate.end);
|
|
2933
|
+
return frame.links.find((candidate) => candidate.line === line
|
|
2934
|
+
&& column >= candidate.start && column < candidate.end) || null;
|
|
2935
|
+
}
|
|
2936
|
+
|
|
2937
|
+
// S6 (prs): a left click on ONE linked PR number opens exactly that pull
|
|
2938
|
+
// request in the PR panel, and a `move` over one highlights it (a move that
|
|
2939
|
+
// lands nowhere clears it, repainting only when the target changes).
|
|
2940
|
+
// Everything else stays unhandled (the host keeps its own mouse behaviour):
|
|
2941
|
+
// the relation row's label, its separators and the truncation ellipsis carry
|
|
2942
|
+
// no range, and a click on a link in a host with no `openLinked` seam does
|
|
2943
|
+
// nothing.
|
|
2944
|
+
function handleMouse(event) {
|
|
2945
|
+
if (!active) return undefined;
|
|
2946
|
+
if (!pointerFrame) return undefined;
|
|
2947
|
+
if (event === null || typeof event !== 'object') return undefined;
|
|
2948
|
+
if (event.type === 'move') {
|
|
2949
|
+
const hit = hitRange(event);
|
|
2950
|
+
const next = hit === null ? null : hit.number;
|
|
2951
|
+
const changed = next !== hoverNumber;
|
|
2952
|
+
hoverNumber = next;
|
|
2953
|
+
hoverIssue = next === null ? null : numOf(selected());
|
|
2954
|
+
if (changed) repaint();
|
|
2955
|
+
return { handled: true, render: changed };
|
|
2956
|
+
}
|
|
2957
|
+
if (event.type !== 'click' || event.button !== 'left') return undefined;
|
|
2958
|
+
const hit = hitRange(event);
|
|
2925
2959
|
if (!hit) return undefined;
|
|
2926
2960
|
const open = actions && typeof actions.openLinked === 'function' ? actions.openLinked : null;
|
|
2927
2961
|
if (typeof open === 'function') {
|
package/lib/pr-preview.js
CHANGED
|
@@ -15,6 +15,18 @@
|
|
|
15
15
|
// again in the painted text — a number that wraps, a truncated list and a
|
|
16
16
|
// narrow pane all keep an exact target, and the whole line is never one range.
|
|
17
17
|
//
|
|
18
|
+
// `options.hover` names the linked issue the pointer is over: that one `#N`
|
|
19
|
+
// token is painted in the hover role the rail gives a hovered row, and no range
|
|
20
|
+
// moves — the caller passes what the SAME hit test as the click answered, so the
|
|
21
|
+
// two can never disagree.
|
|
22
|
+
//
|
|
23
|
+
// The pane's blocks are separated by the full-width rule the ODD reader already
|
|
24
|
+
// draws (`lib/odd-markdown.js` paints `'─'.repeat(width)`, here in the muted
|
|
25
|
+
// role): the metadata block (the `Changes` and `Checks` summaries included) from
|
|
26
|
+
// the body, the body from the comments and each comment from the next. No rule
|
|
27
|
+
// precedes the first row, none follows the last, and a block the pull request
|
|
28
|
+
// does not have adds none.
|
|
29
|
+
//
|
|
18
30
|
// The small pure helpers below (`relativeTime`, `wrapText`, the wrap memo) are
|
|
19
31
|
// deliberate copies of the issues preview's, not imports: the two panels are
|
|
20
32
|
// owned by parallel units, so neither may gain a load-time dependency on the
|
|
@@ -26,6 +38,16 @@ const { ROLES: PALETTE_ROLES } = require('./tui-paint.js');
|
|
|
26
38
|
// The one role a title is painted with, read from the shared table so this
|
|
27
39
|
// preview cannot drift into its own title colour.
|
|
28
40
|
const TITLE_ROLE = PALETTE_ROLES.title;
|
|
41
|
+
// The role a hovered click target takes: the rail's own choice for a hovered row
|
|
42
|
+
// (`lib/files-scope-view.js` paints it with the palette `key`).
|
|
43
|
+
const HOVER_ROLE = PALETTE_ROLES.key;
|
|
44
|
+
|
|
45
|
+
// The horizontal rule the ODD reader draws between its blocks, as wide as the
|
|
46
|
+
// pane and in the muted role. One helper, so every boundary of both reading
|
|
47
|
+
// panes draws the same characters.
|
|
48
|
+
function ruleRow(width, paint) {
|
|
49
|
+
return paint('muted', '─'.repeat(Math.max(1, Math.floor(Number(width) || 1))));
|
|
50
|
+
}
|
|
29
51
|
|
|
30
52
|
function labelName(label) {
|
|
31
53
|
if (typeof label === 'string') return label;
|
|
@@ -176,7 +198,9 @@ function bold(text) {
|
|
|
176
198
|
|
|
177
199
|
// The `linked issues:` row, composed token by token so every number keeps its
|
|
178
200
|
// own cell range even when the pane forces the row onto several lines.
|
|
179
|
-
|
|
201
|
+
// `hoverPaint(text, number)` paints the hovered token and leaves every other one
|
|
202
|
+
// exactly as it was, so the ranges below stay the columns of the same cells.
|
|
203
|
+
function linkedIssuesBlock(numbers, truncated, width, measure, hoverPaint) {
|
|
180
204
|
const lines = [];
|
|
181
205
|
const ranges = [];
|
|
182
206
|
let text = '';
|
|
@@ -195,7 +219,7 @@ function linkedIssuesBlock(numbers, truncated, width, measure) {
|
|
|
195
219
|
// The separator between two numbers belongs to the row, not to the click
|
|
196
220
|
// target: the range starts at the `#` itself.
|
|
197
221
|
const lead = measure(piece) - measure(piece.replace(/^\s+/, ''));
|
|
198
|
-
push(piece);
|
|
222
|
+
push(typeof hoverPaint === 'function' ? hoverPaint(piece, link) : piece);
|
|
199
223
|
setLength();
|
|
200
224
|
if (link !== undefined) ranges.push({ line: lines.length, start: before + lead, end: length, number: link });
|
|
201
225
|
};
|
|
@@ -229,6 +253,11 @@ function pullRequestDetailLines(pullRequest, comments, options = {}) {
|
|
|
229
253
|
const wrap = typeof settings.wrap === 'function' ? settings.wrap : (text) => cache.wrap(text, width);
|
|
230
254
|
const measure = typeof settings.measure === 'function' ? settings.measure : plainWidth;
|
|
231
255
|
const links = Array.isArray(settings.links) ? settings.links : null;
|
|
256
|
+
// The pointer's target: the linked issue number it is over, if any.
|
|
257
|
+
const hover = Number.isInteger(settings.hover) && settings.hover > 0 ? settings.hover : null;
|
|
258
|
+
const hoverPaint = hover === null
|
|
259
|
+
? null
|
|
260
|
+
: (text, number) => (number === hover ? emphasize(paint(HOVER_ROLE, text)) : text);
|
|
232
261
|
const list = Array.isArray(comments) ? comments : [];
|
|
233
262
|
const nowMs = Number.isFinite(settings.now) ? settings.now : Date.now();
|
|
234
263
|
|
|
@@ -279,7 +308,7 @@ function pullRequestDetailLines(pullRequest, comments, options = {}) {
|
|
|
279
308
|
const linked = (Array.isArray(entry.linkedIssues) ? entry.linkedIssues : [])
|
|
280
309
|
.filter((number) => Number.isInteger(number) && number > 0);
|
|
281
310
|
if (linked.length > 0) {
|
|
282
|
-
const block = linkedIssuesBlock(linked, entry.linkedIssuesTruncated === true, width, measure);
|
|
311
|
+
const block = linkedIssuesBlock(linked, entry.linkedIssuesTruncated === true, width, measure, hoverPaint);
|
|
283
312
|
const base = out.length;
|
|
284
313
|
for (const line of block.lines) out.push(line);
|
|
285
314
|
if (links !== null) {
|
|
@@ -334,10 +363,12 @@ function pullRequestDetailLines(pullRequest, comments, options = {}) {
|
|
|
334
363
|
|
|
335
364
|
// A relation that could not be read paints NOTHING: the pane stays quiet,
|
|
336
365
|
// exactly as it does for a relation the pull request does not have.
|
|
337
|
-
|
|
366
|
+
// The metadata block ends here, and the body follows behind ONE full-width
|
|
367
|
+
// rule; the comments and every comment-to-comment boundary get the same one.
|
|
368
|
+
out.push(ruleRow(width, paint));
|
|
338
369
|
for (const row of wrap(entry.body || '(no description)')) out.push(row);
|
|
339
370
|
list.forEach((comment, at) => {
|
|
340
|
-
out.push(
|
|
371
|
+
out.push(ruleRow(width, paint));
|
|
341
372
|
out.push(paint('border', `─ ${commentAuthor(comment)} · ${relativeTime(comment.createdAt, nowMs)} ─`));
|
|
342
373
|
const body = typeof comment.body === 'string' ? comment.body : '';
|
|
343
374
|
for (const row of wrap(body)) out.push(row);
|