opencode-azure-devops-pr-review 0.4.4 → 0.4.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.5 — 2026-11-20
4
+
5
+ While a run is under way, the terminal panel offers to stop it. The reviewer,
6
+ verifier and comment-planning instructions are those of 0.4.4, and no setting
7
+ is new.
8
+
9
+ The terminal panel:
10
+
11
+ - A `STARTED` notice says how its run is stopped (`/pr-stop <run-id>`), but
12
+ in the conversation, which a person who reads the panel does not watch, and
13
+ with an ID to copy. While a run is under way (a review, a preview that is
14
+ being planned, a publication, a check) the row at the panel's foot now
15
+ offers **Stop this run…** (`s`), and nothing else.
16
+ - Stopping asks first, in a list whose first row is "No, let it run" and
17
+ names the run. "Yes, stop it" sends `/pr-stop` with that run's ID to the
18
+ session on screen, and AZPR takes it like a typed command; the run ends
19
+ with its `CANCELLED` receipt, and requests that were already sent may still
20
+ be billed.
21
+ - What is typed into such a question finds a row by the beginning of its
22
+ title: `y` finds "Yes" and `n` "No". The key that opened the question,
23
+ pressed once more than meant, is typed into it, and OpenCode's own search
24
+ would find `s` in "Yes, stop it" alone and select it; now it leaves no row
25
+ for Enter to take. The question before posting answers the same way.
26
+ - An answer is acted on only while the panel still shows that run as under
27
+ way. If the run has ended, or the next run has started, while the question
28
+ was open, nothing is sent and the panel says so; a step that reaches AZPR
29
+ after its run has ended stops nothing, and no other run.
30
+ - That a run can be stopped comes from the runtime, like every other step: in
31
+ the metadata of the run's `STARTED` notice, which no model reads (the run's
32
+ ID). The text of that notice is unchanged, and progress notices and
33
+ receipts are sent as before. A run that an earlier version started offers
34
+ nothing; it is stopped by typing the command its notice shows.
35
+ - Where the panel has no report or preview to show, it said "No report or
36
+ preview yet." also of a run that had ended, such as one that was stopped.
37
+ Once the run has its receipt it now says "This run ended with no report or
38
+ preview to show."
39
+ - A click on a step at the panel's foot could be lost (since 0.4.4). The
40
+ steps were drawn anew whenever the panel worked its content out again,
41
+ which every notice and every answer of the server causes, and OpenTUI finds
42
+ what lies under the pointer in the frame it drew last: a press or a release
43
+ that came before the next frame went nowhere. Each step now keeps its
44
+ element, as the session rows do, and its highlight under the pointer.
45
+
46
+ Documentation:
47
+
48
+ - The recording at the top of the README and the pictures of the panel in
49
+ the demonstration are new: a real review with the row at the panel's foot
50
+ (the step that stops a run, then posting and adjusting), a review stopped
51
+ from the panel, and the whole terminal in every frame. They showed the
52
+ panel of 0.4.2.
53
+
3
54
  ## 0.4.4 — 2026-11-19
4
55
 
5
56
  After a comment preview, the terminal panel lists what you can do next at its
package/README.md CHANGED
@@ -47,7 +47,7 @@ is an actual capture excerpt with identifying UI removed and its text unchanged.
47
47
 
48
48
  ## Watch the workflow
49
49
 
