@osdlc/wayfinder 0.8.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/CONTRIBUTING.md +6 -1
  3. package/README.md +31 -11
  4. package/dist/args.d.ts +7 -8
  5. package/dist/args.js +7 -8
  6. package/dist/catalog.d.ts +26 -3
  7. package/dist/catalog.js +65 -12
  8. package/dist/clean-command.d.ts +3 -1
  9. package/dist/clean-command.js +23 -11
  10. package/dist/cli.js +3 -3
  11. package/dist/commands/browse.js +4 -2
  12. package/dist/commands/index.js +1 -1
  13. package/dist/commands/list.d.ts +21 -2
  14. package/dist/commands/list.js +85 -9
  15. package/dist/commands/query.js +1 -1
  16. package/dist/commands/run.js +1 -1
  17. package/dist/commands/shared.js +2 -1
  18. package/dist/config-keys.d.ts +4 -0
  19. package/dist/config-keys.js +4 -0
  20. package/dist/config.d.ts +24 -9
  21. package/dist/config.js +64 -18
  22. package/dist/core/run.d.ts +2 -1
  23. package/dist/core/run.js +10 -2
  24. package/dist/core/saved-view.d.ts +2 -7
  25. package/dist/core/saved-view.js +5 -12
  26. package/dist/core/session.d.ts +32 -6
  27. package/dist/core/session.js +86 -36
  28. package/dist/core/writes.d.ts +13 -0
  29. package/dist/core/writes.js +22 -0
  30. package/dist/document-schemas.generated.js +6 -0
  31. package/dist/documents.d.ts +90 -1
  32. package/dist/documents.js +39 -12
  33. package/dist/guide.js +2 -2
  34. package/dist/index.d.ts +8 -2
  35. package/dist/index.js +8 -5
  36. package/dist/providers-command.d.ts +2 -2
  37. package/dist/schema.d.ts +1 -1
  38. package/dist/schema.js +1 -1
  39. package/dist/serve/auth.js +3 -16
  40. package/dist/serve/catalog-share.d.ts +13 -1
  41. package/dist/serve/catalog-share.js +42 -3
  42. package/dist/serve/index.d.ts +5 -3
  43. package/dist/serve/index.js +20 -12
  44. package/dist/serve/routes.d.ts +1 -1
  45. package/dist/serve/routes.js +1 -26
  46. package/dist/terminal-text.d.ts +4 -4
  47. package/dist/terminal-text.js +17 -12
  48. package/dist/tool-info.d.ts +2 -2
  49. package/dist/tools.js +1 -1
  50. package/dist/tui/app.d.ts +15 -2
  51. package/dist/tui/app.js +189 -43
  52. package/dist/tui/index.js +3 -3
  53. package/dist/vocabulary.d.ts +7 -1
  54. package/dist/vocabulary.js +5 -1
  55. package/dist/web/main.js +345 -59
  56. package/dist/web/page.html +2 -0
  57. package/dist/web/styles.css +56 -0
  58. package/dist/xdg.d.ts +0 -7
  59. package/dist/xdg.js +0 -14
  60. package/package.json +16 -14
  61. package/schema/config.json +14 -1
package/dist/tui/app.js CHANGED
@@ -5,7 +5,9 @@
5
5
  * host, so every key and every frame can be checked without a terminal.
6
6
  *
7
7
  * Collection is async, which is what much of the state handling is for: keys
8
- * arrive during a refresh, and a row can be stale.
8
+ * arrive during a refresh, and a row can be stale. With nothing on screen,
9
+ * each runner's rows are drawn as that runner answers. Over rows already on
10
+ * screen, a refresh replaces them all at once when it ends.
9
11
  */
10
12
  import { commandString } from '@osdlc/command-seam';
11
13
  import { humanAge, humanMs } from '@osdlc/system-model/duration';
@@ -13,14 +15,14 @@ import { paramShape } from '@osdlc/system-model/params';
13
15
  import { fitWidth } from '@osdlc/ux';
14
16
  import { BIN } from "../app.js";
15
17
  import { splitArgs } from "../args.js";
16
- import { orderedCatalog } from "../catalog.js";
18
+ import { inDisplayOrder, orderedCatalog } from "../catalog.js";
17
19
  import { COPY_REFUSED, skillCopyText, taskCopyText } from "../core/copy-text.js";
