opencode-copilot-delegate 0.10.0 → 0.11.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-copilot-delegate",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "OpenCode plugin that delegates tasks to GitHub Copilot CLI as background subprocesses",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -55,9 +55,9 @@
55
55
  "@opencode-ai/plugin": ">=1.14.0"
56
56
  },
57
57
  "devDependencies": {
58
- "@biomejs/biome": "2.4.13",
58
+ "@biomejs/biome": "2.4.14",
59
59
  "@changesets/cli": "2.31.0",
60
- "@opencode-ai/plugin": "1.14.30",
60
+ "@opencode-ai/plugin": "1.14.31",
61
61
  "@types/bun": "1.3.13",
62
62
  "@types/node": "24.12.2",
63
63
  "rimraf": "6.1.3",
@@ -78,10 +78,10 @@
78
78
  "publish-changesets": "bun run build && changeset publish"
79
79
  },
80
80
  "dependencies": {
81
- "@opentui/core": "0.1.105",
82
- "@opentui/solid": "0.1.105",
81
+ "@opentui/core": "0.2.1",
82
+ "@opentui/solid": "0.2.1",
83
83
  "fkill": "10.0.3",
84
- "solid-js": "1.9.11",
84
+ "solid-js": "1.9.12",
85
85
  "zod": "^4.3.0"
86
86
  },