50
- [![Real OpenCode run: a review starts, a panel beside the conversation lists its sessions, then shows the report and the comment preview rendered.](docs/assets/terminal-panel-teaser.gif)](docs/DEMO.md#the-terminal-panel)
50
+ [![Real OpenCode run: a review starts and a panel beside the conversation lists its sessions, with a step at its foot that stops the run; the panel then shows the report and the comment preview rendered, with the next step at its foot, and the findings as a list.](docs/assets/terminal-panel-teaser.gif)](docs/DEMO.md#the-terminal-panel)
51
51
 
52
52
  *A 15-second edit of a real OpenCode 2.3.0 session on a dedicated test PR.
53
53
  Waiting time is shortened, so the length is not the review duration.
@@ -61,7 +61,7 @@ Waiting time is shortened, so the length is not the review duration.
61
61
  [company networks](docs/ENTERPRISE.md#company-networks) first):
62
62
 
63
63
  ```sh
64
- opencode plugin add opencode-azure-devops-pr-review@0.4.4
64
+ opencode plugin add opencode-azure-devops-pr-review@0.4.5
65
65
  ```
66
66
 
67
67
  2. In OpenCode's terminal UI, type `/pr-setup`. Dialogs ask for your Azure
@@ -92,9 +92,10 @@ without a model.
92
92
 
93
93
  In OpenCode's terminal UI a [panel](#terminal-panel) opens beside the
94
94
  conversation: it shows the report and the preview rendered, and at its foot
95
- what you can do next. Pick **Post N comments…** there, or leave findings out
96
- first with **Adjust findings…**, without typing a command; posting always asks
97
- once more.
95
+ what you can do next, without typing a command. While the review runs that is
96
+ **Stop this run…**. After the preview, pick **Post N comments…** there, or
97
+ leave findings out first with **Adjust findings…**. Stopping and posting
98
+ always ask once more.
98
99
 
99
100
  <details>
100
101
  <summary>Optional: adjust findings and publish after reading the preview</summary>
@@ -412,7 +413,8 @@ acknowledge `STARTED` and continue in the current OpenCode process; short
412
413
  `PROGRESS` notices and a final receipt return to the invoking conversation.
413
414
  They start no response of that conversation's own model; when you prompt it
414
415
  later, it reads them together with your prompt, in one request. Use
415
- the displayed `/pr-stop <run-id>` to cancel. `/pr-setup` (including `--help`),
416
+ the displayed `/pr-stop <run-id>` to cancel, or **Stop this run…** at the
417
+ foot of the [terminal panel](#terminal-panel). `/pr-setup` (including `--help`),
416
418
  `/pr-stop`, `/pr-comment --show`, an adjustment that changes nothing and a
417
419
  refused command answer directly, without a background run.
418
420
  Completed reviews, previews and publication ledgers are saved privately and
@@ -433,14 +435,14 @@ Azure DevOps REST API with the runtime's built-in `fetch`.
433
435
  Install the npm package with OpenCode's plugin manager:
434
436
 
435
437
  ```sh
436
- opencode plugin add opencode-azure-devops-pr-review@0.4.4
438
+ opencode plugin add opencode-azure-devops-pr-review@0.4.5
437
439
  ```
438
440
 
439
441
  The same release is also a versioned Git package, which needs Git but not the
440
442
  npm registry:
441
443
 
442
444
  ```sh
443
- opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.4'
445
+ opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.5'
444
446
  ```
445
447
 
446
448
  Add only one of them. OpenCode 2.3.0 loads the plugin into a running OpenCode
@@ -455,7 +457,7 @@ To select another configuration file, use an absolute path in the host config:
455
457
  ```json
456
458
  {
457
459
  "plugins": [{
458
- "package": "opencode-azure-devops-pr-review@0.4.4",
460
+ "package": "opencode-azure-devops-pr-review@0.4.5",
459
461
  "options": { "settingsFile": "/absolute/path/to/azpr/settings.json" }
460
462
  }]
461
463
  }
@@ -480,7 +482,7 @@ For an entry that `opencode plugin add` created, add the new version and,
480
482
  only when that succeeds, remove the previous one:
481
483
 
482
484
  ```sh
483
- opencode plugin add opencode-azure-devops-pr-review@0.4.4 &&
485
+ opencode plugin add opencode-azure-devops-pr-review@0.4.5 &&
484
486
  opencode plugin remove opencode-azure-devops-pr-review@PREVIOUS_VERSION
485
487
  ```
486
488
 
@@ -512,7 +514,8 @@ the first one (`Unknown setting settings.terminalPanel`) instead of starting. `o
512
514
  show a single `azpr` row with the new version (from 0.3.1, `/pr-check` names
513
515
  it too); if it still shows the previous one, run `opencode service restart`.
514
516
  Exact versions stay pinned, so `opencode plugin update` leaves them unchanged.
515
- See the [0.4.4 release notes](docs/releases/v0.4.4.md) for what changed, the
517
+ See the [0.4.5 release notes](docs/releases/v0.4.5.md) for what changed, the
518
+ [0.4.4 release notes](docs/releases/v0.4.4.md) for the steps at the panel's foot, the
516
519
  [0.4.3 release notes](docs/releases/v0.4.3.md) for setup in the terminal UI, the
517
520
  [0.4.0 release notes](docs/releases/v0.4.0.md) for commands without review IDs and the
518
521
  [0.2.0 release notes](docs/releases/v0.2.0.md) for automatic comments. A
@@ -525,8 +528,8 @@ review command flag.
525
528
  <details>
526
529
  <summary>Source installation and replacement</summary>
527
530
 
528
- Download the [v0.4.4 source archive](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/archive/refs/tags/v0.4.4.tar.gz)
529
- and extract it, or check out tag `v0.4.4`. The installer needs POSIX `sh` and
531
+ Download the [v0.4.5 source archive](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/archive/refs/tags/v0.4.5.tar.gz)
532
+ and extract it, or check out tag `v0.4.5`. The installer needs POSIX `sh` and
530
533
  Python 3's standard library. From that source directory:
531
534
 
532
535
  ```sh
@@ -903,7 +906,7 @@ troubleshooting.
903
906
  | `/pr-review <PR URL> [flag] [context]` | Sharded functional and risk reviews, then sharded verification. |
904
907
  | `/pr-deep <PR URL> [flag] [context]` | The same review with the stronger models of `models.deep`; usually slower and costlier. |
905
908
  | `/pr-quick <PR URL> [flag] [context]` | One reviewer per shard for both focuses, no verification; findings are reported, not verified. |
906
- | `/pr-stop [run-id]` | Cancel this conversation's active command. |
909
+ | `/pr-stop [run-id]` | Cancel this conversation's active command. The terminal panel offers the same while a run is under way (**Stop this run…**). |
907
910
  | `/pr-comment [review-id]` | Preview comments for this conversation's current review. |
908
911
  | `/pr-comment [review-id] --publish` | Post the saved preview. A review that was never adjusted is planned first if needed; an adjusted one needs its new preview. Safe to repeat. |
909
912
  | `/pr-comment [review-id] --show` | Show the saved preview again; no model or Azure DevOps request. |
@@ -972,8 +975,9 @@ OpenCode shows what a plugin tells a conversation as plain text, so a report
972
975
  or a comment preview appears there as Markdown source. In OpenCode's terminal
973
976
  UI, AZPR therefore adds a panel beside the conversation: it shows the newest
974
977
  report or preview rendered, lists the sessions of the review so that you can
975
- open one, and after a preview lists what you can do next, so that you pick a
976
- step instead of typing its command. The
978
+ open one, and lists at its foot what you can do next (stop a run that is
979
+ under way; after a preview, post it or adjust its findings), so that you pick
980
+ a step instead of typing its command. The
977
981
  [recording of a real review](docs/DEMO.md#the-terminal-panel) shows the report
978
982
  and the conversation side by side.
979
983
 
@@ -1025,10 +1029,24 @@ and the conversation side by side.
1025
1029
  when they are others by now, for instance after a command typed in the
1026
1030
  review's own session or in another client: nothing is posted that you have
1027
1031
  not read.
1032
+
1033
+ While a run is under way (a review, a preview that is being planned, a
1034
+ publication), the row offers one thing instead:
1035
+
1036
+ ```text
1037
+ [s] Stop this run…
1038
+ ```
1039
+
1040
+ It asks first, with "No, let it run" first, and then sends `/pr-stop` for
1041
+ that run, as if you had typed it: the run ends with its `CANCELLED`
1042
+ receipt, and requests that were already sent may still be billed. If the
1043
+ run has ended while the question was open, nothing is sent and the panel
1044
+ says so. A run that an earlier AZPR started is stopped by typing the
1045
+ command its STARTED notice shows.
1028
1046
  - **Keys.** `/pr-panel` shows and hides the panel; it is the panel's only
1029
1047
  command. A click inside its text gives it the keyboard: the arrow keys or
1030
- `j` and `k`, Page Up and Page Down, Home and End scroll, `p`, `a`, `u` and
1031
- `c` pick what the foot offers, and Escape or `q` closes it.
1048
+ `j` and `k`, Page Up and Page Down, Home and End scroll, `p`, `a`, `u`,
1049
+ `c` and `s` pick what the foot offers, and Escape or `q` closes it.
1032
1050
  - **A narrow terminal** (fewer than 108 columns) has no room for two panes,
1033
1051
  and OpenCode would show the panel in place of the conversation. There the
1034
1052
  panel does not open by itself; it says that something is ready, and
@@ -1036,8 +1054,9 @@ and the conversation side by side.
1036
1054
 
1037
1055
  The panel shows what AZPR already put into your conversation and into the
1038
1056
  session that holds a report. It sends nothing by itself and never a prompt:
1039
- the one thing it sends is the `/pr-comment` command of a step you pick, which
1040
- AZPR takes like a typed one, and posting always asks first. It comes with
1057
+ the one thing it sends is the command of a step you pick (`/pr-comment`, or
1058
+ `/pr-stop` for a run under way), which AZPR takes like a typed one, and
1059
+ posting and stopping always ask first. It comes with
1041
1060
  the package and needs no setup; `terminalPanel` is its one setting. Other
1042
1061
  OpenCode clients, such as the desktop app, do not load it and show AZPR's
1043
1062
  notices as before. The same terminal part brings the
@@ -1262,8 +1281,8 @@ dependency and is not built on your machine.
1262
1281
  Uninstall without `--apply` previews; `--apply` archives only this package under
1263
1282
  `azpr-v2-backups` and leaves the private state directory for you to delete.
1264
1283
  For a native installation, remove the entry you added, for example
1265
- `opencode plugin remove opencode-azure-devops-pr-review@0.4.4` or
1266
- `opencode plugin remove 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.4'`;
1284
+ `opencode plugin remove opencode-azure-devops-pr-review@0.4.5` or
1285
+ `opencode plugin remove 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.5'`;
1267
1286
  the external settings, PAT file and private review state remain available.
1268
1287
 
1269
1288
  [Architecture](docs/ARCHITECTURE.md), [commenting](docs/COMMENTING.md),
@@ -1276,7 +1295,7 @@ or personal model selections.
1276
1295
  ## License and releases
1277
1296
 
1278
1297
  [MIT](LICENSE), copyright 2026 WTLAIB. See the [changelog](CHANGELOG.md) for the
1279
- release scope, [v0.4.4](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.4.4)
1298
+ release scope, [v0.4.5](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.4.5)
1280
1299
  for downloads, the [npm package](https://www.npmjs.com/package/opencode-azure-devops-pr-review),
1281
1300
  [v0.2.0](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.2.0)
1282
1301
  for the recorded demonstration, and [releasing](docs/RELEASING.md) for the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-azure-devops-pr-review",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "type": "module",
5
5
  "description": "Azure DevOps PR reviews from a URL in OpenCode, with no checkout, configurable models, separate verification, and comment previews you can adjust before posting",
6
6
  "scripts": {
package/src/runtime.mjs CHANGED
@@ -683,8 +683,9 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
683
683
  // The terminal panel reads no settings file: what it needs of the settings travels with the notices. Only
684
684
  // terminalPanel: manual is marked, so the default sends every notice exactly as before.
685
685
  const noticeMetadata = settings.terminalPanel === 'manual' ? { azpr: { panel: 'manual' } } : undefined;
686
- // `extra` is what one notice carries besides, under the same key: the next steps of a preview, as data for the
687
- // panel's rows. No model reads a notice's metadata, and every other notice is sent exactly as before.
686
+ // `extra` is what one notice carries besides, under the same key: what it offers as a next step, as data for the
687
+ // steps at the panel's foot (stopping the run a STARTED notice announces; the next steps of a review or a
688
+ // preview). No model reads a notice's metadata, and every other notice is sent exactly as before.
688
689
  const notice = ({ extra, ...input }) => appendReport(context, { ...input, metadata: extra ? { azpr: { ...noticeMetadata?.azpr, ...extra } } : noticeMetadata });
689
690
  async function deliver(sessionID, body, runId, extra) {
690
691
  let failure;
@@ -1782,8 +1783,11 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1782
1783
  jobs.add(completion);
1783
1784
  void completion.finally(() => jobs.delete(completion));
1784
1785
  try {
1786
+ // What the notice's last sentence says is also there as data, for the terminal panel: the run can be
1787
+ // stopped, by its ID, from now until its receipt.
1785
1788
  await deadline(signal => notice({ sessionID,
1786
- text: `[AZPR ${run.id}] STARTED /${name}${run.startLabel ? ` ${run.startLabel}` : ''}. Work continues in this OpenCode process; the result will return to this conversation.${run.startNote ?? ''} Stop with /pr-stop ${run.id}.`, signal }), 10000);
1789
+ text: `[AZPR ${run.id}] STARTED /${name}${run.startLabel ? ` ${run.startLabel}` : ''}. Work continues in this OpenCode process; the result will return to this conversation.${run.startNote ?? ''} Stop with /pr-stop ${run.id}.`, signal,
1790
+ extra: { next: { stop: run.id } } }), 10000);
1787
1791
  } catch (error) {
1788
1792
  await abortRun(run, 'The command start notice could not be queued. No review was started.', 'INCOMPLETE');
1789
1793
  throw error;
@@ -1,15 +1,17 @@
1
- // What a person can do from AZPR's terminal panel after a review or a comment preview: have the comments
2
- // previewed, post the preview, leave findings out or change a level, reset those adjustments. The panel lists
3
- // these in one row at its foot; picking one asks what is needed in the host's own dialogs and then sends the
4
- // same /pr-comment command a person would type, to the session on screen. Nothing else is ever sent from the
5
- // terminal part, and nothing is decided here: the server part takes the command as it takes a typed one,
6
- // with its own checks, its STARTED notice and its receipt.
1
+ // What a person can do from AZPR's terminal panel. After a review or a comment preview: have the comments
2
+ // previewed, post the preview, leave findings out or change a level, reset those adjustments. While a run is
3
+ // under way: stop it. The panel lists these in one row at its foot; picking one asks what is needed in the
4
+ // host's own dialogs and then sends the same command a person would type, /pr-comment or /pr-stop, to the
5
+ // session on screen. Nothing else is ever sent from the terminal part, and nothing is decided here: the server
6
+ // part takes the command as it takes a typed one, with its own checks, its notices and its receipt.
7
7
  //
8
- // What is offered comes from the runtime (`previewActions` in comments.mjs), in the metadata of the notice
9
- // that offers it, and is checked before it gets here (`nextOf` in tui-model.mjs): a command is made only of
10
- // a review ID, finding IDs, level names and the word for the review's comments, all of the checked forms,
11
- // never of a text. Every command hands that word back (`--seen`): a notice shows what its own conversation was
12
- // told, and the runtime refuses a command whose review was planned or adjusted since, from wherever.
8
+ // What is offered comes from the runtime, in the metadata of the notice that offers it (`previewActions` in
9
+ // comments.mjs for a review or a preview; the run's ID with its STARTED notice), and is checked before it gets
10
+ // here (`nextOf` and `stopOf` in tui-model.mjs): a command is made only of a review ID, finding IDs, level
11
+ // names and the word for the review's comments, or of a run ID, all of the checked forms, never of a text.
12
+ // Every /pr-comment command hands that word back (`--seen`): a notice shows what its own conversation was
13
+ // told, and the runtime refuses a command whose review was planned or adjusted since, from wherever. /pr-stop
14
+ // names its run, and a run that has ended is not stopped.
13
15
  //
14
16
  // Nothing here imports anything, so that the order of the dialogs is tested with scripted answers
15
17
  // (tests/tui-actions.test.mjs); src/tui-view.jsx supplies the dialogs and the sending.
@@ -22,6 +24,18 @@ const APPLY_KEY = 'ctrl+s';
22
24
  // Said when a person's answer comes back for something the panel no longer offers.
23
25
  const CHANGED = 'Nothing was sent: what the panel showed has changed since. Read it again, then pick.';
24
26
 
27
+ /**
28
+ * How the rows of a question answer to what is typed into its search line: by the beginning of their titles, in
29
+ * the order they are listed, and all of them while nothing is typed. The host's own search finds a letter
30
+ * anywhere in a title and lists the best match first. A step's key pressed once more than meant is typed into
31
+ * the question it opened, and `s` is in "Yes, stop it" and not in "No, let it run": "yes" would be the only
32
+ * row, and Enter would take it. By the beginning of a title, a stray letter leaves no row at all.
33
+ */
34
+ const byBeginning = (query, options) => {
35
+ const typed = String(query ?? '').trim().toLowerCase();
36
+ return typed ? options.filter(option => String(option.title).toLowerCase().startsWith(typed)) : [...options];
37
+ };
38
+
25
39
  /** The level the review itself gave a finding. */
26
40
  const own = finding => finding.original ?? finding.severity;
27
41
  const plural = (count, word) => `${count} ${word}${count === 1 ? '' : 's'}`;
@@ -33,6 +47,8 @@ const plural = (count, word) => `${count} ${word}${count === 1 ? '' : 's'}`;
33
47
  */
34
48
  export function actionRows(next) {
35
49
  if (!next) return [];
50
+ // A run under way offers one thing. It is asked about first, and it is not the step anything leads to.
51
+ if (next.stop) return [{ id: 'stop', key: 's', label: 'Stop this run…' }];
36
52
  const adjusted = next.findings.some(finding => finding.excluded || finding.original !== undefined);
37
53
  return [
38
54
  // A review without a preview yet: one is planned first, so that what is posted was read. A model runs,
@@ -67,6 +83,8 @@ export const planCommand = next => ({ name: 'pr-comment', text: `${next.review}
67
83
  export const publishCommand = next => ({ name: 'pr-comment', text: `${next.review} --publish ${seen(next)}` });
68
84
  /** The command that clears a person's adjustments. */
69
85
  export const resetCommand = next => ({ name: 'pr-comment', text: `${next.review} --reset ${seen(next)}` });
86
+ /** The command that stops the run under way. It names the run, so it stops no other one. */
87
+ export const stopCommand = next => ({ name: 'pr-stop', text: next.stop });
70
88
 
71
89
  /**
72
90
  * The command that saves `adjustments` for a preview's review, or undefined when they are the saved ones.
@@ -128,15 +146,24 @@ export function createActions(host) {
128
146
  }
129
147
  }
130
148
 
131
- /** Posting is asked once more, with "no" first: a key pressed twice posts nothing. */
149
+ /** Posting is asked once more, with "no" first: a key pressed twice, or more often, posts nothing. */
132
150
  async function publish(next, sessionID, still) {
133
- const answer = await dialog.select({ title: 'Post these comments on the pull request?', options: [
151
+ const answer = await dialog.select({ title: 'Post these comments on the pull request?', search: byBeginning, options: [
134
152
  { title: 'No, post nothing', value: 'keep', description: next.target || undefined },
135
153
  { title: `Yes, post ${plural(next.posts, 'comment')}`, value: 'post', description: 'As the PAT owner; what is on the PR already is skipped' }] });
136
154
  if (answer !== 'post' || stopped) return;
137
155
  await dispatch(sessionID, publishCommand(next), still);
138
156
  }
139
157
 
158
+ /** Stopping is asked once more, with "no" first: the run goes on unless a person says otherwise. */
159
+ async function stopRun(next, sessionID, still) {
160
+ const answer = await dialog.select({ title: 'Stop this run?', search: byBeginning, options: [
161
+ { title: 'No, let it run', value: 'keep', description: `AZPR ${next.stop}${next.command ? ` (/${next.command})` : ''}` },
162
+ { title: 'Yes, stop it', value: 'stop', description: 'Sent requests may still be billed' }] });
163
+ if (answer !== 'stop' || stopped) return;
164
+ await dispatch(sessionID, stopCommand(next), still);
165
+ }
166
+
140
167
  /**
141
168
  * The findings as a list: picking one says what happens to it. Once something differs from what is saved, it is
142
169
  * applied at once from the foot of the dialog, which stays in view however long the list is (clicked there, or
@@ -188,8 +215,8 @@ export function createActions(host) {
188
215
 
189
216
  return {
190
217
  /**
191
- * Run one action (`plan`, `publish`, `adjust` or `reset`) for what a notice offers, in the session on
192
- * screen. `still` says whether the panel still offers it there; without one it is taken to.
218
+ * Run one action (`plan`, `publish`, `adjust`, `reset` or `stop`) for what a notice offers, in the session
219
+ * on screen. `still` says whether the panel still offers it there; without one it is taken to.
193
220
  */
194
221
  async run(id, next, sessionID, still = () => true) {
195
222
  if (running || stopped || !next || typeof sessionID !== 'string' || !actionRows(next).some(row => row.id === id)) return;
@@ -199,6 +226,7 @@ export function createActions(host) {
199
226
  else if (id === 'publish') await publish(next, sessionID, still);
200
227
  else if (id === 'adjust') await adjust(next, sessionID, still);
201
228
  else if (id === 'reset') await dispatch(sessionID, resetCommand(next), still);
229
+ else if (id === 'stop') await stopRun(next, sessionID, still);
202
230
  } catch {
203
231
  // A dialog the host could not show: nothing was sent, and the commands can still be typed.
204
232
  if (!stopped) toast({ title: 'AZPR', message: 'That could not be done here. Type the command in the conversation instead.', variant: 'error', duration: 8000 });
package/src/tui-model.mjs CHANGED
@@ -8,8 +8,9 @@
8
8
  * decides anything about a review. It only reads texts whose form the runtime
9
9
  * owns (attribution.mjs, runtime.mjs) and what the runtime sends along with
10
10
  * its notices: the one setting meant for it, and what a notice offers as a
11
- * next step (`nextOf`), which the rows of tui-actions.mjs turn into the
12
- * command a person picks. tests/tui-model.test.mjs holds that form.
11
+ * next step (`nextOf` for a review or a preview, `stopOf` for a run under
12
+ * way), which the rows of tui-actions.mjs turn into the command a person
13
+ * picks. tests/tui-model.test.mjs holds that form.
13
14
  */
14
15
 
15
16
  /** The panel's name in the host's `session.panel` slot; names are shared between plugins. */
@@ -26,6 +27,8 @@ const REPORT_SESSION = new RegExp(`Report delivery: report queued to session=(${
26
27
  const ACTS_ON = / It acts on review ([a-f0-9]{8}) /;
27
28
  const SOURCE_REVIEW = /; source review=([a-f0-9]{8})/;
28
29
  const RUN_STARTED = /^\[AZPR [a-f0-9]{8}\] STARTED \/pr-(?:review|quick|deep|comment)\b/;
30
+ // The command a STARTED notice names, of those that start a run (a check is one, though it opens no panel).
31
+ const STARTED_COMMAND = /^\[AZPR [a-f0-9]{8}\] STARTED \/(pr-(?:review|quick|deep|comment|check))\b/;
29
32
  // A run's receipt: its status, then `;`, a line break or the end. Text follows STARTED and PROGRESS, and a run
30
33
  // also says things that are neither (`[AZPR <run>] Automatic preview skipped: …`).
31
34
  const RECEIPT = /^\[AZPR [a-f0-9]{8}\] [A-Z_]+(?:;|\n|$)/;
@@ -193,6 +196,17 @@ export function nextOf(metadata, review) {
193
196
  plan: next.plan === true, publish: next.publish === true && next.plan !== true, adjust: next.adjust === true, posts: Number.isInteger(next.posts) && next.posts >= 0 ? next.posts : 0, findings };
194
197
  }
195
198
 
199
+ /**
200
+ * The run a STARTED notice says can be stopped, as the runtime stored it with the notice (`azpr.next.stop`), or
201
+ * undefined. A command is made of it, so it is checked like the rest: by its form, and as the ID of the very run
202
+ * the notice starts. A notice of an earlier version says nothing of it, and its run is stopped by typing.
203
+ */
204
+ export function stopOf(metadata, run) {
205
+ const stop = metadata?.azpr?.next?.stop;
206
+ // A run's ID has the form of a review's: a review is named after the run that made it.
207
+ return typeof stop === 'string' && REVIEW_ID.test(stop) && stop === run ? stop : undefined;
208
+ }
209
+
196
210
  /** Whether a failed request says that the session is not there, as opposed to a request that did not get through. */
197
211
  export const notFound = error => /NotFound|\b404\b/.test(String(error?.name ?? '') + String(error?._tag ?? '') + String(error));
198
212
 
@@ -510,10 +524,11 @@ export function buildPanel(source, sessionID, { known = {}, read = {}, titles =
510
524
  const ofRun = notices.filter(notice => notice.run === run && notice.kind !== 'NOTE');
511
525
  const receipt = ofRun.findLast(notice => notice.kind === 'RECEIPT');
512
526
  const progress = ofRun.findLast(notice => notice.kind === 'PROGRESS');
527
+ const started = ofRun.find(notice => notice.kind === 'STARTED');
513
528
  const status = receipt ? receipt.status : run && !answered ? 'RUNNING' : '';
514
529
  // A comment run belongs with the review it acts on: that review's sessions and report stay in view.
515
530
  // Any other run stands alone, so a review under way never shows the report of the review before it.
516
- const reviewRun = SOURCE_REVIEW.exec(receipt?.text.split('\n')[0] ?? '')?.[1] ?? ACTS_ON.exec(ofRun.find(notice => notice.kind === 'STARTED')?.text ?? '')?.[1] ?? run;
531
+ const reviewRun = SOURCE_REVIEW.exec(receipt?.text.split('\n')[0] ?? '')?.[1] ?? ACTS_ON.exec(started?.text ?? '')?.[1] ?? run;
517
532
  const review = reviewRun === run ? receipt : notices.findLast(notice => notice.kind === 'RECEIPT' && notice.run === reviewRun);
518
533
  const reportSession = REPORT_SESSION.exec(ledgerOf(review?.text ?? ''))?.[1];
519
534
 
@@ -566,6 +581,11 @@ export function buildPanel(source, sessionID, { known = {}, read = {}, titles =
566
581
  // `offer` names the notice, so that a row that was picked is acted on only while that notice still offers.
567
582
  const checked = offering ? nextOf(offering.metadata, answered ?? reviewRun) : undefined;
568
583
  const offered = checked && checked.plan === (offering.kind === 'RECEIPT' && offering.status === 'COMPLETE') ? { ...checked, offer: offering.id } : undefined;
584
+ // A run under way can be stopped, as its STARTED notice says: from that notice until the run's receipt, whatever
585
+ // progress it reports in between. It names its command (the runtime's own word, one of a fixed few) for the
586
+ // question that is asked first, and its notice, like every offer.
587
+ const stoppable = status === 'RUNNING' && started ? stopOf(started.metadata, run) : undefined;
588
+ const halting = stoppable ? { stop: stoppable, command: STARTED_COMMAND.exec(started.text)?.[1] ?? '', offer: started.id } : undefined;
569
589
  const rows = [];
570
590
  let deleted = 0;
571
591
  for (const id of candidates) {
@@ -606,8 +626,9 @@ export function buildPanel(source, sessionID, { known = {}, read = {}, titles =
606
626
  // A report read from its session says its run and status in its own first line; an enclosed document is named by
607
627
  // the notice that encloses it.
608
628
  documentHead: own || document?.session ? '' : document?.head ?? '',
609
- // The steps a preview offers, for the review shown; absent while a run is under way or after another notice.
610
- ...(offered ? { next: offered } : {}),
629
+ // What can be done next: the steps a review or a preview offers, for the review shown, or stopping the run
630
+ // under way. Absent once another notice has followed the one that offers, or the run has its receipt.
631
+ ...(offered ? { next: offered } : halting ? { next: halting } : {}),
611
632
  inbox,
612
633
  notices: notes,
613
634
  loading,
package/src/tui-view.jsx CHANGED
@@ -9,9 +9,10 @@
9
9
  // The panel reads AZPR's own notices in the conversation, the report queued to a review session, and
10
10
  // the sessions' `metadata.azpr` (src/tui-model.mjs works out what to show). It reads no settings file:
11
11
  // the server part writes that setting into the metadata of its notices. After a review or a comment
12
- // preview it lists what can be done next in one row at its foot, picked instead of typed: each sends
13
- // the /pr-comment command a person would type, to the session on screen, after asking what is needed
14
- // (src/tui-actions.mjs). It sends nothing by itself, and never a prompt.
12
+ // preview, and while a run is under way, it lists what can be done next in one row at its foot, picked
13
+ // instead of typed: each sends the command a person would type (/pr-comment, or /pr-stop for the run
14
+ // under way), to the session on screen, after asking what is needed (src/tui-actions.mjs). It sends
15
+ // nothing by itself, and never a prompt.
15
16
  //
16
17
  // The dialogs of /pr-setup ask for AZPR's settings (src/tui-setup.mjs says what and in which order) and
17
18
  // hand every answer to the server part over the plugin's RPC. They read and write no file and make no
@@ -197,9 +198,17 @@ function Panel(props) {
197
198
  forget()
198
199
  context.ui.router.navigate({ type: "session", sessionID })
199
200
  }
200
- // What a notice offers next, where this host lets the panel send a command; picking one asks first.
201
+ // What a notice offers next (a review or a preview its steps, a run under way that it can be stopped), where
202
+ // this host lets the panel send a command; picking one asks first.
201
203
  const offered = createMemo(() => (state.actions ? actionRows(model().next) : []))
202
204
  const offers = (id) => offered().some((item) => item.id === id)
205
+ // Steps are keyed by their name, so a step keeps its element, and with it its place and its hover, while the
206
+ // list is worked out again, which every notice and every answer of the server causes. A step that was drawn
207
+ // anew is, until the next frame, not where the renderer looks for what lies under the pointer: a press or a
208
+ // release in that moment would go nowhere, and the click would be lost. While a run is under way, the
209
+ // moments are many.
210
+ const steps = createMemo(() => offered().map((item) => item.id), [], { equals: (a, b) => a.length === b.length && a.every((id, index) => id === b[index]) })
211
+ const step = (id) => offered().find((item) => item.id === id) ?? { id, key: "", label: "" }
203
212
  let drawn = true
204
213
  onCleanup(() => (drawn = false))
205
214
  const act = (id) => {
@@ -303,14 +312,18 @@ function Panel(props) {
303
312
  { id: "azpr.panel.page.down", title: "AZPR panel: page down", group: "AZPR", bind: "pagedown", run: () => scroll?.scrollBy(page()) },
304
313
  { id: "azpr.panel.top", title: "AZPR panel: go to the top", group: "AZPR", bind: "home", run: () => scroll?.scrollTo(0) },
305
314
  { id: "azpr.panel.bottom", title: "AZPR panel: go to the end", group: "AZPR", bind: "end", run: () => scroll?.scrollTo(scroll.scrollHeight) },
306
- // What a review or a preview offers; each is there only while the panel lists it.
315
+ // What a review, a preview or a run under way offers; each is there only while the panel lists it.
307
316
  { id: "azpr.panel.plan", title: "AZPR panel: preview the comments", group: "AZPR", bind: "c", enabled: () => offers("plan"), run: () => act("plan") },
308
317
  { id: "azpr.panel.publish", title: "AZPR panel: post the previewed comments", group: "AZPR", bind: "p", enabled: () => offers("publish"), run: () => act("publish") },
309
318
  { id: "azpr.panel.adjust", title: "AZPR panel: leave findings out or change a level", group: "AZPR", bind: "a", enabled: () => offers("adjust"), run: () => act("adjust") },
310
319
  { id: "azpr.panel.reset", title: "AZPR panel: reset your adjustments", group: "AZPR", bind: "u", enabled: () => offers("reset"), run: () => act("reset") },
320
+ { id: "azpr.panel.stop", title: "AZPR panel: stop the run under way", group: "AZPR", bind: "s", enabled: () => offers("stop"), run: () => act("stop") },
311
321
  ],
312
322
  }))
313
323
 
324
+ // A run with a receipt has ended: one that was stopped, or failed before it had anything to show, is not
325
+ // waited for, so the panel does not say "yet" of it.
326
+ const ended = () => Boolean(model().status) && model().status !== "RUNNING"
314
327
  // Rows are keyed by session, so a row keeps its place and its hover while the list is worked out again.
315
328
  const ids = createMemo(() => model().rows.map((row) => row.id), [], { equals: (a, b) => a.length === b.length && a.every((id, index) => id === b[index]) })
316
329
  const row = (id) => model().rows.find((item) => item.id === id) ?? { id, label: "", state: "", report: false }
@@ -372,7 +385,9 @@ function Panel(props) {
372
385
  : model().inbox
373
386
  ? "The report is in its session: open it above."
374
387
  : model().run
375
- ? "No report or preview yet."
388
+ ? ended()
389
+ ? "This run ended with no report or preview to show."
390
+ : "No report or preview yet."
376
391
  : "No AZPR run in this conversation yet."}
377
392
  </text>
378
393
  }
@@ -391,11 +406,11 @@ function Panel(props) {
391
406
  conversation it is level with the host's status bar (the row under it is empty there as well), with
392
407
  the line level with the lower edge of the prompt. Keys and labels that do not fit in one row go on
393
408
  to the next one together. */}
394
- <Show when={offered().length > 0}>
409
+ <Show when={steps().length > 0}>
395
410
  <box flexDirection="column" flexShrink={0}>
396
411
  <box height={1} flexShrink={0} border={["top"]} borderColor={palette().rule} />
397
412
  <box flexDirection="row" flexWrap="wrap" columnGap={3} flexShrink={0} paddingLeft={2} paddingRight={2}>
398
- <For each={offered()}>{(item) => <Button item={item} colors={palette()} live={props.panel.focused} press={press} lift={lift} forget={forget} />}</For>
413
+ <For each={steps()}>{(id) => <Button item={step(id)} colors={palette()} live={props.panel.focused} press={press} lift={lift} forget={forget} />}</For>
399
414
  </box>
400
415
  <Show when={props.panel.presentation !== "fullscreen"}>
401
416
  <box height={1} flexShrink={0} />
@@ -445,8 +460,8 @@ function panelPart(context) {
445
460
  let unasked
446
461
  // The session in which another plugin's panel is open; the host shows one panel at a time.
447
462
  let occupied
448
- // The rows of what a preview offers send a command of the server part, as the host's own prompt does for one
449
- // that is typed. A host without that, or without the dialogs that ask first, shows no such rows.
463
+ // The steps at the panel's foot send a command of the server part, as the host's own prompt does for one
464
+ // that is typed. A host without that, or without the dialogs that ask first, shows no such steps.
450
465
  const actions =
451
466
  typeof context.client?.session?.command === "function" && typeof context.ui?.dialog?.select === "function" && typeof context.ui?.toast?.show === "function"
452
467
  ? createActions({
package/src/tui.js CHANGED
@@ -20,9 +20,10 @@ import { createElement as _$createElement } from "@opentui/solid";
20
20
  // The panel reads AZPR's own notices in the conversation, the report queued to a review session, and
21
21
  // the sessions' `metadata.azpr` (src/tui-model.mjs works out what to show). It reads no settings file:
22
22
  // the server part writes that setting into the metadata of its notices. After a review or a comment
23
- // preview it lists what can be done next in one row at its foot, picked instead of typed: each sends
24
- // the /pr-comment command a person would type, to the session on screen, after asking what is needed
25
- // (src/tui-actions.mjs). It sends nothing by itself, and never a prompt.
23
+ // preview, and while a run is under way, it lists what can be done next in one row at its foot, picked
24
+ // instead of typed: each sends the command a person would type (/pr-comment, or /pr-stop for the run
25
+ // under way), to the session on screen, after asking what is needed (src/tui-actions.mjs). It sends
26
+ // nothing by itself, and never a prompt.
26
27
  //
27
28
  // The dialogs of /pr-setup ask for AZPR's settings (src/tui-setup.mjs says what and in which order) and
28
29
  // hand every answer to the server part over the plugin's RPC. They read and write no file and make no
@@ -304,9 +305,23 @@ function Panel(props) {
304
305
  sessionID
305
306
  });
306
307
  };
307
- // What a notice offers next, where this host lets the panel send a command; picking one asks first.
308
+ // What a notice offers next (a review or a preview its steps, a run under way that it can be stopped), where
309
+ // this host lets the panel send a command; picking one asks first.
308
310
  const offered = createMemo(() => state.actions ? actionRows(model().next) : []);
309
311
  const offers = id => offered().some(item => item.id === id);
312
+ // Steps are keyed by their name, so a step keeps its element, and with it its place and its hover, while the
313
+ // list is worked out again, which every notice and every answer of the server causes. A step that was drawn
314
+ // anew is, until the next frame, not where the renderer looks for what lies under the pointer: a press or a
315
+ // release in that moment would go nowhere, and the click would be lost. While a run is under way, the
316
+ // moments are many.
317
+ const steps = createMemo(() => offered().map(item => item.id), [], {
318
+ equals: (a, b) => a.length === b.length && a.every((id, index) => id === b[index])
319
+ });
320
+ const step = id => offered().find(item => item.id === id) ?? {
321
+ id,
322
+ key: "",
323
+ label: ""
324
+ };
310
325
  let drawn = true;
311
326
  onCleanup(() => drawn = false);
312
327
  const act = id => {
@@ -451,7 +466,7 @@ function Panel(props) {
451
466
  bind: "end",
452
467
  run: () => scroll?.scrollTo(scroll.scrollHeight)
453
468
  },
454
- // What a review or a preview offers; each is there only while the panel lists it.
469
+ // What a review, a preview or a run under way offers; each is there only while the panel lists it.
455
470
  {
456
471
  id: "azpr.panel.plan",
457
472
  title: "AZPR panel: preview the comments",
@@ -480,9 +495,19 @@ function Panel(props) {
480
495
  bind: "u",
481
496
  enabled: () => offers("reset"),
482
497
  run: () => act("reset")
498
+ }, {
499
+ id: "azpr.panel.stop",
500
+ title: "AZPR panel: stop the run under way",
501
+ group: "AZPR",
502
+ bind: "s",
503
+ enabled: () => offers("stop"),
504
+ run: () => act("stop")
483
505
  }]
484
506
  }));
485
507
 
508
+ // A run with a receipt has ended: one that was stopped, or failed before it had anything to show, is not
509
+ // waited for, so the panel does not say "yet" of it.
510
+ const ended = () => Boolean(model().status) && model().status !== "RUNNING";
486
511
  // Rows are keyed by session, so a row keeps its place and its hover while the list is worked out again.
487
512
  const ids = createMemo(() => model().rows.map(row => row.id), [], {
488
513
  equals: (a, b) => a.length === b.length && a.every((id, index) => id === b[index])
@@ -648,7 +673,7 @@ function Panel(props) {
648
673
  var _el$34 = _$createElement("text");
649
674
  _$insert(_el$34, (() => {
650
675
  var _c$ = _$memo(() => !!model().loading);
651
- return () => _c$() ? "Loading the report…" : _$memo(() => !!model().inbox)() ? "The report is in its session: open it above." : model().run ? "No report or preview yet." : "No AZPR run in this conversation yet.";
676
+ return () => _c$() ? "Loading the report…" : _$memo(() => !!model().inbox)() ? "The report is in its session: open it above." : _$memo(() => !!model().run)() ? ended() ? "This run ended with no report or preview to show." : "No report or preview yet." : "No AZPR run in this conversation yet.";
652
677
  })());
653
678
  _$effect(_$p => _$setProp(_el$34, "fg", palette().muted, _$p));
654
679
  return _el$34;
@@ -696,7 +721,7 @@ function Panel(props) {
696
721
  }), null);
697
722
  _$insert(_el$9, _$createComponent(Show, {
698
723
  get when() {
699
- return offered().length > 0;
724
+ return steps().length > 0;
700
725
  },
701
726
  get children() {
702
727
  var _el$30 = _$createElement("box"),
@@ -717,10 +742,12 @@ function Panel(props) {
717
742
  _$setProp(_el$32, "paddingRight", 2);
718
743
  _$insert(_el$32, _$createComponent(For, {
719
744
  get each() {
720
- return offered();
745
+ return steps();
721
746
  },
722
- children: item => _$createComponent(Button, {
723
- item: item,
747
+ children: id => _$createComponent(Button, {
748
+ get item() {
749
+ return step(id);
750
+ },
724
751
  get colors() {
725
752
  return palette();
726
753
  },
@@ -806,8 +833,8 @@ function panelPart(context) {
806
833
  let unasked;
807
834
  // The session in which another plugin's panel is open; the host shows one panel at a time.
808
835
  let occupied;
809
- // The rows of what a preview offers send a command of the server part, as the host's own prompt does for one
810
- // that is typed. A host without that, or without the dialogs that ask first, shows no such rows.
836
+ // The steps at the panel's foot send a command of the server part, as the host's own prompt does for one
837
+ // that is typed. A host without that, or without the dialogs that ask first, shows no such steps.
811
838
  const actions = typeof context.client?.session?.command === "function" && typeof context.ui?.dialog?.select === "function" && typeof context.ui?.toast?.show === "function" ? createActions({
812
839
  dialog: context.ui.dialog,
813
840
  toast: options => {