vite-plugin-opencode-assistant 1.0.27 → 1.0.29
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/es/client/App.vue.js +64 -36
- package/es/client/composables/index.d.ts +10 -0
- package/es/client/composables/index.js +22 -0
- package/es/client/composables/useOpencodeSSE.d.ts +64 -0
- package/es/client/composables/useOpencodeSSE.js +29 -0
- package/es/client/composables/useOpencodeSessionSSE.d.ts +66 -0
- package/es/client/composables/useOpencodeSessionSSE.js +168 -0
- package/es/client/composables/useSSE.d.ts +85 -18
- package/es/client/composables/useSSE.js +101 -44
- package/es/client/composables/useServerSSE.d.ts +53 -0
- package/es/client/composables/useServerSSE.js +36 -0
- package/es/client/composables/useServiceStatus.d.ts +0 -2
- package/es/client/composables/useServiceStatus.js +1 -7
- package/es/client/composables/useSessions.d.ts +24 -5
- package/es/client/composables/useSessions.js +16 -2
- package/es/core/proxy-server.js +67 -159
- package/es/index.js +3 -1
- package/lib/client/App.vue.js +63 -35
- package/lib/client/composables/index.d.ts +10 -0
- package/lib/client/composables/index.js +54 -0
- package/lib/client/composables/useOpencodeSSE.d.ts +64 -0
- package/lib/client/composables/useOpencodeSSE.js +52 -0
- package/lib/client/composables/useOpencodeSessionSSE.d.ts +66 -0
- package/lib/client/composables/useOpencodeSessionSSE.js +187 -0
- package/lib/client/composables/useSSE.d.ts +85 -18
- package/lib/client/composables/useSSE.js +100 -43
- package/lib/client/composables/useServerSSE.d.ts +53 -0
- package/lib/client/composables/useServerSSE.js +59 -0
- package/lib/client/composables/useServiceStatus.d.ts +0 -2
- package/lib/client/composables/useServiceStatus.js +1 -7
- package/lib/client/composables/useSessions.d.ts +24 -5
- package/lib/client/composables/useSessions.js +16 -2
- package/lib/client.js +2823 -2566
- package/lib/core/proxy-server.js +67 -159
- package/lib/index.js +3 -1
- package/lib/style.css +1 -1
- package/package.json +4 -4
package/es/core/proxy-server.js
CHANGED
|
@@ -102,44 +102,61 @@ function generateBridgeScript(options) {
|
|
|
102
102
|
if (event.data && event.data.type === "OPENCODE_SET_THEME") {
|
|
103
103
|
setTheme(event.data.theme);
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
if (event.data && event.data.type === "OPENCODE_INSERT_FILE_PART") {
|
|
107
107
|
insertFilePart(event.data.element);
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
|
|
110
110
|
if (event.data && event.data.type === "minimize-state-change") {
|
|
111
111
|
handleMinimizeStateChange(event.data.minimized);
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
if (event.data && event.data.type === "prompt-dock-visibility-change") {
|
|
115
115
|
handlePromptDockVisibilityChange(event.data.visible);
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
+
// === \u6700\u5C0F\u5316\u72B6\u6001\u6837\u5F0F ===
|
|
120
|
+
const minimizeStyles = \`
|
|
121
|
+
.opencode-minimized [data-dock-surface="tray"]:not([data-slot="permission-footer"]) {
|
|
122
|
+
display: none !important;
|
|
123
|
+
}
|
|
124
|
+
.opencode-minimized [data-slot="session-turn-list"] {
|
|
125
|
+
padding-bottom: 10px !important;
|
|
126
|
+
}
|
|
127
|
+
.opencode-prompt-dock-hidden [data-component="session-prompt-dock"]:not(:has([data-kind="permission"])) {
|
|
128
|
+
display: none !important;
|
|
129
|
+
}
|
|
130
|
+
\`;
|
|
131
|
+
|
|
132
|
+
function injectMinimizeStyles() {
|
|
133
|
+
if (document.getElementById('opencode-minimize-styles')) return;
|
|
134
|
+
const style = document.createElement('style');
|
|
135
|
+
style.id = 'opencode-minimize-styles';
|
|
136
|
+
style.textContent = minimizeStyles;
|
|
137
|
+
document.head.appendChild(style);
|
|
138
|
+
}
|
|
139
|
+
|
|
119
140
|
// === \u6700\u5C0F\u5316\u72B6\u6001\u5904\u7406 ===
|
|
120
141
|
let savedMinimizedState = null;
|
|
121
142
|
let savedPromptDockVisibleState = null;
|
|
122
|
-
|
|
143
|
+
|
|
123
144
|
function handleMinimizeStateChange(minimized) {
|
|
124
145
|
savedMinimizedState = minimized;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
dockSurface.style.display = minimized ? 'none' : '';
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (sessionTurnList) {
|
|
133
|
-
sessionTurnList.style.paddingBottom = minimized ? '10px' : '';
|
|
146
|
+
if (minimized) {
|
|
147
|
+
document.documentElement.classList.add('opencode-minimized');
|
|
148
|
+
} else {
|
|
149
|
+
document.documentElement.classList.remove('opencode-minimized');
|
|
134
150
|
}
|
|
135
151
|
}
|
|
136
152
|
|
|
137
153
|
// === \u5BF9\u8BDD\u6846\u663E\u793A\u72B6\u6001\u5904\u7406 ===
|
|
138
154
|
function handlePromptDockVisibilityChange(visible) {
|
|
139
155
|
savedPromptDockVisibleState = visible;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
156
|
+
if (!visible) {
|
|
157
|
+
document.documentElement.classList.add('opencode-prompt-dock-hidden');
|
|
158
|
+
} else {
|
|
159
|
+
document.documentElement.classList.remove('opencode-prompt-dock-hidden');
|
|
143
160
|
}
|
|
144
161
|
}
|
|
145
162
|
|
|
@@ -155,11 +172,11 @@ function generateBridgeScript(options) {
|
|
|
155
172
|
|
|
156
173
|
// === \u4FDD\u5B58\u8F93\u5165\u6846\u5149\u6807\u4F4D\u7F6E ===
|
|
157
174
|
let savedRange = null;
|
|
158
|
-
|
|
175
|
+
|
|
159
176
|
function setupPromptInputListener() {
|
|
160
177
|
const promptInput = document.querySelector('[data-component="prompt-input"]');
|
|
161
178
|
if (!promptInput) return;
|
|
162
|
-
|
|
179
|
+
|
|
163
180
|
promptInput.addEventListener('blur', function() {
|
|
164
181
|
const selection = window.getSelection();
|
|
165
182
|
if (selection && selection.rangeCount > 0) {
|
|
@@ -169,7 +186,7 @@ function generateBridgeScript(options) {
|
|
|
169
186
|
}
|
|
170
187
|
}
|
|
171
188
|
});
|
|
172
|
-
|
|
189
|
+
|
|
173
190
|
promptInput.addEventListener('focus', function() {
|
|
174
191
|
savedRange = null;
|
|
175
192
|
});
|
|
@@ -195,29 +212,29 @@ function generateBridgeScript(options) {
|
|
|
195
212
|
|
|
196
213
|
const jsonStr = JSON.stringify({
|
|
197
214
|
nodeContext: {
|
|
198
|
-
"filePath": {
|
|
199
|
-
"value": filePath ?? '\u672A\u77E5',
|
|
200
|
-
"desc": "\u6E90\u7801\u6587\u4EF6\u8DEF\u5F84"
|
|
215
|
+
"filePath": {
|
|
216
|
+
"value": filePath ?? '\u672A\u77E5',
|
|
217
|
+
"desc": "\u6E90\u7801\u6587\u4EF6\u8DEF\u5F84"
|
|
201
218
|
},
|
|
202
|
-
"line": {
|
|
203
|
-
"value": line ?? '\u672A\u77E5',
|
|
204
|
-
"desc": "\u4EE3\u7801\u6240\u5728\u884C\u53F7"
|
|
219
|
+
"line": {
|
|
220
|
+
"value": line ?? '\u672A\u77E5',
|
|
221
|
+
"desc": "\u4EE3\u7801\u6240\u5728\u884C\u53F7"
|
|
205
222
|
},
|
|
206
|
-
"column": {
|
|
207
|
-
"value": column ?? '\u672A\u77E5',
|
|
208
|
-
"desc": "\u4EE3\u7801\u6240\u5728\u5217\u53F7"
|
|
223
|
+
"column": {
|
|
224
|
+
"value": column ?? '\u672A\u77E5',
|
|
225
|
+
"desc": "\u4EE3\u7801\u6240\u5728\u5217\u53F7"
|
|
209
226
|
},
|
|
210
|
-
"description": {
|
|
211
|
-
"value": description ?? '\u672A\u77E5',
|
|
212
|
-
"desc": "DOM \u5143\u7D20\u9009\u62E9\u5668"
|
|
227
|
+
"description": {
|
|
228
|
+
"value": description ?? '\u672A\u77E5',
|
|
229
|
+
"desc": "DOM \u5143\u7D20\u9009\u62E9\u5668"
|
|
213
230
|
},
|
|
214
|
-
"innerText": {
|
|
215
|
-
"value": innerText ? innerText.substring(0, 500) : '',
|
|
216
|
-
"desc": "DOM \u5143\u7D20\u5185\u90E8\u6587\u672C"
|
|
231
|
+
"innerText": {
|
|
232
|
+
"value": innerText ? innerText.substring(0, 500) : '',
|
|
233
|
+
"desc": "DOM \u5143\u7D20\u5185\u90E8\u6587\u672C"
|
|
217
234
|
},
|
|
218
|
-
"selectAt": {
|
|
219
|
-
"value": previewPageUrl || '\u672A\u77E5',
|
|
220
|
-
"desc": "\u7528\u6237\u9009\u4E2D\u8282\u70B9\u65F6\u7684\u9875\u9762 URL"
|
|
235
|
+
"selectAt": {
|
|
236
|
+
"value": previewPageUrl || '\u672A\u77E5',
|
|
237
|
+
"desc": "\u7528\u6237\u9009\u4E2D\u8282\u70B9\u65F6\u7684\u9875\u9762 URL"
|
|
221
238
|
}
|
|
222
239
|
}
|
|
223
240
|
});
|
|
@@ -226,30 +243,30 @@ function generateBridgeScript(options) {
|
|
|
226
243
|
span.setAttribute('data-type', 'file');
|
|
227
244
|
span.setAttribute('data-path', jsonStr);
|
|
228
245
|
span.setAttribute('contenteditable', 'false');
|
|
229
|
-
|
|
246
|
+
|
|
230
247
|
span.textContent = displayText;
|
|
231
248
|
|
|
232
249
|
if (savedRange) {
|
|
233
250
|
const range = savedRange;
|
|
234
251
|
range.collapse(false);
|
|
235
252
|
range.insertNode(span);
|
|
236
|
-
|
|
253
|
+
|
|
237
254
|
const space = document.createTextNode('\\u00A0');
|
|
238
255
|
span.parentNode.insertBefore(space, span.nextSibling);
|
|
239
|
-
|
|
256
|
+
|
|
240
257
|
const newRange = document.createRange();
|
|
241
258
|
newRange.setStartAfter(space);
|
|
242
259
|
newRange.collapse(true);
|
|
243
|
-
|
|
260
|
+
|
|
244
261
|
promptInput.focus();
|
|
245
|
-
|
|
262
|
+
|
|
246
263
|
const selection = window.getSelection();
|
|
247
264
|
if (selection) {
|
|
248
265
|
selection.removeAllRanges();
|
|
249
266
|
selection.addRange(newRange);
|
|
250
267
|
}
|
|
251
268
|
savedRange = null;
|
|
252
|
-
|
|
269
|
+
|
|
253
270
|
promptInput.dispatchEvent(new Event('input', { bubbles: true }));
|
|
254
271
|
return;
|
|
255
272
|
}
|
|
@@ -257,20 +274,20 @@ function generateBridgeScript(options) {
|
|
|
257
274
|
const selection = window.getSelection();
|
|
258
275
|
if (selection && selection.rangeCount > 0) {
|
|
259
276
|
const range = selection.getRangeAt(0);
|
|
260
|
-
|
|
277
|
+
|
|
261
278
|
if (promptInput.contains(range.commonAncestorContainer)) {
|
|
262
279
|
range.collapse(false);
|
|
263
280
|
range.insertNode(span);
|
|
264
|
-
|
|
281
|
+
|
|
265
282
|
const space = document.createTextNode('\\u00A0');
|
|
266
283
|
span.parentNode.insertBefore(space, span.nextSibling);
|
|
267
|
-
|
|
284
|
+
|
|
268
285
|
const newRange = document.createRange();
|
|
269
286
|
newRange.setStartAfter(space);
|
|
270
287
|
newRange.collapse(true);
|
|
271
288
|
selection.removeAllRanges();
|
|
272
289
|
selection.addRange(newRange);
|
|
273
|
-
|
|
290
|
+
|
|
274
291
|
promptInput.dispatchEvent(new Event('input', { bubbles: true }));
|
|
275
292
|
return;
|
|
276
293
|
}
|
|
@@ -279,7 +296,7 @@ function generateBridgeScript(options) {
|
|
|
279
296
|
promptInput.appendChild(span);
|
|
280
297
|
const space = document.createTextNode('\\u00A0');
|
|
281
298
|
promptInput.appendChild(space);
|
|
282
|
-
|
|
299
|
+
|
|
283
300
|
const newRange = document.createRange();
|
|
284
301
|
newRange.setStartAfter(space);
|
|
285
302
|
newRange.collapse(true);
|
|
@@ -288,119 +305,17 @@ function generateBridgeScript(options) {
|
|
|
288
305
|
newSelection.removeAllRanges();
|
|
289
306
|
newSelection.addRange(newRange);
|
|
290
307
|
}
|
|
291
|
-
|
|
308
|
+
|
|
292
309
|
promptInput.dispatchEvent(new Event('input', { bubbles: true }));
|
|
293
310
|
promptInput.focus();
|
|
294
311
|
}
|
|
295
312
|
|
|
296
|
-
// === \u601D\u8003\u72B6\u6001\u76D1\u542C (\u5B8C\u5168\u590D\u523B OpenCode Web \u5B9E\u73B0) ===
|
|
297
|
-
// OpenCode Web \u6838\u5FC3\u903B\u8F91:
|
|
298
|
-
// working = !!pending() || sessionStatus().type !== "idle"
|
|
299
|
-
// pending = \u6700\u540E\u4E00\u6761\u672A\u5B8C\u6210\u7684 assistant \u6D88\u606F (time.completed \u4E0D\u662F\u6570\u5B57)
|
|
300
|
-
// sessionStatus = sync.data.session_status[sessionID]
|
|
301
|
-
|
|
302
|
-
let eventSource = null;
|
|
303
|
-
const sessionStatus = {};
|
|
304
|
-
const pendingMessages = {};
|
|
305
|
-
|
|
306
|
-
function getCurrentSessionID() {
|
|
307
|
-
const match = window.location.pathname.match(/\\/session\\/([^\\/]+)/);
|
|
308
|
-
return match ? match[1] : null;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function isPending(message) {
|
|
312
|
-
return message.role === 'assistant' && typeof message.time?.completed !== 'number';
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function updateThinkingState(sessionID) {
|
|
316
|
-
const status = sessionStatus[sessionID];
|
|
317
|
-
const pending = pendingMessages[sessionID];
|
|
318
|
-
|
|
319
|
-
const isThinking = !!pending || (status && status.type !== 'idle');
|
|
320
|
-
|
|
321
|
-
if (window.parent !== window) {
|
|
322
|
-
window.parent.postMessage({
|
|
323
|
-
type: 'OPENCODE_THINKING_STATE',
|
|
324
|
-
thinking: isThinking,
|
|
325
|
-
sessionID: sessionID,
|
|
326
|
-
statusType: status?.type || 'idle',
|
|
327
|
-
hasPending: !!pending
|
|
328
|
-
}, '*');
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
function handleEvent(payload) {
|
|
333
|
-
const type = payload.type;
|
|
334
|
-
const props = payload.properties;
|
|
335
|
-
|
|
336
|
-
switch (type) {
|
|
337
|
-
case 'session.status': {
|
|
338
|
-
const sessionID = props.sessionID;
|
|
339
|
-
sessionStatus[sessionID] = props.status;
|
|
340
|
-
updateThinkingState(sessionID);
|
|
341
|
-
break;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
case 'message.updated': {
|
|
345
|
-
const info = props.info;
|
|
346
|
-
if (!info || !info.sessionID) break;
|
|
347
|
-
const sessionID = info.sessionID;
|
|
348
|
-
|
|
349
|
-
if (info.role === 'assistant') {
|
|
350
|
-
if (isPending(info)) {
|
|
351
|
-
pendingMessages[sessionID] = info;
|
|
352
|
-
} else {
|
|
353
|
-
delete pendingMessages[sessionID];
|
|
354
|
-
}
|
|
355
|
-
updateThinkingState(sessionID);
|
|
356
|
-
}
|
|
357
|
-
break;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
case 'message.part.delta': {
|
|
361
|
-
const sessionID = props.sessionID;
|
|
362
|
-
if (sessionID && !pendingMessages[sessionID]) {
|
|
363
|
-
pendingMessages[sessionID] = { role: 'assistant', time: {} };
|
|
364
|
-
updateThinkingState(sessionID);
|
|
365
|
-
}
|
|
366
|
-
break;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
function setupThinkingListener() {
|
|
372
|
-
if (eventSource) {
|
|
373
|
-
eventSource.close();
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
eventSource = new EventSource('/global/event');
|
|
377
|
-
|
|
378
|
-
eventSource.onmessage = function(event) {
|
|
379
|
-
try {
|
|
380
|
-
const data = JSON.parse(event.data);
|
|
381
|
-
const payload = data.payload;
|
|
382
|
-
if (!payload) return;
|
|
383
|
-
handleEvent(payload);
|
|
384
|
-
} catch (e) {
|
|
385
|
-
// ignore parse errors
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
eventSource.onerror = function(err) {
|
|
390
|
-
console.warn('[OpenCode Bridge] SSE connection error, retrying in 3s...');
|
|
391
|
-
eventSource.close();
|
|
392
|
-
setTimeout(setupThinkingListener, 3000);
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
console.log('[OpenCode Bridge] SSE listener setup complete');
|
|
396
|
-
}
|
|
397
|
-
|
|
398
313
|
// === \u5C31\u7EEA\u901A\u77E5 ===
|
|
399
314
|
function init() {
|
|
315
|
+
injectMinimizeStyles();
|
|
400
316
|
if (window.parent !== window) {
|
|
401
317
|
window.parent.postMessage({ type: "OPENCODE_READY" }, "*");
|
|
402
318
|
}
|
|
403
|
-
setupThinkingListener();
|
|
404
319
|
setupPromptInputListener();
|
|
405
320
|
applySavedStates();
|
|
406
321
|
|
|
@@ -426,13 +341,6 @@ function generateBridgeScript(options) {
|
|
|
426
341
|
} else {
|
|
427
342
|
init();
|
|
428
343
|
}
|
|
429
|
-
|
|
430
|
-
window.addEventListener('beforeunload', function() {
|
|
431
|
-
if (eventSource) {
|
|
432
|
-
eventSource.close();
|
|
433
|
-
eventSource = null;
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
344
|
})();
|
|
437
345
|
`;
|
|
438
346
|
}
|
package/es/index.js
CHANGED
|
@@ -175,7 +175,9 @@ function createOpenCodePlugin(options = {}) {
|
|
|
175
175
|
const widget = injectWidget({
|
|
176
176
|
theme: config.theme,
|
|
177
177
|
open: config.open,
|
|
178
|
-
hotkey: config.hotkey
|
|
178
|
+
hotkey: config.hotkey,
|
|
179
|
+
proxyPort: actualProxyPort,
|
|
180
|
+
proxyHost: config.hostname
|
|
179
181
|
});
|
|
180
182
|
timer.end();
|
|
181
183
|
return html.replace("</body>", `${widget}</body>`);
|
package/lib/client/App.vue.js
CHANGED
|
@@ -71,7 +71,8 @@ var import_vue = require("vue");
|
|
|
71
71
|
var import_vue2 = require("vue");
|
|
72
72
|
var import_components = require("@vite-plugin-opencode-assistant/components");
|
|
73
73
|
var import_useHotkey = require("./composables/useHotkey");
|
|
74
|
-
var
|
|
74
|
+
var import_useServerSSE = require("./composables/useServerSSE");
|
|
75
|
+
var import_useOpencodeSessionSSE = require("./composables/useOpencodeSessionSSE");
|
|
75
76
|
var import_useSessions = require("./composables/useSessions");
|
|
76
77
|
var import_useTheme = require("./composables/useTheme");
|
|
77
78
|
var import_useSelectedElements = require("./composables/useSelectedElements");
|
|
@@ -97,9 +98,14 @@ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
|
|
|
97
98
|
const {
|
|
98
99
|
theme: initialTheme = "auto",
|
|
99
100
|
open: autoOpen = false,
|
|
100
|
-
hotkey = "ctrl+k"
|
|
101
|
+
hotkey = "ctrl+k",
|
|
102
|
+
proxyPort = 4098,
|
|
103
|
+
proxyHost = "localhost"
|
|
101
104
|
} = props.config;
|
|
102
105
|
const widgetTheme = initialTheme;
|
|
106
|
+
const proxyBaseUrl = (0, import_vue2.computed)(() => {
|
|
107
|
+
return `http://${proxyHost}:${proxyPort}`;
|
|
108
|
+
});
|
|
103
109
|
const showNotification = (msg, options) => {
|
|
104
110
|
var _a, _b;
|
|
105
111
|
(_b = (_a = widgetRef.value) == null ? void 0 : _a.showNotification) == null ? void 0 : _b.call(_a, msg, options);
|
|
@@ -109,11 +115,9 @@ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
|
|
|
109
115
|
chromeMcpFailed,
|
|
110
116
|
chromeMcpErrorType,
|
|
111
117
|
chromeMcpErrorMessage,
|
|
112
|
-
thinking,
|
|
113
118
|
loadingText,
|
|
114
119
|
updateStatusFromTask,
|
|
115
|
-
setStarting
|
|
116
|
-
setThinking
|
|
120
|
+
setStarting
|
|
117
121
|
} = (0, import_useServiceStatus.useServiceStatus)();
|
|
118
122
|
const {
|
|
119
123
|
selectedElements,
|
|
@@ -133,13 +137,50 @@ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
|
|
|
133
137
|
loadSessions,
|
|
134
138
|
createSession,
|
|
135
139
|
deleteSession,
|
|
136
|
-
selectSession
|
|
137
|
-
|
|
140
|
+
selectSession,
|
|
141
|
+
updateSessionInfo
|
|
142
|
+
} = (0, import_useSessions.useSessions)({ showNotification });
|
|
138
143
|
const { updateContext } = (0, import_useContext.useContext)(serviceStatus, selectedElements);
|
|
144
|
+
const serverSSE = (0, import_useServerSSE.useServerSSE)({
|
|
145
|
+
onStatusSync: (data) => {
|
|
146
|
+
if (data.isStarted !== void 0 && data.isStarted && serviceStatus.value === "idle") {
|
|
147
|
+
setStarting();
|
|
148
|
+
}
|
|
149
|
+
if (data.task) {
|
|
150
|
+
updateStatusFromTask(data.task, data.errorType, data.errorMessage);
|
|
151
|
+
}
|
|
152
|
+
if (serviceStatus.value !== "idle") {
|
|
153
|
+
loadSessions();
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
onTaskUpdate: (data) => {
|
|
157
|
+
updateStatusFromTask(data.task, data.errorType, data.errorMessage);
|
|
158
|
+
},
|
|
159
|
+
onClearElements: () => clearElements(),
|
|
160
|
+
onConnected: () => updateContext(true)
|
|
161
|
+
});
|
|
162
|
+
const opencodeSSE = (0, import_useOpencodeSessionSSE.useOpencodeSessionSSE)({
|
|
163
|
+
proxyBaseUrl: proxyBaseUrl.value,
|
|
164
|
+
currentSessionId,
|
|
165
|
+
onConnected: () => {
|
|
166
|
+
console.log("[OpenCode] Session SSE connected");
|
|
167
|
+
},
|
|
168
|
+
onSessionUpdate: (session) => {
|
|
169
|
+
updateSessionInfo(session);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const thinking = opencodeSSE.hasAnyThinking;
|
|
173
|
+
const sessionStates = opencodeSSE.sessionStates;
|
|
139
174
|
const showSessionListSkeleton = (0, import_vue2.computed)(() => serviceStatus.value === "starting");
|
|
140
175
|
const computedLoading = (0, import_vue2.computed)(() => {
|
|
141
176
|
return serviceStatus.value === "starting" || iframeLoading.value;
|
|
142
177
|
});
|
|
178
|
+
const displayLoadingText = (0, import_vue2.computed)(() => {
|
|
179
|
+
if (serviceStatus.value === "starting") {
|
|
180
|
+
return loadingText.value;
|
|
181
|
+
}
|
|
182
|
+
return "\u52A0\u8F7D\u4F1A\u8BDD...";
|
|
183
|
+
});
|
|
143
184
|
const retryWarmup = () => __async(null, null, function* () {
|
|
144
185
|
retryingWarmup.value = true;
|
|
145
186
|
try {
|
|
@@ -167,24 +208,6 @@ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
|
|
|
167
208
|
retryingWarmup.value = false;
|
|
168
209
|
}
|
|
169
210
|
});
|
|
170
|
-
const { setupSSE } = (0, import_useSSE.useSSE)(
|
|
171
|
-
(data) => {
|
|
172
|
-
if (data.isStarted !== void 0 && data.isStarted && serviceStatus.value === "idle") {
|
|
173
|
-
setStarting();
|
|
174
|
-
}
|
|
175
|
-
if (data.task) {
|
|
176
|
-
updateStatusFromTask(data.task, data.errorType, data.errorMessage);
|
|
177
|
-
}
|
|
178
|
-
if (serviceStatus.value !== "idle") {
|
|
179
|
-
loadSessions();
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
(data) => {
|
|
183
|
-
updateStatusFromTask(data.task, data.errorType, data.errorMessage);
|
|
184
|
-
},
|
|
185
|
-
() => clearElements(),
|
|
186
|
-
() => updateContext(true)
|
|
187
|
-
);
|
|
188
211
|
const ensureServicesStarted = () => __async(null, null, function* () {
|
|
189
212
|
if (serviceStatus.value !== "idle") return true;
|
|
190
213
|
try {
|
|
@@ -192,7 +215,7 @@ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
|
|
|
192
215
|
const data = yield res.json();
|
|
193
216
|
if (data.success) {
|
|
194
217
|
setStarting();
|
|
195
|
-
|
|
218
|
+
serverSSE.connect();
|
|
196
219
|
return true;
|
|
197
220
|
}
|
|
198
221
|
} catch (e) {
|
|
@@ -212,10 +235,17 @@ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
|
|
|
212
235
|
showNotification("Vue Inspector \u672A\u52A0\u8F7D\uFF0C\u65E0\u6CD5\u4F7F\u7528\u5143\u7D20\u9009\u62E9\u529F\u80FD");
|
|
213
236
|
}
|
|
214
237
|
});
|
|
238
|
+
(0, import_vue2.watch)(serviceStatus, (status, oldStatus) => {
|
|
239
|
+
if (status !== "idle" && oldStatus === "idle") {
|
|
240
|
+
serverSSE.connect();
|
|
241
|
+
opencodeSSE.connect();
|
|
242
|
+
}
|
|
243
|
+
});
|
|
215
244
|
(0, import_vue2.onMounted)(() => {
|
|
216
245
|
if (serviceStatus.value !== "idle") {
|
|
217
246
|
loadSessions();
|
|
218
|
-
|
|
247
|
+
serverSSE.connect();
|
|
248
|
+
opencodeSSE.connect();
|
|
219
249
|
updateContext(true);
|
|
220
250
|
}
|
|
221
251
|
if (autoOpen && serviceStatus.value !== "idle") {
|
|
@@ -224,11 +254,8 @@ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
|
|
|
224
254
|
}, 1e3);
|
|
225
255
|
}
|
|
226
256
|
const handleIframeMessage = (event) => {
|
|
227
|
-
var _a
|
|
228
|
-
if (((_a = event.data) == null ? void 0 : _a.type) === "
|
|
229
|
-
setThinking(event.data.thinking);
|
|
230
|
-
}
|
|
231
|
-
if (((_b = event.data) == null ? void 0 : _b.type) === "OPENCODE_READY") {
|
|
257
|
+
var _a;
|
|
258
|
+
if (((_a = event.data) == null ? void 0 : _a.type) === "OPENCODE_READY") {
|
|
232
259
|
sendThemeToIframe();
|
|
233
260
|
}
|
|
234
261
|
};
|
|
@@ -283,7 +310,7 @@ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
|
|
|
283
310
|
const handleFrameLoaded = () => {
|
|
284
311
|
iframeLoading.value = false;
|
|
285
312
|
};
|
|
286
|
-
const __returned__ = { props, open, selectMode, sessionListCollapsed, loading, widgetRef, retryingWarmup, initialTheme, autoOpen, hotkey, widgetTheme, showNotification, serviceStatus, chromeMcpFailed, chromeMcpErrorType, chromeMcpErrorMessage,
|
|
313
|
+
const __returned__ = { props, open, selectMode, sessionListCollapsed, loading, widgetRef, retryingWarmup, initialTheme, autoOpen, hotkey, proxyPort, proxyHost, widgetTheme, proxyBaseUrl, showNotification, serviceStatus, chromeMcpFailed, chromeMcpErrorType, chromeMcpErrorMessage, loadingText, updateStatusFromTask, setStarting, selectedElements, removeElement, clearElements, theme, sendThemeToIframe, sessions, loadingSessionList, currentSessionId, iframeSrc, iframeLoading, loadSessions, createSession, deleteSession, selectSession, updateSessionInfo, updateContext, serverSSE, opencodeSSE, thinking, sessionStates, showSessionListSkeleton, computedLoading, displayLoadingText, retryWarmup, ensureServicesStarted, handleToggle, handleSelectNode, handleClearSelected, handleSelectModeChange, handleSessionListCollapsedChange, handleThemeChange, handleRemoveSelectedNode, handleFrameLoaded, get OpenCodeWidget() {
|
|
287
314
|
return import_components.OpenCodeWidget;
|
|
288
315
|
}, LoadingContent: import_LoadingContent_vue.default, ChromeWarmupError: import_ChromeWarmupError_vue.default };
|
|
289
316
|
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
@@ -304,6 +331,7 @@ function __vue_render__(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
304
331
|
"iframe-src": $setup.iframeSrc,
|
|
305
332
|
"current-session-id": $setup.currentSessionId,
|
|
306
333
|
sessions: $setup.sessions,
|
|
334
|
+
"session-states": $setup.sessionStates,
|
|
307
335
|
"session-key": "id",
|
|
308
336
|
"hotkey-label": $setup.hotkey,
|
|
309
337
|
thinking: $setup.thinking,
|
|
@@ -322,7 +350,7 @@ function __vue_render__(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
322
350
|
onFrameLoaded: $setup.handleFrameLoaded
|
|
323
351
|
}, {
|
|
324
352
|
loading: (0, import_vue3.withCtx)(() => [
|
|
325
|
-
(0, import_vue3.createVNode)($setup["LoadingContent"], { "loading-text": $setup.
|
|
353
|
+
(0, import_vue3.createVNode)($setup["LoadingContent"], { "loading-text": $setup.displayLoadingText }, null, 8, ["loading-text"])
|
|
326
354
|
]),
|
|
327
355
|
error: (0, import_vue3.withCtx)(() => [
|
|
328
356
|
$setup.chromeMcpFailed ? ((0, import_vue3.openBlock)(), (0, import_vue3.createBlock)($setup["ChromeWarmupError"], {
|
|
@@ -335,7 +363,7 @@ function __vue_render__(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
335
363
|
]),
|
|
336
364
|
_: 1
|
|
337
365
|
/* STABLE */
|
|
338
|
-
}, 8, ["theme", "open", "select-mode", "session-list-collapsed", "frame-loading", "loading-session-list", "show-session-list-skeleton", "show-error", "iframe-src", "current-session-id", "sessions", "hotkey-label", "thinking", "onCreateSession", "onDeleteSession", "onSelectSession", "onEmptyAction"]);
|
|
366
|
+
}, 8, ["theme", "open", "select-mode", "session-list-collapsed", "frame-loading", "loading-session-list", "show-session-list-skeleton", "show-error", "iframe-src", "current-session-id", "sessions", "session-states", "hotkey-label", "thinking", "onCreateSession", "onDeleteSession", "onSelectSession", "onEmptyAction"]);
|
|
339
367
|
}
|
|
340
368
|
__vue_sfc__.render = __vue_render__;
|
|
341
369
|
var App_vue_default = __vue_sfc__;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { useSSE } from "./useSSE";
|
|
2
|
+
export { useServerSSE } from "./useServerSSE";
|
|
3
|
+
export { useOpencodeSSE } from "./useOpencodeSSE";
|
|
4
|
+
export { useOpencodeSessionSSE } from "./useOpencodeSessionSSE";
|
|
5
|
+
export { useHotkey } from "./useHotkey";
|
|
6
|
+
export { useSessions } from "./useSessions";
|
|
7
|
+
export { useTheme } from "./useTheme";
|
|
8
|
+
export { useSelectedElements } from "./useSelectedElements";
|
|
9
|
+
export { useServiceStatus } from "./useServiceStatus";
|
|
10
|
+
export { useContext } from "./useContext";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var composables_exports = {};
|
|
19
|
+
__export(composables_exports, {
|
|
20
|
+
useContext: () => import_useContext.useContext,
|
|
21
|
+
useHotkey: () => import_useHotkey.useHotkey,
|
|
22
|
+
useOpencodeSSE: () => import_useOpencodeSSE.useOpencodeSSE,
|
|
23
|
+
useOpencodeSessionSSE: () => import_useOpencodeSessionSSE.useOpencodeSessionSSE,
|
|
24
|
+
useSSE: () => import_useSSE.useSSE,
|
|
25
|
+
useSelectedElements: () => import_useSelectedElements.useSelectedElements,
|
|
26
|
+
useServerSSE: () => import_useServerSSE.useServerSSE,
|
|
27
|
+
useServiceStatus: () => import_useServiceStatus.useServiceStatus,
|
|
28
|
+
useSessions: () => import_useSessions.useSessions,
|
|
29
|
+
useTheme: () => import_useTheme.useTheme
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(composables_exports);
|
|
32
|
+
var import_useSSE = require("./useSSE");
|
|
33
|
+
var import_useServerSSE = require("./useServerSSE");
|
|
34
|
+
var import_useOpencodeSSE = require("./useOpencodeSSE");
|
|
35
|
+
var import_useOpencodeSessionSSE = require("./useOpencodeSessionSSE");
|
|
36
|
+
var import_useHotkey = require("./useHotkey");
|
|
37
|
+
var import_useSessions = require("./useSessions");
|
|
38
|
+
var import_useTheme = require("./useTheme");
|
|
39
|
+
var import_useSelectedElements = require("./useSelectedElements");
|
|
40
|
+
var import_useServiceStatus = require("./useServiceStatus");
|
|
41
|
+
var import_useContext = require("./useContext");
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
useContext,
|
|
45
|
+
useHotkey,
|
|
46
|
+
useOpencodeSSE,
|
|
47
|
+
useOpencodeSessionSSE,
|
|
48
|
+
useSSE,
|
|
49
|
+
useSelectedElements,
|
|
50
|
+
useServerSSE,
|
|
51
|
+
useServiceStatus,
|
|
52
|
+
useSessions,
|
|
53
|
+
useTheme
|
|
54
|
+
});
|