opencode-azure-devops-pr-review 0.4.3 → 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 +185 -0
- package/README.md +209 -81
- package/package.json +2 -2
- package/src/attribution.mjs +9 -0
- package/src/comments.mjs +56 -1
- package/src/host.mjs +12 -0
- package/src/output.mjs +14 -3
- package/src/runtime.mjs +277 -22
- package/src/setup.mjs +23 -12
- package/src/tui-actions.mjs +239 -0
- package/src/tui-model.mjs +81 -10
- package/src/tui-setup.mjs +7 -4
- package/src/tui-view.jsx +233 -69
- package/src/tui.js +428 -162
package/src/tui-view.jsx
CHANGED
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
// the session on screen and leaves the keyboard with the prompt; with the setting
|
|
7
7
|
// terminalPanel: manual it opens only with /pr-panel, its one command.
|
|
8
8
|
//
|
|
9
|
-
// The panel
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
9
|
+
// The panel reads AZPR's own notices in the conversation, the report queued to a review session, and
|
|
10
|
+
// the sessions' `metadata.azpr` (src/tui-model.mjs works out what to show). It reads no settings file:
|
|
11
|
+
// the server part writes that setting into the metadata of its notices. After a review or a comment
|
|
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.
|
|
13
16
|
//
|
|
14
17
|
// The dialogs of /pr-setup ask for AZPR's settings (src/tui-setup.mjs says what and in which order) and
|
|
15
18
|
// hand every answer to the server part over the plugin's RPC. They read and write no file and make no
|
|
@@ -20,6 +23,7 @@
|
|
|
20
23
|
import { For, Show, createEffect, createMemo, createSignal, onCleanup, onMount } from "solid-js"
|
|
21
24
|
import { MouseButton, SyntaxStyle, TextAttributes } from "@opentui/core"
|
|
22
25
|
import { PANEL, buildPanel, conversationOf, createReader, opensPanel } from "./tui-model.mjs"
|
|
26
|
+
import { actionRows, createActions } from "./tui-actions.mjs"
|
|
23
27
|
import { SETUP_RPC, createSetup, isSetupNotice } from "./tui-setup.mjs"
|
|
24
28
|
|
|
25
29
|
// Short enough for one line of a toast, which the host wraps at about fifty characters.
|
|
@@ -34,9 +38,11 @@ const token = (theme, ...paths) => {
|
|
|
34
38
|
}
|
|
35
39
|
const colors = (theme) => {
|
|
36
40
|
const base = token(theme, "text.base", "text.default")
|
|
41
|
+
const muted = token(theme, "text.muted", "text.subdued") ?? base
|
|
37
42
|
return {
|
|
38
43
|
base,
|
|
39
|
-
muted
|
|
44
|
+
muted,
|
|
45
|
+
rule: token(theme, "border.base", "border.default") ?? muted,
|
|
40
46
|
running: token(theme, "text.feedback.info.base") ?? base,
|
|
41
47
|
failed: token(theme, "text.feedback.error.base") ?? base,
|
|
42
48
|
done: token(theme, "text.feedback.success.base") ?? base,
|
|
@@ -72,6 +78,23 @@ function markdownStyle(context) {
|
|
|
72
78
|
return SyntaxStyle.fromStyles(styles, context.renderer.nativeScene)
|
|
73
79
|
}
|
|
74
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Whether the release of a mouse button is a click: the left button, and not the end of a selection. A
|
|
83
|
+
* selection of text that is dragged across the panel ends where the button is released, and OpenTUI sends that
|
|
84
|
+
* release to whatever lies under the pointer, marked as dragging: it picks nothing.
|
|
85
|
+
*/
|
|
86
|
+
const clicked = (event) => event.button === MouseButton.LEFT && !event.isDragging
|
|
87
|
+
/**
|
|
88
|
+
* Whether the pointer of a mouse event is over the element whose handler runs. OpenTUI sends the release of a
|
|
89
|
+
* button that was dragged away to the element it was pressed on, wherever the pointer is by then: a step that
|
|
90
|
+
* was pressed and then left is not picked. True where the host does not say where either of them is.
|
|
91
|
+
*/
|
|
92
|
+
const inside = (event) => {
|
|
93
|
+
const at = event.currentTarget
|
|
94
|
+
if (!at || ![event.x, event.y, at.x, at.y, at.width, at.height].every(Number.isFinite)) return true
|
|
95
|
+
return event.x >= at.x && event.x < at.x + at.width && event.y >= at.y && event.y < at.y + at.height
|
|
96
|
+
}
|
|
97
|
+
|
|
75
98
|
function Row(props) {
|
|
76
99
|
const [hover, setHover] = createSignal(false)
|
|
77
100
|
const mark = () => (props.row.state === "running" ? props.colors.running : props.row.state === "failed" ? props.colors.failed : props.colors.done)
|
|
@@ -83,7 +106,7 @@ function Row(props) {
|
|
|
83
106
|
onMouseOver={() => setHover(true)}
|
|
84
107
|
onMouseOut={() => setHover(false)}
|
|
85
108
|
onMouseUp={(event) => {
|
|
86
|
-
if (event
|
|
109
|
+
if (!clicked(event)) return
|
|
87
110
|
event.stopPropagation()
|
|
88
111
|
props.open(props.row.id)
|
|
89
112
|
}}
|
|
@@ -107,6 +130,46 @@ function Row(props) {
|
|
|
107
130
|
)
|
|
108
131
|
}
|
|
109
132
|
|
|
133
|
+
/**
|
|
134
|
+
* One thing that can be done next, in the row at the panel's foot: its key and a word or two. It is clicked,
|
|
135
|
+
* or picked with the key while the panel has the keyboard, which is when the key has its colour: a key that
|
|
136
|
+
* would only type a letter into the prompt is drawn dim.
|
|
137
|
+
* A click on it is a button pressed, not the keyboard asked for. The host gives a panel the keyboard on mouse
|
|
138
|
+
* down, so that is stopped here: what is typed next still goes to the prompt. The press and its release are
|
|
139
|
+
* handed on separately, since a click is both, on one step of one offer; any other press or release here ends
|
|
140
|
+
* what was pressed (`forget`), as it does anywhere else in the panel.
|
|
141
|
+
*/
|
|
142
|
+
function Button(props) {
|
|
143
|
+
const [hover, setHover] = createSignal(false)
|
|
144
|
+
return (
|
|
145
|
+
<box
|
|
146
|
+
flexDirection="row"
|
|
147
|
+
flexShrink={0}
|
|
148
|
+
gap={1}
|
|
149
|
+
backgroundColor={hover() ? props.colors.hover : undefined}
|
|
150
|
+
onMouseOver={() => setHover(true)}
|
|
151
|
+
onMouseOut={() => setHover(false)}
|
|
152
|
+
onMouseDown={(event) => {
|
|
153
|
+
if (event.button !== MouseButton.LEFT) return props.forget()
|
|
154
|
+
event.stopPropagation()
|
|
155
|
+
props.press(props.item.id)
|
|
156
|
+
}}
|
|
157
|
+
onMouseUp={(event) => {
|
|
158
|
+
if (!clicked(event)) return props.forget()
|
|
159
|
+
event.stopPropagation()
|
|
160
|
+
props.lift(props.item.id, inside(event))
|
|
161
|
+
}}
|
|
162
|
+
>
|
|
163
|
+
<text fg={props.live ? props.colors.link : props.colors.muted} flexShrink={0} selectable={false}>
|
|
164
|
+
{`[${props.item.key}]`}
|
|
165
|
+
</text>
|
|
166
|
+
<text fg={props.item.primary ? props.colors.base : props.colors.text} attributes={props.item.primary ? TextAttributes.BOLD : 0} flexShrink={0} selectable={false}>
|
|
167
|
+
{props.item.label}
|
|
168
|
+
</text>
|
|
169
|
+
</box>
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
|
|
110
173
|
function Panel(props) {
|
|
111
174
|
const context = props.context
|
|
112
175
|
const state = props.state
|
|
@@ -127,10 +190,55 @@ function Panel(props) {
|
|
|
127
190
|
onCleanup(() => release(syntax()))
|
|
128
191
|
|
|
129
192
|
const close = () => {
|
|
193
|
+
forget()
|
|
130
194
|
state.dismiss(props.panel.sessionID)
|
|
131
195
|
props.panel.close()
|
|
132
196
|
}
|
|
133
|
-
const open = (sessionID) =>
|
|
197
|
+
const open = (sessionID) => {
|
|
198
|
+
forget()
|
|
199
|
+
context.ui.router.navigate({ type: "session", sessionID })
|
|
200
|
+
}
|
|
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.
|
|
203
|
+
const offered = createMemo(() => (state.actions ? actionRows(model().next) : []))
|
|
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: "" }
|
|
212
|
+
let drawn = true
|
|
213
|
+
onCleanup(() => (drawn = false))
|
|
214
|
+
const act = (id) => {
|
|
215
|
+
const next = model().next
|
|
216
|
+
if (!next || !offers(id)) return
|
|
217
|
+
const sessionID = props.panel.sessionID
|
|
218
|
+
// A dialog can stay open for any time. Its answer counts only while this panel still shows that notice's
|
|
219
|
+
// offer in that session: not for a preview planned again meanwhile, for another session on screen, or
|
|
220
|
+
// once the panel was closed.
|
|
221
|
+
const still = () => drawn && mine() && props.panel.sessionID === sessionID && model().next?.offer === next.offer
|
|
222
|
+
void state.actions.run(id, next, sessionID, still)
|
|
223
|
+
}
|
|
224
|
+
// A click is the left button pressed and let go on the same step of the same offer, with the pointer still on
|
|
225
|
+
// it. A preview can be planned again while the button is held, and the row then shows the steps of another
|
|
226
|
+
// notice: the release would act on what was not pressed, so it picks nothing. Nor does a release whose press
|
|
227
|
+
// was elsewhere, or one after the pointer left the step. A press is one gesture's: whatever the panel sees
|
|
228
|
+
// of another press or release (on a step, a session's row, `close` or anywhere in it) ends what was pressed,
|
|
229
|
+
// so that a gesture that was given up does not make a later release a click.
|
|
230
|
+
let pressed
|
|
231
|
+
const press = (id) => {
|
|
232
|
+
pressed = { id, offer: model().next?.offer }
|
|
233
|
+
}
|
|
234
|
+
const forget = () => {
|
|
235
|
+
pressed = undefined
|
|
236
|
+
}
|
|
237
|
+
const lift = (id, over) => {
|
|
238
|
+
const was = pressed
|
|
239
|
+
pressed = undefined
|
|
240
|
+
if (over && was && was.id === id && was.offer !== undefined && was.offer === model().next?.offer) act(id)
|
|
241
|
+
}
|
|
134
242
|
|
|
135
243
|
// The host gives the keyboard to a panel that opens, and has no way to open one without it. AZPR is
|
|
136
244
|
// driven by commands, so the panel hands the keyboard back to the prompt: the next command can be typed
|
|
@@ -183,6 +291,16 @@ function Panel(props) {
|
|
|
183
291
|
if (notices) state.readInbox(notices.sessionID, notices.token, false)
|
|
184
292
|
})
|
|
185
293
|
|
|
294
|
+
// Another document (a preview planned again, a report after a preview) is read from its beginning, wherever
|
|
295
|
+
// the one before it was left.
|
|
296
|
+
let shownBefore
|
|
297
|
+
createEffect(() => {
|
|
298
|
+
const markdown = model().markdown
|
|
299
|
+
if (!markdown) return
|
|
300
|
+
if (shownBefore !== undefined && markdown !== shownBefore) scroll?.scrollTo(0)
|
|
301
|
+
shownBefore = markdown
|
|
302
|
+
})
|
|
303
|
+
|
|
186
304
|
// Active only while the panel has the keyboard; the IDs let a user bind other keys in the TUI's configuration.
|
|
187
305
|
const page = () => Math.max(4, (scroll?.viewport?.height ?? scroll?.height ?? 10) - 2)
|
|
188
306
|
context.keymap.layer(() => ({
|
|
@@ -194,85 +312,116 @@ function Panel(props) {
|
|
|
194
312
|
{ id: "azpr.panel.page.down", title: "AZPR panel: page down", group: "AZPR", bind: "pagedown", run: () => scroll?.scrollBy(page()) },
|
|
195
313
|
{ id: "azpr.panel.top", title: "AZPR panel: go to the top", group: "AZPR", bind: "home", run: () => scroll?.scrollTo(0) },
|
|
196
314
|
{ id: "azpr.panel.bottom", title: "AZPR panel: go to the end", group: "AZPR", bind: "end", run: () => scroll?.scrollTo(scroll.scrollHeight) },
|
|
315
|
+
// What a review, a preview or a run under way offers; each is there only while the panel lists it.
|
|
316
|
+
{ id: "azpr.panel.plan", title: "AZPR panel: preview the comments", group: "AZPR", bind: "c", enabled: () => offers("plan"), run: () => act("plan") },
|
|
317
|
+
{ id: "azpr.panel.publish", title: "AZPR panel: post the previewed comments", group: "AZPR", bind: "p", enabled: () => offers("publish"), run: () => act("publish") },
|
|
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") },
|
|
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") },
|
|
197
321
|
],
|
|
198
322
|
}))
|
|
199
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"
|
|
200
327
|
// Rows are keyed by session, so a row keeps its place and its hover while the list is worked out again.
|
|
201
328
|
const ids = createMemo(() => model().rows.map((row) => row.id), [], { equals: (a, b) => a.length === b.length && a.every((id, index) => id === b[index]) })
|
|
202
329
|
const row = (id) => model().rows.find((item) => item.id === id) ?? { id, label: "", state: "", report: false }
|
|
203
330
|
|
|
204
331
|
return (
|
|
205
|
-
<box flexDirection="column" flexGrow={1} minHeight={0}
|
|
206
|
-
<box flexDirection="
|
|
207
|
-
<
|
|
208
|
-
<
|
|
209
|
-
|
|
210
|
-
<
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
<
|
|
332
|
+
<box flexDirection="column" flexGrow={1} minHeight={0} onMouseDown={forget} onMouseUp={forget}>
|
|
333
|
+
<box flexDirection="column" flexGrow={1} minHeight={0} paddingLeft={2} paddingRight={2} paddingTop={1}>
|
|
334
|
+
<box flexDirection="row" flexShrink={0}>
|
|
335
|
+
<text fg={palette().base} flexShrink={0}>
|
|
336
|
+
<b>AZPR</b>
|
|
337
|
+
<Show when={model().run}>
|
|
338
|
+
<span> {model().run}</span>
|
|
339
|
+
</Show>
|
|
340
|
+
<Show when={model().status}>
|
|
341
|
+
<span style={{ fg: palette().muted }}> · {model().status}</span>
|
|
342
|
+
</Show>
|
|
343
|
+
</text>
|
|
344
|
+
<box flexGrow={1} />
|
|
345
|
+
<text
|
|
346
|
+
fg={palette().muted}
|
|
347
|
+
flexShrink={0}
|
|
348
|
+
selectable={false}
|
|
349
|
+
onMouseUp={(event) => {
|
|
350
|
+
if (!clicked(event)) return
|
|
351
|
+
event.stopPropagation()
|
|
352
|
+
close()
|
|
353
|
+
}}
|
|
354
|
+
>
|
|
355
|
+
close
|
|
356
|
+
</text>
|
|
357
|
+
</box>
|
|
358
|
+
<Show when={model().progress}>
|
|
359
|
+
<text fg={palette().muted} flexShrink={0}>
|
|
360
|
+
{model().progress}
|
|
361
|
+
</text>
|
|
362
|
+
</Show>
|
|
363
|
+
{/* One empty row stays under the header: the text that scrolls below never touches it. */}
|
|
364
|
+
<box height={1} flexShrink={0} />
|
|
365
|
+
<scrollbox ref={(element) => (scroll = element)} flexGrow={1} minHeight={0} verticalScrollbarOptions={{ visible: false }} contentOptions={{ minHeight: 0 }}>
|
|
366
|
+
<Show when={ids().length > 0 || model().deleted > 0}>
|
|
367
|
+
<box flexDirection="column" flexShrink={0} paddingBottom={1}>
|
|
368
|
+
<Show when={ids().length > 0}>
|
|
369
|
+
<text fg={palette().muted} selectable={false}>
|
|
370
|
+
Sessions (click one to open it)
|
|
371
|
+
</text>
|
|
372
|
+
</Show>
|
|
373
|
+
<For each={ids()}>{(id) => <Row row={row(id)} colors={palette()} wide={props.panel.width >= 64} open={open} />}</For>
|
|
374
|
+
<Show when={model().deleted > 0}>
|
|
375
|
+
<text fg={palette().muted}>{model().deleted} session(s) were deleted when their run ended.</text>
|
|
376
|
+
</Show>
|
|
377
|
+
</box>
|
|
214
378
|
</Show>
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
</Show>
|
|
235
|
-
<scrollbox ref={(element) => (scroll = element)} flexGrow={1} minHeight={0} paddingTop={1} verticalScrollbarOptions={{ visible: false }} contentOptions={{ minHeight: 0 }}>
|
|
236
|
-
<Show when={ids().length > 0 || model().deleted > 0}>
|
|
237
|
-
<box flexDirection="column" flexShrink={0} paddingBottom={1}>
|
|
238
|
-
<Show when={ids().length > 0}>
|
|
239
|
-
<text fg={palette().muted} selectable={false}>
|
|
240
|
-
Sessions (click one to open it)
|
|
379
|
+
<Show
|
|
380
|
+
when={model().markdown}
|
|
381
|
+
fallback={
|
|
382
|
+
<text fg={palette().muted}>
|
|
383
|
+
{model().loading
|
|
384
|
+
? "Loading the report…"
|
|
385
|
+
: model().inbox
|
|
386
|
+
? "The report is in its session: open it above."
|
|
387
|
+
: model().run
|
|
388
|
+
? ended()
|
|
389
|
+
? "This run ended with no report or preview to show."
|
|
390
|
+
: "No report or preview yet."
|
|
391
|
+
: "No AZPR run in this conversation yet."}
|
|
392
|
+
</text>
|
|
393
|
+
}
|
|
394
|
+
>
|
|
395
|
+
<Show when={model().documentHead}>
|
|
396
|
+
<text fg={palette().muted} flexShrink={0} paddingBottom={1}>
|
|
397
|
+
{model().documentHead}
|
|
241
398
|
</text>
|
|
242
399
|
</Show>
|
|
243
|
-
<
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
400
|
+
<markdown syntaxStyle={syntax()} content={model().markdown} conceal tableOptions={{ style: "grid", cellPaddingX: 1 }} fg={palette().text} bg={palette().surface} />
|
|
401
|
+
</Show>
|
|
402
|
+
</scrollbox>
|
|
403
|
+
</box>
|
|
404
|
+
{/* What can be done next belongs to what is read above it: on the same ground, under a line that crosses
|
|
405
|
+
the panel, and in its place while the text scrolls. It is where reading ends, and beside the
|
|
406
|
+
conversation it is level with the host's status bar (the row under it is empty there as well), with
|
|
407
|
+
the line level with the lower edge of the prompt. Keys and labels that do not fit in one row go on
|
|
408
|
+
to the next one together. */}
|
|
409
|
+
<Show when={steps().length > 0}>
|
|
410
|
+
<box flexDirection="column" flexShrink={0}>
|
|
411
|
+
<box height={1} flexShrink={0} border={["top"]} borderColor={palette().rule} />
|
|
412
|
+
<box flexDirection="row" flexWrap="wrap" columnGap={3} flexShrink={0} paddingLeft={2} paddingRight={2}>
|
|
413
|
+
<For each={steps()}>{(id) => <Button item={step(id)} colors={palette()} live={props.panel.focused} press={press} lift={lift} forget={forget} />}</For>
|
|
247
414
|
</box>
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
when={model().markdown}
|
|
251
|
-
fallback={
|
|
252
|
-
<text fg={palette().muted}>
|
|
253
|
-
{model().loading
|
|
254
|
-
? "Loading the report…"
|
|
255
|
-
: model().inbox
|
|
256
|
-
? "The report is in its session: open it above."
|
|
257
|
-
: model().run
|
|
258
|
-
? "No report or preview yet."
|
|
259
|
-
: "No AZPR run in this conversation yet."}
|
|
260
|
-
</text>
|
|
261
|
-
}
|
|
262
|
-
>
|
|
263
|
-
<Show when={model().documentHead}>
|
|
264
|
-
<text fg={palette().muted} flexShrink={0} paddingBottom={1}>
|
|
265
|
-
{model().documentHead}
|
|
266
|
-
</text>
|
|
415
|
+
<Show when={props.panel.presentation !== "fullscreen"}>
|
|
416
|
+
<box height={1} flexShrink={0} />
|
|
267
417
|
</Show>
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
</scrollbox>
|
|
418
|
+
</box>
|
|
419
|
+
</Show>
|
|
271
420
|
</box>
|
|
272
421
|
)
|
|
273
422
|
}
|
|
274
423
|
|
|
275
|
-
/** The review panel: opens by itself or with /pr-panel
|
|
424
|
+
/** The review panel: opens by itself or with /pr-panel. Returns its cleanup, or nothing on a host without a place for it. */
|
|
276
425
|
function panelPart(context) {
|
|
277
426
|
// A host without these parts of the plugin API has no place for the panel: stay out of its way.
|
|
278
427
|
const needed = [context?.ui?.slot, context?.ui?.panel?.open, context?.ui?.router?.navigate, context?.keymap?.layer, context?.data?.listen, context?.data?.session?.pending?.list]
|
|
@@ -311,10 +460,23 @@ function panelPart(context) {
|
|
|
311
460
|
let unasked
|
|
312
461
|
// The session in which another plugin's panel is open; the host shows one panel at a time.
|
|
313
462
|
let occupied
|
|
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.
|
|
465
|
+
const actions =
|
|
466
|
+
typeof context.client?.session?.command === "function" && typeof context.ui?.dialog?.select === "function" && typeof context.ui?.toast?.show === "function"
|
|
467
|
+
? createActions({
|
|
468
|
+
dialog: context.ui.dialog,
|
|
469
|
+
toast: (options) => {
|
|
470
|
+
if (!disposed) context.ui.toast.show(options)
|
|
471
|
+
},
|
|
472
|
+
send: (sessionID, command) => context.client.session.command({ sessionID, name: command.name, text: command.text }),
|
|
473
|
+
})
|
|
474
|
+
: undefined
|
|
314
475
|
const state = {
|
|
315
476
|
source,
|
|
316
477
|
known,
|
|
317
478
|
read,
|
|
479
|
+
actions,
|
|
318
480
|
titles: new Map(),
|
|
319
481
|
lookup: reader.lookup,
|
|
320
482
|
readInbox: reader.readInbox,
|
|
@@ -435,6 +597,8 @@ function panelPart(context) {
|
|
|
435
597
|
|
|
436
598
|
return () => {
|
|
437
599
|
disposed = true
|
|
600
|
+
// An action that is open ends at its next step: nothing is sent by a part that was unloaded.
|
|
601
|
+
actions?.stop()
|
|
438
602
|
reader.dispose()
|
|
439
603
|
stop?.()
|
|
440
604
|
}
|