@osdlc/wayfinder 0.7.1 → 0.7.3

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/dist/web/main.js CHANGED
@@ -1,9 +1,9 @@
1
1
  //#region src/web/state.ts
2
2
  const SEP = " › ";
3
3
  /**
4
- * Every static element this page touches is declared in `page.html` and never
5
- * removed, so a lookup that fails is a bug in the markup, not a runtime case
6
- * to handle — the `!` reflects that invariant rather than hiding a real null.
4
+ * Every static element this page uses is declared in `page.html` and never
5
+ * removed, so a failed lookup is a bug in the markup, not a case to handle at
6
+ * runtime. The `!` states that rule rather than hiding a real null.
7
7
  */
8
8
  function $(id) {
9
9
  return document.getElementById(id);
@@ -70,27 +70,27 @@ function restoreRunnerOrder() {
70
70
  //#endregion
71
71
  //#region ../system-model/dist/duration.js
72
72
  /**
73
- * Durations and ages a person reads, not numbers of milliseconds.
73
+ * Durations and ages formatted for people, not raw milliseconds.
74
74
  *
75
- * These format the two numbers `cache.ts` measures — how long a probe takes
76
- * ({@link humanMs}) and how old a stored answer is ({@link humanAge}) — and
77
- * every surface that reports on the cache (both CLIs, the TUI, the web view)
78
- * prints one or both of them.
75
+ * These format the two numbers `cache.ts` measures: how long a probe takes
76
+ * ({@link humanMs}) and how old a stored answer is ({@link humanAge}). Every
77
+ * caller that reports on the cache (both CLIs, the TUI, the web view) prints
78
+ * one or both.
79
79
  *
80
- * They are NOT in `cache.ts`, for the same reason `match.ts` is not: the web
81
- * view is bundled for the browser, and `cache.ts` reaches for `node:fs`,
82
- * `node:crypto` and `node:os`. This module has its own `./duration` export
83
- * subpath and must stay free of DOM and of node builtins.
80
+ * They are not in `cache.ts`, for the same reason `match.ts` is not. The web
81
+ * view is bundled for the browser, and `cache.ts` imports `node:fs`,
82
+ * `node:path` and `node:crypto`. This module has its own `./duration` export
83
+ * subpath and must not use the DOM or Node built-ins.
84
84
  *
85
- * What a surface does NOT get from here is the sentence around the number. The
86
- * CLIs say "35s old, refresh usually about 149ms", the TUI says "~149ms", the
87
- * page says "never timed here" — four voices, deliberately, each written for
88
- * where it is read. Only the number's spelling is shared.
85
+ * Callers do not get the sentence around the number from here. The CLIs say
86
+ * "35s old, refresh usually about 149ms", the TUI says "~149ms", and the page
87
+ * says "never timed here". Each caller words it for where it is read, on
88
+ * purpose. Only the number's format is shared.
89
89
  */
90
90
  /**
91
91
  * A duration, at a precision that suits its size: milliseconds under a second,
92
92
  * one decimal of a second under ten, then whole seconds and whole minutes. A
93
- * probe cost is a rough expectation, and `1.4s` reads where `1423ms` does not.
93
+ * probe cost is a rough estimate, and `1.4s` is easier to read than `1423ms`.
94
94
  */
95
95
  function humanMs(ms) {
96
96
  if (ms < 1e3) return `${Math.round(ms)}ms`;
@@ -99,13 +99,13 @@ function humanMs(ms) {
99
99
  return `${Math.round(ms / 6e4)}m`;
100
100
  }
101
101
  /**
102
- * How old a cached answer is. `undefined` is a miss, which has no age at all —
103
- * and says so rather than reading as "0s old", which would claim a freshness
102
+ * How old a cached answer is. `undefined` is a miss, which has no age. It
103
+ * returns "of unknown age" rather than "0s old", which would claim a freshness
104
104
  * nothing measured.
105
105
  *
106
- * The floor of one second is deliberate: an answer read out of the store
107
- * moments after it was written is still an answer from the store, and "0s old"
108
- * invites the reader to think it is live.
106
+ * The minimum of one second is deliberate. An answer read from the store
107
+ * moments after it was written is still a stored answer, and "0s old" would
108
+ * suggest it is live.
109
109
  */
110
110
  function humanAge(ms) {
111
111
  if (ms === void 0) return "of unknown age";
@@ -117,16 +117,16 @@ function humanAge(ms) {
117
117
  //#endregion
118
118
  //#region ../system-model/dist/match.js
119
119
  /**
120
- * Ranked search over catalog entries — the one matcher both views use.
120
+ * Ranked search over catalog entries. Both views use this one matcher.
121
121
  *
122
- * Every surface over this catalog has to agree on what a query means, or the
123
- * same keystrokes rank differently depending on which one you reached for.
124
- * The terminal UI imports it directly; the web view loads it transpiled for
125
- * the browser, which is why it has its own `./match` export subpath and why it
126
- * must stay free of DOM and of node builtins. Importing anything from
127
- * `node:fs` here breaks the browser build.
122
+ * Every view of this catalog must agree on what a query means. Otherwise the
123
+ * same query ranks differently depending on which view you use. The terminal
124
+ * UI imports it directly. The web view loads it transpiled for the browser.
125
+ * That is why it has its own `./match` export subpath, and why it must not use
126
+ * the DOM or Node built-ins. Importing anything from `node:fs` here breaks the
127
+ * browser build.
128
128
  *
129
- * Query language, such as it is:
129
+ * Query language:
130
130
  * - terms are whitespace-separated and ANDed; every term must match a field
131
131
  * - a leading `'` forces that term to match as a substring, fzf-style
132
132
  * - `mode: "exact"` forces every term to, without the prefix
@@ -220,27 +220,27 @@ function matchEntry(entry, queryTerms, mode) {
220
220
  //#endregion
221
221
  //#region ../system-model/dist/params.js
222
222
  /**
223
- * How a task's parameters are spelled for a reader.
223
+ * How a task's parameters are written for a reader.
224
224
  *
225
- * Its own module with its own `./params` export subpath, for the same reason
226
- * `duration.ts` and `match.ts` are: the web view is bundled for the browser,
227
- * and importing this from the package entry would drag `node:fs`,
228
- * `node:crypto` and `child_process` into that bundle. This module must stay
229
- * free of DOM and of node builtins — the `Param` import below is a type, so it
230
- * is erased.
225
+ * This is its own module with its own `./params` export subpath, for the same
226
+ * reason as `duration.ts` and `match.ts`. The web view is bundled for the
227
+ * browser, and importing this from the detection entry would pull `node:fs`,
228
+ * `node:crypto` and `child_process` into that bundle. This module must not use
229
+ * the DOM or Node built-ins. The `Param` import below is type-only, so it is
230
+ * erased.
231
231
  *
232
- * One spelling, three callers: just's runner builds `display` with it, the
232
+ * Three callers share this format. just's runner builds `display` with it, the
233
233
  * TUI prints it under a command that ran without arguments, and the web view's
234
234
  * run bar shows it under the field.
235
235
  */
236
236
  /**
237
- * Parameters in just's own notation — `<required>`, `[optional]`, and `+`/`*`
238
- * for a variadic that does and does not need an argument.
237
+ * Parameters in just's own notation: `<required>`, `[optional]`, and `+` or
238
+ * `*` for a variadic that does or does not need an argument.
239
239
  *
240
- * Display only, and never executable: `<name>` is a shell redirection and `*`
241
- * globs, which is exactly why `argv` and `display` are separate fields. Empty
242
- * string for a task that takes none, so a caller can concatenate without a
243
- * length check.
240
+ * For display only, never for running. `<name>` is a shell redirection and
241
+ * `*` is a glob, which is why `argv` and `display` are separate fields.
242
+ * Returns an empty string for a task with no parameters, so a caller can
243
+ * concatenate without a length check.
244
244
  */
245
245
  function paramShape(parameters) {
246
246
  return parameters.map((p) => {
@@ -290,6 +290,39 @@ function runnerLabel(runner) {
290
290
  return group.runner === runner ? group.title.toLowerCase() : runner;
291
291
  }
292
292
  //#endregion
293
+ //#region src/app.ts
294
+ /**
295
+ * The app's names. Every user-facing name that carries the product name
296
+ * derives from here. Browser-safe: the page imports it too.
297
+ */
298
+ /** The product name: config directory, cache directory, trust store key, message prefix. */
299
+ const APP = "wayfinder";
300
+ /**
301
+ * The name before the rename to wayfinder. Its user config, project config,
302
+ * trust store and config variable are still read when the new ones are
303
+ * absent. Nothing is written under it.
304
+ */
305
+ const LEGACY_APP = "waypost";
306
+ `${APP.toUpperCase()}`;
307
+ `${LEGACY_APP.toUpperCase()}`;
308
+ /** The request header that carries the web view's session token. */
309
+ const TOKEN_HEADER = `x-${APP}-token`;
310
+ //#endregion
311
+ //#region src/terminal-text.ts
312
+ /** C0 (tab and newline included), DEL, C1, and bidi U+202A-202E and U+2066-2069. */
313
+ const CONTROL = /[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g;
314
+ /** The same, but tab and newline are kept. */
315
+ const CONTROL_KEEP_LINES = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g;
316
+ const REPLACEMENT = "�";
317
+ /**
318
+ * `text` with every C0 control character (ESC included), DEL, C1 control
319
+ * character and bidi control replaced by U+FFFD. With `multiline`, tab and
320
+ * newline are kept, for output that is already more than one line.
321
+ */
322
+ function terminalSafe(text, opts = {}) {
323
+ return text.replace(opts.multiline === true ? CONTROL_KEEP_LINES : CONTROL, REPLACEMENT);
324
+ }
325
+ //#endregion
293
326
  //#region src/web/view.ts
294
327
  function escapeHtml(s) {
295
328
  return s.replace(/[&<>"]/g, (c) => ({
@@ -304,31 +337,31 @@ function brandOf(runner) {
304
337
  return (state.catalog?.reports || []).find((r) => r.runner === runner)?.brand || null;
305
338
  }
306
339
  /**
307
- * The runner's icon, injected RAW on purpose: it is inline SVG the server's
308
- * own providers declare, the same trust this page already extends to every
309
- * field it renders. Running it through escapeHtml would print the markup as
310
- * text instead of drawing it.
340
+ * The runner's icon, inserted unescaped on purpose. It is inline SVG that the
341
+ * server's own runners declare, which this page trusts as it trusts every
342
+ * field it renders. Escaping it would print the markup as text instead of
343
+ * drawing it.
311
344
  */
312
345
  function iconHtml(runner) {
313
346
  const icon = brandOf(runner)?.icon;
314
347
  return icon ? "<span class=\"ricon\" aria-hidden=\"true\">" + icon + "</span>" : "";
315
348
  }
316
- /** Row tint attributes. The color is data handed to CSS, so it IS escaped. */
349
+ /** Row tint attributes. The color is data passed to CSS, so it is escaped. */
317
350
  function brandAttrs(runner) {
318
351
  const color = brandOf(runner)?.color;
319
352
  return color ? " class=\"branded\" style=\"--rb:" + escapeHtml(color) + "\"" : "";
320
353
  }
321
354
  /**
322
- * The attributes every body row carries: the brand tint, the task's stable id,
323
- * and a roving-tabindex slot.
355
+ * The attributes every body row has: the brand tint, the task's stable id,
356
+ * and a tabindex for roving focus.
324
357
  *
325
- * `data-id` is the task's own id, not its position: the list is traversed by
326
- * keyboard and render() replaces #out wholesale, so the focused row has to be
327
- * findable again by identity after a rebuild reorders or drops rows.
358
+ * `data-id` is the task's own id, not its position. The list is used by
359
+ * keyboard and render() replaces all of #out, so the focused row must be
360
+ * found again by id after a rebuild reorders or drops rows.
328
361
  *
329
- * Every row starts at -1. markEnterTarget() promotes exactly one to 0, so the
330
- * whole list is a single tab stop and the arrows move within it — the same
331
- * pattern rovingGroup() uses for the toolbar segments.
362
+ * Every row starts at -1. markEnterTarget() sets exactly one to 0, so the
363
+ * whole list is a single tab stop and the arrows move within it. This is the
364
+ * same pattern rovingGroup() uses for the toolbar segments.
332
365
  */
333
366
  function rowAttrs(e) {
334
367
  return brandAttrs(e.runner) + " data-id=\"" + escapeHtml(e.id) + "\" tabindex=\"-1\"";
@@ -401,10 +434,10 @@ function renderNode(node, prefix) {
401
434
  return html;
402
435
  }
403
436
  /**
404
- * The service icon, authored here rather than taken from a runner's brand:
405
- * the brand icons identify RUNNERS, and this marks a property of the task.
406
- * No fixed size and no colour of its own — styles.css sizes the box and
407
- * `currentColor` lets the theme tokens paint it.
437
+ * The service icon, drawn here rather than taken from a runner's brand. Brand
438
+ * icons identify runners, and this marks a property of the task. It has no
439
+ * fixed size or colour: styles.css sizes the box and `currentColor` takes the
440
+ * theme colour.
408
441
  */
409
442
  function serviceIcon(declared) {
410
443
  return declared ? "<svg viewBox=\"0 0 16 16\" aria-hidden=\"true\"><circle cx=\"8\" cy=\"8\" r=\"4.5\" fill=\"currentColor\" /></svg>" : "<svg viewBox=\"0 0 16 16\" aria-hidden=\"true\"><circle cx=\"8\" cy=\"8\" r=\"4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" /></svg>";
@@ -419,15 +452,15 @@ function quoteDir(dir) {
419
452
  /**
420
453
  * What Copy hands over, which is not always what the Command column shows.
421
454
  *
422
- * Most tasks are written to run from the repository root and copy bare. A task
423
- * bound to its own directory gets the `cd` that makes it work — omitting it
424
- * would hand the user a command that fails. `argv` is untouched either way:
425
- * anything that SPAWNS a task already has the directory.
455
+ * Most tasks are written to run from the repository root and are copied as
456
+ * they are. A task bound to its own directory gets the `cd` it needs, since
457
+ * without it the copied command would fail. `argv` is unchanged either way,
458
+ * because anything that spawns a task already uses the directory.
426
459
  */
427
460
  function copyText(task) {
428
- return task.cwd === "." ? task.display : "cd " + quoteDir(task.cwd) + " && " + task.display;
461
+ return terminalSafe(task.cwd === "." ? task.display : "cd " + quoteDir(task.cwd) + " && " + task.display);
429
462
  }
430
- /** What Run costs, said up front: the page ends and the terminal takes over. */
463
+ /** What Run does, stated up front: the page ends and the task takes the terminal. */
431
464
  function runTip(task) {
432
465
  return "Run " + task.display + " in the terminal wayfinder is serving from. The server exits and this page is finished.";
433
466
  }
@@ -437,9 +470,9 @@ function copyTip(task) {
437
470
  }
438
471
  /**
439
472
  * The columns, in the order the colgroup declares them, plus the depth spacer
440
- * that sits between the first two below the root. Five of them, or four once
441
- * Runs drops at a narrow width (see `showRuns`). The indicator sits in its own
442
- * gutter rather than inline in the name: prefixing the text pushed every marked
473
+ * between the first two below the root. Five of them, or four once Runs is
474
+ * dropped at a narrow width (see `showRuns`). The indicator has its own column
475
+ * rather than sitting before the name, because a prefix would push each marked
443
476
  * row's chain out of line with its neighbours.
444
477
  */
445
478
  function cells(e, nameHtml, depth = 0) {
@@ -454,26 +487,23 @@ function outdent(depth) {
454
487
  return "margin-left:-" + px + "px;width:calc(100% + " + px + "px)";
455
488
  }
456
489
  /**
457
- * The action gutter. Wide enough for `run` beside the enter-target row's
458
- * `↵ copy`, which is the widest the column ever gets — the plain `copy` on
459
- * every other row leaves 14px more spare. Measured in Chromium at 1700px and
460
- * 1100px, which agree: `run` 35.23 + a 4px gap + `↵ copy` 57.89 + the cell's
461
- * own 8px right padding is 105.12.
490
+ * The action column. Wide enough for `run` beside the enter-target row's
491
+ * `↵ copy`, the widest the column gets. The plain `copy` on other rows leaves
492
+ * 14px more. Measured in Chromium at 1700px and 1100px, which agree: `run`
493
+ * 35.23 + a 4px gap + `↵ copy` 57.89 + the cell's 8px right padding is 105.12.
462
494
  *
463
- * 112 rather than that 106, because 106 left 0.88px. Nothing clipped, but a
464
- * fallback font or one more pixel of button padding would have, and the
465
- * failure is silent — the row's actions simply lose their right edge. The
466
- * 6.88px here is slack a re-measure can spend.
495
+ * 112 rather than 106, because 106 leaves only 0.88px. A fallback font or one
496
+ * more pixel of button padding would then clip, and silently: the row's
497
+ * actions would lose their right edge. The 6.88px is spare room.
467
498
  */
468
499
  const ACT_W = 112;
469
500
  /** The indicator gutter: one icon wide, with room to centre a second later. */
470
501
  const IND_W = 30;
471
502
  /**
472
- * Below this the Runs column is dropped. The UX review put the point where
473
- * Runs truncates to noise at a 1100px VIEWPORT; `main` pads 16px each side,
474
- * so that is about 1068px of table width. The number is in the same units as
475
- * `availWidth()` — the width of the table area itself (`main` minus its own
476
- * padding), not of the window.
503
+ * Below this the Runs column is dropped. Runs is cut off too much to be useful
504
+ * below a 1100px viewport. `main` pads 16px on each side, so that is about
505
+ * 1068px of table width. The number is in the same units as `availWidth()`:
506
+ * the width of the table area (`main` minus its padding), not of the window.
477
507
  */
478
508
  const RUNS_MIN_W = 1068;
479
509
  /** The width every table's columns are measured against. */
@@ -481,18 +511,18 @@ function availWidth() {
481
511
  return Math.max(320, state.mainWidth || 1e3);
482
512
  }
483
513
  /**
484
- * Whether the Runs column exists at all right now. `colgroup`, `cells` and
485
- * `renderColHeads` all ask this one question, because a table whose colgroup,
486
- * head row and body rows disagree about how many columns there are misaligns
487
- * every column after the first.
514
+ * Whether the Runs column is shown right now. `colgroup`, `cells` and
515
+ * `renderColHeads` all call this, because if a table's colgroup, head row and
516
+ * body rows disagree on the number of columns, every column after the first
517
+ * is misaligned.
488
518
  */
489
519
  function showRuns() {
490
520
  return availWidth() >= RUNS_MIN_W;
491
521
  }
492
522
  /**
493
- * The columns, named once. `tip` is the hover explanation; the modal carries
494
- * the longer version for anything a tooltip cannot hold. This is the full
495
- * roster; `renderColHeads` drops Runs from it when the width does.
523
+ * The columns, named once. `tip` is the hover text. The help modal has the
524
+ * longer version of anything a tooltip cannot hold. This is the full list;
525
+ * `renderColHeads` drops Runs when the width does.
496
526
  */
497
527
  const COLUMNS = [
498
528
  {
@@ -517,23 +547,22 @@ const COLUMNS = [
517
547
  }
518
548
  ];
519
549
  /**
520
- * Column widths, in pixels rather than percentages, because the tables are
521
- * different widths: each is outdented by its depth (see `outdent`) so their
522
- * left edges agree, which makes a percentage mean a different number of
523
- * pixels at every level.
550
+ * Column widths, in pixels rather than percentages, because the tables have
551
+ * different widths. Each is outdented by its depth (see `outdent`) so their
552
+ * left edges agree, so a percentage would be a different number of pixels at
553
+ * each level.
524
554
  *
525
- * A leading spacer column of exactly the outdent puts the CONTENT back where
526
- * its group header is, and the name column gives up the same amount — so the
527
- * command column starts at the same absolute x whatever the depth, and no row
528
- * text lands in the strip to the left of the headers. Painting text there was
529
- * the visible bug: a header's background stops at its own indented box, so a
530
- * row scrolling under one showed through beside it.
555
+ * A leading spacer column as wide as the outdent puts the content back under
556
+ * its group header, and the name column gives up the same amount. So the
557
+ * command column starts at the same x at every depth, and no row text lands
558
+ * in the strip left of the headers. Text there would show through beside a
559
+ * header as rows scroll under it, because a header's background stops at its
560
+ * own indented box.
531
561
  *
532
- * Which columns exist is itself a function of the width: under RUNS_MIN_W the
533
- * Runs column is dropped and its space goes back to Task and Command. That
534
- * has to happen in this arithmetic rather than in a media query, because the
535
- * widths are computed pixels — a media query can hide the cells but cannot
536
- * recompute what the others are worth.
562
+ * Which columns exist depends on the width: under RUNS_MIN_W the Runs column
563
+ * is dropped and its space goes to Task and Command. That has to happen here
564
+ * rather than in a media query, because the widths are computed pixels. A
565
+ * media query can hide cells but cannot recompute the other widths.
537
566
  */
538
567
  function colgroup(depth) {
539
568
  const indent = depth * INDENT_PER_LEVEL;
@@ -600,27 +629,26 @@ function renderSearchRow(row) {
600
629
  return "<tr" + rowAttrs(e) + ">" + cells(e, out) + "</tr>";
601
630
  }
602
631
  /**
603
- * How deep in the repository a task is DECLARED — the number of directories
632
+ * How deep in the repository a task is declared: the number of directories
604
633
  * above its source file. `justfile` and `moon.yml` at the root are 0;
605
634
  * `apps/web/client/moon.yml` is 3.
606
635
  *
607
- * This is where a task LIVES, not how the tree draws it. The Depth control
608
- * filters on it, so "Root" is the handful of commands the repository itself
609
- * declares rather than the ones its packages do.
636
+ * This is where a task is declared, not how the tree draws it. The Depth
637
+ * control filters on it, so "Root" is the few commands the repository itself
638
+ * declares, not the ones its packages do.
610
639
  */
611
640
  function sourceDepth(task) {
612
641
  const at = task.source.lastIndexOf("/");
613
642
  return at === -1 ? 0 : task.source.slice(0, at).split("/").length;
614
643
  }
615
644
  /**
616
- * The one runner order, driving the tabs, the picker and the tree's top
617
- * level — three surfaces that must agree or the tab bar stops predicting the
618
- * page under it.
645
+ * The one runner order, used by the tabs, the picker and the tree's top level.
646
+ * All three must agree, or the tab bar no longer matches the page below it.
619
647
  *
620
648
  * Grouped first (tasks, dependencies, tools, git hooks), then alphabetical
621
- * within a group. Any explicit arrangement (dragged on either surface) is
622
- * kept in localStorage and wins within its group. A runner not in the saved
623
- * arrangement slots in alphabetically after it rather than vanishing.
649
+ * within a group. An order the user dragged (on either surface) is kept in
650
+ * localStorage and wins within its group. A runner not in the saved order is
651
+ * placed alphabetically after it rather than left out.
624
652
  */
625
653
  function runnerOrder() {
626
654
  const present = (state.catalog?.reports || []).map((r) => r.runner);
@@ -645,21 +673,20 @@ function sortedRunnerOrder(key, dir) {
645
673
  });
646
674
  }
647
675
  /**
648
- * The sort the user last ASKED for. Not a claim about the order on screen —
649
- * activeSort verifies it against the live order before the header shows
650
- * anything, so a drag clears the arrow. It only decides WHICH column is
651
- * credited when an order satisfies two sorts, which every order does when the
652
- * counts are all equal.
676
+ * The sort the user last asked for. It does not say what order is on screen.
677
+ * activeSort checks it against the live order before the header shows
678
+ * anything, so a drag clears the arrow. It only decides which column gets the
679
+ * arrow when an order matches two sorts, as every order does when all the
680
+ * counts are equal.
653
681
  */
654
682
  let requestedSort = null;
655
683
  /**
656
- * Which sort the order ALREADY is, if any - verified by comparing, never taken
657
- * on trust. A stored "sorted by name" flag alone would keep claiming that after
658
- * a drag had rearranged the list out from under it, and the header would be
659
- * lying about what is on screen.
684
+ * Which sort the current order already matches, if any, found by comparing.
685
+ * A stored "sorted by name" flag would stay set after a drag rearranged the
686
+ * list, and the header would then be wrong about what is on screen.
660
687
  *
661
- * The last requested sort is tried FIRST, because two sorts can both describe
662
- * one order and only one of them is the one the user pressed.
688
+ * The last requested sort is tried first, because two sorts can match one
689
+ * order and only one of them is the one the user pressed.
663
690
  */
664
691
  function activeSort() {
665
692
  const now = runnerOrder().join("\0");
@@ -678,7 +705,7 @@ function activeSort() {
678
705
  };
679
706
  return null;
680
707
  }
681
- /** Sorting IS reordering: one persisted order, so the tab bar follows at once. */
708
+ /** Sorting reorders the one saved order, so the tab bar updates at once. */
682
709
  function sortRunners(key, dir) {
683
710
  requestedSort = {
684
711
  key,
@@ -703,13 +730,13 @@ function treeStart() {
703
730
  return state.runner === "all" ? 0 : 1;
704
731
  }
705
732
  /**
706
- * Why a runner reports nothing when execution is off. Said in one place
707
- * because three surfaces say it: the tab's tooltip, the picker's note and the
733
+ * Why a runner reports nothing when execution is off. Defined once because
734
+ * three places show it: the tab's tooltip, the picker's note and the
708
735
  * per-runner modal.
709
736
  *
710
- * Two sentences, because there are two reasons. Reading this runner means
711
- * running it either way; whether that is fixable from here depends on whether
712
- * trust is what is missing, which only the server knows (see `state.trustable`).
737
+ * Two sentences, for two reasons. Either way, reading this runner means
738
+ * running it. Whether the page can fix that depends on whether trust is what
739
+ * is missing, which only the server knows (see `state.trustable`).
713
740
  */
714
741
  const EXEC_NOTE_OFF = "This runner can only be read by running it, and execution is off for this session.";
715
742
  const EXEC_NOTE_UNTRUSTED = "This runner can only be read by running it, and this repository is not trusted yet.";
@@ -717,19 +744,17 @@ function execNote() {
717
744
  return state.trustable ? EXEC_NOTE_UNTRUSTED : EXEC_NOTE_OFF;
718
745
  }
719
746
  /**
720
- * The grant. Offered wherever the withholding is EXPLAINED, which now includes
721
- * the status bar: this used to appear only in the per-runner modal and the
722
- * picker, on the reasoning that the toolbar was the wrong place for it, and the
723
- * result was that a person who opened neither was never told anything at all. A
724
- * three-letter badge and a tooltip are not telling. Confirmed before it POSTs —
725
- * see input.ts.
747
+ * The trust grant button. Offered wherever the withheld runners are explained:
748
+ * the trust bar, the per-runner modal and the picker. A badge and a tooltip
749
+ * alone would leave someone who opens neither menu uninformed. It asks for
750
+ * confirmation before it POSTs (see input.ts).
726
751
  */
727
752
  const TRUST_BUTTON = "<button class=\"toolbtn\" data-trust-repo=\"1\" title=\"Record that this repository may run subprocesses to be read. Remembered per repository.\">Trust this repository</button>";
728
753
  /**
729
- * The stand-in for every folded runner's tab: one quiet chip naming how many,
730
- * with the who and the why in its title. It is not a menu of its own — the
731
- * runner picker already lists each one with its count and its (failed) /
732
- * (needs --exec) / (not trusted) note, so this only has to point there (see
754
+ * One chip in place of the tabs of all folded runners. It shows how many, and
755
+ * its title says which and why. It is not a menu of its own. The runner
756
+ * picker already lists each one with its count and its (failed),
757
+ * (needs --exec) or (not trusted) note, so this only opens the picker (see
733
758
  * input.ts).
734
759
  */
735
760
  function foldedChip(reports) {
@@ -840,11 +865,10 @@ function render() {
840
865
  /**
841
866
  * Put keyboard focus back in the rebuilt list.
842
867
  *
843
- * The focused row is found by task id. When that task is gone — a filter, the
844
- * 15s poll or a resize dropped it — focus would otherwise fall to <body> and
845
- * the arrows would stop working with nothing on screen saying why. The first
846
- * surviving row takes it instead, and with no rows left focus goes back to the
847
- * search box, which is where the user can act.
868
+ * The focused row is found by task id. When that task is gone (a filter, the
869
+ * 15s poll or a resize dropped it), focus would fall to <body> and the arrows
870
+ * would stop working with no sign why. So the first remaining row takes
871
+ * focus, and with no rows left focus goes back to the search box.
848
872
  */
849
873
  function restoreListFocus() {
850
874
  const rows = listRows();
@@ -859,9 +883,9 @@ function restoreListFocus() {
859
883
  /**
860
884
  * A selector naming one picker control, stable across a rebuild.
861
885
  *
862
- * The picker's markup is regenerated wholesale, so a node reference is useless
863
- * afterwards. Every control in it is identified by a runner id or a fixed
864
- * attribute, which survives.
886
+ * The picker's markup is regenerated in full, so an element reference is no
887
+ * use afterwards. Every control in it has a runner id or a fixed attribute,
888
+ * which stays the same.
865
889
  */
866
890
  function pickerFocusSelector(el) {
867
891
  if (el.closest("#pickbtn")) return "#pickbtn";
@@ -876,10 +900,10 @@ function pickerFocusSelector(el) {
876
900
  return null;
877
901
  }
878
902
  /**
879
- * The longer explanation, for what a tooltip is too small to hold — chiefly
880
- * the two distinctions that surprise people: part of a task's chain is
881
- * grouping this page invents, and a task can be one a runner declares or one
882
- * a convention merely implies.
903
+ * The longer explanation, for what a tooltip is too small to hold. Mainly the
904
+ * two points that surprise people: part of a task's chain is grouping this
905
+ * page adds, and a task can be declared by a runner or only implied by a
906
+ * convention.
883
907
  */
884
908
  const HELP = [
885
909
  "<h3>What this is</h3>",
@@ -916,28 +940,25 @@ const HELP = [
916
940
  "<p>The very first paint may come from a stored listing so the page appears at once on a repository whose slowest runner takes seconds. When it does, the status bar names those runners after <code>cached:</code> and marks their tabs with <code>~</code>, and a fresh read is already running behind the page. Rows never come from a store without saying so.</p>"
917
941
  ].join("");
918
942
  /**
919
- * The header cell for the selection column: a checkbox mark, sized to sit with
920
- * the row checkboxes below it. Presentational only — the accessible name comes
921
- * from the button's aria-label, so a screen reader hears "Shown", not a shape.
943
+ * The header for the selection column: a checkbox mark, sized to match the
944
+ * row checkboxes below it. Visual only. The accessible name comes from the
945
+ * button's aria-label, so a screen reader says "Shown", not a shape.
922
946
  */
923
947
  const CHECK_GLYPH = "<svg viewBox=\"0 0 16 16\" width=\"11\" height=\"11\" aria-hidden=\"true\" focusable=\"false\"><rect x=\"1.5\" y=\"1.5\" width=\"13\" height=\"13\" rx=\"2.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\"/><path d=\"M4.5 8.4l2.4 2.4 4.6-5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>";
924
948
  /**
925
- * The picker's sort header: three columns that reorder the one persisted order.
949
+ * The picker's sort header: three columns that reorder the one saved order.
926
950
  *
927
- * The columns are emitted in the order the ROW puts them — shown, name, count.
928
- * A header column names the thing underneath it, so it has to sit above the
929
- * column it sorts; one placed elsewhere reads as a control belonging to
930
- * whatever it is nearest.
951
+ * The columns are in the same order as in each row: shown, name, count. A
952
+ * header must sit above the column it sorts, or it looks like it belongs to
953
+ * whatever is nearest.
931
954
  *
932
- * The row's leading drag handle is repeated here, hidden, rather than being
933
- * replaced by a width. It is the same element and the same character, so the
934
- * columns keep starting where the row's own content starts even if that handle
935
- * ever changes.
955
+ * The row's leading drag handle is repeated here, hidden, instead of a fixed
956
+ * width. It is the same element and character, so the columns start where the
957
+ * row's content starts even if the handle changes.
936
958
  *
937
959
  * Real buttons, so the header is reachable by Tab and by voice. The arrow
938
- * appears only while the current order IS that sort - after a drag breaks it,
939
- * neither column claims anything. Count reads the live task counts, so it
940
- * follows a refresh rather than a snapshot.
960
+ * shows only while the current order matches that sort. After a drag, neither
961
+ * column shows one. Count uses the live task counts, so it follows a refresh.
941
962
  */
942
963
  function renderSortHead() {
943
964
  const active = activeSort();
@@ -952,10 +973,10 @@ function renderSortHead() {
952
973
  /**
953
974
  * The runner picker, a control in the toolbar's Scope cluster.
954
975
  *
955
- * A DISABLED runner is still collected — the library probes what it probes —
956
- * and only hidden here. That keeps the toggle instant, and the counts you see
957
- * when you re-enable one are current rather than stale. A runner that failed to
958
- * probe still lists, with its error, so unchecking it silences a broken one.
976
+ * A runner turned off here is still collected and only hidden. That keeps the
977
+ * toggle instant, and its counts are current when you turn it back on. A
978
+ * runner that failed to probe is still listed with its error, so unchecking
979
+ * it hides a broken runner.
959
980
  */
960
981
  function renderRunnerPicker(cat) {
961
982
  const enabled = state.enabled;
@@ -976,14 +997,13 @@ function listRows() {
976
997
  /**
977
998
  * Which row Enter takes, and where the single tab stop into the list sits.
978
999
  *
979
- * Two meanings, by whether a row is focused. While `focusedId` names a row the
980
- * mark follows it: Enter there copies the row you are on. The mark reverts to
981
- * the top hit when `focusedId` is cleared, which is what the search box's own
982
- * focus handler does (see input.ts) — moving to a toolbar button leaves the
983
- * row marked, because Enter from there still belongs to that button, not to
984
- * the list. The top hit is only marked while a query is active: with no query
985
- * there is no "top" anything, and a permanently marked first row would be a
986
- * lie about what the key does.
1000
+ * It depends on whether a row is focused. While `focusedId` names a row, the
1001
+ * mark follows it: Enter there copies that row. The mark goes back to the top
1002
+ * hit when `focusedId` is cleared, which the search box's focus handler does
1003
+ * (see input.ts). Moving to a toolbar button leaves the row marked, because
1004
+ * Enter there presses that button, not the list. The top hit is marked only
1005
+ * while a query is active. With no query there is no top hit, and a marked
1006
+ * first row would misstate what Enter does.
987
1007
  *
988
1008
  * A focused row whose task no longer exists (a filter dropped it) clears
989
1009
  * `focusedId` rather than leaving the list marked with a row that is gone.
@@ -1007,8 +1027,8 @@ function markEnterTarget() {
1007
1027
  /**
1008
1028
  * Move the list's keyboard focus to `id`, or off the list entirely with null.
1009
1029
  *
1010
- * Re-marks rather than re-rendering: the rows themselves have not changed, and
1011
- * a full render() on every arrow key would rebuild the whole table to move one
1030
+ * Updates the mark rather than re-rendering. The rows have not changed, and a
1031
+ * full render() on every arrow key would rebuild the whole table to move one
1012
1032
  * class.
1013
1033
  */
1014
1034
  function setFocusedRow(id) {
@@ -1016,12 +1036,8 @@ function setFocusedRow(id) {
1016
1036
  markEnterTarget();
1017
1037
  }
1018
1038
  /**
1019
- * One runner's own explanation: what each position of its path selects, how
1020
- * it is read, and whether reading it means running anything.
1021
- *
1022
- * This is what the legend's chain chips used to say, for every runner at
1023
- * once. Asked for one runner at a time it fits, and it can say more than a
1024
- * chip had room for.
1039
+ * One runner's explanation: what each position of its path selects, how it
1040
+ * is read, and whether reading it means running anything.
1025
1041
  */
1026
1042
  function showRunnerInfo(runner) {
1027
1043
  const report = (state.catalog?.reports || []).find((r) => r.runner === runner);
@@ -1042,23 +1058,23 @@ function showRunnerInfo(runner) {
1042
1058
  $("help").showModal();
1043
1059
  }
1044
1060
  /**
1045
- * The column heads, drawn as their own depth-0 table in the chrome. Putting a
1046
- * `thead` in each group's table would repeat the row down the whole page;
1047
- * this stays put and still lines up, because every table's command column
1048
- * starts at the same x whatever its depth.
1061
+ * The column headers, drawn as their own depth-0 table in the sticky header.
1062
+ * A `thead` in each group's table would repeat the row down the whole page.
1063
+ * This one stays in place and still lines up, because every table's command
1064
+ * column starts at the same x at every depth.
1049
1065
  */
1050
1066
  function renderColHeads() {
1051
1067
  const cells = COLUMNS.filter((c) => c.label !== "Runs" || showRuns()).map((c) => "<th title=\"" + escapeHtml(c.tip) + "\">" + (escapeHtml(c.label) || "&#160;") + "</th>").join("");
1052
1068
  $("colheads").innerHTML = "<table>" + colgroup(0) + "<thead><tr>" + cells + "</tr></thead></table>";
1053
1069
  }
1054
1070
  /**
1055
- * The cache's three states, as one status span — the same three the TUI shows.
1071
+ * The cache's three states, as one status span, the same three the TUI shows.
1056
1072
  *
1057
1073
  * Fresh returns "": there is nothing to report, and a span that is always
1058
- * present is a span nobody reads. Stale-and-SLOW is separated from ordinary
1059
- * stale because it is the case the cache exists for — a runner MEASURED at
1060
- * seconds is why the page has rows instead of a spinner, and it earns the
1061
- * louder class. Slow is measured, never declared.
1074
+ * shown is a span nobody reads. Stale and slow is kept apart from ordinary
1075
+ * stale because it is the case the cache exists for. A runner measured at
1076
+ * seconds is why the page has rows instead of a spinner, so it gets the more
1077
+ * prominent class. Slowness is measured, never assumed.
1062
1078
  */
1063
1079
  function cacheSpan(rows) {
1064
1080
  const stale = rows.filter((r) => r.state === "stale");
@@ -1069,27 +1085,23 @@ function cacheSpan(rows) {
1069
1085
  return "<span>cached: " + escapeHtml(stale.map((r) => r.runner + " " + humanAge(r.ageMs)).join(", ")) + " - re-probing</span>";
1070
1086
  }
1071
1087
  /**
1072
- * Runners held back for want of execution, as the page's own bar above
1073
- * everything — the equivalent of the CLI's "N runners not collected" line.
1088
+ * Runners withheld because execution is off, shown in the page's own bar
1089
+ * above everything. It matches the CLI's "N runners not collected" line.
1074
1090
  *
1075
- * This exists because the page used to say it NOWHERE at rest. The withholding
1076
- * was on the tab as a three-letter badge, in that tab's tooltip, in the
1077
- * per-runner modal and in the picker — every one of them behind a hover or a
1078
- * click. Someone looking at a repository whose exec runners were all withheld
1079
- * saw a shorter catalog and no statement that anything was missing, which is
1080
- * the one thing this tool must never do quietly.
1091
+ * Without it, the page would mention withheld runners only on the tab badge,
1092
+ * in its tooltip, in the per-runner modal and in the picker, all behind a
1093
+ * hover or a click. Someone would see a shorter catalog with nothing saying
1094
+ * that anything was missing, which this tool must never do quietly.
1081
1095
  *
1082
- * Its own bar rather than a span in the status strip. The first attempt put it
1083
- * there, between the clock and the keyboard hints, and it was wrong for a
1084
- * reason worth keeping written down: that strip reports NUMBERS about what you
1085
- * are looking at, and this asks for a DECISION about what you are not. A button
1086
- * in a row of counts reads as one more piece of chrome.
1096
+ * It is its own bar rather than a span in the status strip. The status strip
1097
+ * reports numbers about what you are looking at, and this asks for a decision
1098
+ * about what you are not. A button in a row of counts looks like one more
1099
+ * control.
1087
1100
  *
1088
- * It names the runners rather than only counting them: "3 runners" invites the
1089
- * question the sentence should already answer. The grant rides along only when
1090
- * trust is what is missing — when it is not, execution is off for the session
1091
- * and trusting the repository would change nothing, so offering it would be a
1092
- * wrong instruction.
1101
+ * It names the runners rather than only counting them, so the reader does not
1102
+ * have to ask which. The trust button is included only when trust is what is
1103
+ * missing. Otherwise execution is off for the session and trusting the
1104
+ * repository would change nothing.
1093
1105
  */
1094
1106
  function withheldBar(reports) {
1095
1107
  const held = reports.filter((s) => s.skippedForExec);
@@ -1109,24 +1121,24 @@ function renderTrustBar() {
1109
1121
  host.hidden = html === "";
1110
1122
  }
1111
1123
  /**
1112
- * Kept separate from the table so an unchanged poll can refresh the clock
1113
- * without touching the DOM under it. Otherwise pressing Refresh on a repo
1114
- * that has not changed looks like nothing happened, and the timestamp claims
1115
- * data is older than it was just verified to be.
1124
+ * Kept separate from the table so an unchanged poll can update the clock
1125
+ * without touching the table. Otherwise Refresh on an unchanged repo would
1126
+ * look like nothing happened, and the timestamp would show data as older than
1127
+ * it is.
1116
1128
  */
1117
1129
  function renderStatus(shown, total) {
1118
1130
  const errs = (state.catalog?.reports || []).filter((s) => s.status === "error").map((s) => s.runner);
1119
1131
  $("status").innerHTML = "<span>" + shown + " of " + total + " " + (state.runner === "all" ? "commands, all runners" : state.runner + " commands") + "</span><span>checked " + new Date(state.checkedAt).toLocaleTimeString() + (state.loading ? " - refreshing" : "") + "</span>" + cacheSpan(state.cache) + (errs.length ? "<span class=\"err\">probe failed: " + errs.join(", ") + "</span>" : "") + "<span><kbd>/</kbd> search &middot; <kbd>Enter</kbd> copy top hit &middot; <kbd>&uarr;</kbd><kbd>&darr;</kbd> move &middot; <kbd>Esc</kbd> back to search, again to clear it</span>";
1120
1132
  }
1121
1133
  /**
1122
- * The run bar: supply a parameterised task's arguments before handing over.
1134
+ * The run bar: enter a task's arguments before handing over the terminal.
1123
1135
  *
1124
- * The command PREFIX is static text, not part of the field. The server appends
1136
+ * The command prefix is static text, not part of the field. The server adds
1125
1137
  * what this sends to the argv it looked up itself and ignores anything else,
1126
- * so an editable `just` that silently still ran `just` would be a control that
1127
- * lies. Only the tail is yours to type, and the bar shows exactly that.
1138
+ * so an editable `just` would mislead: editing it would change nothing. Only
1139
+ * the trailing arguments can be typed, and the bar shows exactly that.
1128
1140
  *
1129
- * A bar rather than a modal: it costs no click to dismiss, and the row that
1141
+ * A bar rather than a modal: it needs no click to dismiss, and the row that
1130
1142
  * opened it stays on screen behind it.
1131
1143
  */
1132
1144
  function showRunBar(task) {
@@ -1142,17 +1154,17 @@ function showRunBar(task) {
1142
1154
  field.focus();
1143
1155
  return field;
1144
1156
  }
1145
- /** Take the run bar down. Idempotent — `esc`, a run and a re-open all call it. */
1157
+ /** Remove the run bar. Idempotent: `esc`, a run and a re-open all call it. */
1146
1158
  function hideRunBar() {
1147
1159
  document.getElementById("runbar")?.remove();
1148
1160
  }
1149
1161
  /**
1150
- * The end of the page: the task now owns the terminal and this server is gone.
1162
+ * The end of the page: the task now has the terminal and this server is gone.
1151
1163
  *
1152
- * It replaces the view rather than sitting beside it, because everything still
1153
- * on screen is about to be a lie — the catalog cannot be refreshed, the
1154
- * buttons cannot act, and a poll would only paint a failed fetch. Saying the
1155
- * tab is finished is the honest state.
1164
+ * It replaces the view rather than sitting beside it, because nothing on
1165
+ * screen works any more. The catalog cannot be refreshed, the buttons cannot
1166
+ * act, and a poll would only show a failed fetch. So the page says the tab
1167
+ * is finished.
1156
1168
  */
1157
1169
  function showHandoff(command) {
1158
1170
  const el = document.createElement("div");
@@ -1164,7 +1176,7 @@ function showHandoff(command) {
1164
1176
  el.tabIndex = -1;
1165
1177
  el.focus();
1166
1178
  }
1167
- /** Said on the row that asked, when another run got the terminal first. */
1179
+ /** Shown on the row that asked, when another run got the terminal first. */
1168
1180
  function showRunTaken(button) {
1169
1181
  const cell = button.closest("td.act");
1170
1182
  if (!cell || cell.querySelector(".runerr")) return;
@@ -1176,10 +1188,10 @@ function showRunTaken(button) {
1176
1188
  setTimeout(() => note.remove(), 4e3);
1177
1189
  }
1178
1190
  /**
1179
- * Publish the sticky chrome's real height as a CSS variable. It is measured
1180
- * rather than hard-coded because the search row and the status line wrap at narrow
1181
- * widths, and a stale number would either hide the first group header behind
1182
- * the chrome or leave a gap under it.
1191
+ * Set the sticky header's real height as a CSS variable. It is measured
1192
+ * rather than hard-coded because the search row and the status line wrap at
1193
+ * narrow widths. A wrong number would hide the first group header behind the
1194
+ * sticky header or leave a gap under it.
1183
1195
  */
1184
1196
  function measureChrome() {
1185
1197
  document.documentElement.style.setProperty("--chrome-h", Math.round($("chrome").getBoundingClientRect().height) + "px");
@@ -1187,17 +1199,17 @@ function measureChrome() {
1187
1199
  //#endregion
1188
1200
  //#region src/args.ts
1189
1201
  /**
1190
- * Split a typed argument tail the way a shell splits words, and in no other
1191
- * way a shell behaves.
1202
+ * Split typed arguments into words the way a shell does, and do nothing else
1203
+ * a shell does.
1192
1204
  *
1193
1205
  * Quotes group and a backslash escapes the next character. There is no
1194
- * globbing, no variable expansion, no operators, no substitution: the result
1195
- * goes to an `execvp`-style spawn as separate argv entries, never to a shell,
1196
- * so `*.log` is passed through as the four characters somebody typed. That is
1197
- * the same rule `argv` and `display` exist to keep.
1206
+ * globbing, no variable expansion, no operators and no substitution. The
1207
+ * result goes to an `execvp`-style spawn as separate argv entries, never to a
1208
+ * shell, so `*.log` is passed through as the five characters typed. This is
1209
+ * the same rule that keeps `argv` separate from `display`.
1198
1210
  *
1199
- * Splitting rather than `.split(/\s+/)` for exactly one reason: a quoted
1200
- * `"two words"` has to stay ONE argument.
1211
+ * This is not `.split(/\s+/)` for one reason: a quoted `"two words"` must stay
1212
+ * one argument.
1201
1213
  */
1202
1214
  function splitArgs(input) {
1203
1215
  const out = [];
@@ -1235,40 +1247,21 @@ function splitArgs(input) {
1235
1247
  return out;
1236
1248
  }
1237
1249
  //#endregion
1238
- //#region src/app.ts
1239
- /**
1240
- * The app's names. Every user-facing name that carries the product name
1241
- * derives from here. Browser-safe: the page imports it too.
1242
- */
1243
- /** The product name: config directory, cache directory, trust store key, message prefix. */
1244
- const APP = "wayfinder";
1245
- /**
1246
- * The name before the rename to wayfinder. Its user config, project config,
1247
- * trust store and config variable are still read when the new ones are
1248
- * absent. Nothing is written under it.
1249
- */
1250
- const LEGACY_APP = "waypost";
1251
- `${APP.toUpperCase()}`;
1252
- `${LEGACY_APP.toUpperCase()}`;
1253
- /** The request header that carries the web view's session token. */
1254
- const TOKEN_HEADER = `x-${APP}-token`;
1255
- //#endregion
1256
1250
  //#region src/web/api.ts
1257
1251
  /**
1258
1252
  * The session token the server embedded in this page, read once at import.
1259
1253
  *
1260
- * Module state and nothing else. localStorage, sessionStorage and cookies all
1261
- * outlive the tab or ride along on requests the page did not make; this dies
1262
- * with the page, which is the lifetime it should have.
1254
+ * Kept in module state only. localStorage, sessionStorage and cookies either
1255
+ * outlive the tab or are sent with requests the page did not make. Module
1256
+ * state ends with the page, which is the lifetime the token should have.
1263
1257
  */
1264
1258
  const token = globalThis.__WAYFINDER_TOKEN__ ?? "";
1265
1259
  /**
1266
- * Every server call goes through here — the one place the token is attached.
1260
+ * Every server call goes through here, the one place the token is attached.
1267
1261
  *
1268
1262
  * The endpoints are on loopback, which any process on this machine and any
1269
- * page the user is visiting can reach, so reads and mutations alike carry the
1270
- * token. Route new endpoints through here; one that skips it gets a 401,
1271
- * which is the point.
1263
+ * page the user visits can reach, so reads and writes both carry the token.
1264
+ * Send new endpoints through here. A request without the token gets a 401.
1272
1265
  */
1273
1266
  function authFetch(path, init = {}) {
1274
1267
  const headers = new Headers(init.headers);
@@ -1292,12 +1285,12 @@ async function getConfig() {
1292
1285
  /**
1293
1286
  * Write staged settings to the project file, and read back what that produced.
1294
1287
  *
1295
- * A PATCH of dotted keys, matching what `way config set` names. The server
1288
+ * A patch of dotted keys, named as `way config set` names them. The server
1296
1289
  * applies it to the file's raw contents, so a key this version does not know
1297
- * survives the save — see `writeProjectConfig` in serve.ts.
1290
+ * survives the save (see `writeProjectConfig` in serve.ts).
1298
1291
  *
1299
- * The success arm carries the config as it now IS rather than as the caller
1300
- * hoped: one round trip, and the screen re-renders from the file.
1292
+ * On success it returns the config as it now is in the file, so the screen
1293
+ * re-renders from the file in one round trip.
1301
1294
  */
1302
1295
  async function saveConfig(set) {
1303
1296
  try {
@@ -1349,11 +1342,10 @@ async function trustRepo() {
1349
1342
  /**
1350
1343
  * Revoke this repository's trust.
1351
1344
  *
1352
- * The store is the durable answer and this makes it `false`. The RUNNING
1353
- * session keeps whatever execution gate it resolved at startup — see the
1354
- * DELETE branch in serve.ts for why the server will not guess whether that
1355
- * came from the store or from an explicit `--exec`. The caller shows that
1356
- * rather than implying a revoke the process did not perform.
1345
+ * The store then says not trusted. The running session keeps the execution
1346
+ * setting it decided at start. See the DELETE branch in serve.ts for why the
1347
+ * server does not guess whether that came from the store or from `--exec`.
1348
+ * The caller says so, rather than implying a revoke that did not happen.
1357
1349
  */
1358
1350
  async function untrustRepo() {
1359
1351
  try {
@@ -1378,12 +1370,11 @@ async function untrustRepo() {
1378
1370
  /**
1379
1371
  * Ask the server to hand its terminal to a task.
1380
1372
  *
1381
- * The id selects the command; `args` is the tail a parameterised recipe needs
1382
- * (`staging` for `just deploy <env>`). The server looks the task up in the
1383
- * catalog it built itself and APPENDS these — the binary, the leading
1384
- * arguments and the cwd never come from here, because a command sent from this
1385
- * side would be a command the server was told to run by whatever could reach
1386
- * the port.
1373
+ * The id selects the command. `args` are the trailing arguments a recipe with
1374
+ * parameters needs (`staging` for `just deploy <env>`). The server looks the
1375
+ * task up in the catalog it built and adds these. The binary, the leading
1376
+ * arguments and the cwd never come from the page, because anything that can
1377
+ * reach the port could send a command.
1387
1378
  */
1388
1379
  async function requestRun(id, args = []) {
1389
1380
  try {
@@ -1420,13 +1411,13 @@ async function requestRun(id, args = []) {
1420
1411
  /**
1421
1412
  * Pull the catalog.
1422
1413
  *
1423
- * `force` is the Refresh button, and it is always a real probe of every runner
1424
- * — an explicit refresh that could be answered from a store is not a refresh.
1425
- * An unforced call (first paint, focus, the poll) takes whatever the server has
1426
- * freshest, which on the very first request is the stored answer with a probe
1427
- * already running behind it; `state.cache` says which rows those were.
1414
+ * `force` is the Refresh button, and it always runs a real probe of every
1415
+ * runner, since a refresh answered from a store is not a refresh. An unforced
1416
+ * call (first view, focus, the poll) takes the newest answer the server has.
1417
+ * On the first request that is the stored answer, with a probe already
1418
+ * running in the background. `state.cache` says which rows those were.
1428
1419
  *
1429
- * The fingerprint check keeps an unchanged poll from blowing away scroll
1420
+ * The fingerprint check stops an unchanged poll from resetting the scroll
1430
1421
  * position and open groups.
1431
1422
  */
1432
1423
  async function load(force) {
@@ -1462,29 +1453,28 @@ async function load(force) {
1462
1453
  //#endregion
1463
1454
  //#region src/web/settings.ts
1464
1455
  /**
1465
- * The settings screen — this project's configuration, and edits to it.
1456
+ * The settings screen: this project's configuration, and edits to it.
1466
1457
  *
1467
- * Edits STAGE: nothing here writes until Save. The project config is a
1468
- * committed file, so a click must not dirty someone's working tree silently.
1458
+ * Edits are staged. Nothing is written until Save. The project config is a
1459
+ * committed file, so a click must not silently change someone's working tree.
1469
1460
  *
1470
- * It is deliberately NOT the runner picker. The picker in the header filters
1471
- * this session and forgets; this describes what the project uses at all.
1461
+ * It is not the runner picker. The picker in the header filters this session
1462
+ * and is then forgotten. This screen sets which runners the project uses.
1472
1463
  *
1473
- * Section order follows the config schema's own key order — runners,
1474
- * execution, discovery, excluded paths — so the screen reads like the file it
1475
- * describes.
1464
+ * Sections follow the config schema's key order (runners, execution,
1465
+ * discovery, excluded paths), so the screen reads like the file it describes.
1476
1466
  *
1477
- * STATE LIVES HERE, not in `state.ts`. The staged document is the dialog's
1478
- * own and meaningless once the dialog closes; in the page-wide `AppState`
1479
- * every consumer would carry a field about a screen they never open.
1467
+ * Its state lives here, not in `state.ts`. The staged edits belong to the
1468
+ * dialog and mean nothing once it closes. In the page-wide `AppState`, every
1469
+ * user of that state would carry a field about a screen it never opens.
1480
1470
  */
1481
1471
  /** What the server last told us the configuration is. */
1482
1472
  let loaded = null;
1483
- /** Runner ids the catalog reported — the config alone cannot supply them. */
1473
+ /** Runner ids the catalog reported. The config alone cannot supply them. */
1484
1474
  let knownRunners = [];
1485
1475
  /**
1486
- * Edits not yet written, by dotted key. Empty means clean — that is the whole
1487
- * dirty test; a separate boolean could disagree with it.
1476
+ * Edits not yet written, by dotted key. Empty means nothing is unsaved. This
1477
+ * is the only unsaved-changes test, since a separate boolean could disagree.
1488
1478
  */
1489
1479
  let staged = {};
1490
1480
  /** A message from the last Save, shown until the next render clears it. */
@@ -1592,8 +1582,8 @@ function openSettings(config, known) {
1592
1582
  return screen();
1593
1583
  }
1594
1584
  /**
1595
- * Handle a click inside the settings dialog. Returns true when it was ours, so
1596
- * the page's delegated listener can stop.
1585
+ * Handle a click inside the settings dialog. Returns true when this function
1586
+ * handled it, so the page's shared click listener can stop.
1597
1587
  */
1598
1588
  function handleSettingsClick(target) {
1599
1589
  const runner = target.closest("[data-set-runner]");
@@ -1692,13 +1682,12 @@ async function commit() {
1692
1682
  //#endregion
1693
1683
  //#region src/web/input.ts
1694
1684
  /**
1695
- * Ask for the terminal and deal with every way that ends.
1685
+ * Ask for the terminal and handle every outcome.
1696
1686
  *
1697
1687
  * Shared by the row button and the run bar so the four outcomes are handled
1698
- * once. `button`, when given, is disabled for the round trip: a double click
1699
- * would otherwise send a second POST the server can only answer 409 to, and
1700
- * "another run took the terminal" is a confusing thing to be told about
1701
- * yourself.
1688
+ * in one place. `button`, when given, is disabled for the round trip.
1689
+ * Otherwise a double click would send a second POST that gets a 409, and the
1690
+ * user would be told "another run took the terminal" about their own click.
1702
1691
  */
1703
1692
  async function handOff(id, args, button) {
1704
1693
  if (button) button.disabled = true;
@@ -1720,9 +1709,9 @@ async function handOff(id, args, button) {
1720
1709
  /**
1721
1710
  * Keys for the run bar's field: Enter runs what is typed, Escape goes back.
1722
1711
  *
1723
- * Bound to the field itself rather than the document, so it dies with the bar
1724
- * and cannot outlive it — a stale document listener would send a run for a
1725
- * task the user had already dismissed.
1712
+ * Bound to the field rather than the document, so it goes away with the bar.
1713
+ * A leftover document listener could send a run for a task the user had
1714
+ * already dismissed.
1726
1715
  */
1727
1716
  function armRunBar(id, field) {
1728
1717
  field.addEventListener("keydown", (ev) => {
@@ -1741,8 +1730,8 @@ function armRunBar(id, field) {
1741
1730
  /**
1742
1731
  * The refresh loop, and the flag that ends it.
1743
1732
  *
1744
- * The flag is not redundant with clearing the interval: the focus listener is
1745
- * a second way in, and one flag turns both off in one place.
1733
+ * The flag is needed as well as clearing the interval, because the focus
1734
+ * listener also loads. One flag turns both off in one place.
1746
1735
  */
1747
1736
  let pollTimer;
1748
1737
  let polling = true;
@@ -1855,29 +1844,28 @@ function wireInput() {
1855
1844
  if (menu && !target.closest(".picker")) menu.hidden = true;
1856
1845
  });
1857
1846
  /**
1858
- * Drag-to-reorder, shared by the tab bar and the picker: both mark their
1859
- * draggables with a runner id, so one pair of handlers serves the two
1860
- * surfaces.
1847
+ * Drag to reorder, shared by the tab bar and the picker. Both mark their
1848
+ * draggable elements with a runner id, so one set of handlers serves both.
1861
1849
  *
1862
- * The drag PREVIEWS itself. A solid clone carries the pointer in place of
1863
- * the browser's near-transparent default ghost, and the real elements move
1864
- * as the pointer passes their midpoints - the dragged one among them, faded,
1865
- * marking the slot it would land in. So the list shows the order the drop
1866
- * will produce rather than only revealing it afterwards.
1850
+ * The drag shows a preview. A solid clone follows the pointer instead of the
1851
+ * browser's faint default drag image, and the real elements move as the
1852
+ * pointer passes their midpoints. The dragged element moves with them,
1853
+ * faded, to mark where it would land. So the list shows the order the drop
1854
+ * will produce before the drop.
1867
1855
  *
1868
- * The DOM is only the preview. State stays the source of truth: the drop
1869
- * commits through saveRunnerOrder, and a drag abandoned without one
1870
- * re-renders from the persisted order, which snaps everything back.
1856
+ * The DOM is only the preview. State is the source of truth: the drop saves
1857
+ * through saveRunnerOrder, and a drag cancelled without a drop re-renders
1858
+ * from the saved order, which puts everything back.
1871
1859
  */
1872
1860
  let dragging = null;
1873
1861
  let dragEl = null;
1874
1862
  let ghost = null;
1875
1863
  /**
1876
- * The arrangement the user has actually SEEN, refreshed once per animation
1877
- * frame. Chromium delivers a last `dragover` in the same task as the `drop`,
1878
- * so the move that dragover makes is committed without ever being painted -
1879
- * and what persisted was one position off from what was on screen.
1880
- * Committing this snapshot instead makes what lands what was last shown.
1864
+ * The order the user has actually seen, updated once per animation frame.
1865
+ * Chromium sends a last `dragover` in the same task as the `drop`, so the
1866
+ * move that dragover makes is never painted. Saving the live DOM order would
1867
+ * then be one position off from what was on screen. Saving this snapshot
1868
+ * saves what was last shown.
1881
1869
  */
1882
1870
  let painted = [];
1883
1871
  let paintQueued = false;
@@ -1893,15 +1881,15 @@ function wireInput() {
1893
1881
  });
1894
1882
  }
1895
1883
  /**
1896
- * Put the page back the way a drag found it. Idempotent, and called from BOTH
1897
- * ends: `drop` runs it before committing, because the commit re-renders the
1898
- * tab strip and the picker, which detaches the drag source - and Chromium
1899
- * fires no `dragend` for a source that is no longer in the document. Cleanup
1900
- * left to that event alone simply never ran, so every committed drag leaked
1901
- * its ghost and left the drag state armed.
1884
+ * Put the page back as it was before the drag. Idempotent, and called from
1885
+ * both `drop` and `dragend`. `drop` runs it before saving, because saving
1886
+ * re-renders the tab strip and the picker, which removes the drag source, and
1887
+ * Chromium fires no `dragend` for a source no longer in the document. If
1888
+ * only `dragend` cleaned up, every saved drag would leave its drag image and
1889
+ * drag state behind.
1902
1890
  *
1903
- * Returns whether there was a drag to end, which is what tells `dragend` it
1904
- * is the cancel path rather than the tail of a commit.
1891
+ * Returns whether there was a drag to end, which tells `dragend` whether it
1892
+ * is the cancel path or the end of a saved drag.
1905
1893
  */
1906
1894
  function endDrag() {
1907
1895
  if (!dragEl) return false;
@@ -2012,9 +2000,9 @@ function wireInput() {
2012
2000
  node.querySelector(".twisty").textContent = state.collapsed.has(key) ? "▸" : "▾";
2013
2001
  });
2014
2002
  /**
2015
- * The results list as one keyboard surface. Rows are <tr> spread across a
2016
- * table per tree group, so "next row" is the next row in DOCUMENT order
2017
- * across all of #out rather than within one table.
2003
+ * Keyboard handling for the whole results list. Rows are <tr> elements in
2004
+ * one table per tree group, so "next row" is the next row in document order
2005
+ * across all of #out, not within one table.
2018
2006
  */
2019
2007
  $("out").addEventListener("keydown", (e) => {
2020
2008
  const ev = e;
@@ -2081,9 +2069,9 @@ function wireInput() {
2081
2069
  /**
2082
2070
  * Put a row's command on the clipboard and say what happened.
2083
2071
  *
2084
- * The button is the ONLY evidence anyone has that the paste buffer changed, so
2085
- * a refused write — a permissions policy, a page that is not the active
2086
- * document — must not be reported as a copy. Returns whether it landed.
2072
+ * The button is the only sign that the clipboard changed, so a refused write
2073
+ * (a permissions policy, or a page that is not the active document) must not
2074
+ * be reported as a copy. Returns whether the write succeeded.
2087
2075
  */
2088
2076
  async function copyCommand(copy) {
2089
2077
  let ok = true;
@@ -2103,10 +2091,10 @@ async function copyCommand(copy) {
2103
2091
  /**
2104
2092
  * Copy a row's command and say so on the row.
2105
2093
  *
2106
- * The confirmation is on the ROW, not just the button, because both paths that
2107
- * reach here act at a distance: from the search box the button is off to the
2108
- * right of where the eye is, and from a focused row the keypress named the row
2109
- * rather than the button. One helper, so the two paths cannot drift.
2094
+ * The confirmation shows on the row, not just the button, because neither
2095
+ * caller is looking at the button. From the search box the button is far to
2096
+ * the right, and from a focused row the keypress was on the row. One helper,
2097
+ * so both callers behave the same.
2110
2098
  */
2111
2099
  function copyRow(row) {
2112
2100
  const button = row.querySelector(".copy");
@@ -2133,10 +2121,10 @@ function runnerOf(el) {
2133
2121
  /**
2134
2122
  * The drag image: a solid, elevated copy of what is being dragged.
2135
2123
  *
2136
- * setDragImage only takes an element that is rendered, so the clone is put in
2137
- * the document and parked off-screen by its own class. It is removed at
2138
- * dragend rather than on the next tick, because a snapshot the engine has not
2139
- * taken yet cannot be removed early.
2124
+ * setDragImage only takes a rendered element, so the clone is added to the
2125
+ * document and placed off-screen by its class. It is removed at the end of
2126
+ * the drag, not on the next tick, because the browser may not have taken its
2127
+ * snapshot yet.
2140
2128
  */
2141
2129
  function makeDragGhost(el, e, dt) {
2142
2130
  const box = el.getBoundingClientRect();
@@ -2162,11 +2150,10 @@ function makeDragGhost(el, e, dt) {
2162
2150
  /**
2163
2151
  * Move `moving` before `before` and let the displaced siblings slide there.
2164
2152
  *
2165
- * insertBefore is instant, so the shift would otherwise be a jump with nothing
2166
- * connecting the two arrangements. Each sibling's old position is measured,
2167
- * then it is offset back to it and released - the standard
2168
- * first/last/invert/play. Reduced motion keeps the jump, which is the setting
2169
- * asking for exactly that.
2153
+ * insertBefore is instant, so without this the siblings would jump. Each
2154
+ * sibling's old position is measured, it is offset back there, and then the
2155
+ * offset is released (the FLIP technique: first, last, invert, play). With
2156
+ * reduced motion set, the siblings jump, which is what that setting asks for.
2170
2157
  */
2171
2158
  function slideInto(parent, moving, before) {
2172
2159
  if (moving.nextSibling === before && before !== null) return;
@@ -2191,14 +2178,14 @@ function slideInto(parent, moving, before) {
2191
2178
  /**
2192
2179
  * Commit a previewed arrangement to the persisted order.
2193
2180
  *
2194
- * The surface being dragged shows a SUBSET of the runners - the tab bar folds
2195
- * the empty ones and hides the disabled ones - so the preview cannot simply
2196
- * become the order. All a drag settles is where the moved runner sits AMONG THE
2197
- * ONES ON SCREEN, and the runners it never showed must keep the neighbours they
2198
- * have. So the moved runner is anchored to its new visible SUCCESSOR, or to its
2199
- * visible predecessor when it was dropped last: a drop at the head means
2200
- * "before the first VISIBLE runner", not "at the front of the full list", which
2201
- * would hoist it past folded and disabled runners the user never saw.
2181
+ * The dragged surface shows only some of the runners (the tab bar folds the
2182
+ * empty ones and hides the disabled ones), so the preview cannot become the
2183
+ * order as it is. A drag only decides where the moved runner sits among the
2184
+ * runners on screen, and the hidden runners must keep their neighbours. So
2185
+ * the moved runner is placed before its new visible successor, or after its
2186
+ * visible predecessor when it was dropped last. A drop at the start means
2187
+ * "before the first visible runner", not "at the front of the full list",
2188
+ * which would move it past folded and disabled runners the user never saw.
2202
2189
  */
2203
2190
  function commitDragOrder(shown, moved) {
2204
2191
  const order = runnerOrder().filter((r) => r !== moved);
@@ -2211,13 +2198,13 @@ function commitDragOrder(shown, moved) {
2211
2198
  saveRunnerOrder(order);
2212
2199
  }
2213
2200
  /**
2214
- * Make a group of buttons ONE tab stop, moved within by arrow keys.
2201
+ * Make a group of buttons one tab stop, with arrow keys moving inside it.
2215
2202
  *
2216
- * Without this, two segmented controls and eight runner tabs are a dozen
2217
- * stops between the search box and anything else — Tab stops meaning "next
2218
- * control" and starts meaning "next button", which is the opposite of what
2219
- * a keyboard user expects. Only the active button stays reachable by Tab;
2220
- * the rest are reached with the arrows, as a radio group or tablist is.
2203
+ * Without this, two segmented controls and eight runner tabs add a dozen Tab
2204
+ * stops between the search box and anything else. Tab would move to the next
2205
+ * button instead of the next control, which is not what a keyboard user
2206
+ * expects. Only the active button is reachable by Tab. The rest are reached
2207
+ * with the arrows, as in a radio group or tab list.
2221
2208
  */
2222
2209
  function rovingGroup(container, selector = "button") {
2223
2210
  if (!container) return;
@@ -2254,7 +2241,7 @@ const THEME_CYCLE = {
2254
2241
  light: "dark",
2255
2242
  dark: "system"
2256
2243
  };
2257
- /** How each scheme presents itself once it is the one in force. */
2244
+ /** How the button shows each scheme when it is the one in use. */
2258
2245
  const THEME_FACE = {
2259
2246
  system: {
2260
2247
  glyph: "◐",
@@ -2273,14 +2260,13 @@ const THEME_FACE = {
2273
2260
  }
2274
2261
  };
2275
2262
  /**
2276
- * Paint the theme button for the choice now in force.
2263
+ * Update the theme button for the choice now in use.
2277
2264
  *
2278
- * The button shows the CURRENT scheme, so both the title and the accessible
2279
- * name have to carry two facts: what is on, and what a click does next. A
2280
- * single cycling control has no other place to say the second one, and a name
2281
- * carrying only the first would leave a screen-reader user guessing what the
2282
- * press does. Boot calls this too, so the button and the restored preference
2283
- * agree from the first frame.
2265
+ * The button shows the current scheme, so both the title and the accessible
2266
+ * name must say two things: what is on, and what a click does next. A single
2267
+ * cycling button has nowhere else to say the second, and a screen-reader user
2268
+ * would otherwise not know what the press does. Startup calls this too, so
2269
+ * the button matches the restored preference from the first frame.
2284
2270
  */
2285
2271
  function setThemeButton(choice) {
2286
2272
  const btn = $("theme");
@@ -2294,10 +2280,9 @@ function setThemeButton(choice) {
2294
2280
  //#endregion
2295
2281
  //#region src/web/main.ts
2296
2282
  /**
2297
- * Boot only: restore saved preferences, wire every listener, draw the first
2298
- * frame. The actual behavior — rendering, data loading, event handling —
2299
- * lives in `view.ts`, `api.ts` and `input.ts`; this module just sequences
2300
- * their startup in the order the page depends on.
2283
+ * Startup only: restore saved preferences, attach every listener, draw the
2284
+ * first frame. Rendering, data loading and event handling live in `view.ts`,
2285
+ * `api.ts` and `input.ts`. This module starts them in the order the page needs.
2301
2286
  */
2302
2287
  if (new URL(location.href).searchParams.has("boot")) {
2303
2288
  const clean = new URL(location.href);