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

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/src/runtime.mjs CHANGED
@@ -23,7 +23,7 @@ import { prepareComments, publishPlan, discussionDigest, PLANNING_PARALLEL_PAGES
23
23
  import { automaticPublicationProblems, automaticPublicationRepeats, publicationItems, publishableFindings, reviewVerification,
24
24
  everAdjusted, hasAdjustments, resolveAdjustments, everyFindingExcluded, publicationStarted, describeAdjustments, describeEarlierText, excludedReferences, previewNextSteps, previewActions, commentToken } from './comments.mjs';
25
25
  import { createToolQueue } from './tool-queue.mjs';
26
- import { API_VERSION, createAzureClient, fetchTransport, pemCertificates, proxyLabel, restBaseUrl, targetKey } from './azure.mjs';
26
+ import { API_VERSION, createAzureClient, fetchTransport, markersInThreads, pemCertificates, proxyLabel, restBaseUrl, targetKey } from './azure.mjs';
27
27
  import { REVIEW_TOOL_NAMES, reviewToolDefinitions, runReviewTool } from './review-tools.mjs';
28
28
  import { runReview } from './review-work.mjs';
29
29
  import { createReviewStore, createReviewWrites, stateRoot, REVIEW_LIMIT } from './store.mjs';
@@ -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;
@@ -831,6 +832,8 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
831
832
  visibleCharacters: input.length, checkpointRequested: false,
832
833
  // The planning page whose sessions this grant serves; its tool evidence is that page's.
833
834
  commentPage: payload.commentWork?.page ?? null,
835
+ // The grouping pass has an answer of its own: no page, no comments, no continuation.
836
+ grouping: payload.commentWork?.kind === 'group',
834
837
  // "commit\npath" of the file contents this session's own tool calls showed;
835
838
  // never the run's shared cache or another session's reads.
836
839
  reads: new Set(),
@@ -1618,16 +1621,24 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1618
1621
  const data = await dataFor(run);
1619
1622
  // Read live discussions once for the planner's duplicate checks; the
1620
1623
  // planner can still read threads itself if this read fails.
1621
- try { discussions = discussionDigest(await azure.threads(run, review.snapshot)); }
1624
+ // The markers among them, each with its thread: a comment for several places does not stand on
1625
+ // lines that already carry a comment of AZPR's.
1626
+ let posted = null;
1627
+ try {
1628
+ const threads = await azure.threads(run, review.snapshot);
1629
+ discussions = discussionDigest(threads);
1630
+ posted = markersInThreads(threads);
1631
+ }
1622
1632
  catch (error) {
1623
1633
  if (!run.active) throw error;
1624
1634
  run.debug.warnings.push(`Existing discussions could not be read before planning: ${errorText(error)}`);
1625
1635
  }
1626
1636
  // Planning pages run side by side, never more than the configured sessions.
1627
1637
  const parallelPages = Math.min(PLANNING_PARALLEL_PAGES, settings.workflow.parallelSessions);
1638
+ // The grouping pass, which looks for one defect at several places before the pages are made, is a stage like a page.
1628
1639
  review.plan = await prepareComments(review, data, (payload, handler) => runStage(run, roleFor(run.profile, 'comment-plan'), payload, handler,
1629
- { label: `page ${payload.commentWork.page}/${payload.commentWork.pages}` }),
1630
- { progress: message => progress(run, message), discussions, parallel: parallelPages,
1640
+ { label: payload.commentWork.kind === 'group' ? 'grouping' : `page ${payload.commentWork.page}/${payload.commentWork.pages}` }),
1641
+ { progress: message => progress(run, message), discussions, posted, parallel: parallelPages, active: () => run.active,
1631
1642
  fetchSource: path => azure.fileContent(run, review.snapshot, path, review.snapshot.head) });
1632
1643
  review.planCreatedAt = new Date().toISOString();
1633
1644
  planning = false;
@@ -1782,8 +1793,11 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1782
1793
  jobs.add(completion);
1783
1794
  void completion.finally(() => jobs.delete(completion));
1784
1795
  try {
1796
+ // What the notice's last sentence says is also there as data, for the terminal panel: the run can be
1797
+ // stopped, by its ID, from now until its receipt.
1785
1798
  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);
1799
+ 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,
1800
+ extra: { next: { stop: run.id } } }), 10000);
1787
1801
  } catch (error) {
1788
1802
  await abortRun(run, 'The command start notice could not be queued. No review was started.', 'INCOMPLETE');
1789
1803
  throw error;
@@ -1912,7 +1926,9 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1912
1926
  if (tools) for (const name of Object.keys(tools)) if (!allowed.has(name)) delete tools[name];
1913
1927
  if (ROLES[g.role].stage === 'comment-plan' && (g.checkpointRequested || g.calls >= 12)) {
1914
1928
  event.tools = {};
1915
- event.system?.push?.({ type: 'text', text: 'Finish this work page now; tools are unavailable for this response. Return exactly one JSON object. If all assigned findings are handled, return READY. Otherwise return CONTINUE with completed comments/skips and a "continuation" note naming exact data references, completed checks and remaining work.' });
1929
+ event.system?.push?.({ type: 'text', text: g.grouping
1930
+ ? 'Finish the grouping now; tools are unavailable for this response. Return exactly one JSON object: {"status": "READY", "groups": [...]} with the groups you are sure of from the findings in your input, and [] when there is none. This pass has no continuation.'
1931
+ : 'Finish this work page now; tools are unavailable for this response. Return exactly one JSON object. If all assigned findings are handled, return READY. Otherwise return CONTINUE with completed comments/skips and a "continuation" note naming exact data references, completed checks and remaining work.' });
1916
1932
  }
1917
1933
  g.primaryPrepared = true;
1918
1934
  }));
@@ -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 => {