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
package/lib/issues-view.js
CHANGED
|
@@ -70,9 +70,23 @@
|
|
|
70
70
|
//
|
|
71
71
|
// S13/S14/S15 (this unit): a tab that was already read paints its rows and its
|
|
72
72
|
// own scroll position again instead of refetching and flashing `loading` — `r`
|
|
73
|
-
// is the explicit refresh of the list the reader is on.
|
|
74
|
-
// `All
|
|
75
|
-
//
|
|
73
|
+
// is the explicit refresh of the list the reader is on. A page marked `lazy`
|
|
74
|
+
// (the caller's `All`) is NOT a tab: it is read the first time the reader's
|
|
75
|
+
// shortcut key enters it (S1/S2 below).
|
|
76
|
+
//
|
|
77
|
+
// S1/S2 (issues-all-toggle): `All` is a shortcut, not a fourth tab. The bar
|
|
78
|
+
// reads the three scoped buckets and the mount prefetch reads exactly those
|
|
79
|
+
// three, so opening the panel is three reads instead of four; a page marked
|
|
80
|
+
// `lazy` in the data the caller hands over is read the first time the shortcut
|
|
81
|
+
// key enters it, and re-entering reuses that page unless the filter changed
|
|
82
|
+
// (D3). Inside the lazy view the bar reads only it and the footer hint says
|
|
83
|
+
// what the same key does there — return to the tab the reader came from (D2).
|
|
84
|
+
// A settled filter is read by EVERY scoped tab (S3), because each tab's count
|
|
85
|
+
// is the filtered total, and it travels into the lazy view with the reader
|
|
86
|
+
// (S4). The unfiltered lazy read is the caller's repository connection and its
|
|
87
|
+
// total is exact; a filtered one is a capped search, so its count is marked
|
|
88
|
+
// inexact the way a truncated bucket is and the note row says which read is on
|
|
89
|
+
// screen (S5).
|
|
76
90
|
//
|
|
77
91
|
// S9 (this unit): the search box is a SERVER search on the page seam. Every
|
|
78
92
|
// request carries `query`, so the seam searches the complete bucket instead of
|
|
@@ -94,6 +108,11 @@
|
|
|
94
108
|
// owns it and no expectation depends on wall-clock timing.
|
|
95
109
|
const QUERY_DEBOUNCE_MS = 180;
|
|
96
110
|
|
|
111
|
+
// S7 (issues-all-toggle): the opening selection reads at most this many pages of
|
|
112
|
+
// its bucket, so a bucket with thousands of rows can never loop the panel's
|
|
113
|
+
// open. The first page counts toward the bound.
|
|
114
|
+
const INITIAL_SELECTION_PAGE_LIMIT = 5;
|
|
115
|
+
|
|
97
116
|
function defaultSchedule(fn, delayMs) {
|
|
98
117
|
return setTimeout(fn, delayMs);
|
|
99
118
|
}
|
|
@@ -123,14 +142,46 @@ const { renderOddMarkdown } = require('./odd-markdown.js');
|
|
|
123
142
|
const CARD_PADDING = layout.CARD_PADDING;
|
|
124
143
|
const MIN_WIDTH = 24;
|
|
125
144
|
// The buckets the server seam reads from unless the caller passes its own
|
|
126
|
-
// `pages` metadata (ids and labels are then the caller's)
|
|
127
|
-
// the whole open repository, and never deduplicates it against the others
|
|
145
|
+
// `pages` metadata (ids and labels are then the caller's). S15 appended `All`,
|
|
146
|
+
// the whole open repository, and never deduplicates it against the others; S1
|
|
147
|
+
// (issues-all-toggle) keeps it in this list — one `state.page` still indexes
|
|
148
|
+
// every bucket — but marks it `lazy`, so it leaves the tab bar, the cycling keys
|
|
149
|
+
// and the mount-time prefetch with it.
|
|
128
150
|
const DEFAULT_BUCKETS = [
|
|
129
151
|
{ id: 'mine', label: 'My issues' },
|
|
130
152
|
{ id: 'assigned', label: 'Assigned' },
|
|
131
153
|
{ id: 'involved', label: 'Involved' },
|
|
132
|
-
{ id: 'all', label: 'All' },
|
|
154
|
+
{ id: 'all', label: 'All', lazy: true },
|
|
133
155
|
];
|
|
156
|
+
// S1/D1: `All` is reached by a shortcut key, so the key has to teach itself in
|
|
157
|
+
// the one legend row. Outside the lazy view the hint reads `all issues`; inside
|
|
158
|
+
// it, the same key reads `related issues`, because there it goes back. `g` is
|
|
159
|
+
// the key because every other letter the reading interaction binds is already
|
|
160
|
+
// taken (`a` assigns, `l` labels, `c` comments, `x` closes, `o` opens, `t`/`/`
|
|
161
|
+
// search, `r` refreshes, `j`/`k`/`J`/`K` move and scroll, `q` closes, `y` is
|
|
162
|
+
// inert) and the preview's scroll bindings own ctrl+j/k, ctrl+d/u and PgUp/PgDn.
|
|
163
|
+
// Its priority puts it above `o web` and `t search` in the one-row legend's drop
|
|
164
|
+
// order, so it survives the widths those two leave at; below 60 cells the legend
|
|
165
|
+
// keeps only the movement keys, the bucket switch and `esc close`, as it already
|
|
166
|
+
// did. `↑↓ move` and `esc close` always outlive it.
|
|
167
|
+
const SHORTCUT_HINT = {
|
|
168
|
+
key: 'g',
|
|
169
|
+
text: 'g all issues',
|
|
170
|
+
short: 'g',
|
|
171
|
+
priority: 38,
|
|
172
|
+
shortcut: true,
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// S1/D1: one hint, two labels. The legend carries whichever one the view the
|
|
176
|
+
// reader is in needs, so the shortcut is discoverable in both directions.
|
|
177
|
+
function shortcutHint(insideLazy) {
|
|
178
|
+
return {
|
|
179
|
+
key: SHORTCUT_HINT.key,
|
|
180
|
+
text: insideLazy ? 'g related issues' : SHORTCUT_HINT.text,
|
|
181
|
+
short: SHORTCUT_HINT.short,
|
|
182
|
+
priority: SHORTCUT_HINT.priority,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
134
185
|
// S17: no `? help` — the footer legend is the only key reference. Its contents
|
|
135
186
|
// stay fixed (S10b: no assignment key rides it) and S13 keeps it free of
|
|
136
187
|
// repetition: every shortcut, the search key included, is named here once and
|
|
@@ -149,18 +200,25 @@ const FOOTER_KEYS = [
|
|
|
149
200
|
// because selection already drags the list window, so it left the row.
|
|
150
201
|
// S16: an editor entry carries the capability it needs, and the render
|
|
151
202
|
// drops the whole hint when that capability is not confirmed true.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
203
|
+
// S11: `needsIssue` is the focused-AND-loaded gate every token that acts on
|
|
204
|
+
// the selected issue carries — an empty bucket, a read still in flight and a
|
|
205
|
+
// failed read all offer none of them, while the movement, bucket, search,
|
|
206
|
+
// shortcut and escape hints stay on the row.
|
|
207
|
+
{ key: 'l', text: 'l labels', short: 'l', priority: 50, requires: 'canEditLabels', needsIssue: true },
|
|
208
|
+
{ key: 'a', text: 'a assign', short: 'a', priority: 48, requires: 'canEditAssignees', needsIssue: true },
|
|
209
|
+
{ key: 'c', text: 'c comment', short: 'c', priority: 45, needsIssue: true },
|
|
155
210
|
// Closing (and reopening) is a TRIAGE-level repository capability like the two
|
|
156
211
|
// editors above, so its hint disappears with it. Only the lowercase key
|
|
157
212
|
// rides the legend; `X` keeps closing without a token.
|
|
158
|
-
{ key: 'x', text: 'x close', short: 'x', priority: 40, requires: 'canCloseIssues' },
|
|
159
|
-
{ key: 'o', text: 'o web', short: 'o', priority: 20 },
|
|
213
|
+
{ key: 'x', text: 'x close', short: 'x', priority: 40, requires: 'canCloseIssues', needsIssue: true },
|
|
214
|
+
{ key: 'o', text: 'o web', short: 'o', priority: 20, needsIssue: true },
|
|
160
215
|
// S4: the search key belongs here with every other shortcut, never on the
|
|
161
216
|
// search row above it. The legend spells the lowercase key `t` (the one a
|
|
162
217
|
// reader reaches for); `T` keeps opening the box without a token.
|
|
163
218
|
{ key: 't', text: 't search', short: 't', priority: 35 },
|
|
219
|
+
// S1/D1: `All` is a shortcut, not a tab, and this is the one hint that says
|
|
220
|
+
// so. Its `text` is swapped for the return label inside the lazy view.
|
|
221
|
+
SHORTCUT_HINT,
|
|
164
222
|
{ key: 'esc', text: 'esc close', short: 'esc close', priority: 100 },
|
|
165
223
|
];
|
|
166
224
|
|
|
@@ -177,11 +235,60 @@ const SEARCH_KEYS = [
|
|
|
177
235
|
{ key: 'enter/esc', text: 'enter/esc keep', short: 'enter/esc', priority: 60 },
|
|
178
236
|
];
|
|
179
237
|
|
|
238
|
+
// S10: a sub-mode's keys live on the ONE footer row while that sub-mode holds
|
|
239
|
+
// the keyboard, replacing the reading legend in the same place on screen and in
|
|
240
|
+
// the same left-to-right shape. They used to be the parenthetical in each
|
|
241
|
+
// editor's title, which now carries the sub-mode's name alone — one fixed
|
|
242
|
+
// position for the keys, and only the keys available at that moment. The search
|
|
243
|
+
// box keeps its own row (SEARCH_KEYS) untouched.
|
|
244
|
+
const LABEL_EDITOR_KEYS = [
|
|
245
|
+
{ key: 'space', text: 'space toggle', short: 'space', priority: 70 },
|
|
246
|
+
// S16: creating a label is the WRITE capability's key, so the row drops it
|
|
247
|
+
// exactly like the editor drops its create row.
|
|
248
|
+
{ key: 'n', text: 'n new', short: 'n', priority: 60, needsCreate: true },
|
|
249
|
+
{ key: 'ctrl+s', text: 'ctrl+s apply', short: 'ctrl+s', priority: 90 },
|
|
250
|
+
{ key: 'esc', text: 'esc back', short: 'esc back', priority: 100 },
|
|
251
|
+
];
|
|
252
|
+
|
|
253
|
+
const ASSIGNEE_EDITOR_KEYS = [
|
|
254
|
+
{ key: 'space', text: 'space toggle', short: 'space', priority: 70 },
|
|
255
|
+
{ key: 'ctrl+s', text: 'ctrl+s apply', short: 'ctrl+s', priority: 90 },
|
|
256
|
+
{ key: 'esc', text: 'esc back', short: 'esc back', priority: 100 },
|
|
257
|
+
];
|
|
258
|
+
|
|
259
|
+
const COMMENT_EDITOR_KEYS = [
|
|
260
|
+
{ key: 'enter', text: 'enter newline', short: 'enter', priority: 70 },
|
|
261
|
+
{ key: 'ctrl+s', text: 'ctrl+s post', short: 'ctrl+s', priority: 90 },
|
|
262
|
+
{ key: 'esc', text: 'esc discard', short: 'esc discard', priority: 100 },
|
|
263
|
+
];
|
|
264
|
+
|
|
265
|
+
// S10 (T14): the nested sub-modes carry their own keys too. Naming a new label
|
|
266
|
+
// and asking to throw a comment draft away used to spell their keys in the body
|
|
267
|
+
// (`(enter add · esc cancel)`, `(y discard · …)`); they ride the same ONE footer
|
|
268
|
+
// row as every other sub-mode instead, and their body says only what is happening.
|
|
269
|
+
const LABEL_CREATE_KEYS = [
|
|
270
|
+
{ key: 'enter', text: 'enter add', short: 'enter', priority: 70 },
|
|
271
|
+
{ key: 'esc', text: 'esc cancel', short: 'esc cancel', priority: 100 },
|
|
272
|
+
];
|
|
273
|
+
|
|
274
|
+
const COMMENT_DISCARD_KEYS = [
|
|
275
|
+
{ key: 'y', text: 'y discard', short: 'y', priority: 60 },
|
|
276
|
+
{ key: 'n/esc', text: 'n/esc keep editing', short: 'n/esc', priority: 70 },
|
|
277
|
+
];
|
|
278
|
+
|
|
279
|
+
// S11 (T14): while an editor's own list is still in flight its handlers accept
|
|
280
|
+
// ONE key — the exit — so that is the only key the footer may offer then.
|
|
281
|
+
const BACK_KEYS = [
|
|
282
|
+
{ key: 'esc', text: 'esc back', short: 'esc back', priority: 100 },
|
|
283
|
+
];
|
|
284
|
+
|
|
180
285
|
// Printable paging keys must not fall through to lowercase list selection.
|
|
181
286
|
const SHIFTED_TWINS = new Set(['j', 'k']);
|
|
182
287
|
|
|
183
288
|
// One page entry, whatever the source: eagerly supplied `pages` and every
|
|
184
289
|
// `loadPages`/`reload` result pass through here so both paths share one shape.
|
|
290
|
+
// S1/S2: `lazy` is the caller's mark for the page the shortcut key owns — it is
|
|
291
|
+
// not a tab, it is not prefetched, and it is read when it is entered.
|
|
185
292
|
function mapPage(page, at) {
|
|
186
293
|
return {
|
|
187
294
|
id: page && page.id != null ? String(page.id) : `p${at}`,
|
|
@@ -189,6 +296,7 @@ function mapPage(page, at) {
|
|
|
189
296
|
issues: Array.isArray(page && page.issues) ? page.issues.slice() : null,
|
|
190
297
|
total: page && Number.isFinite(Number(page.total)) ? Number(page.total) : null,
|
|
191
298
|
truncated: !!(page && page.truncated),
|
|
299
|
+
lazy: !!(page && page.lazy === true),
|
|
192
300
|
};
|
|
193
301
|
}
|
|
194
302
|
|
|
@@ -438,16 +546,64 @@ function createIssuesView(options = {}) {
|
|
|
438
546
|
let pages = Array.isArray(options.pages) && options.pages.length > 0
|
|
439
547
|
? options.pages.map(mapPage)
|
|
440
548
|
: (serverMode
|
|
441
|
-
? DEFAULT_BUCKETS.map((bucket, at) => mapPage({ id: bucket.id, label: bucket.label, issues: null }, at))
|
|
549
|
+
? DEFAULT_BUCKETS.map((bucket, at) => mapPage({ id: bucket.id, label: bucket.label, issues: null, lazy: bucket.lazy === true }, at))
|
|
442
550
|
: (loaderMode ? [] : [{ id: 'mine', label: 'My issues', issues: null, total: null }]));
|
|
443
551
|
let fallbackIssues = Array.isArray(options.issues) ? options.issues.slice() : [];
|
|
444
552
|
let repoLabels = Array.isArray(options.labels)
|
|
445
553
|
? options.labels.map((label) => ({ name: labelName(label) })).filter((label) => label.name)
|
|
446
554
|
: [];
|
|
447
555
|
|
|
556
|
+
// S7: `/issues <number>` opens the reader on one bucket with that issue
|
|
557
|
+
// selected. The command passes the bucket (`assigned`) and the number; a
|
|
558
|
+
// plain open passes neither, so every existing path starts at bucket 0 with
|
|
559
|
+
// no pending selection. Only a positive integer reaches here — the command
|
|
560
|
+
// refuses every other argument before mounting this view.
|
|
561
|
+
const initialBucketId = typeof options.initialBucket === 'string' ? options.initialBucket : null;
|
|
562
|
+
const initialIssueNumber = Number.isFinite(Number(options.initialIssue)) && Number(options.initialIssue) > 0
|
|
563
|
+
? Math.floor(Number(options.initialIssue))
|
|
564
|
+
: null;
|
|
565
|
+
const initialBucketFound = initialBucketId === null || pages.some((page) => page.id === initialBucketId);
|
|
566
|
+
const initialPageIndex = initialBucketId === null
|
|
567
|
+
? 0
|
|
568
|
+
: Math.max(0, pages.findIndex((page) => page.id === initialBucketId));
|
|
569
|
+
|
|
570
|
+
// S7: one shot. The pending selection exists only for the OPENING read of the
|
|
571
|
+
// bucket the reader was opened on. It clears when it lands, misses, reaches
|
|
572
|
+
// its page bound, or the reader presses a key — a later filter, refresh, tab
|
|
573
|
+
// switch or paging never moves the selection back to this number.
|
|
574
|
+
let pendingSelection = initialIssueNumber !== null && initialBucketFound
|
|
575
|
+
? { number: initialIssueNumber, bucketIndex: initialPageIndex, pagesRead: 0, triedFallback: false }
|
|
576
|
+
: null;
|
|
577
|
+
|
|
578
|
+
// E18 (S4): the number a numbered open asked for, until an ANSWER has proven
|
|
579
|
+
// it — the row it names was found, or the bucket was searched to its bound and
|
|
580
|
+
// the number is not there. A seeded page (S8/T4: the rail's cache) can put
|
|
581
|
+
// rows, and therefore a selection, under the keyboard BEFORE that answer, and
|
|
582
|
+
// a mutation aimed at row one would then land on an issue nobody chose. So
|
|
583
|
+
// while the proof is open, only the asked row may be written; a plain open
|
|
584
|
+
// asks for no number and is never gated by this.
|
|
585
|
+
let initialNumberProof = pendingSelection === null
|
|
586
|
+
? null
|
|
587
|
+
: { number: pendingSelection.number, bucketIndex: pendingSelection.bucketIndex, proven: false };
|
|
588
|
+
|
|
589
|
+
// E18 (S4, blocker c): the rows the CALLER supplied (the rail's cache seed)
|
|
590
|
+
// were read with NO filter, so they answer the empty query and nothing else —
|
|
591
|
+
// exactly what a freshly loaded page's rows answer. Stamped here, once, before
|
|
592
|
+
// any frame: without it a seeded page kept painting itself under a filter it
|
|
593
|
+
// had never been read for, with the counts that filter never produced. A real
|
|
594
|
+
// answer replaces the rows AND this stamp together.
|
|
595
|
+
if (serverMode) {
|
|
596
|
+
pages.forEach((page) => {
|
|
597
|
+
if (Array.isArray(page.issues)) bucketState(page).rowsQuery = '';
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
|
|
448
601
|
const state = {
|
|
449
|
-
page:
|
|
602
|
+
page: initialPageIndex,
|
|
450
603
|
index: 0,
|
|
604
|
+
// S1/D2: while the reader is in the lazy view, the tab they came from. The
|
|
605
|
+
// shortcut key returns there instead of to the first tab.
|
|
606
|
+
allFrom: null,
|
|
451
607
|
// S3: the first painted row of the list window. There is no page to move to
|
|
452
608
|
// — `]`/`[` scroll this window and the focused row follows it (S10).
|
|
453
609
|
listStart: 0,
|
|
@@ -522,6 +678,11 @@ function createIssuesView(options = {}) {
|
|
|
522
678
|
}
|
|
523
679
|
|
|
524
680
|
function filteredIssues() {
|
|
681
|
+
// S3: a bucket whose held rows answer ANOTHER query while its own read for
|
|
682
|
+
// the current one is still in flight has no result to show yet, so it lists
|
|
683
|
+
// none — the frame paints its loading state instead of a list the reader
|
|
684
|
+
// would read as this query's matches.
|
|
685
|
+
if (serverMode && !rowsArePaintable(pages[state.page])) return [];
|
|
525
686
|
// S10a: open issues only. The row's own state decides, so a page that
|
|
526
687
|
// arrives with a closed row never lists it, whatever the fetch claimed.
|
|
527
688
|
const open = baseIssues().filter((row) => rowState(row) === 'open');
|
|
@@ -543,6 +704,135 @@ function createIssuesView(options = {}) {
|
|
|
543
704
|
return list[state.index] || null;
|
|
544
705
|
}
|
|
545
706
|
|
|
707
|
+
// S7: any key means the reader has taken over, so a still-pending opening
|
|
708
|
+
// selection never moves the focus after this point. E18 (S4) is the one
|
|
709
|
+
// exception: while a NUMBERED open's own read has not answered yet, a seeded
|
|
710
|
+
// page has already put rows under the keyboard, so a key can only act on rows
|
|
711
|
+
// the cache remembered. Letting that answer then move the focus to the head of
|
|
712
|
+
// the list would move the reader off the very issue they asked for — the same
|
|
713
|
+
// wrong-row window, one key later. The one-shot rule still holds once the
|
|
714
|
+
// number is proven: no later filter, refresh, switch or page re-selects it.
|
|
715
|
+
function disarmInitialSelection() {
|
|
716
|
+
if (initialNumberProof !== null && initialNumberProof.proven !== true) return;
|
|
717
|
+
pendingSelection = null;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
// E18 (S4): the proof is settled by an ANSWER, never by a seed. `completeBucket`
|
|
721
|
+
// is the one read that can prove the number ABSENT (the whole bucket came back
|
|
722
|
+
// and the number is not in it, on the empty query the seeded rows answered).
|
|
723
|
+
function settleInitialNumberProof(completeBucket) {
|
|
724
|
+
const proof = initialNumberProof;
|
|
725
|
+
if (proof === null || proof.proven === true) return;
|
|
726
|
+
if (proof.bucketIndex !== state.page) return;
|
|
727
|
+
if (filteredIssues().some((row) => numOf(row) === proof.number)) {
|
|
728
|
+
proof.proven = true;
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
if (completeBucket === true) proof.proven = true;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// E18 (S4): no mutation may reach a row a numbered open did not name while its
|
|
735
|
+
// number is still unproven. `number` is the row a mutation would write — the
|
|
736
|
+
// selected row, or the row a label/assignee draft was opened on.
|
|
737
|
+
function unprovenTargetRefusal(number) {
|
|
738
|
+
const proof = initialNumberProof;
|
|
739
|
+
if (proof === null || proof.proven === true) return null;
|
|
740
|
+
if (Number.isFinite(number) && number === proof.number) return null;
|
|
741
|
+
const label = pages[proof.bucketIndex] ? pages[proof.bucketIndex].label : 'Assigned';
|
|
742
|
+
return `#${proof.number} has not been found in ${label} yet; nothing was changed`;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
// The refusal is a visible line, never a silent no-op: the reader is told why
|
|
746
|
+
// nothing was written, and the draft (a comment, a label or assignee delta, a
|
|
747
|
+
// close confirmation) stays exactly as it was so it can be applied on the same
|
|
748
|
+
// issue once the answer decides.
|
|
749
|
+
function refuseUnprovenTarget(number) {
|
|
750
|
+
const refusal = unprovenTargetRefusal(number);
|
|
751
|
+
if (refusal === null) return false;
|
|
752
|
+
actionError = refusal;
|
|
753
|
+
repaint();
|
|
754
|
+
return true;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
// S9 (T10): the two buckets a numbered open searches. `/issues <n>` asks for
|
|
758
|
+
// one of the two the rail draws, but a cold cache cannot know which holds the
|
|
759
|
+
// number, so ONE look in the other bucket follows before the miss. `involved`
|
|
760
|
+
// and the lazy `All` view are never part of that pair.
|
|
761
|
+
const INITIAL_FALLBACK_BUCKET = { mine: 'assigned', assigned: 'mine' };
|
|
762
|
+
|
|
763
|
+
function fallbackPageIndex(bucketIndex) {
|
|
764
|
+
const page = pages[bucketIndex];
|
|
765
|
+
const id = page && typeof page.id === 'string' ? page.id : '';
|
|
766
|
+
const other = INITIAL_FALLBACK_BUCKET[id];
|
|
767
|
+
if (!other) return -1;
|
|
768
|
+
return pages.findIndex((candidate) => candidate && candidate.id === other);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// The open rows of ONE bucket, without moving the reader: the fallback search
|
|
772
|
+
// reads a bucket that is not on screen, so it must not go through
|
|
773
|
+
// `filteredIssues()` (which reads `state.page`).
|
|
774
|
+
function bucketRows(bucketIndex) {
|
|
775
|
+
const page = pages[bucketIndex];
|
|
776
|
+
if (!page || !Array.isArray(page.issues)) return [];
|
|
777
|
+
if (serverMode && !rowsArePaintable(page)) return [];
|
|
778
|
+
return page.issues.filter((row) => rowState(row) === 'open');
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// S7: the one-shot opening selection. It runs for the bucket the read just
|
|
782
|
+
// landed in, counts every page it reads toward the bound, and either selects
|
|
783
|
+
// the match (loading its detail) or — after ONE look in the other bucket of the
|
|
784
|
+
// pair (S9/T10) — honestly says the number is not in the requested view.
|
|
785
|
+
function resolveInitialSelection(bucketIndex = state.page) {
|
|
786
|
+
const pending = pendingSelection;
|
|
787
|
+
if (!pending || pending.bucketIndex !== bucketIndex) return;
|
|
788
|
+
pending.pagesRead += 1;
|
|
789
|
+
const at = bucketRows(bucketIndex).findIndex((row) => numOf(row) === pending.number);
|
|
790
|
+
if (at >= 0) {
|
|
791
|
+
pendingSelection = null;
|
|
792
|
+
if (initialNumberProof !== null) initialNumberProof.proven = true;
|
|
793
|
+
// A match found in the fallback bucket makes THAT bucket the visible one,
|
|
794
|
+
// so the reader lands on the tab that holds the issue.
|
|
795
|
+
if (state.page !== bucketIndex) {
|
|
796
|
+
state.page = bucketIndex;
|
|
797
|
+
state.loading = bucketState(pages[bucketIndex]).loading;
|
|
798
|
+
}
|
|
799
|
+
state.index = at;
|
|
800
|
+
state.listStart = 0;
|
|
801
|
+
state.scroll = 0;
|
|
802
|
+
ensureDetail(selected());
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
if (pending.pagesRead < INITIAL_SELECTION_PAGE_LIMIT) {
|
|
806
|
+
// The next page through the SAME paging seam the reader's own scroll
|
|
807
|
+
// uses; a bucket with nothing more to give ends the search here.
|
|
808
|
+
if (requestBucketPage(pending.bucketIndex, { append: true })) return;
|
|
809
|
+
}
|
|
810
|
+
// S9 (T10): the number may be in the other bucket of the pair. One fallback
|
|
811
|
+
// only — `triedFallback` keeps a miss in each from bouncing between them.
|
|
812
|
+
if (pending.triedFallback !== true) {
|
|
813
|
+
const fallback = fallbackPageIndex(bucketIndex);
|
|
814
|
+
if (fallback >= 0 && fallback !== bucketIndex) {
|
|
815
|
+
pendingSelection = { number: pending.number, bucketIndex: fallback, pagesRead: 0, triedFallback: true };
|
|
816
|
+
if (initialNumberProof !== null) initialNumberProof.bucketIndex = fallback;
|
|
817
|
+
const rt = bucketState(pages[fallback]);
|
|
818
|
+
if (rt.loaded && rt.query === String(state.query || '') && !rt.loading) {
|
|
819
|
+
// Already read for this query (the mount prefetches every tab):
|
|
820
|
+
// search it where it lies instead of reading it again.
|
|
821
|
+
resolveInitialSelection(fallback);
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
if (requestBucketPage(fallback, {})) return;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
pendingSelection = null;
|
|
828
|
+
// Both buckets are the answer: every page of each was searched and the
|
|
829
|
+
// number is in neither, so the proof is settled (absent) and mutations are
|
|
830
|
+
// no longer held back by it. The miss names the bucket the open REQUESTED.
|
|
831
|
+
if (initialNumberProof !== null) initialNumberProof.proven = true;
|
|
832
|
+
const label = pages[initialPageIndex] ? pages[initialPageIndex].label : 'Assigned';
|
|
833
|
+
notice = `#${pending.number} is not in ${label}`;
|
|
834
|
+
}
|
|
835
|
+
|
|
546
836
|
function availableRows() {
|
|
547
837
|
try {
|
|
548
838
|
if (typeof rowsAvailable === 'function') {
|
|
@@ -612,6 +902,36 @@ function createIssuesView(options = {}) {
|
|
|
612
902
|
state.listStart = 0;
|
|
613
903
|
state.scroll = 0;
|
|
614
904
|
actionError = null;
|
|
905
|
+
// S7: an eager/list-loader open resolves its opening selection from the
|
|
906
|
+
// pages it was just handed; there is no further page to continue to here.
|
|
907
|
+
if (pendingSelection) {
|
|
908
|
+
const pending = pendingSelection;
|
|
909
|
+
pendingSelection = null;
|
|
910
|
+
const at = filteredIssues().findIndex((row) => numOf(row) === pending.number);
|
|
911
|
+
if (initialNumberProof !== null) initialNumberProof.proven = true;
|
|
912
|
+
if (at >= 0) {
|
|
913
|
+
state.index = at;
|
|
914
|
+
state.listStart = 0;
|
|
915
|
+
state.scroll = 0;
|
|
916
|
+
} else {
|
|
917
|
+
// S9 (T10): the same one look in the other bucket of the pair. An eager
|
|
918
|
+
// mount holds every page already, so the search costs no read.
|
|
919
|
+
const fallback = fallbackPageIndex(state.page);
|
|
920
|
+
const fallbackRows = fallback >= 0 && pages[fallback] ? pages[fallback].issues : null;
|
|
921
|
+
const fallbackAt = Array.isArray(fallbackRows)
|
|
922
|
+
? fallbackRows.findIndex((row) => numOf(row) === pending.number)
|
|
923
|
+
: -1;
|
|
924
|
+
if (fallbackAt >= 0) {
|
|
925
|
+
state.page = fallback;
|
|
926
|
+
state.index = fallbackAt;
|
|
927
|
+
state.listStart = 0;
|
|
928
|
+
state.scroll = 0;
|
|
929
|
+
} else {
|
|
930
|
+
const label = pages[initialPageIndex] ? pages[initialPageIndex].label : 'Assigned';
|
|
931
|
+
notice = `#${pending.number} is not in ${label}`;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
}
|
|
615
935
|
ensureDetail(selected());
|
|
616
936
|
}
|
|
617
937
|
|
|
@@ -673,6 +993,30 @@ function createIssuesView(options = {}) {
|
|
|
673
993
|
return page.rt;
|
|
674
994
|
}
|
|
675
995
|
|
|
996
|
+
// S1/S2: the one page the shortcut key owns, or -1 when the caller marked
|
|
997
|
+
// none. The view never invents the mark: a caller that passes no lazy page
|
|
998
|
+
// keeps every bucket in the bar exactly as before.
|
|
999
|
+
function lazyPageIndex() {
|
|
1000
|
+
for (let at = 0; at < pages.length; at += 1) {
|
|
1001
|
+
if (pages[at].lazy === true) return at;
|
|
1002
|
+
}
|
|
1003
|
+
return -1;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
// The buckets the bar shows and the cycling keys visit.
|
|
1007
|
+
function tabPageIndices() {
|
|
1008
|
+
const out = [];
|
|
1009
|
+
pages.forEach((page, at) => {
|
|
1010
|
+
if (page.lazy !== true) out.push(at);
|
|
1011
|
+
});
|
|
1012
|
+
// A caller that marks every page lazy still gets one view to cycle.
|
|
1013
|
+
return out.length > 0 ? out : pages.map((_, at) => at);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
function insideLazyView() {
|
|
1017
|
+
return lazyPageIndex() >= 0 && state.page === lazyPageIndex();
|
|
1018
|
+
}
|
|
1019
|
+
|
|
676
1020
|
function normalizePageResult(result) {
|
|
677
1021
|
if (!result || typeof result !== 'object') return { ok: false, error: 'issues could not be loaded' };
|
|
678
1022
|
if (result.ok === false) {
|
|
@@ -768,6 +1112,9 @@ function createIssuesView(options = {}) {
|
|
|
768
1112
|
state.loading = false;
|
|
769
1113
|
state.loadError = null;
|
|
770
1114
|
actionError = null;
|
|
1115
|
+
// E18 (S4): an answer is what settles a numbered open's proof — found on
|
|
1116
|
+
// this page, or absent because this answer IS the whole bucket.
|
|
1117
|
+
settleInitialNumberProof(!append && normalized.hasNextPage !== true && query === '');
|
|
771
1118
|
if (keepSelection) {
|
|
772
1119
|
// S10: an explicit refresh re-reads the list the reader is on, so the
|
|
773
1120
|
// focused row (and the preview beside it) survives.
|
|
@@ -778,6 +1125,9 @@ function createIssuesView(options = {}) {
|
|
|
778
1125
|
state.listStart = 0;
|
|
779
1126
|
state.scroll = 0;
|
|
780
1127
|
}
|
|
1128
|
+
// S7: the opening selection runs after the target bucket's rows land —
|
|
1129
|
+
// the first page and every page the search itself continues to.
|
|
1130
|
+
if (!keepSelection) resolveInitialSelection(bucketIndex);
|
|
781
1131
|
// An appended page lands BELOW the reader, so the selection, the window
|
|
782
1132
|
// and the preview stay exactly where they were.
|
|
783
1133
|
if (!append || keepSelection) {
|
|
@@ -785,6 +1135,10 @@ function createIssuesView(options = {}) {
|
|
|
785
1135
|
// because comments live only in the detail.
|
|
786
1136
|
ensureDetail(selected(), keepSelection ? { refresh: true } : undefined);
|
|
787
1137
|
}
|
|
1138
|
+
} else if (!keepSelection) {
|
|
1139
|
+
// S9 (T10): the FALLBACK bucket's answer feeds the same one-shot search
|
|
1140
|
+
// even though that bucket is not the one on screen.
|
|
1141
|
+
resolveInitialSelection(bucketIndex);
|
|
788
1142
|
}
|
|
789
1143
|
repaint();
|
|
790
1144
|
};
|
|
@@ -813,6 +1167,24 @@ function createIssuesView(options = {}) {
|
|
|
813
1167
|
});
|
|
814
1168
|
}
|
|
815
1169
|
|
|
1170
|
+
// S21 (T17): a save that changed the VIEWER's own assignment changed which
|
|
1171
|
+
// bucket holds the issue, and the answer says so (`self`). Only `assigned`
|
|
1172
|
+
// moves: `mine` is authorship and `involved` excludes the viewer's own
|
|
1173
|
+
// issues. Marking that page merely unloaded is not enough — it keeps painting
|
|
1174
|
+
// the rows and the count it holds until the reader visits it again, which is
|
|
1175
|
+
// exactly the row the human had just unassigned staying on screen. So the
|
|
1176
|
+
// bucket is read again through the SAME seam every other read uses: its
|
|
1177
|
+
// ordered answer replaces the rows and the count, no row is invented here, and
|
|
1178
|
+
// a failed read keeps the old rows (the `actions` seam already refused the
|
|
1179
|
+
// write in that case). The reader's place is kept when `assigned` is the
|
|
1180
|
+
// bucket on screen.
|
|
1181
|
+
function refreshSelfAssignment() {
|
|
1182
|
+
if (!serverMode) return false;
|
|
1183
|
+
const at = pages.findIndex((page) => page.id === 'assigned');
|
|
1184
|
+
if (at < 0) return false;
|
|
1185
|
+
return requestBucketPage(at, { keepSelection: true }) !== null;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
816
1188
|
// S3: the left row is the title alone — the number lives in the preview — so
|
|
817
1189
|
// the wrapped title owns the whole wider pane.
|
|
818
1190
|
function listTitle(row) {
|
|
@@ -883,20 +1255,83 @@ function createIssuesView(options = {}) {
|
|
|
883
1255
|
});
|
|
884
1256
|
}
|
|
885
1257
|
|
|
1258
|
+
// S5: a trimmed query that is empty is NO filter. The route that decides
|
|
1259
|
+
// between the repository CONNECTION (which takes no search text) and the
|
|
1260
|
+
// capped SEARCH trims the query, so every read-shape decision here reads the
|
|
1261
|
+
// SAME trimmed text — a whitespace-only filter is the connection's read.
|
|
1262
|
+
function hasFilter(text) {
|
|
1263
|
+
return typeof text === 'string' && text.trim() !== '';
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
// S3/D3: the ONE fact that decides whether a bucket's held rows are the result
|
|
1267
|
+
// of the query on screen: the query those rows were READ for (`rt.rowsQuery`),
|
|
1268
|
+
// against the query the reader has now. A bucket holding no rows answers any
|
|
1269
|
+
// query; a bucket whose rows answer another one holds no result for this one.
|
|
1270
|
+
function rowsAnswerCurrentQuery(page) {
|
|
1271
|
+
const rt = page && page.rt ? page.rt : null;
|
|
1272
|
+
if (!rt || rt.rowsQuery === null) return true;
|
|
1273
|
+
return rt.rowsQuery === String(state.query || '');
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
// S3: rows of another query are never PAINTED either. While the bucket on
|
|
1277
|
+
// screen waits for its own read, the rows it still holds answer the previous
|
|
1278
|
+
// query, and the frame paints the loading state it already uses instead of a
|
|
1279
|
+
// list the reader would read as this query's matches. A reload of the SAME
|
|
1280
|
+
// query keeps its rows on screen (the anti-flash behavior).
|
|
1281
|
+
function rowsArePaintable(page) {
|
|
1282
|
+
if (!page) return false;
|
|
1283
|
+
if (rowsAnswerCurrentQuery(page)) return true;
|
|
1284
|
+
const rt = page.rt;
|
|
1285
|
+
return !(rt && rt.loading === true);
|
|
1286
|
+
}
|
|
1287
|
+
|
|
886
1288
|
// S10a: a tab names the OPEN issues it lists. A page's own reported total
|
|
887
1289
|
// describes the list exactly while every row it carries is open — a closed
|
|
888
1290
|
// row means that total counts issues this view never shows, so the count
|
|
889
1291
|
// falls back to the open rows actually listed.
|
|
890
1292
|
function tabCount(page) {
|
|
891
1293
|
const rows = Array.isArray(page.issues) ? page.issues : null;
|
|
1294
|
+
const rt = page.rt;
|
|
1295
|
+
// S3/D3: rows answer exactly one query. A bucket still holding the rows of
|
|
1296
|
+
// another query holds no total for this one, so its count is UNKNOWN until
|
|
1297
|
+
// its own read lands — a filtered list is never painted next to an
|
|
1298
|
+
// unfiltered number.
|
|
1299
|
+
if (serverMode && !rowsAnswerCurrentQuery(page)) return '–';
|
|
892
1300
|
const open = rows ? rows.filter((row) => rowState(row) === 'open') : null;
|
|
893
1301
|
const honorsState = !rows || open.length === rows.length;
|
|
894
|
-
|
|
1302
|
+
// S5: the `+` marks a total the view cannot know EXACTLY. Only three facts
|
|
1303
|
+
// justify it: a SEARCH read of the lazy view (a trimmed filter, which GitHub
|
|
1304
|
+
// caps), a read whose own answer reported its bucket bounded (`truncated`),
|
|
1305
|
+
// and a count derived from the rows held instead of a reported total. The
|
|
1306
|
+
// unfiltered lazy read is the repository CONNECTION with an EXACT total, so
|
|
1307
|
+
// its `hasNextPage` — more pages still to page through — marks nothing.
|
|
1308
|
+
const searchRead = page.lazy === true && hasFilter(rt && rt.rowsQuery);
|
|
1309
|
+
if (page.total != null && honorsState) {
|
|
1310
|
+
const inexact = page.lazy === true ? searchRead : page.truncated === true;
|
|
1311
|
+
return `${page.total}${inexact ? '+' : ''}`;
|
|
1312
|
+
}
|
|
895
1313
|
// A bucket nobody has read yet is UNKNOWN, never an invented zero: the
|
|
896
1314
|
// reported `All (0)` described a repository that does have open issues.
|
|
897
1315
|
if (rows === null && page.total == null) return '–';
|
|
898
1316
|
const count = open ? open.length : fallbackIssues.filter((row) => rowState(row) === 'open').length;
|
|
899
|
-
|
|
1317
|
+
// This count is derived from the rows HELD, not a reported total, so the
|
|
1318
|
+
// lazy view never claims it exact; every other bucket keeps its own bounded
|
|
1319
|
+
// mark exactly as before.
|
|
1320
|
+
const inexact = page.lazy === true ? true : page.truncated === true;
|
|
1321
|
+
return `${count}${inexact ? '+' : ''}`;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
// S5: the lazy view says which read is on screen. Its unfiltered read is the
|
|
1325
|
+
// exact repository connection; its filtered one is a capped search, and the
|
|
1326
|
+
// count beside it is marked the same way (`n+`). The line shares the note row
|
|
1327
|
+
// the frame already paints, so it costs no extra row and never hides an error.
|
|
1328
|
+
// It decides from the SAME fact the route does — the TRIMMED query — so a
|
|
1329
|
+
// whitespace-only filter names the connection, never a search that never ran.
|
|
1330
|
+
function lazyReadNote() {
|
|
1331
|
+
const lazyAt = lazyPageIndex();
|
|
1332
|
+
if (lazyAt < 0 || state.page !== lazyAt) return '';
|
|
1333
|
+
const rt = bucketState(pages[lazyAt]);
|
|
1334
|
+
return paint(theme, 'muted', hasFilter(rt.rowsQuery) ? 'via search (total capped)' : 'via connection (exact total)');
|
|
900
1335
|
}
|
|
901
1336
|
|
|
902
1337
|
function titleText() {
|
|
@@ -1024,8 +1459,23 @@ function createIssuesView(options = {}) {
|
|
|
1024
1459
|
const entry = ensureDetail(row);
|
|
1025
1460
|
if (!entry) return [paint(theme, 'muted', '(no issue selected)')];
|
|
1026
1461
|
if (entry.status === 'error') return [paint(theme, 'error', `unreadable: ${entry.error}`)];
|
|
1027
|
-
if (entry.status !== 'ready') return [paint(theme, 'muted', 'loading…')];
|
|
1028
1462
|
const issue = entry.issue || row;
|
|
1463
|
+
// S9 (T10): while the detail read is still in flight the pane shows what the
|
|
1464
|
+
// row already carries — number, title, state, labels, assignees, author —
|
|
1465
|
+
// through the ONE pending rendering `lib/issue-preview.js` owns, with the read
|
|
1466
|
+
// named at the end. Only the body and its counters wait for that answer. A
|
|
1467
|
+
// bare `loading…` pane was the defect: the rail had already handed the panel
|
|
1468
|
+
// every one of those facts for the issue the human clicked.
|
|
1469
|
+
if (entry.status !== 'ready') {
|
|
1470
|
+
const known = markdownBodySources(issue, []);
|
|
1471
|
+
return issueDetailLines(issue, [], {
|
|
1472
|
+
width,
|
|
1473
|
+
pending: true,
|
|
1474
|
+
paint: (role, text) => paint(theme, role, text),
|
|
1475
|
+
emphasis: (text) => emphasize(theme, text),
|
|
1476
|
+
wrap: detailWrap(known, width),
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1029
1479
|
const comments = Array.isArray(entry.comments) ? entry.comments : [];
|
|
1030
1480
|
return issueDetailLines(issue, comments, {
|
|
1031
1481
|
width,
|
|
@@ -1054,6 +1504,37 @@ function createIssuesView(options = {}) {
|
|
|
1054
1504
|
return NO_PERMISSIONS;
|
|
1055
1505
|
}
|
|
1056
1506
|
|
|
1507
|
+
// S11: the five hints that act on the selected issue need an issue that is
|
|
1508
|
+
// both focused and loaded. The detail read is that proof: with no row under
|
|
1509
|
+
// the cursor, while its read is still in flight and after it failed, there is
|
|
1510
|
+
// nothing those keys could act on. A view with no detail seam holds only the
|
|
1511
|
+
// row, so there the row is what "loaded" means. Like permissionsFor, this
|
|
1512
|
+
// starts no fetch.
|
|
1513
|
+
function issueReady(row) {
|
|
1514
|
+
if (!row) return false;
|
|
1515
|
+
if (typeof loadIssue !== 'function') return true;
|
|
1516
|
+
const number = numOf(row);
|
|
1517
|
+
const entry = Number.isFinite(number) ? details.get(number) : null;
|
|
1518
|
+
return Boolean(entry && entry.status === 'ready');
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
// S10: the sub-mode row while an editor holds the keyboard, null otherwise,
|
|
1522
|
+
// so the one footer slot carries whichever interaction is live. A `needsCreate`
|
|
1523
|
+
// entry follows the same WRITE capability the editor's own create row does.
|
|
1524
|
+
function subModeKeys() {
|
|
1525
|
+
// S11: an editor whose list is in flight accepts nothing but the exit, so
|
|
1526
|
+
// the footer offers nothing but that key. S10: a nested sub-mode carries its
|
|
1527
|
+
// own keys in the same slot.
|
|
1528
|
+
if (state.mode === 'labels') {
|
|
1529
|
+
if (labelsLoading) return BACK_KEYS;
|
|
1530
|
+
if (state.labelCreating) return LABEL_CREATE_KEYS;
|
|
1531
|
+
return LABEL_EDITOR_KEYS.filter((entry) => !entry.needsCreate || Boolean(labelDraft && labelDraft.createAllowed));
|
|
1532
|
+
}
|
|
1533
|
+
if (state.mode === 'assignees') return assigneesLoading ? BACK_KEYS : ASSIGNEE_EDITOR_KEYS;
|
|
1534
|
+
if (state.mode === 'comment') return state.discardAsk ? COMMENT_DISCARD_KEYS : COMMENT_EDITOR_KEYS;
|
|
1535
|
+
return null;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1057
1538
|
function render(width) {
|
|
1058
1539
|
const w = typeof width === 'number' && Number.isFinite(width) ? Math.floor(width) : 0;
|
|
1059
1540
|
if (w <= 0) return [];
|
|
@@ -1088,10 +1569,18 @@ function createIssuesView(options = {}) {
|
|
|
1088
1569
|
// alias; the keys themselves resolve through the same helper, so a hint
|
|
1089
1570
|
// leaving the row never drops a binding.
|
|
1090
1571
|
const documentScroll = palette.scrollHint(scrollKeys.previewScrollKeys(), 'scroll');
|
|
1572
|
+
// S10: a sub-mode replaces the whole reading legend with its own keys in
|
|
1573
|
+
// the same slot; S11: the five issue tokens leave the reading legend
|
|
1574
|
+
// whenever the issue they act on is not there to act on.
|
|
1575
|
+
const subMode = state.searching ? null : subModeKeys();
|
|
1576
|
+
const issueAvailable = issueReady(selected());
|
|
1091
1577
|
const footerKeys = state.searching
|
|
1092
1578
|
? SEARCH_KEYS
|
|
1093
|
-
: [FOOTER_KEYS[0], documentScroll, ...FOOTER_KEYS.slice(1)]
|
|
1094
|
-
.filter((entry) => entry
|
|
1579
|
+
: subMode || [FOOTER_KEYS[0], documentScroll, ...FOOTER_KEYS.slice(1)]
|
|
1580
|
+
.filter((entry) => entry
|
|
1581
|
+
&& (!entry.needsIssue || issueAvailable)
|
|
1582
|
+
&& (!entry.requires || permissions[entry.requires] === true))
|
|
1583
|
+
.map((entry) => (entry.shortcut === true ? shortcutHint(insideLazyView()) : entry));
|
|
1095
1584
|
const footerCell = () => `${border('│')} ${pad(helpers, palette.legendRow(theme, footerKeys, inner, (text) => measure(helpers, text)), inner)} ${border('│')}`;
|
|
1096
1585
|
const lines = [];
|
|
1097
1586
|
// S11/S13: the frame title takes `customMessageLabel` (the Pi Agents view's own
|
|
@@ -1145,7 +1634,12 @@ function createIssuesView(options = {}) {
|
|
|
1145
1634
|
// TITLE (`customMessageLabel`, with its `▸` mark, so focus
|
|
1146
1635
|
// survives a monochrome theme) while every COUNT is muted, active or not,
|
|
1147
1636
|
// and an unvisited tab's label is muted.
|
|
1148
|
-
|
|
1637
|
+
// S1/D1: the scoped tabs — or ONLY the lazy view while the reader is in it,
|
|
1638
|
+
// because it is one view of its own. The count of each visible bucket rides
|
|
1639
|
+
// the tab, so a filtered list is never painted beside an unfiltered number.
|
|
1640
|
+
const barIndices = insideLazyView() ? [lazyPageIndex()] : tabPageIndices();
|
|
1641
|
+
const tabs = barIndices.map((at) => {
|
|
1642
|
+
const page = pages[at];
|
|
1149
1643
|
const active = at === state.page;
|
|
1150
1644
|
const name = `${active ? '▸ ' : ''}${page.label}`;
|
|
1151
1645
|
const tabTotal = ` (${tabCount(page)})`;
|
|
@@ -1162,9 +1656,12 @@ function createIssuesView(options = {}) {
|
|
|
1162
1656
|
const errorNote = savingNote || (actionError ? paint(theme, 'error', actionError)
|
|
1163
1657
|
: (loadError ? paint(theme, 'error', String(loadError)) : ''));
|
|
1164
1658
|
// S9: a scheduled remote search names itself instead of looking frozen.
|
|
1659
|
+
// S5: in the lazy view the same row also says which read is on screen; it is
|
|
1660
|
+
// last, so a save, a failure, a notice or a read in flight always wins it.
|
|
1165
1661
|
const note = errorNote || (notice ? paint(theme, 'accent', notice) : '')
|
|
1166
1662
|
|| (state.searchPending ? paint(theme, 'muted', 'searching…') : '')
|
|
1167
|
-
|| (state.loading ? paint(theme, 'muted', 'loading…') : '')
|
|
1663
|
+
|| (state.loading ? paint(theme, 'muted', 'loading…') : '')
|
|
1664
|
+
|| lazyReadNote();
|
|
1168
1665
|
lines.push(`${border('│')} ${pad(helpers, note, inner)} ${border('│')}`);
|
|
1169
1666
|
|
|
1170
1667
|
const list = filteredIssues();
|
|
@@ -1277,13 +1774,8 @@ function createIssuesView(options = {}) {
|
|
|
1277
1774
|
}
|
|
1278
1775
|
|
|
1279
1776
|
function labelEditorLines(width) {
|
|
1280
|
-
//
|
|
1281
|
-
|
|
1282
|
-
// capability it does not have.
|
|
1283
|
-
const keys = ['space toggle'];
|
|
1284
|
-
if (labelDraft && labelDraft.createAllowed) keys.push('n new');
|
|
1285
|
-
keys.push('ctrl+s apply', 'esc back');
|
|
1286
|
-
const out = [emphasize(theme, `Labels (${keys.join(' · ')})`)];
|
|
1777
|
+
// S10: the title is the sub-mode's name alone; its keys ride the footer row.
|
|
1778
|
+
const out = [emphasize(theme, 'Labels')];
|
|
1287
1779
|
if (!labelDraft) return out;
|
|
1288
1780
|
if (labelsLoading) {
|
|
1289
1781
|
out.push(paint(theme, 'muted', 'loading labels…'));
|
|
@@ -1299,7 +1791,8 @@ function createIssuesView(options = {}) {
|
|
|
1299
1791
|
const on = !isCreate && labelDraft.selected.has(name);
|
|
1300
1792
|
const cursor = at === state.labelIndex ? '▸ ' : ' ';
|
|
1301
1793
|
if (isCreate && state.labelCreating) {
|
|
1302
|
-
|
|
1794
|
+
// S10 (T14): the field alone; `enter add` / `esc cancel` ride the footer.
|
|
1795
|
+
out.push(...wrapText(`${cursor}new: ${state.createName}█`, width));
|
|
1303
1796
|
} else {
|
|
1304
1797
|
out.push(...wrapText(`${cursor}[${on ? 'x' : ' '}] ${name}`, width));
|
|
1305
1798
|
}
|
|
@@ -1310,10 +1803,11 @@ function createIssuesView(options = {}) {
|
|
|
1310
1803
|
}
|
|
1311
1804
|
|
|
1312
1805
|
function commentLines(width) {
|
|
1313
|
-
|
|
1806
|
+
// S10: the title is the sub-mode's name alone; its keys ride the footer row.
|
|
1807
|
+
const out = [emphasize(theme, 'Leave a comment…')];
|
|
1314
1808
|
// The discard ask names what is at stake; the draft stays visible
|
|
1315
|
-
// below it until `y` throws it away.
|
|
1316
|
-
if (state.discardAsk) out.push(paint(theme, 'error', 'Discard this draft?
|
|
1809
|
+
// below it until `y` throws it away. S10 (T14): its keys ride the footer.
|
|
1810
|
+
if (state.discardAsk) out.push(paint(theme, 'error', 'Discard this draft?'));
|
|
1317
1811
|
// S11: the caret sits at the real insertion point — after the last typed
|
|
1318
1812
|
// character, on the line typing would continue on — so the editor shows
|
|
1319
1813
|
// where the text goes instead of a marker detached from it. The wrapped
|
|
@@ -1380,9 +1874,10 @@ function createIssuesView(options = {}) {
|
|
|
1380
1874
|
// row, no request and no loading flash — while a bucket that was never read
|
|
1381
1875
|
// (or whose rows a write invalidated) is read once. `r` stays the explicit
|
|
1382
1876
|
// refresh.
|
|
1383
|
-
function
|
|
1877
|
+
function activatePage(index) {
|
|
1384
1878
|
if (pages.length === 0) return;
|
|
1385
|
-
|
|
1879
|
+
const at = Math.floor(Number(index));
|
|
1880
|
+
state.page = Number.isFinite(at) ? Math.max(0, Math.min(pages.length - 1, at)) : 0;
|
|
1386
1881
|
state.index = 0;
|
|
1387
1882
|
state.listStart = 0;
|
|
1388
1883
|
state.scroll = 0;
|
|
@@ -1409,6 +1904,32 @@ function createIssuesView(options = {}) {
|
|
|
1409
1904
|
repaint();
|
|
1410
1905
|
}
|
|
1411
1906
|
|
|
1907
|
+
// S1: tab (and `←`/`→`) cycle the SCOPED buckets and nothing else. The lazy
|
|
1908
|
+
// view has one view of its own, so the cycling keys do nothing there.
|
|
1909
|
+
function switchPage(step) {
|
|
1910
|
+
if (pages.length === 0) return;
|
|
1911
|
+
const tabs = tabPageIndices();
|
|
1912
|
+
const at = tabs.indexOf(state.page);
|
|
1913
|
+
if (at < 0) return;
|
|
1914
|
+
activatePage(tabs[(at + step + tabs.length) % tabs.length]);
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
// S1/D2: the shortcut key enters the lazy view and, pressed again, returns to
|
|
1918
|
+
// the tab the reader came from — never “always the first one”.
|
|
1919
|
+
function toggleLazyView() {
|
|
1920
|
+
const lazyAt = lazyPageIndex();
|
|
1921
|
+
if (lazyAt < 0) return;
|
|
1922
|
+
if (state.page === lazyAt) {
|
|
1923
|
+
const tabs = tabPageIndices();
|
|
1924
|
+
const previous = tabs.includes(state.allFrom) ? state.allFrom : tabs[0];
|
|
1925
|
+
state.allFrom = null;
|
|
1926
|
+
activatePage(previous);
|
|
1927
|
+
return;
|
|
1928
|
+
}
|
|
1929
|
+
state.allFrom = state.page;
|
|
1930
|
+
activatePage(lazyAt);
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1412
1933
|
// S3: `]`/`[` scroll the ACTIVE list a screenful (S10 moved the arrows to the
|
|
1413
1934
|
// bucket switch). There is no page to move to and
|
|
1414
1935
|
// no boundary to record: the window moves over the one list, the focused row
|
|
@@ -1498,6 +2019,8 @@ function createIssuesView(options = {}) {
|
|
|
1498
2019
|
const add = [...labelDraft.selected].filter((name) => !labelDraft.original.has(name));
|
|
1499
2020
|
const remove = [...labelDraft.original].filter((name) => !labelDraft.selected.has(name));
|
|
1500
2021
|
const number = labelDraft.number;
|
|
2022
|
+
// E18 (S4): the draft names one row, and only that row may be written.
|
|
2023
|
+
if (refuseUnprovenTarget(number)) return;
|
|
1501
2024
|
beginSave('labels');
|
|
1502
2025
|
let result = null;
|
|
1503
2026
|
try {
|
|
@@ -1586,7 +2109,8 @@ function createIssuesView(options = {}) {
|
|
|
1586
2109
|
}
|
|
1587
2110
|
|
|
1588
2111
|
function assigneeEditorLines(width) {
|
|
1589
|
-
|
|
2112
|
+
// S10: the title is the sub-mode's name alone; its keys ride the footer row.
|
|
2113
|
+
const out = [emphasize(theme, 'Assignees')];
|
|
1590
2114
|
if (!assigneeDraft) return out;
|
|
1591
2115
|
if (assigneesLoading) {
|
|
1592
2116
|
out.push(paint(theme, 'muted', 'loading assignees…'));
|
|
@@ -1617,6 +2141,8 @@ function createIssuesView(options = {}) {
|
|
|
1617
2141
|
const add = [...assigneeDraft.selected].filter((login) => !assigneeDraft.original.has(login));
|
|
1618
2142
|
const remove = [...assigneeDraft.original].filter((login) => !assigneeDraft.selected.has(login));
|
|
1619
2143
|
const number = assigneeDraft.number;
|
|
2144
|
+
// E18 (S4): same rule as the label draft above.
|
|
2145
|
+
if (refuseUnprovenTarget(number)) return;
|
|
1620
2146
|
beginSave('assignees');
|
|
1621
2147
|
let result = null;
|
|
1622
2148
|
try {
|
|
@@ -1624,13 +2150,20 @@ function createIssuesView(options = {}) {
|
|
|
1624
2150
|
} catch (err) {
|
|
1625
2151
|
result = { ok: false, error: (err && err.message) || 'action failed' };
|
|
1626
2152
|
}
|
|
1627
|
-
settleSave(result, () => {
|
|
2153
|
+
settleSave(result, (answer) => {
|
|
2154
|
+
// S21 (T17): the answer's own `self` (see `lib/gh-issues.js`) says whether
|
|
2155
|
+
// this delta was the viewer's assignment; the outer `result` may be the
|
|
2156
|
+
// pending promise this seam exists to await.
|
|
2157
|
+
const self = answer !== null && typeof answer === 'object' && answer.self === true;
|
|
1628
2158
|
const row = filteredIssues().find((candidate) => numOf(candidate) === number);
|
|
1629
2159
|
if (row) row.assignees = [...assigneeDraft.selected].map((login) => ({ login }));
|
|
1630
2160
|
assigneeDraft = null;
|
|
1631
2161
|
state.mode = 'list';
|
|
1632
2162
|
actionError = null;
|
|
1633
2163
|
invalidateLoadedPages();
|
|
2164
|
+
// S21 (T17): the write's own answer decides whether the viewer's own
|
|
2165
|
+
// `assigned` bucket changed, and that page is read again now.
|
|
2166
|
+
if (self) refreshSelfAssignment();
|
|
1634
2167
|
refetchDetail(number);
|
|
1635
2168
|
repaint();
|
|
1636
2169
|
}, (error) => {
|
|
@@ -1700,6 +2233,9 @@ function createIssuesView(options = {}) {
|
|
|
1700
2233
|
if (state.saving !== null) return;
|
|
1701
2234
|
const text = state.commentText;
|
|
1702
2235
|
const number = numOf(row);
|
|
2236
|
+
// E18 (S4): `c` then `ctrl+s` is the verifier's exact scenario — the comment
|
|
2237
|
+
// may only reach the row the numbered open asked for.
|
|
2238
|
+
if (refuseUnprovenTarget(number)) return;
|
|
1703
2239
|
beginSave('comment');
|
|
1704
2240
|
let result = null;
|
|
1705
2241
|
try {
|
|
@@ -1744,6 +2280,8 @@ function createIssuesView(options = {}) {
|
|
|
1744
2280
|
}
|
|
1745
2281
|
if (state.saving !== null) return;
|
|
1746
2282
|
const number = numOf(row);
|
|
2283
|
+
// E18 (S4): a close is a mutation of one row too.
|
|
2284
|
+
if (refuseUnprovenTarget(number)) return;
|
|
1747
2285
|
beginSave('close');
|
|
1748
2286
|
let result = null;
|
|
1749
2287
|
try {
|
|
@@ -1772,8 +2310,8 @@ function createIssuesView(options = {}) {
|
|
|
1772
2310
|
|
|
1773
2311
|
// S9: the remote search read is scheduled, not issued. One live callback at
|
|
1774
2312
|
// a time: scheduling a new query cancels the previous one, so a burst of
|
|
1775
|
-
// typing never accumulates timers, and the read that finally goes out
|
|
1776
|
-
//
|
|
2313
|
+
// typing never accumulates timers, and the read that finally goes out is the
|
|
2314
|
+
// one every scoped tab needs (S3).
|
|
1777
2315
|
function scheduleQueryRead(query) {
|
|
1778
2316
|
cancelScheduledQuery();
|
|
1779
2317
|
state.searchPending = true;
|
|
@@ -1785,7 +2323,7 @@ function createIssuesView(options = {}) {
|
|
|
1785
2323
|
scheduledQuery = null;
|
|
1786
2324
|
state.searchPending = false;
|
|
1787
2325
|
if (!active || query !== String(state.query || '')) return;
|
|
1788
|
-
|
|
2326
|
+
readSettledQuery();
|
|
1789
2327
|
};
|
|
1790
2328
|
let handle = null;
|
|
1791
2329
|
try {
|
|
@@ -1799,6 +2337,16 @@ function createIssuesView(options = {}) {
|
|
|
1799
2337
|
repaint();
|
|
1800
2338
|
}
|
|
1801
2339
|
|
|
2340
|
+
// S3/S4: a settled filter is what every scoped tab shows, so every scoped tab
|
|
2341
|
+
// reads it — not only the one on screen — and the lazy view reads it too when
|
|
2342
|
+
// it is the one on screen (its filtered read is a search, S5). This is the one
|
|
2343
|
+
// place a settled query turns into requests.
|
|
2344
|
+
function readSettledQuery() {
|
|
2345
|
+
if (!serverMode) return;
|
|
2346
|
+
tabPageIndices().forEach((index) => requestBucketPage(index, {}));
|
|
2347
|
+
if (insideLazyView()) requestBucketPage(state.page, {});
|
|
2348
|
+
}
|
|
2349
|
+
|
|
1802
2350
|
function cancelScheduledQuery() {
|
|
1803
2351
|
if (scheduledQuery === null) return false;
|
|
1804
2352
|
const { handle } = scheduledQuery;
|
|
@@ -1815,14 +2363,15 @@ function createIssuesView(options = {}) {
|
|
|
1815
2363
|
// The scheduled read, issued now. Leaving the box, refreshing or paging under
|
|
1816
2364
|
// a query nobody has read yet must not wait for a timer the reader can no
|
|
1817
2365
|
// longer see, and must not fire it a second time afterwards: page one of the
|
|
1818
|
-
// current query is the only honest page, and the flushed call IS that read
|
|
2366
|
+
// current query is the only honest page, and the flushed call IS that read —
|
|
2367
|
+
// for every scoped tab (S3).
|
|
1819
2368
|
function flushScheduledQuery() {
|
|
1820
2369
|
if (scheduledQuery === null) return false;
|
|
1821
2370
|
const { query } = scheduledQuery;
|
|
1822
2371
|
cancelScheduledQuery();
|
|
1823
2372
|
if (!active || !serverMode) return false;
|
|
1824
2373
|
if (query !== String(state.query || '')) return false;
|
|
1825
|
-
|
|
2374
|
+
readSettledQuery();
|
|
1826
2375
|
return true;
|
|
1827
2376
|
}
|
|
1828
2377
|
|
|
@@ -1836,15 +2385,28 @@ function createIssuesView(options = {}) {
|
|
|
1836
2385
|
state.listStart = 0;
|
|
1837
2386
|
state.scroll = 0;
|
|
1838
2387
|
if (serverMode) {
|
|
1839
|
-
const
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
2388
|
+
const current = pages[state.page] || null;
|
|
2389
|
+
// S3/D3: EVERY bucket's rows answer the previous query, so every bucket's
|
|
2390
|
+
// loaded page is invalidated at once — a slow earlier answer can never
|
|
2391
|
+
// paint inside this query's debounce window, and no count from the old
|
|
2392
|
+
// filter survives beside the filtered list. The lazy page's ROWS are
|
|
2393
|
+
// dropped too, so the `All` view can never show rows that belong to a
|
|
2394
|
+
// previous filter; its read is issued when the reader is inside it.
|
|
2395
|
+
pages.forEach((page) => {
|
|
2396
|
+
const rt = bucketState(page);
|
|
1845
2397
|
rt.loaded = false;
|
|
1846
2398
|
rt.loading = false;
|
|
1847
2399
|
rt.seq = ++pageSeq;
|
|
2400
|
+
if (page.lazy === true) {
|
|
2401
|
+
page.issues = null;
|
|
2402
|
+
page.total = null;
|
|
2403
|
+
page.truncated = false;
|
|
2404
|
+
rt.rowsQuery = null;
|
|
2405
|
+
rt.hasMore = false;
|
|
2406
|
+
rt.error = null;
|
|
2407
|
+
}
|
|
2408
|
+
});
|
|
2409
|
+
if (current) {
|
|
1848
2410
|
state.loading = false;
|
|
1849
2411
|
// A failure still on screen belongs to the previous query, so it is
|
|
1850
2412
|
// never the answer to this one either.
|
|
@@ -2048,6 +2610,8 @@ function createIssuesView(options = {}) {
|
|
|
2048
2610
|
if (state.saving !== null) return;
|
|
2049
2611
|
// A finished action's notice lives until the next key.
|
|
2050
2612
|
notice = null;
|
|
2613
|
+
// S7: the reader has the keyboard now; the opening selection is spent.
|
|
2614
|
+
disarmInitialSelection();
|
|
2051
2615
|
if (state.searching) {
|
|
2052
2616
|
if (handleSearchInput(data)) return;
|
|
2053
2617
|
return;
|
|
@@ -2088,22 +2652,22 @@ function createIssuesView(options = {}) {
|
|
|
2088
2652
|
// and a list scroll can only scroll the query that was actually read, so it
|
|
2089
2653
|
// flushes that read instead of firing an old-cursor request later.
|
|
2090
2654
|
if (keyMatches(helpers, data, ['tab'])) {
|
|
2091
|
-
|
|
2655
|
+
flushScheduledQuery();
|
|
2092
2656
|
switchPage(1);
|
|
2093
2657
|
return;
|
|
2094
2658
|
}
|
|
2095
2659
|
if (keyMatches(helpers, data, ['shift+tab'])) {
|
|
2096
|
-
|
|
2660
|
+
flushScheduledQuery();
|
|
2097
2661
|
switchPage(-1);
|
|
2098
2662
|
return;
|
|
2099
2663
|
}
|
|
2100
2664
|
if (keyMatches(helpers, data, ['right'])) {
|
|
2101
|
-
|
|
2665
|
+
flushScheduledQuery();
|
|
2102
2666
|
switchPage(1);
|
|
2103
2667
|
return;
|
|
2104
2668
|
}
|
|
2105
2669
|
if (keyMatches(helpers, data, ['left'])) {
|
|
2106
|
-
|
|
2670
|
+
flushScheduledQuery();
|
|
2107
2671
|
switchPage(-1);
|
|
2108
2672
|
return;
|
|
2109
2673
|
}
|
|
@@ -2165,6 +2729,15 @@ function createIssuesView(options = {}) {
|
|
|
2165
2729
|
repaint();
|
|
2166
2730
|
return;
|
|
2167
2731
|
}
|
|
2732
|
+
// S1/D1: `All` is a shortcut, not a tab: `g` enters the lazy view and the
|
|
2733
|
+
// same key returns to the tab it came from (D2). A filter still inside its
|
|
2734
|
+
// debounce window is settled first, exactly like any other view change, so
|
|
2735
|
+
// the view the reader lands on reads the query it shows. No other key moves.
|
|
2736
|
+
if (keyMatches(helpers, data, ['g'])) {
|
|
2737
|
+
flushScheduledQuery();
|
|
2738
|
+
toggleLazyView();
|
|
2739
|
+
return;
|
|
2740
|
+
}
|
|
2168
2741
|
if (keyMatches(helpers, data, ['l', 'L'])) {
|
|
2169
2742
|
openLabelEditor();
|
|
2170
2743
|
return;
|
|
@@ -2194,7 +2767,9 @@ function createIssuesView(options = {}) {
|
|
|
2194
2767
|
if (keyMatches(helpers, data, ['o'])) {
|
|
2195
2768
|
const open = actions && typeof actions.openBrowser === 'function' ? actions.openBrowser : null;
|
|
2196
2769
|
const row = selected();
|
|
2197
|
-
|
|
2770
|
+
// E18 (S4): `o web` opens ONE issue, so it is the same wrong-row question
|
|
2771
|
+
// as a write; a number the numbered open has not proven is not opened.
|
|
2772
|
+
if (typeof open === 'function' && row && !refuseUnprovenTarget(numOf(row))) {
|
|
2198
2773
|
try {
|
|
2199
2774
|
open(numOf(row));
|
|
2200
2775
|
} catch {
|
|
@@ -2248,6 +2823,24 @@ function createIssuesView(options = {}) {
|
|
|
2248
2823
|
|
|
2249
2824
|
function invalidate() {}
|
|
2250
2825
|
|
|
2826
|
+
// E18 (S4): a seeded page is rows, so the opening selection matches them too —
|
|
2827
|
+
// `/issues 22` over a cache holding #22 focuses it in the FIRST frame instead
|
|
2828
|
+
// of waiting for a read, which is what the cache exists for. It proves nothing
|
|
2829
|
+
// (the seed is the cache's word, not an answer): the proof above stays open and
|
|
2830
|
+
// the settled answer runs the same one-shot search that always ran.
|
|
2831
|
+
function selectInitialFromSeed() {
|
|
2832
|
+
const pending = pendingSelection;
|
|
2833
|
+
if (!pending || !serverMode || pending.bucketIndex !== state.page) return;
|
|
2834
|
+
const page = pages[pending.bucketIndex];
|
|
2835
|
+
if (!page || !Array.isArray(page.issues)) return;
|
|
2836
|
+
const at = filteredIssues().findIndex((row) => numOf(row) === pending.number);
|
|
2837
|
+
if (at < 0) return;
|
|
2838
|
+
state.index = at;
|
|
2839
|
+
state.listStart = 0;
|
|
2840
|
+
state.scroll = 0;
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2843
|
+
selectInitialFromSeed();
|
|
2251
2844
|
ensureDetail(selected());
|
|
2252
2845
|
if (loaderMode) requestPages(loadPageFn);
|
|
2253
2846
|
else if (serverMode) {
|
|
@@ -2262,7 +2855,11 @@ function createIssuesView(options = {}) {
|
|
|
2262
2855
|
// one bucket at a time keeps the lazy default.
|
|
2263
2856
|
if (prefetchBuckets) {
|
|
2264
2857
|
pages.forEach((page, index) => {
|
|
2265
|
-
|
|
2858
|
+
// S2: the lazy page is not prefetched — it is read the first time the
|
|
2859
|
+
// shortcut enters it, which is what keeps opening `/issues` at three
|
|
2860
|
+
// reads. The visible bucket is already read above, and a bucket that
|
|
2861
|
+
// answered eagerly is left alone.
|
|
2862
|
+
if (index === state.page || page.lazy === true || Array.isArray(page.issues)) return;
|
|
2266
2863
|
requestBucketPage(index, {});
|
|
2267
2864
|
});
|
|
2268
2865
|
}
|