18
20
  import { SessionError } from "../core/session.js";
19
21
  import { skillLine } from "../core/skills.js";
20
22
  import { groupOf, SKILLS_GROUP } from "../groups.js";
21
23
  import { footerHints, keyLines, keysFor } from "../keys.js";
22
24
  import { terminalSafe } from "../terminal-text.js";
23
- import { countRunners, displayPath, parametersUnknownLabel, probeTimeLabel, runnerLabel, withheldLabel, } from "../vocabulary.js";
25
+ import { countRunners, displayPath, parametersUnknownLabel, probeTimeLabel, runnerLabel, withheldLabel, WAITING_AFTER_MS, } from "../vocabulary.js";
24
26
  import { isText, namedKey, splitKeys } from "./keys-input.js";
25
27
  import { cycleDiscovery, editPaths, execOffCause, moveRunner, settingsLines, toggleRunner, } from "./settings.js";
26
28
  import { CLEAR_EOL, chunksWidth, line } from "./style.js";
@@ -96,12 +98,23 @@ const CLEAR_BELOW = '\x1b[J';
96
98
  /** The one separator line character. */
97
99
  const RULE = '─';
98
100
  const errorText = (err) => (err instanceof Error ? err.message : String(err));
101
+ /** At most this many failed runners get a line above the rows. */
102
+ const MAX_FAILURE_LINES = 3;
103
+ /** A failed runner's reason, as the web view words it: `runner: message`. */
104
+ function failureText(r) {
105
+ const message = r.diagnostics.find((d) => d.severity === 'error')?.message ?? 'probe failed';
106
+ return terminalSafe(`${r.runner}: ${message}`);
107
+ }
99
108
  /** Make a terminal UI. Nothing is drawn or probed until {@link Tui.boot}. */
