opencode-copilot-delegate 0.12.2 → 0.13.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/dist/tui/index.js CHANGED
@@ -1,236 +1,7 @@
1
1
  // @bun
2
- // src/tui/index.tsx
3
- import { createComponent as _$createComponent } from "@opentui/solid";
4
-
5
- // src/tui/components/modal-list.tsx
6
- import { createTextNode as _$createTextNode } from "@opentui/solid";
7
- import { insertNode as _$insertNode } from "@opentui/solid";
8
- import { use as _$use } from "@opentui/solid";
9
- import { setProp as _$setProp } from "@opentui/solid";
10
- import { createElement as _$createElement } from "@opentui/solid";
11
- import { TextAttributes } from "@opentui/core";
12
- import { useRenderer } from "@opentui/solid";
13
- import { onCleanup } from "solid-js";
14
-
15
- // src/tui/components/row.tsx
16
- function displayValue(value) {
17
- const trimmed = value.trim();
18
- return trimmed.length > 0 ? trimmed : "default";
19
- }
20
- function formatElapsed(elapsedMs) {
21
- const totalSeconds = Math.max(0, Math.floor(elapsedMs / 1000));
22
- if (totalSeconds >= 3600) {
23
- const hours = Math.floor(totalSeconds / 3600);
24
- const minutes = Math.floor(totalSeconds % 3600 / 60);
25
- return `${hours}h ${minutes}m`;
26
- }
27
- if (totalSeconds >= 60) {
28
- const minutes = Math.floor(totalSeconds / 60);
29
- const seconds = totalSeconds % 60;
30
- return `${minutes}m ${seconds}s`;
31
- }
32
- return `${totalSeconds}s`;
33
- }
34
- function formatStatus(status) {
35
- return status === "running" ? `\u25CF ${status}` : status;
36
- }
37
- function formatToolCalls(toolCallCount) {
38
- return `${toolCallCount} ${toolCallCount === 1 ? "call" : "calls"}`;
39
- }
40
- function formatRowText(task, nowMs) {
41
- const elapsed = Math.max(0, nowMs - task.startedAt);
42
- return `${formatStatus(task.status)} ${task.taskId} ${displayValue(task.agent)} ${displayValue(task.model)} ${formatElapsed(elapsed)} ${formatToolCalls(task.toolCallCount)}`;
43
- }
44
-
45
- // src/tui/components/modal-list.tsx
46
- var LOADING_HEADER = "Loading delegations\u2026";
47
- var EMPTY_STATE_TITLE = "No Copilot delegations are running.";
48
- var EMPTY_STATE_HINT = "Start one with the copilot_delegate tool, then reopen /copilot-status.";
49
- var defaultClock = {
50
- now: () => Date.now(),
51
- setInterval: (fn, delayMs) => globalThis.setInterval(fn, delayMs),
52
- clearInterval: (handle) => {
53
- globalThis.clearInterval(handle);
54
- }
55
- };
56
- function updateText(node, content, attributes = TextAttributes.NONE) {
57
- if (!node) {
58
- return;
59
- }
60
- node.content = content;
61
- node.attributes = attributes;
62
- }
63
- function updateBoxVisibility(node, visible) {
64
- if (!node) {
65
- return;
66
- }
67
- node.visible = visible;
68
- }
69
- function renderLoadingState(refs) {
70
- updateText(refs.headerText, LOADING_HEADER);
71
- updateText(refs.footerText, "Esc close");
72
- updateBoxVisibility(refs.emptyBox, false);
73
- updateBoxVisibility(refs.rowsBox, false);
74
- }
75
- function renderEmptyView(refs) {
76
- updateText(refs.headerText, "0 running \xB7 0 recent");
77
- updateText(refs.footerText, "Esc close");
78
- updateBoxVisibility(refs.emptyBox, true);
79
- updateBoxVisibility(refs.rowsBox, false);
80
- updateText(refs.emptyLineOne, EMPTY_STATE_TITLE);
81
- updateText(refs.emptyLineTwo, EMPTY_STATE_HINT);
82
- }
83
- function renderTaskRows(refs, tasks, nowMs) {
84
- updateText(refs.headerText, `${tasks.length} running \xB7 0 recent`);
85
- updateText(refs.footerText, "Esc close");
86
- updateBoxVisibility(refs.emptyBox, false);
87
- updateBoxVisibility(refs.rowsBox, true);
88
- for (const [index, rowText] of refs.rowTexts.entries()) {
89
- const task = tasks[index];
90
- if (!rowText) {
91
- continue;
92
- }
93
- rowText.visible = task !== undefined;
94
- rowText.content = task ? formatRowText(task, nowMs) : "";
95
- rowText.attributes = TextAttributes.NONE;
96
- }
97
- }
98
- function ModalList(props) {
99
- const renderer = useRenderer();
100
- const clock = props.clock ?? defaultClock;
101
- const now = {
102
- value: clock.now()
103
- };
104
- const state = {
105
- value: {
106
- kind: "loading"
107
- }
108
- };
109
- let disposed = false;
110
- let headerText;
111
- let footerText;
112
- let emptyBox;
113
- let emptyLineOne;
114
- let emptyLineTwo;
115
- let rowsBox;
116
- const rowTexts = [];
117
- const refs = () => ({
118
- headerText,
119
- footerText,
120
- emptyBox,
121
- emptyLineOne,
122
- emptyLineTwo,
123
- rowsBox,
124
- rowTexts
125
- });
126
- const renderView = () => {
127
- if (disposed) {
128
- return;
129
- }
130
- const currentState = state.value;
131
- const currentRefs = refs();
132
- if (currentState.kind === "loading") {
133
- renderLoadingState(currentRefs);
134
- renderer.requestRender();
135
- return;
136
- }
137
- const tasks = currentState.tasks;
138
- if (tasks.length === 0) {
139
- renderEmptyView(currentRefs);
140
- renderer.requestRender();
141
- return;
142
- }
143
- renderTaskRows(currentRefs, tasks, now.value);
144
- renderer.requestRender();
145
- };
146
- const loadTasks = async () => {
147
- const response = await props.rpc.tasksList();
148
- if (disposed) {
149
- return;
150
- }
151
- state.value = {
152
- kind: "ready",
153
- tasks: response.tasks
154
- };
155
- renderView();
156
- };
157
- const intervalHandle = clock.setInterval(() => {
158
- now.value = clock.now();
159
- if (state.value.kind === "ready" && state.value.tasks.length > 0) {
160
- renderView();
161
- }
162
- }, 1000);
163
- loadTasks().catch((error) => {
164
- if (disposed) {
165
- return;
166
- }
167
- props.onLoadError?.(error);
168
- });
169
- onCleanup(() => {
170
- disposed = true;
171
- clock.clearInterval(intervalHandle);
172
- });
173
- return (() => {
174
- var _el$ = _$createElement("box"), _el$2 = _$createElement("text"), _el$4 = _$createElement("box"), _el$5 = _$createElement("text"), _el$6 = _$createElement("text"), _el$7 = _$createElement("box"), _el$8 = _$createElement("text"), _el$9 = _$createElement("text"), _el$0 = _$createElement("text"), _el$1 = _$createElement("text"), _el$10 = _$createElement("text"), _el$11 = _$createElement("text"), _el$12 = _$createElement("text"), _el$13 = _$createElement("text"), _el$14 = _$createElement("text"), _el$15 = _$createElement("text"), _el$16 = _$createElement("text");
175
- _$insertNode(_el$, _el$2);
176
- _$insertNode(_el$, _el$4);
177
- _$insertNode(_el$, _el$7);
178
- _$insertNode(_el$, _el$16);
179
- _$setProp(_el$, "flexDirection", "column");
180
- _$setProp(_el$, "gap", 1);
181
- _$setProp(_el$, "padding", 1);
182
- _$setProp(_el$, "width", "100%");
183
- _$insertNode(_el$2, _$createTextNode(`Loading delegations\u2026`));
184
- var _ref$ = headerText;
185
- typeof _ref$ === "function" ? _$use(_ref$, _el$2) : headerText = _el$2;
186
- _$insertNode(_el$4, _el$5);
187
- _$insertNode(_el$4, _el$6);
188
- var _ref$2 = emptyBox;
189
- typeof _ref$2 === "function" ? _$use(_ref$2, _el$4) : emptyBox = _el$4;
190
- _$setProp(_el$4, "flexDirection", "column");
191
- _$setProp(_el$4, "flexGrow", 1);
192
- _$setProp(_el$4, "justifyContent", "center");
193
- _$setProp(_el$4, "visible", false);
194
- var _ref$3 = emptyLineOne;
195
- typeof _ref$3 === "function" ? _$use(_ref$3, _el$5) : emptyLineOne = _el$5;
196
- var _ref$4 = emptyLineTwo;
197
- typeof _ref$4 === "function" ? _$use(_ref$4, _el$6) : emptyLineTwo = _el$6;
198
- _$insertNode(_el$7, _el$8);
199
- _$insertNode(_el$7, _el$9);
200
- _$insertNode(_el$7, _el$0);
201
- _$insertNode(_el$7, _el$1);
202
- _$insertNode(_el$7, _el$10);
203
- _$insertNode(_el$7, _el$11);
204
- _$insertNode(_el$7, _el$12);
205
- _$insertNode(_el$7, _el$13);
206
- _$insertNode(_el$7, _el$14);
207
- _$insertNode(_el$7, _el$15);
208
- var _ref$5 = rowsBox;
209
- typeof _ref$5 === "function" ? _$use(_ref$5, _el$7) : rowsBox = _el$7;
210
- _$setProp(_el$7, "flexDirection", "column");
211
- _$setProp(_el$7, "flexGrow", 1);
212
- _$setProp(_el$7, "visible", false);
213
- _$use((node) => rowTexts[0] = node, _el$8);
214
- _$use((node) => rowTexts[1] = node, _el$9);
215
- _$use((node) => rowTexts[2] = node, _el$0);
216
- _$use((node) => rowTexts[3] = node, _el$1);
217
- _$use((node) => rowTexts[4] = node, _el$10);
218
- _$use((node) => rowTexts[5] = node, _el$11);
219
- _$use((node) => rowTexts[6] = node, _el$12);
220
- _$use((node) => rowTexts[7] = node, _el$13);
221
- _$use((node) => rowTexts[8] = node, _el$14);
222
- _$use((node) => rowTexts[9] = node, _el$15);
223
- _$insertNode(_el$16, _$createTextNode(`Esc close`));
224
- var _ref$6 = footerText;
225
- typeof _ref$6 === "function" ? _$use(_ref$6, _el$16) : footerText = _el$16;
226
- return _el$;
227
- })();
228
- }
229
-
230
2
  // src/tui/rpc-client.ts