87
87
  "overrides": {
@@ -1,7 +1,6 @@
1
1
  /** @jsxImportSource @opentui/solid */
2
2
 
3
3
  import { describe, expect, it } from 'bun:test'
4
- import type { TuiDialogProps } from '@opencode-ai/plugin/tui'
5
4
  import { type JSX, testRender } from '@opentui/solid'
6
5
  import {
7
6
  RpcAuthError,
@@ -22,7 +21,6 @@ type TaskRow = {
22
21
  }
23
22
 
24
23
  type ConfirmCardProps = {
25
- Dialog: (props: TuiDialogProps) => JSX.Element
26
24
  task: TaskRow
27
25
  rpc: {
28
26
  tasksCancel(taskId: string): Promise<{ cancelled: boolean; error?: string }>
@@ -77,20 +75,6 @@ function createDeferred<T>(): Deferred<T> {
77
75
  }
78
76
  }
79
77
 
80
- function createDialogStub() {
81
- let onClose: (() => void) | undefined
82
-
83
- const Dialog = (props: TuiDialogProps) => {
84
- onClose = props.onClose
85
- return <box flexDirection="column">{props.children}</box>
86
- }
87
-
88
- return {
89
- Dialog,
90
- getOnClose: () => onClose,
91
- }
92
- }
93
-
94
78
  function makeTask(taskId: string, overrides: Partial<TaskRow> = {}): TaskRow {
95
79
  return {
96
80
  taskId,
@@ -143,11 +127,9 @@ describe('confirm card', () => {
143
127
  expect(typeof ConfirmCard).toBe('function')
144
128
  if (!ConfirmCard) return
145
129
 
146
- const dialog = createDialogStub()
147
130
  const { renderOnce, captureCharFrame, renderer } = await testRender(
148
131
  () => (
149
132
  <ConfirmCard
150
- Dialog={dialog.Dialog}
151
133
  task={makeTask('cpl_abc')}
152
134
  rpc={{ tasksCancel: async () => ({ cancelled: true }) }}
153
135
  onConfirm={() => {}}
@@ -178,7 +160,6 @@ describe('confirm card', () => {
178
160
  expect(typeof ConfirmCard).toBe('function')
179
161
  if (!ConfirmCard) return
180
162
 
181
- const dialog = createDialogStub()
182
163
  const cancelledTaskIds: string[] = []
183
164
  let confirmed = 0
184
165
  let keptRunning = 0
@@ -187,7 +168,6 @@ describe('confirm card', () => {
187
168
  const { renderOnce, mockInput, renderer } = await testRender(
188
169
  () => (
189
170
  <ConfirmCard
190
- Dialog={dialog.Dialog}
191
171
  task={makeTask('cpl_keep_running')}
192
172
  rpc={{
193
173
  tasksCancel: async (taskId) => {
@@ -229,14 +209,12 @@ describe('confirm card', () => {
229
209
  expect(typeof ConfirmCard).toBe('function')
230
210
  if (!ConfirmCard) return
231
211
 
232
- const dialog = createDialogStub()
233
212
  const cancelledTaskIds: string[] = []
234
213
  let confirmed = 0
235
214
 
236
215
  const { renderOnce, mockInput, renderer } = await testRender(
237
216
  () => (
238
217
  <ConfirmCard
239
- Dialog={dialog.Dialog}
240
218
  task={makeTask('cpl_cancel_success')}
241
219
  rpc={{
242
220
  tasksCancel: async (taskId) => {
@@ -270,12 +248,10 @@ describe('confirm card', () => {
270
248
  expect(typeof ConfirmCard).toBe('function')
271
249
  if (!ConfirmCard) return
272
250
 
273
- const dialog = createDialogStub()
274
251
  const { renderOnce, captureCharFrame, mockInput, renderer } =
275
252
  await testRender(
276
253
  () => (
277
254
  <ConfirmCard
278
- Dialog={dialog.Dialog}
279
255
  task={makeTask('cpl_cancel_error')}
280
256
  rpc={{
281
257
  tasksCancel: async () => {
@@ -324,14 +300,12 @@ describe('confirm card', () => {
324
300
  ]
325
301
 
326
302
  for (const error of cases) {
327
- const dialog = createDialogStub()
328
303
  let confirmed = 0
329
304
 
330
305
  const { renderOnce, captureCharFrame, mockInput, renderer } =
331
306
  await testRender(
332
307
  () => (
333
308
  <ConfirmCard
334
- Dialog={dialog.Dialog}
335
309
  task={makeTask('cpl_cancel_error')}
336
310
  rpc={{
337
311
  tasksCancel: async () => {
@@ -371,7 +345,6 @@ describe('confirm card', () => {
371
345
  expect(typeof ConfirmCard).toBe('function')
372
346
  if (!ConfirmCard) return
373
347
 
374
- const dialog = createDialogStub()
375
348
  let confirmed = 0
376
349
  let keptRunning = 0
377
350
 
@@ -379,7 +352,6 @@ describe('confirm card', () => {
379
352
  await testRender(
380
353
  () => (
381
354
  <ConfirmCard
382
- Dialog={dialog.Dialog}
383
355
  task={makeTask('cpl_finished')}
384
356
  rpc={{
385
357
  tasksCancel: async () => ({
@@ -410,34 +382,33 @@ describe('confirm card', () => {
410
382
  expect(captureCharFrame()).not.toContain('Cancel failed')
411
383
  })
412
384
 
413
- it('dismisses and returns after an inline cancellation error', async () => {
385
+ it('keeps inline cancellation errors open when escape is pressed', async () => {
414
386
  const ConfirmCard = await loadConfirmCard()
415
387
 
416
388
  expect(typeof ConfirmCard).toBe('function')
417
389
  if (!ConfirmCard) return
418
390
 
419
- const dialog = createDialogStub()
420
391
  let dismissedAfterError = 0
421
392
 
422
- const { renderOnce, mockInput, renderer } = await testRender(
423
- () => (
424
- <ConfirmCard
425
- Dialog={dialog.Dialog}
426
- task={makeTask('cpl_dismiss_after_error')}
427
- rpc={{
428
- tasksCancel: async () => {
429
- throw new RpcUnreachableError('rpc offline')
430
- },
431
- }}
432
- onConfirm={() => {}}
433
- onCancel={() => {}}
434
- onDismissAfterError={() => {
435
- dismissedAfterError += 1
436
- }}
437
- />
438
- ),
439
- { width: 80, height: 20, useThread: false },
440
- )
393
+ const { renderOnce, captureCharFrame, mockInput, renderer } =
394
+ await testRender(
395
+ () => (
396
+ <ConfirmCard
397
+ task={makeTask('cpl_dismiss_after_error')}
398
+ rpc={{
399
+ tasksCancel: async () => {
400
+ throw new RpcUnreachableError('rpc offline')
401
+ },
402
+ }}
403
+ onConfirm={() => {}}
404
+ onCancel={() => {}}
405
+ onDismissAfterError={() => {
406
+ dismissedAfterError += 1
407
+ }}
408
+ />
409
+ ),
410
+ { width: 80, height: 20, useThread: false },
411
+ )
441
412
 
442
413
  await renderOnce()
443
414
  await settle(renderOnce, () => renderer.idle())
@@ -448,7 +419,54 @@ describe('confirm card', () => {
448
419
  await new Promise((resolve) => setTimeout(resolve, 30))
449
420
  await settle(renderOnce, () => renderer.idle())
450
421
 
451
- expect(dismissedAfterError).toBe(1)
422
+ expect(dismissedAfterError).toBe(0)
423
+ expect(captureCharFrame()).toContain('Cancel failed: rpc offline')
424
+ })
425
+
426
+ it('does not intercept escape while still in the confirm state', async () => {
427
+ const ConfirmCard = await loadConfirmCard()
428
+
429
+ expect(typeof ConfirmCard).toBe('function')
430
+ if (!ConfirmCard) return
431
+
432
+ let confirmed = 0
433
+ let keptRunning = 0
434
+ let dismissedAfterError = 0
435
+
436
+ const { renderOnce, captureCharFrame, mockInput, renderer } =
437
+ await testRender(
438
+ () => (
439
+ <ConfirmCard
440
+ task={makeTask('cpl_escape_confirm')}
441
+ rpc={{
442
+ tasksCancel: async () => ({ cancelled: true }),
443
+ }}
444
+ onConfirm={() => {
445
+ confirmed += 1
446
+ }}
447
+ onCancel={() => {
448
+ keptRunning += 1
449
+ }}
450
+ onDismissAfterError={() => {
451
+ dismissedAfterError += 1
452
+ }}
453
+ />
454
+ ),
455
+ { width: 80, height: 20, useThread: false },
456
+ )
457
+
458
+ await renderOnce()
459
+ await settle(renderOnce, () => renderer.idle())
460
+
461
+ mockInput.pressEscape()
462
+ await new Promise((resolve) => setTimeout(resolve, 30))
463
+ await settle(renderOnce, () => renderer.idle())
464
+
465
+ expect(confirmed).toBe(0)
466
+ expect(keptRunning).toBe(0)
467
+ expect(dismissedAfterError).toBe(0)
468
+ expect(captureCharFrame()).toContain('Cancel Task')
469
+ expect(captureCharFrame()).toContain('Keep Running')
452
470
  })
453
471
 
454
472
  it('ignores repeated confirm activations while cancellation is in flight', async () => {
@@ -457,7 +475,6 @@ describe('confirm card', () => {
457
475
  expect(typeof ConfirmCard).toBe('function')
458
476
  if (!ConfirmCard) return
459
477
 
460
- const dialog = createDialogStub()
461
478
  const deferred = createDeferred<{ cancelled: boolean }>()
462
479
  const cancelledTaskIds: string[] = []
463
480
  let confirmed = 0
@@ -465,7 +482,6 @@ describe('confirm card', () => {
465
482
  const { renderOnce, mockInput, renderer } = await testRender(
466
483
  () => (
467
484
  <ConfirmCard
468
- Dialog={dialog.Dialog}
469
485
  task={makeTask('cpl_guard')}
470
486
  rpc={{
471
487
  tasksCancel: async (taskId) => {
@@ -6,6 +6,7 @@ import type {
6
6
  TuiCommand,
7
7
  TuiPluginApi,
8
8
  TuiPluginMeta,
9
+ TuiToast,
9
10
  } from '@opencode-ai/plugin/tui'
10
11
  import { type JSX, testRender } from '@opentui/solid'
11
12
 
@@ -25,11 +26,20 @@ type DialogReplacement = {
25
26
  onClose?: () => void
26
27
  }
27
28
 
29
+ type ToastCall = {
30
+ message: string
31
+ variant?: string
32
+ duration?: number
33
+ }
34
+
28
35
  type TestApiControls = {
29
36
  api: TuiPluginApi
30
37
  commandFactories: Array<() => TuiCommand[]>
31
38
  dialogReplacements: DialogReplacement[]
39
+ dialogSizes: Array<'medium' | 'large' | 'xlarge'>
40
+ clearCalls: number
32
41
  disposeHandlers: Array<() => void | Promise<void>>
42
+ toastCalls: ToastCall[]
33
43
  unregisterCalls: number
34
44
  }
35
45
 
@@ -68,7 +78,10 @@ async function loadTuiPlugin(): Promise<TuiPlugin> {
68
78
  function createTestApi(): TestApiControls {
69
79
  const commandFactories: Array<() => TuiCommand[]> = []
70
80
  const dialogReplacements: DialogReplacement[] = []
81
+ const dialogSizes: Array<'medium' | 'large' | 'xlarge'> = []
71
82
  const disposeHandlers: Array<() => void | Promise<void>> = []
83
+ const toastCalls: ToastCall[] = []
84
+ let clearCalls = 0
72
85
  let unregisterCalls = 0
73
86
 
74
87
  const api = {
@@ -91,13 +104,23 @@ function createTestApi(): TestApiControls {
91
104
  DialogSelect: (() => null) as TuiPluginApi['ui']['DialogSelect'],
92
105
  Slot: (() => null) as TuiPluginApi['ui']['Slot'],
93
106
  Prompt: (() => null) as TuiPluginApi['ui']['Prompt'],
94
- toast: () => {},
107
+ toast: (input: TuiToast) => {
108
+ toastCalls.push({
109
+ message: input.message,
110
+ variant: input.variant,
111
+ duration: input.duration,
112
+ })
113
+ },
95
114
  dialog: {
96
115
  replace: (render: () => JSX.Element, onClose?: () => void) => {
97
116
  dialogReplacements.push({ render, onClose })
98
117
  },
99
- clear: () => {},
100
- setSize: () => {},
118
+ clear: () => {
119
+ clearCalls += 1
120
+ },
121
+ setSize: (size: 'medium' | 'large' | 'xlarge') => {
122
+ dialogSizes.push(size)
123
+ },
101
124
  size: 'medium',
102
125
  depth: 0,
103
126
  open: false,
@@ -116,7 +139,12 @@ function createTestApi(): TestApiControls {
116
139
  api,
117
140
  commandFactories,
118
141
  dialogReplacements,
142
+ dialogSizes,
143
+ get clearCalls() {
144
+ return clearCalls
145
+ },
119
146
  disposeHandlers,
147
+ toastCalls,
120
148
  get unregisterCalls() {
121
149
  return unregisterCalls
122
150
  },
@@ -256,6 +284,7 @@ describe('tui entrypoint', () => {
256
284
  command.onSelect?.()
257
285
 
258
286
  expect(controls.dialogReplacements).toHaveLength(1)
287
+ expect(controls.dialogSizes).toEqual(['large'])
259
288
 
260
289
  const { renderOnce, captureCharFrame, renderer } = await testRender(
261
290
  () => controls.dialogReplacements[0].render(),
@@ -281,11 +310,54 @@ describe('tui entrypoint', () => {
281
310
  expect(frame).not.toContain('Unit 6')
282
311
  })
283
312
 
284
- it('opens the confirm card for the selected task when c is pressed in the modal list', async () => {
313
+ it('does not pass a re-entrant host onClose callback to the custom status dialog', async () => {
314
+ const plugin = await loadTuiPlugin()
315
+ const controls = createTestApi()
316
+
317
+ await plugin(controls.api, undefined, makePluginMeta())
318
+
319
+ const [command] = controls.commandFactories[0]()
320
+ command.onSelect?.()
321
+
322
+ expect(controls.dialogReplacements).toHaveLength(1)
323
+ expect(controls.dialogReplacements[0].onClose).toBeUndefined()
324
+ expect(controls.clearCalls).toBe(0)
325
+ })
326
+
327
+ it('does not toast when rpc is unavailable', async () => {
328
+ const plugin = await loadTuiPlugin()
329
+ const controls = createTestApi()
330
+ const cacheHome = makeCacheHome()
331
+ process.env.XDG_CACHE_HOME = cacheHome
332
+ process.env.OPENCODE_SESSION_ID = 'tui-index-error'
333
+
334
+ await plugin(controls.api, undefined, makePluginMeta())
335
+
336
+ const [command] = controls.commandFactories[0]()
337
+ command.onSelect?.()
338
+
339
+ expect(controls.dialogReplacements).toHaveLength(1)
340
+ expect(controls.dialogSizes).toEqual(['large'])
341
+
342
+ const { renderOnce, renderer } = await testRender(
343
+ () => controls.dialogReplacements[0].render(),
344
+ { useThread: false },
345
+ )
346
+
347
+ await renderOnce()
348
+ await renderer.idle()
349
+ await renderOnce()
350
+
351
+ expect(controls.dialogReplacements).toHaveLength(1)
352
+ expect(controls.dialogSizes).toEqual(['large'])
353
+ expect(controls.toastCalls).toEqual([])
354
+ })
355
+
356
+ it('keeps /copilot-status on a single read-only dialog replacement', async () => {
285
357
  const plugin = await loadTuiPlugin()
286
358
  const controls = createTestApi()
287
359
  const cacheHome = makeCacheHome()
288
- const sessionDiscriminator = 'tui-index-confirm-card'
360
+ const sessionDiscriminator = 'tui-index-read-only'
289
361
 
290
362
  process.env.XDG_CACHE_HOME = cacheHome
291
363
  process.env.OPENCODE_SESSION_ID = sessionDiscriminator
@@ -293,18 +365,11 @@ describe('tui entrypoint', () => {
293
365
  writePortFile(cacheHome, sessionDiscriminator, {
294
366
  port: 43124,
295
367
  pid: process.pid,
296
- token: 'token-index-confirm-card',
368
+ token: 'token-index-read-only',
297
369
  })
298
370
 
299
371
  const stubFetch = Object.assign(
300
- async (_input: string | URL | Request, init?: RequestInit) => {
301
- if (typeof init?.body === 'string' && init.body.includes('taskId')) {
302
- return new Response(JSON.stringify({ cancelled: true }), {
303
- status: 200,
304
- headers: { 'content-type': 'application/json' },
305
- })
306
- }
307
-
372
+ async (_input: string | URL | Request) => {
308
373
  return new Response(
309
374
  JSON.stringify({
310
375
  tasks: [
@@ -364,44 +429,10 @@ describe('tui entrypoint', () => {
364
429
  includes: '2 running · 0 recent',
365
430
  })
366
431
  expect(listFrame).toContain('cpl_beta')
367
-
368
- listRender.mockInput.pressKey('j')
369
- await waitForFrame({
370
- renderOnce: listRender.renderOnce,
371
- idle: () => listRender.renderer.idle(),
372
- captureCharFrame: listRender.captureCharFrame,
373
- includes: 'cpl_beta',
374
- })
375
- listRender.mockInput.pressKey('c')
376
- await waitForFrame({
377
- renderOnce: listRender.renderOnce,
378
- idle: () => listRender.renderer.idle(),
379
- captureCharFrame: listRender.captureCharFrame,
380
- includes: 'cpl_beta',
381
- })
382
-
383
- expect(controls.dialogReplacements).toHaveLength(2)
384
-
385
- const confirmRender = await testRender(
386
- () => controls.dialogReplacements[1].render(),
387
- {
388
- width: 120,
389
- height: 20,
390
- useThread: false,
391
- },
392
- )
393
-
394
- await confirmRender.renderOnce()
395
-
396
- const confirmFrame = await waitForFrame({
397
- renderOnce: confirmRender.renderOnce,
398
- idle: () => confirmRender.renderer.idle(),
399
- captureCharFrame: confirmRender.captureCharFrame,
400
- includes: 'Cancel Copilot delegation cpl_beta?',
401
- })
402
-
403
- expect(confirmFrame).toContain('Cancel Copilot delegation cpl_beta?')
404
- expect(confirmFrame).toContain('Cancel Task')
405
- expect(confirmFrame).toContain('Keep Running')
432
+ expect(listFrame).toContain('Esc close')
433
+ expect(listFrame).not.toContain('navigate')
434
+ expect(listFrame).not.toContain('c cancel')
435
+ expect(controls.dialogReplacements).toHaveLength(1)
436
+ expect(controls.dialogSizes).toEqual(['large'])
406
437
  })
407
438
  })