100
109
  export function createTui({ session, host, styles: s }) {
101
110
  /** `argv` quoted for the shell, as the CLI prints the run line. */
102
111
  const commandLine = (argv) => commandString(argv, { platform: host.platform });
103
112
  const state = {
104
113
  catalog: null,
114
+ partial: null,
115
+ pending: [],
116
+ expected: 0,
117
+ loadStarted: 0,
105
118
  cache: [],
106
119
  skills: [],
107
120
  runnerOrder: session.runnerOrder(),
@@ -144,22 +157,31 @@ export function createTui({ session, host, styles: s }) {
144
157
  state.message = { text, tone };
145
158
  };
146
159
  // ------------------------------------------------------------ the catalog
147
- const reports = () => state.catalog?.reports ?? [];
160
+ /** The rows to show: the catalog's, else what the first probe has sent so far. */
161
+ const shown = () => state.catalog ?? (state.partial !== null ? { reports: state.partial } : null);
162
+ const reports = () => shown()?.reports ?? [];
148
163
  const reportFor = (runner) => reports().find((r) => r.runner === runner);
149
- const tabs = () => [
150
- ALL,
151
- ...reports().map((r) => r.runner),
152
- ...(state.skills.length > 0 ? [SKILLS_TAB] : []),
153
- ];
164
+ /** A runner the first probe will report but has not yet. It has a tab and a placeholder. */
165
+ const waiting = () => state.partial === null ? [] : state.pending.filter((r) => reportFor(r) === undefined);
166
+ const tabs = () => {
167
+ const held = waiting();
168
+ const runners = held.length === 0
169
+ ? reports().map((r) => r.runner)
170
+ : inDisplayOrder([...reports().map((r) => r.runner), ...held].map((runner) => ({ runner })), state.runnerOrder).map((r) => r.runner);
171
+ return [ALL, ...runners, ...(state.skills.length > 0 ? [SKILLS_TAB] : [])];
172
+ };
154
173
  const showsSkills = () => state.runner === ALL || state.runner === SKILLS_TAB;
155
174
  const cacheFor = (runner) => state.cache.find((c) => c.runner === runner);
156
175
  const chainOf = (runner) => reportFor(runner)?.chain ?? [];
157
176
  /** Each withheld runner, with its label and the scopes it needs. */
158
- const withheldRunners = () => state.catalog === null
159
- ? []
160
- : session
161
- .unknowns({ catalog: state.catalog, cache: state.cache })
162
- .filter((u) => u.kind === 'withheld');
177
+ const withheldRunners = () => {
178
+ const catalog = shown();
179
+ return catalog === null
180
+ ? []
181
+ : session
182
+ .unknowns({ catalog, cache: state.cache })
183
+ .filter((u) => u.kind === 'withheld');
184
+ };
163
185
  /** The withheld runners, and why, or null when execution is allowed. */
164
186
  const withheld = () => {
165
187
  const reason = session.withheldReason();
@@ -197,18 +219,22 @@ export function createTui({ session, host, styles: s }) {
197
219
  declaredOnly: state.declaredOnly,
198
220
  maxDepth: SCOPES[state.scope].maxDepth,
199
221
  };
200
- if (state.catalog === null || state.runner === SKILLS_TAB) {
222
+ if (shown() === null || state.runner === SKILLS_TAB) {
201
223
  state.rows = [];
202
224
  }
203
225
  else {
204
226
  const scoped = state.runner === ALL ? reports() : reports().filter((r) => r.runner === state.runner);
205
- state.rows = session.search({ ...state.catalog, reports: scoped }, filter);
227
+ state.rows = session.search({ reports: scoped }, filter);
206
228
  }
207
229
  state.skillRows = showsSkills() ? session.searchSkills(state.skills, filter) : [];
208
230
  const all = entries();
209
231
  if (state.selectedId !== null && !all.some((e) => entryId(e) === state.selectedId)) {
210
232
  state.selectedId = entryId(all[0]);
211
233
  }
234
+ // While rows arrive, Enter runs the row on screen, not whatever lands
235
+ // at the top after it was drawn.
236
+ if (state.loading && state.selectedId === null)
237
+ state.selectedId = entryId(all[0]);
212
238
  }
213
239
  function cursor() {
214
240
  if (state.selectedId === null)
@@ -307,8 +333,10 @@ export function createTui({ session, host, styles: s }) {
307
333
  ? state.cache.some((c) => c.state === 'stale')
308
334
  : cacheFor(name)?.state === 'stale';
309
335
  const held = name !== ALL && reportFor(name)?.skippedForExec === true;
336
+ const loading = name !== ALL && name !== SKILLS_TAB && reportFor(name) === undefined;
337
+ const failed = name !== ALL && reportFor(name)?.status === 'error';
310
338
  const title = name === ALL ? ALL : name === SKILLS_TAB ? SKILLS_GROUP.id : runnerLabel(name);
311
- const label = `${stale ? '~' : ''}${title} ${held ? '–' : count}`;
339
+ const label = `${stale ? '~' : ''}${title} ${held ? '–' : loading ? '…' : count}${failed ? ' !' : ''}`;
312
340
  const selected = name === state.runner;
313
341
  const chunks = [];
314
342
  const prev = names[i - 1];
@@ -320,7 +348,7 @@ export function createTui({ session, host, styles: s }) {
320
348
  // around the others, so it shows without color or inverse.
321
349
  chunks.push({
322
350
  text: selected ? `[${label}]` : ` ${label} `,
323
- paint: selected ? s.selected : stale || held ? s.warning : s.dim,
351
+ paint: selected ? s.selected : failed ? s.error : stale || held ? s.warning : s.dim,
324
352
  });
325
353
  return chunks;
326
354
  });
@@ -371,8 +399,20 @@ export function createTui({ session, host, styles: s }) {
371
399
  // The clock and the probe time give way first when the line is too long,
372
400
  // so a warning after them is not cut.
373
401
  const clock = [];
402
+ // The names give way after the clock, so the warnings after them stay.
403
+ let named = null;
404
+ const left = state.pending;
374
405
  if (state.catalog === null) {
375
- chunks.push({ text: ' collecting', paint: s.dim });
406
+ if (state.loading && state.partial !== null && left.length > 0) {
407
+ const short = ` loading ${left.length} of ${state.expected}`;
408
+ const chunk = { text: `${short}: ${left.map(runnerLabel).join(', ')}`, paint: s.note };
409
+ named = { chunk, short };
410
+ chunks.push(chunk);
411
+ }
412
+ else if (state.loading) {
413
+ const text = state.expected < 0 ? ' detecting the project…' : ' loading…';
414
+ chunks.push({ text, paint: s.dim });
415
+ }
376
416
  }
377
417
  else {
378
418
  clock.push({
@@ -387,7 +427,18 @@ export function createTui({ session, host, styles: s }) {
387
427
  }
388
428
  const note = refreshNote(state.cache, state.loading);
389
429
  if (state.loading && note === null && state.catalog !== null) {
390
- chunks.push({ text: ' refreshing', paint: s.note });
430
+ const short = ' refreshing…';
431
+ if (left.length > 0 && Date.now() - state.loadStarted >= WAITING_AFTER_MS) {
432
+ const chunk = {
433
+ text: `${short} waiting on ${left.map(runnerLabel).join(', ')}`,
434
+ paint: s.note,
435
+ };
436
+ named = { chunk, short };
437
+ chunks.push(chunk);
438
+ }
439
+ else {
440
+ chunks.push({ text: short, paint: s.note });
441
+ }
391
442
  }
392
443
  if (note !== null) {
393
444
  chunks.push({ text: ` ${note.text}`, paint: note.slow ? s.error : s.warning });
@@ -415,6 +466,8 @@ export function createTui({ session, host, styles: s }) {
415
466
  }
416
467
  const length = (list) => list.reduce((n, c) => n + c.text.length, 0);
417
468
  const fitted = length(chunks) > width ? chunks.filter((c) => !clock.includes(c)) : chunks;
469
+ if (named !== null && length(fitted) > width)
470
+ named.chunk.text = named.short;
418
471
  return line(fitted, width);
419
472
  }
420
473
  function queryLine(width) {
@@ -522,6 +575,13 @@ export function createTui({ session, host, styles: s }) {
522
575
  // The list, in the rows left over. The entry line takes one more row than
523
576
  // the key hints it replaces, so the list gives up a row while arguments
524
577
  // are typed.
578
+ // A failed runner's reason, above the rows, as the web view shows it.
579
+ const failures = (state.runner === ALL ? reports() : [reportFor(state.runner)])
580
+ .filter((r) => r?.status === 'error')
581
+ .slice(0, MAX_FAILURE_LINES);
582
+ for (const r of failures) {
583
+ out.push(line([{ text: ` ${failureText(r)}`, paint: s.error }], width));
584
+ }
525
585
  const at = cursor();
526
586
  const list = entries();
527
587
  const listHeight = Math.max(1, height - out.length - (state.entering ? 5 : 4));
@@ -531,10 +591,19 @@ export function createTui({ session, host, styles: s }) {
531
591
  state.scroll = at - listHeight + 1;
532
592
  if (state.scroll < 0)
533
593
  state.scroll = 0;
594
+ // A runner the first probe has not heard from yet holds a line after the rows.
595
+ const placeholders = state.runner === ALL ? waiting() : [];
534
596
  for (let i = 0; i < listHeight; i++) {
535
597
  const entry = list[state.scroll + i];
536
598
  if (!entry) {
537
- out.push(i === 0 ? emptyList(width) : CLEAR_EOL);
599
+ const at = state.scroll + i - list.length;
600
+ const held = placeholders[at];
601
+ if (held !== undefined) {
602
+ out.push(line([{ text: ` … ${runnerLabel(held)} loading`, paint: s.dim }], width));
603
+ }
604
+ else {
605
+ out.push(i === 0 ? emptyList(width) : CLEAR_EOL);
606
+ }
538
607
  continue;
539
608
  }
540
609
  if (entry.skill !== undefined) {
@@ -616,8 +685,14 @@ export function createTui({ session, host, styles: s }) {
616
685
  let text;
617
686
  if (state.runner === SKILLS_TAB)
618
687
  text = state.query !== '' ? 'no match' : 'no skills';
619
- else if (state.catalog === null)
620
- text = state.probed ? 'nothing collected' : 'collecting…';
688
+ else if (state.runner !== ALL && waiting().includes(state.runner)) {
689
+ text = `… loading ${runnerLabel(state.runner)}`;
690
+ }
691
+ else if (shown() === null)
692
+ text = state.probed ? 'nothing collected' : 'loading…';
693
+ else if (state.runner !== ALL && reportFor(state.runner)?.status === 'error') {
694
+ text = 'probe failed';
695
+ }
621
696
  else if (state.runner !== ALL && reportFor(state.runner)?.skippedForExec === true) {
622
697
  const held = withheld();
623
698
  text = held === null ? 'withheld' : `${held.cause}${held.trustable ? ' — ^s to trust' : ''}`;
@@ -627,7 +702,7 @@ export function createTui({ session, host, styles: s }) {
627
702
  else if (tabTasks().length > 0)
628
703
  text = 'no task passes the filters';
629
704
  else
630
- text = state.probed || !state.loading ? 'nothing collected' : 'collecting…';
705
+ text = state.probed || !state.loading ? 'nothing collected' : 'loading…';
631
706
  return line([{ text: ` ${text}`, paint: s.dim }], width);
632
707
  }
633
708
  /** The line under the selected task: its marks spelled out, then its doc. */
@@ -644,13 +719,18 @@ export function createTui({ session, host, styles: s }) {
644
719
  chunks.push({ text: task.doc ?? task.detail ?? '', paint: s.dim });
645
720
  return chunks;
646
721
  }
722
+ /** Set once the terminal is given back: nothing may draw over the shell after that. */
723
+ let ended = false;
647
724
  function draw() {
725
+ if (ended)
726
+ return;
648
727
  recompute();
649
728
  host.write(frame(host.columns() || 100, host.rows() || 30));
650
729
  }
651
730
  // --------------------------------------------------------------- actions
652
731
  function quit(code) {
653
732
  state.inFlight?.abort();
733
+ ended = true;
654
734
  host.release();
655
735
  host.exit(code);
656
736
  }
@@ -661,11 +741,12 @@ export function createTui({ session, host, styles: s }) {
661
741
  */
662
742
  let confirming = false;
663
743
  function run(task, args) {
664
- if (state.catalog === null)
744
+ const catalog = shown();
745
+ if (catalog === null)
665
746
  return;
666
747
  let plan;
667
748
  try {
668
- plan = session.resolveRun(state.catalog, task.id, args);
749
+ plan = session.resolveRun(catalog, task.id, args);
669
750
  }
670
751
  catch (err) {
671
752
  if (err instanceof SessionError) {
@@ -674,7 +755,8 @@ export function createTui({ session, host, styles: s }) {
674
755
  }
675
756
  throw err;
676
757
  }
677
- if (state.fromProbe) {
758
+ // Rows the first probe sent as it ran are as fresh as its final answer.
759
+ if (state.fromProbe || state.catalog === null) {
678
760
  handOver(task, plan, args);
679
761
  return;
680
762
  }
@@ -697,6 +779,7 @@ export function createTui({ session, host, styles: s }) {
697
779
  /** Hand the terminal to `plan`'s task and exit with its code. */
698
780
  function handOver(task, plan, args) {
699
781
  state.inFlight?.abort();
782
+ ended = true;
700
783
  host.release();
701
784
  host.write(`$ ${terminalSafe(commandLine(plan.argv))}\n`);
702
785
  if (task.parameters.length > 0 && args.length === 0) {
@@ -736,14 +819,76 @@ export function createTui({ session, host, styles: s }) {
736
819
  state.inFlight = controller;
737
820
  state.loading = true;
738
821
  state.message = note ?? null;
822
+ state.pending = [];
823
+ state.expected = -1;
824
+ state.loadStarted = Date.now();
825
+ // With nothing on screen, each runner is drawn as it answers. Rows
826
+ // already on screen stay until the whole answer replaces them; then the
827
+ // progress only names, after a while, the runners still out.
828
+ const live = state.catalog === null;
829
+ state.partial = live ? [] : null;
830
+ const current = () => generation === state.generation;
831
+ const waitingShown = () => Date.now() - state.loadStarted >= WAITING_AFTER_MS;
832
+ const waitTimer = setTimeout(() => {
833
+ if (current() && state.loading)
834
+ draw();
835
+ }, WAITING_AFTER_MS);
836
+ // Skills wait for the first task row, so later rows go above them and the
837
+ // cursor stays put. The Skills tab has no task rows and shows them at once.
838
+ let held = null;
839
+ const showSkills = () => {
840
+ if (held === null)
841
+ return false;
842
+ if (state.runner !== SKILLS_TAB) {
843
+ recompute();
844
+ if (state.rows.length === 0)
845
+ return false;
846
+ }
847
+ state.skills = held;
848
+ held = null;
849
+ return true;
850
+ };
851
+ const progress = {
852
+ onRunners(runners) {
853
+ if (!current())
854
+ return;
855
+ state.pending = inDisplayOrder(runners.map((runner) => ({ runner })), state.runnerOrder).map((r) => r.runner);
856
+ state.expected = runners.length;
857
+ if (live || waitingShown())
858
+ draw();
859
+ },
860
+ onRunner(report, cache) {
861
+ if (!current())
862
+ return;
863
+ state.pending = state.pending.filter((r) => r !== report.runner);
864
+ if (state.partial === null) {
865
+ if (waitingShown())
866
+ draw();
867
+ return;
868
+ }
869
+ state.partial = inDisplayOrder([...state.partial.filter((r) => r.runner !== report.runner), report], state.runnerOrder);
870
+ state.cache = [...state.cache.filter((c) => c.runner !== report.runner), cache];
871
+ showSkills();
872
+ draw();
873
+ },
874
+ onSkills(skills) {
875
+ // Over rows already on screen, the skills come with the whole answer.
876
+ if (!current() || state.partial === null)
877
+ return;
878
+ held = [...skills];
879
+ if (showSkills())
880
+ draw();
881
+ },
882
+ };
739
883
  draw();
740
884
  try {
741
885
  // Always a real probe. ^r means "ask again", and an answer from the
742
886
  // store would look the same as doing nothing.
743
- const snapshot = await session.catalog({ signal: controller.signal });
887
+ const snapshot = await session.catalog({ signal: controller.signal, progress });
744
888
  if (generation !== state.generation)
745
889
  return;
746
890
  state.catalog = orderedCatalog(snapshot.catalog, state.runnerOrder);
891
+ state.partial = null;
747
892
  state.cache = snapshot.cache;
748
893
  state.skills = snapshot.skills;
749
894
  state.fromProbe = snapshot.origin === 'probe';
@@ -756,32 +901,31 @@ export function createTui({ session, host, styles: s }) {
756
901
  }
757
902
  }
758
903
  finally {
904
+ clearTimeout(waitTimer);
759
905
  if (generation === state.generation) {
760
906
  state.loading = false;
761
907
  state.inFlight = null;
762
908
  state.probed = true;
909
+ state.pending = [];
763
910
  if (note !== undefined && state.message === note)
764
911
  state.message = null;
765
912
  }
766
913
  }
767
914
  }
768
915
  async function boot() {
769
- // The saved view first: one file, so the tasks show at once. Without
770
- // one, the store: no probe, but it detects the project and hashes each
771
- // runner's files, which takes seconds on a large repository.
772
- try {
773
- // savedCatalog never throws; a bad file reads as none.
774
- const stored = (await session.savedCatalog()) ?? (await session.storedCatalog());
775
- if (stored !== null) {
776
- state.catalog = orderedCatalog(stored.catalog, state.runnerOrder);
777
- state.cache = stored.cache;
778
- state.skills = stored.skills;
779
- }
780
- }
781
- catch {
782
- // A store that cannot be read is the same as an empty one.
783
- }
916
+ // The frame at once, then the saved view: one file, so the tasks show
917
+ // at once. Without one, the probe draws each runner as it answers. The
918
+ // store is not read first: it detects the project and hashes each
919
+ // runner's files, which costs as long as the probe's own detection.
784
920
  draw();
921
+ // savedCatalog never throws; a bad file reads as none.
922
+ const saved = await session.savedCatalog();
923
+ if (saved !== null) {
924
+ state.catalog = orderedCatalog(saved.catalog, state.runnerOrder);
925
+ state.cache = saved.cache;
926
+ state.skills = saved.skills;
927
+ draw();
928
+ }
785
929
  await refresh();
786
930
  draw();
787
931
  }
@@ -897,6 +1041,8 @@ export function createTui({ session, host, styles: s }) {
897
1041
  state.runnerOrder = settings.runnerOrder.value;
898
1042
  if (state.catalog !== null)
899
1043
  state.catalog = orderedCatalog(state.catalog, state.runnerOrder);
1044
+ if (state.partial !== null)
1045
+ state.partial = inDisplayOrder(state.partial, state.runnerOrder);
900
1046
  }
901
1047
  async function openSettings() {
902
1048
  let settings;
package/dist/tui/index.js CHANGED
@@ -14,7 +14,7 @@
14
14
  import { constants } from 'node:os';
15
15
  import { BIN } from "../app.js";
16
16
  import { handOff } from "../core/run.js";
17
- import { flushViews } from "../core/saved-view.js";
17
+ import { flushWrites } from "../core/writes.js";
18
18
  import { createTui } from "./app.js";
19
19
  import { writeClipboard } from "./copy.js";
20
20
  import { stylesFor } from "./style.js";
@@ -76,8 +76,8 @@ export async function runTui(session) {
76
76
  process.stdout.write(SHOW + ALT_OFF);
77
77
  },
78
78
  handOff,
79
- // A view write still in flight would be dropped by process.exit.
80
- exit: (code) => void flushViews().finally(() => process.exit(code)),
79
+ // A view or store write still in flight would be dropped by process.exit.
80
+ exit: (code) => void flushWrites().finally(() => process.exit(code)),
81
81
  };
82
82
  const tui = createTui({
83
83
  session,
@@ -9,6 +9,8 @@
9
9
  import type { ParametersUnknownReason } from '@osdlc/system-model/detect';
10
10
  import type { StaleReason } from '@osdlc/system-model/detect';
11
11
  export { APP, BIN } from './app.ts';
12
+ /** How long a refresh runs before the status names the runners it still waits on. */
13
+ export declare const WAITING_AFTER_MS = 3000;
12
14
  /** What one row is called on every surface. */
13
15
  export declare const TASK_NOUN: {
14
16
  readonly one: "task";
@@ -37,7 +39,11 @@ export declare const WITHHELD = "withheld";
37
39
  * runs has no trust grant while others in the repository have one, or
38
40
  * execution is off by a flag or a config file.
39
41
  */
40
- export type WithheldReason = 'untrusted' | 'tool-untrusted' | 'exec-off';
42
+ export type WithheldReason = (typeof ALL_WITHHELD_REASONS)[number];
43
+ /** Every {@link WithheldReason}, for the JSON documents' schema. */
44
+ export declare const ALL_WITHHELD_REASONS: readonly ["untrusted", "tool-untrusted", "exec-off"];
45
+ /** `a`, `a and b`, `a, b and c`. */
46
+ export declare function listWords(words: readonly string[]): string;
41
47
  /**
42
48
  * What turned execution off: the `--no-exec` flag, or `allowExec: false` in
43
49
  * the user or the project config.
@@ -9,6 +9,8 @@
9
9
  import { groupOf } from '@osdlc/system-model/groups';
10
10
  import { humanAge, humanMs } from '@osdlc/system-model/duration';
11
11
  export { APP, BIN } from "./app.js";
12
+ /** How long a refresh runs before the status names the runners it still waits on. */
13
+ export const WAITING_AFTER_MS = 3000;
12
14
  /** What one row is called on every surface. */
13
15
  export const TASK_NOUN = { one: 'task', many: 'tasks' };
14
16
  /** `1 task`, `3 tasks`. */
@@ -38,13 +40,15 @@ export function displayPath(path, runner) {
38
40
  }
39
41
  /** The word for a runner that was not read because reading it means running it. */
40
42
  export const WITHHELD = 'withheld';
43
+ /** Every {@link WithheldReason}, for the JSON documents' schema. */
44
+ export const ALL_WITHHELD_REASONS = ['untrusted', 'tool-untrusted', 'exec-off'];
41
45
  const WITHHELD_REASONS = {
42
46
  untrusted: 'this repository is not trusted',
43
47
  'tool-untrusted': 'a tool it runs is not trusted',
44
48
  'exec-off': 'execution is off',
45
49
  };
46
50
  /** `a`, `a and b`, `a, b and c`. */
47
- function listWords(words) {
51
+ export function listWords(words) {
48
52
  if (words.length <= 1)
49
53
  return words.join('');
50
54
  return `${words.slice(0, -1).join(', ')} and ${words.at(-1)}`;