231
3
  import { readFile } from "fs/promises";
232
- import { homedir } from "os";
233
- import { join } from "path";
4
+ import { join as join2 } from "path";
234
5
 
235
6
  // node_modules/zod/v4/core/util.js
236
7
  function getEnumValues(entries) {
@@ -5777,6 +5548,17 @@ var PortFileSchema = object({
5777
5548
  token: string2().min(1)
5778
5549
  }).strict();
5779
5550
 
5551
+ // src/runtime/rpc-paths.ts
5552
+ import { homedir } from "os";
5553
+ import { join } from "path";
5554
+ function defaultPortFileBaseDir() {
5555
+ const cacheHome = process.env.XDG_CACHE_HOME ?? join(process.env.HOME ?? homedir(), ".cache");
5556
+ return join(cacheHome, "opencode", "copilot-delegate");
5557
+ }
5558
+ function defaultSessionDiscriminator() {
5559
+ return process.env.OPENCODE_SESSION_ID ?? String(process.pid);
5560
+ }
5561
+
5780
5562
  // src/tui/rpc-client.ts
5781
5563
  class RpcUnreachableError extends Error {
5782
5564
  constructor(message, options) {
@@ -5815,15 +5597,8 @@ class RpcAuthError extends RpcServerError {
5815
5597
  Object.setPrototypeOf(this, new.target.prototype);
5816
5598
  }
5817
5599
  }
5818
- function defaultBaseDir() {
5819
- const cacheHome = process.env.XDG_CACHE_HOME ?? join(process.env.HOME ?? homedir(), ".cache");
5820
- return join(cacheHome, "opencode", "copilot-delegate");
5821
- }
5822
- function defaultSessionDiscriminator() {
5823
- return process.env.OPENCODE_SESSION_ID ?? String(process.pid);
5824
- }
5825
5600
  function resolvePortFilePath(options) {
5826
- return join(options.baseDir ?? defaultBaseDir(), options.sessionDiscriminator ?? defaultSessionDiscriminator(), "server-port.json");
5601
+ return join2(options.baseDir ?? defaultPortFileBaseDir(), options.sessionDiscriminator ?? defaultSessionDiscriminator(), "server-port.json");
5827
5602
  }
5828
5603
  function summarizeIssues(issues) {
5829
5604
  return issues.map((issue) => {
@@ -6007,13 +5782,194 @@ function createRpcClient(options = {}) {
6007
5782
  };
6008
5783
  }
6009
5784
 
6010
- // src/tui/index.tsx
5785
+ // src/tui/status-dialogs.tsx
5786
+ import { createComponent as _$createComponent } from "@opentui/solid";
5787
+
5788
+ // src/tui/status-format.ts
5789
+ function displayValue(value) {
5790
+ const trimmed = value.trim();
5791
+ return trimmed.length > 0 ? trimmed : "default";
5792
+ }
5793
+ function formatElapsed(elapsedMs) {
5794
+ const totalSeconds = Math.max(0, Math.floor(elapsedMs / 1000));
5795
+ if (totalSeconds >= 3600) {
5796
+ const hours = Math.floor(totalSeconds / 3600);
5797
+ const minutes = Math.floor(totalSeconds % 3600 / 60);
5798
+ return `${hours}h ${minutes}m`;
5799
+ }
5800
+ if (totalSeconds >= 60) {
5801
+ const minutes = Math.floor(totalSeconds / 60);
5802
+ const seconds = totalSeconds % 60;
5803
+ return `${minutes}m ${seconds}s`;
5804
+ }
5805
+ return `${totalSeconds}s`;
5806
+ }
5807
+ function formatStatus(status) {
5808
+ return status === "running" ? `\u25CF ${status}` : status;
5809
+ }
5810
+ function formatToolCalls(toolCallCount) {
5811
+ return `${toolCallCount} ${toolCallCount === 1 ? "call" : "calls"}`;
5812
+ }
5813
+ function formatTaskDescription(task) {
5814
+ return `${displayValue(task.agent)} \xB7 ${displayValue(task.model)} \xB7 ${formatToolCalls(task.toolCallCount)}`;
5815
+ }
5816
+ function formatTaskFooter(task, nowMs) {
5817
+ return `${formatStatus(task.status)} \xB7 ${formatElapsed(Math.max(0, nowMs - task.startedAt))}`;
5818
+ }
5819
+
5820
+ // src/tui/status-dialogs.tsx
5821
+ var REOPEN_DELAY_MS = 50;
6011
5822
  function errorMessage2(error) {
6012
5823
  if (error instanceof Error && error.message.trim().length > 0) {
6013
5824
  return error.message.trim();
6014
5825
  }
6015
5826
  return "Unknown RPC error.";
6016
5827
  }
5828
+ function warnNonFatal(error) {
5829
+ console.warn(`[opencode-copilot-delegate] /copilot-status dialog failed: ${errorMessage2(error)}`);
5830
+ }
5831
+ function defaultDefer(fn) {
5832
+ const handle = setTimeout(fn, REOPEN_DELAY_MS);
5833
+ return () => {
5834
+ clearTimeout(handle);
5835
+ };
5836
+ }
5837
+ function createStatusDialogs(api, options) {
5838
+ const {
5839
+ rpc
5840
+ } = options;
5841
+ const defer = options.defer ?? defaultDefer;
5842
+ const now = options.now ?? (() => Date.now());
5843
+ const pending = new Set;
5844
+ let disposed = false;
5845
+ let generation = 0;
5846
+ const deferred = (fn) => {
5847
+ const cancel = defer(() => {
5848
+ pending.delete(cancel);
5849
+ if (disposed) {
5850
+ return;
5851
+ }
5852
+ try {
5853
+ fn();
5854
+ } catch (error) {
5855
+ warnNonFatal(error);
5856
+ }
5857
+ });
5858
+ pending.add(cancel);
5859
+ };
5860
+ const showAlert = (title, message, onConfirm) => {
5861
+ api.ui.dialog.setSize("medium");
5862
+ api.ui.dialog.replace(() => _$createComponent(api.ui.DialogAlert, {
5863
+ title,
5864
+ message,
5865
+ onConfirm
5866
+ }));
5867
+ };
5868
+ const showCancelFailure = (task, message) => {
5869
+ showAlert(`Could not cancel ${task.taskId}`, message, () => {
5870
+ deferred(() => {
5871
+ openList(task.taskId);
5872
+ });
5873
+ });
5874
+ };
5875
+ const cancelTask = async (task) => {
5876
+ let failure;
5877
+ try {
5878
+ const response = await rpc.tasksCancel(task.taskId);
5879
+ if (!response.cancelled && response.error !== "no such task") {
5880
+ failure = response.error ?? "Unknown RPC error.";
5881
+ }
5882
+ } catch (error) {
5883
+ failure = errorMessage2(error);
5884
+ }
5885
+ if (disposed) {
5886
+ return;
5887
+ }
5888
+ deferred(() => {
5889
+ if (failure === undefined) {
5890
+ openList();
5891
+ } else {
5892
+ showCancelFailure(task, failure);
5893
+ }
5894
+ });
5895
+ };
5896
+ const openConfirm = (task) => {
5897
+ api.ui.dialog.setSize("medium");
5898
+ api.ui.dialog.replace(() => _$createComponent(api.ui.DialogConfirm, {
5899
+ get title() {
5900
+ return `Cancel Copilot delegation ${task.taskId}?`;
5901
+ },
5902
+ message: "Confirm stops the running Copilot process. Cancel keeps it running.",
5903
+ onConfirm: () => {
5904
+ cancelTask(task);
5905
+ },
5906
+ onCancel: () => {
5907
+ deferred(() => {
5908
+ openList(task.taskId);
5909
+ });
5910
+ }
5911
+ }));
5912
+ };
5913
+ const renderList = (tasks, currentTaskId) => {
5914
+ if (tasks.length === 0) {
5915
+ showAlert("No Copilot delegations are running.", "Start one with the copilot_delegate tool, then reopen /copilot-status.");
5916
+ return;
5917
+ }
5918
+ const nowMs = now();
5919
+ const byId = new Map(tasks.map((task) => [task.taskId, task]));
5920
+ const running = tasks.filter((task) => task.status === "running").length;
5921
+ api.ui.dialog.setSize("large");
5922
+ api.ui.dialog.replace(() => _$createComponent(api.ui.DialogSelect, {
5923
+ title: `Copilot delegations (${running} running)`,
5924
+ current: currentTaskId,
5925
+ get options() {
5926
+ return tasks.map((task) => ({
5927
+ title: task.taskId,
5928
+ value: task.taskId,
5929
+ description: formatTaskDescription(task),
5930
+ footer: formatTaskFooter(task, nowMs),
5931
+ disabled: task.status !== "running"
5932
+ }));
5933
+ },
5934
+ onSelect: (option) => {
5935
+ const task = byId.get(option.value);
5936
+ if (task?.status === "running") {
5937
+ openConfirm(task);
5938
+ }
5939
+ }
5940
+ }));
5941
+ };
5942
+ const openList = (currentTaskId) => {
5943
+ const mine = ++generation;
5944
+ (async () => {
5945
+ let tasks;
5946
+ try {
5947
+ tasks = (await rpc.tasksList()).tasks;
5948
+ } catch (error) {
5949
+ if (!disposed && mine === generation) {
5950
+ showAlert("Status unavailable.", errorMessage2(error));
5951
+ }
5952
+ return;
5953
+ }
5954
+ if (disposed || mine !== generation) {
5955
+ return;
5956
+ }
5957
+ renderList(tasks, currentTaskId);
5958
+ })().catch(warnNonFatal);
5959
+ };
5960
+ return {
5961
+ openList,
5962
+ dispose() {
5963
+ disposed = true;
5964
+ for (const cancel of pending) {
5965
+ cancel();
5966
+ }
5967
+ pending.clear();
5968
+ }
5969
+ };
5970
+ }
5971
+
5972
+ // src/tui/index.tsx
6017
5973
  function hasKeymapRegisterLayer(api) {
6018
5974
  const candidate = api.keymap;
6019
5975
  return candidate != null && typeof candidate.registerLayer === "function";
@@ -6026,6 +5982,8 @@ function registerCopilotStatusCommand(api, openList) {
6026
5982
  name: "copilot-status",
6027
5983
  title: "Copilot Status",
6028
5984
  category: "Copilot",
5985
+ slashName: "copilot-status",
5986
+ desc: "Show running Copilot delegations",
6029
5987
  run() {
6030
5988
  openList();
6031
5989
  }
@@ -6050,36 +6008,14 @@ function registerCopilotStatusCommand(api, openList) {
6050
6008
  }
6051
6009
  var tui = async (api) => {
6052
6010
  const rpc = createRpcClient();
6053
- const closeDialog = () => {
6054
- api.ui.dialog.clear();
6055
- };
6056
- const showUnavailableAlert = (error) => {
6057
- api.ui.dialog.setSize("medium");
6058
- api.ui.dialog.replace(() => {
6059
- return _$createComponent(api.ui.DialogAlert, {
6060
- title: "Status unavailable.",
6061
- get message() {
6062
- return errorMessage2(error);
6063
- },
6064
- onConfirm: closeDialog
6065
- });
6066
- });
6067
- };
6068
- const openList = (initialTaskId) => {
6069
- api.ui.dialog.setSize("large");
6070
- api.ui.dialog.replace(() => {
6071
- return _$createComponent(ModalList, {
6072
- onClose: closeDialog,
6073
- onLoadError: showUnavailableAlert,
6074
- initialTaskId,
6075
- rpc
6076
- });
6077
- });
6078
- };
6011
+ const dialogs = createStatusDialogs(api, {
6012
+ rpc
6013
+ });
6079
6014
  const unregister = registerCopilotStatusCommand(api, () => {
6080
- openList();
6015
+ dialogs.openList();
6081
6016
  });
6082
6017
  api.lifecycle.onDispose(() => {
6018
+ dialogs.dispose();
6083
6019
  rpc.dispose();
6084
6020
  unregister();
6085
6021
  });
@@ -0,0 +1,17 @@
1
+ /** @jsxImportSource @opentui/solid */
2
+ import type { TuiPluginApi } from '@opencode-ai/plugin/tui';
3
+ import type { RpcClient } from './rpc-client';
4
+ export type StatusDialogsRpc = Pick<RpcClient, 'tasksList' | 'tasksCancel'>;
5
+ export type StatusDialogsOptions = {
6
+ rpc: StatusDialogsRpc;
7
+ /** Schedules `fn` after the host's own close has finished. Returns a canceller. */
8
+ defer?: (fn: () => void) => () => void;
9
+ now?: () => number;
10
+ };
11
+ export type StatusDialogs = {
12
+ openList: (currentTaskId?: string) => void;
13
+ dispose: () => void;
14
+ };
15
+ type DialogApi = Pick<TuiPluginApi, 'ui'>;
16
+ export declare function createStatusDialogs(api: DialogApi, options: StatusDialogsOptions): StatusDialogs;
17
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { TasksListResponse } from '../runtime/rpc-contract';
2
+ export type StatusTask = TasksListResponse['tasks'][number];
3
+ export declare function displayValue(value: string): string;
4
+ export declare function formatElapsed(elapsedMs: number): string;
5
+ export declare function formatStatus(status: StatusTask['status']): string;
6
+ export declare function formatToolCalls(toolCallCount: number): string;
7
+ /** Secondary line of a list option: who is running it and how busy it is. */
8
+ export declare function formatTaskDescription(task: StatusTask): string;
9
+ /** Right-hand footer of a list option: status and elapsed time. */
10
+ export declare function formatTaskFooter(task: StatusTask, nowMs: number): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-copilot-delegate",
3
- "version": "0.12.2",
3
+ "version": "0.13.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",
@@ -62,7 +62,7 @@
62
62
  "@opencode-ai/plugin": "1.19.6",
63
63
  "@types/babel__core": "7.20.5",
64
64
  "@types/bun": "1.4.4",
65
- "@types/node": "24.19.2",
65
+ "@types/node": "26.6.6",
66
66
  "rimraf": "6.1.4",
67
67
  "typescript": "7.0.2"
68
68
  },
@@ -76,18 +76,20 @@
76
76
  "test:integration": "bun test tests/integration/",
77
77
  "lint": "biome check .",
78
78
  "fix": "biome check . --write",
79
- "prepublishOnly": "bun run build",
79
+ "prepublishOnly": "bun run typecheck && bun run test:unit && bun run build",
80
80
  "version-changesets": "changeset version && bun install --lockfile-only",
81
81
  "publish-changesets": "bun run build && changeset publish"
82
82
  },
83
83
  "dependencies": {
84
- "@opentui/core": "0.2.7",
85
- "@opentui/solid": "0.2.7",
84
+ "@opentui/core": "0.4.5",
85
+ "@opentui/solid": "0.4.5",
86
86
  "fkill": "10.0.3",
87
87
  "solid-js": "1.9.19",
88
88
  "zod": "^4.6.7"
89
89
  },
90
90
  "overrides": {
91
- "zod": "^4.6.7"
91
+ "@opentui/core": "0.4.5",
92
+ "zod": "^4.6.7",
93
+ "brace-expansion@2": "^2.1.8"
92
94
  }
93
95
  }
package/src/tui/index.tsx CHANGED
@@ -1,16 +1,8 @@
1
1
  /** @jsxImportSource @opentui/solid */
2
2
 
3
3
  import type { TuiPlugin, TuiPluginModule } from '@opencode-ai/plugin/tui'
4
- import { ModalList } from './components/modal-list'
5
4
  import { createRpcClient } from './rpc-client'
6
-
7
- function errorMessage(error: unknown): string {
8
- if (error instanceof Error && error.message.trim().length > 0) {
9
- return error.message.trim()
10
- }
11
-
12
- return 'Unknown RPC error.'
13
- }
5
+ import { createStatusDialogs } from './status-dialogs'
14
6
 
15
7
  /**
16
8
  * Narrow structural interface for `api.keymap.registerLayer`. Mirrors the
@@ -28,6 +20,9 @@ interface KeymapRegisterLayerHost {
28
20
  name: string
29
21
  title: string
30
22
  category: string
23
+ slashName?: string
24
+ slashAliases?: ReadonlyArray<string>
25
+ desc?: string
31
26
  run: () => void
32
27
  }>
33
28
  bindings: ReadonlyArray<unknown>
@@ -53,8 +48,8 @@ function hasKeymapRegisterLayer(
53
48
  * back to `command.register` for hosts pinned at 1.14.41 or earlier.
54
49
  *
55
50
  * If neither surface is available, registration is a no-op and a warning
56
- * is logged. The TUI plugin still loads (dialog UI continues to work);
57
- * only the slash command discovery affordance is missing.
51
+ * is logged. The TUI plugin still loads; only the slash command discovery
52
+ * affordance is missing.
58
53
  *
59
54
  * Reference: Magic Context commit `5fe1c4f` on cortexkit/magic-context
60
55
  * established this dual-path pattern across the same upstream gap.
@@ -71,6 +66,8 @@ function registerCopilotStatusCommand(
71
66
  name: 'copilot-status',
72
67
  title: 'Copilot Status',
73
68
  category: 'Copilot',
69
+ slashName: 'copilot-status',
70
+ desc: 'Show running Copilot delegations',
74
71
  run() {
75
72
  openList()
76
73
  },
@@ -106,42 +103,14 @@ function registerCopilotStatusCommand(
106
103
 
107
104
  const tui: TuiPlugin = async (api) => {
108
105
  const rpc = createRpcClient()
109
- const closeDialog = () => {
110
- api.ui.dialog.clear()
111
- }
112
-
113
- const showUnavailableAlert = (error: unknown) => {
114
- api.ui.dialog.setSize('medium')
115
- api.ui.dialog.replace(() => {
116
- return (
117
- <api.ui.DialogAlert
118
- title="Status unavailable."
119
- message={errorMessage(error)}
120
- onConfirm={closeDialog}
121
- />
122
- )
123
- })
124
- }
125
-
126
- const openList = (initialTaskId?: string) => {
127
- api.ui.dialog.setSize('large')
128
- api.ui.dialog.replace(() => {
129
- return (
130
- <ModalList
131
- onClose={closeDialog}
132
- onLoadError={showUnavailableAlert}
133
- initialTaskId={initialTaskId}
134
- rpc={rpc}
135
- />
136
- )
137
- })
138
- }
106
+ const dialogs = createStatusDialogs(api, { rpc })
139
107
 
140
108
  const unregister = registerCopilotStatusCommand(api, () => {
141
- openList()
109
+ dialogs.openList()
142
110
  })
143
111
 
144
112
  api.lifecycle.onDispose(() => {
113
+ dialogs.dispose()
145
114
  rpc.dispose()
146
115
  unregister()
147
116
  })