pi-odd-worktree 3.10.0 → 3.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/extensions/odd-worktree-tools.ts +250 -44
- 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 +477 -0
- 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/package-surface.test.js +4 -2
- 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 +963 -0
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);
|