vite-plugin-opencode-assistant 1.0.40 → 1.0.42

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.
@@ -115,9 +115,6 @@ const __vue_sfc__ = /* @__PURE__ */ _defineComponent({
115
115
  if (data.task) {
116
116
  updateStatusFromTask(data.task, data.errorType, data.errorMessage);
117
117
  }
118
- if (serviceStatus.value !== "idle") {
119
- loadSessions();
120
- }
121
118
  },
122
119
  onTaskUpdate: (data) => {
123
120
  updateStatusFromTask(data.task, data.errorType, data.errorMessage);
@@ -154,9 +151,13 @@ const __vue_sfc__ = /* @__PURE__ */ _defineComponent({
154
151
  const data = yield res.json();
155
152
  if (data.success) {
156
153
  chromeMcpFailed.value = false;
154
+ chromeMcpErrorType.value = void 0;
155
+ chromeMcpErrorMessage.value = void 0;
157
156
  serviceStatus.value = "ready";
158
157
  showNotification("Chrome DevTools MCP \u8FDE\u63A5\u6210\u529F");
159
158
  } else {
159
+ chromeMcpErrorType.value = data.errorType;
160
+ chromeMcpErrorMessage.value = data.error;
160
161
  if (data.errorType === "AI_TIMEOUT") {
161
162
  showNotification("AI \u54CD\u5E94\u8D85\u65F6\uFF0C\u8BF7\u68C0\u67E5 OpenCode AI \u6A21\u578B\u914D\u7F6E");
162
163
  } else if (data.errorType === "AI_RESPONSE_ERROR") {
@@ -192,20 +193,26 @@ const __vue_sfc__ = /* @__PURE__ */ _defineComponent({
192
193
  e.preventDefault();
193
194
  handleToggle(!open.value);
194
195
  });
195
- useHotkey("ctrl+p", (e) => {
196
- e.preventDefault();
196
+ const toggleSelectMode = () => {
197
197
  const win = window;
198
198
  if (win.__VUE_INSPECTOR__) {
199
- selectMode.value = !selectMode.value;
199
+ handleSelectModeChange(!selectMode.value);
200
200
  } else {
201
201
  showNotification("Vue Inspector \u672A\u52A0\u8F7D\uFF0C\u65E0\u6CD5\u4F7F\u7528\u5143\u7D20\u9009\u62E9\u529F\u80FD");
202
202
  }
203
+ };
204
+ useHotkey("ctrl+p", (e) => {
205
+ e.preventDefault();
206
+ toggleSelectMode();
203
207
  });
204
208
  watch(serviceStatus, (status, oldStatus) => {
205
209
  if (status !== "idle" && oldStatus === "idle") {
206
210
  serverSSE.connect();
207
211
  opencodeSSE.connect();
208
212
  }
213
+ if (status === "ready" && oldStatus !== "ready") {
214
+ loadSessions();
215
+ }
209
216
  });
210
217
  onMounted(() => {
211
218
  if (serviceStatus.value === "ready") {
@@ -220,10 +227,18 @@ const __vue_sfc__ = /* @__PURE__ */ _defineComponent({
220
227
  }, 1e3);
221
228
  }
222
229
  const handleIframeMessage = (event) => {
223
- var _a2;
230
+ var _a2, _b;
224
231
  if (((_a2 = event.data) == null ? void 0 : _a2.type) === "OPENCODE_READY") {
225
232
  sendThemeToIframe();
226
233
  }
234
+ if (((_b = event.data) == null ? void 0 : _b.type) === "OPENCODE_KEYDOWN") {
235
+ if (event.data.key === "Escape" && selectMode.value) {
236
+ handleSelectModeChange(false);
237
+ }
238
+ if (event.data.ctrlKey && event.data.key.toLowerCase() === "p") {
239
+ toggleSelectMode();
240
+ }
241
+ }
227
242
  };
228
243
  window.addEventListener("message", handleIframeMessage);
229
244
  });
@@ -260,7 +275,12 @@ const __vue_sfc__ = /* @__PURE__ */ _defineComponent({
260
275
  showNotification("\u5DF2\u6E05\u9664\u6240\u6709\u9009\u4E2D\u5143\u7D20");
261
276
  };
262
277
  const handleSelectModeChange = (val) => {
278
+ var _a2;
263
279
  selectMode.value = val;
280
+ const isSplit = (_a2 = widgetRef.value) == null ? void 0 : _a2.isSplitMode;
281
+ if (val && !isSplit && open.value) {
282
+ open.value = false;
283
+ }
264
284
  if (!val && !open.value) {
265
285
  open.value = true;
266
286
  }
@@ -281,7 +301,7 @@ const __vue_sfc__ = /* @__PURE__ */ _defineComponent({
281
301
  const handleFrameLoaded = () => {
282
302
  iframeLoading.value = false;
283
303
  };
284
- const __returned__ = { props, open, selectMode, sessionListCollapsed, loading, widgetRef, retryingWarmup, initialTheme, autoOpen, hotkey, proxyPort, proxyHost, displayMode, splitMode, widgetTheme, splitPanelWidth, 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, handleSplitPanelWidthChange, handleRemoveSelectedNode, handleFrameLoaded, get OpenCodeWidget() {
304
+ const __returned__ = { props, open, selectMode, sessionListCollapsed, loading, widgetRef, retryingWarmup, initialTheme, autoOpen, hotkey, proxyPort, proxyHost, displayMode, splitMode, widgetTheme, splitPanelWidth, 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, toggleSelectMode, handleToggle, handleSelectNode, handleClearSelected, handleSelectModeChange, handleSessionListCollapsedChange, handleThemeChange, handleSplitPanelWidthChange, handleRemoveSelectedNode, handleFrameLoaded, get OpenCodeWidget() {
285
305
  return OpenCodeWidget;
286
306
  }, LoadingContent, ChromeWarmupError };
287
307
  Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
@@ -1 +1 @@
1
- .opencode-chrome-warmup-error-details[data-v-798041da]{margin-top:8px;padding:12px;background:var(--oc-bg-tertiary);border-radius:6px;font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:12px;color:var(--oc-text-secondary);max-height:120px;overflow-y:auto;word-break:break-word}
1
+ .opencode-chrome-warmup-error-details[data-v-13778a4c]{margin-top:8px;padding:12px;background:var(--oc-bg-tertiary);border-radius:6px;font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:12px;color:var(--oc-text-secondary);max-height:120px;overflow-y:auto;word-break:break-word}
@@ -189,7 +189,7 @@ function __vue_render__(_ctx, _cache, $props, $setup, $data, $options) {
189
189
  ]);
190
190
  }
191
191
  __vue_sfc__.render = __vue_render__;
192
- __vue_sfc__.__scopeId = "data-v-798041da";
192
+ __vue_sfc__.__scopeId = "data-v-13778a4c";
193
193
  var ChromeWarmupError_vue_default = __vue_sfc__;
194
194
  export {
195
195
  ChromeWarmupError_vue_default as default
@@ -4,7 +4,7 @@ function parseHotkey(hotkeyStr) {
4
4
  const parts = hotkeyStr.toLowerCase().split("+");
5
5
  const key = parts.pop();
6
6
  return {
7
- ctrl: parts.includes("ctrl") || parts.includes("cmd") || parts.includes("meta"),
7
+ ctrl: parts.includes("ctrl") || parts.includes("meta"),
8
8
  shift: parts.includes("shift"),
9
9
  alt: parts.includes("alt"),
10
10
  key: key || "k"
package/es/core/api.js CHANGED
@@ -122,7 +122,7 @@ class OpenCodeAPI {
122
122
  path: `/session?directory=${encodeURIComponent(projectDir)}`
123
123
  });
124
124
  const sessionsWithUrl = sessions.map((s) => __spreadProps(__spreadValues({}, s), {
125
- url: `http://${this.hostname}:${this.getProxyPort()}/${base64Encode(s.directory)}/session/${s.id}`
125
+ url: s.directory ? `http://${this.hostname}:${this.getProxyPort()}/${base64Encode(s.directory)}/session/${s.id}` : ""
126
126
  }));
127
127
  timer.end(`Found ${sessions.length} sessions`);
128
128
  return sessionsWithUrl;
@@ -116,6 +116,22 @@ function generateBridgeScript(options) {
116
116
  }
117
117
  });
118
118
 
119
+ // === \u952E\u76D8\u4E8B\u4EF6\u8F6C\u53D1\uFF08\u7528\u4E8E\u9000\u51FA\u9009\u62E9\u6A21\u5F0F\uFF09 ===
120
+ window.addEventListener("keydown", function(event) {
121
+ if (event.key === "Escape" || (event.ctrlKey && event.key.toLowerCase() === "p")) {
122
+ if (window.parent !== window) {
123
+ window.parent.postMessage({
124
+ type: "OPENCODE_KEYDOWN",
125
+ key: event.key,
126
+ ctrlKey: event.ctrlKey,
127
+ metaKey: event.metaKey,
128
+ shiftKey: event.shiftKey,
129
+ altKey: event.altKey
130
+ }, "*");
131
+ }
132
+ }
133
+ }, true);
134
+
119
135
  // === \u6700\u5C0F\u5316\u72B6\u6001\u6837\u5F0F ===
120
136
  const minimizeStyles = \`
121
137
  .opencode-minimized [data-dock-surface="tray"]:not([data-slot="permission-footer"]) {
@@ -214,7 +214,7 @@ Please install OpenCode first:
214
214
  } catch (err) {
215
215
  const nodeErr = err;
216
216
  if (nodeErr.code === "EADDRINUSE") {
217
- log.warn(`Proxy port ${this.actualProxyPort} became unavailable, trying next port...`);
217
+ log.debug(`Proxy port ${this.actualProxyPort} became unavailable, trying next port...`);
218
218
  const nextPort = yield findAvailablePort(this.actualProxyPort + 1, this.config.hostname);
219
219
  const result = yield startProxyServer(webUrl, nextPort, {
220
220
  theme: this.config.theme,
@@ -224,7 +224,7 @@ Please install OpenCode first:
224
224
  this.proxyServer = result.server;
225
225
  this.actualProxyPort = result.actualPort;
226
226
  this.onProxyPortAllocated(this.actualProxyPort);
227
- log.info(`Proxy server started on fallback port ${this.actualProxyPort}`);
227
+ log.debug(`Proxy server started on fallback port ${this.actualProxyPort}`);
228
228
  } else {
229
229
  throw err;
230
230
  }
@@ -248,12 +248,12 @@ Please install OpenCode first:
248
248
  }
249
249
  }
250
250
  this.sendTaskUpdate("creating_session");
251
+ this.isStarted = true;
251
252
  if (warmupFailed) {
252
253
  this.sendTaskUpdate("chrome_mcp_failed", {
253
254
  errorType: this.chromeMcpWarmupErrorType,
254
255
  errorMessage: this.chromeMcpWarmupErrorMessage
255
256
  });
256
- this.isStarted = true;
257
257
  } else {
258
258
  this.sendTaskUpdate("ready");
259
259
  }
@@ -41,9 +41,11 @@ function setupSseEndpoint(server, ctx) {
41
41
  }
42
42
  if (ctx.currentTask) {
43
43
  statusPayload.task = ctx.currentTask.task;
44
- if (ctx.currentTask.data) {
45
- Object.assign(statusPayload, ctx.currentTask.data);
46
- }
44
+ Object.keys(ctx.currentTask).forEach((key) => {
45
+ if (key !== "task") {
46
+ statusPayload[key] = ctx.currentTask[key];
47
+ }
48
+ });
47
49
  }
48
50
  res.write(`data: ${JSON.stringify(statusPayload)}
49
51
 
@@ -146,9 +146,6 @@ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
146
146
  if (data.task) {
147
147
  updateStatusFromTask(data.task, data.errorType, data.errorMessage);
148
148
  }
149
- if (serviceStatus.value !== "idle") {
150
- loadSessions();
151
- }
152
149
  },
153
150
  onTaskUpdate: (data) => {
154
151
  updateStatusFromTask(data.task, data.errorType, data.errorMessage);
@@ -185,9 +182,13 @@ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
185
182
  const data = yield res.json();
186
183
  if (data.success) {
187
184
  chromeMcpFailed.value = false;
185
+ chromeMcpErrorType.value = void 0;
186
+ chromeMcpErrorMessage.value = void 0;
188
187
  serviceStatus.value = "ready";
189
188
  showNotification("Chrome DevTools MCP \u8FDE\u63A5\u6210\u529F");
190
189
  } else {
190
+ chromeMcpErrorType.value = data.errorType;
191
+ chromeMcpErrorMessage.value = data.error;
191
192
  if (data.errorType === "AI_TIMEOUT") {
192
193
  showNotification("AI \u54CD\u5E94\u8D85\u65F6\uFF0C\u8BF7\u68C0\u67E5 OpenCode AI \u6A21\u578B\u914D\u7F6E");
193
194
  } else if (data.errorType === "AI_RESPONSE_ERROR") {
@@ -223,20 +224,26 @@ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
223
224
  e.preventDefault();
224
225
  handleToggle(!open.value);
225
226
  });
226
- (0, import_useHotkey.useHotkey)("ctrl+p", (e) => {
227
- e.preventDefault();
227
+ const toggleSelectMode = () => {
228
228
  const win = window;
229
229
  if (win.__VUE_INSPECTOR__) {
230
- selectMode.value = !selectMode.value;
230
+ handleSelectModeChange(!selectMode.value);
231
231
  } else {
232
232
  showNotification("Vue Inspector \u672A\u52A0\u8F7D\uFF0C\u65E0\u6CD5\u4F7F\u7528\u5143\u7D20\u9009\u62E9\u529F\u80FD");
233
233
  }
234
+ };
235
+ (0, import_useHotkey.useHotkey)("ctrl+p", (e) => {
236
+ e.preventDefault();
237
+ toggleSelectMode();
234
238
  });
235
239
  (0, import_vue2.watch)(serviceStatus, (status, oldStatus) => {
236
240
  if (status !== "idle" && oldStatus === "idle") {
237
241
  serverSSE.connect();
238
242
  opencodeSSE.connect();
239
243
  }
244
+ if (status === "ready" && oldStatus !== "ready") {
245
+ loadSessions();
246
+ }
240
247
  });
241
248
  (0, import_vue2.onMounted)(() => {
242
249
  if (serviceStatus.value === "ready") {
@@ -251,10 +258,18 @@ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
251
258
  }, 1e3);
252
259
  }
253
260
  const handleIframeMessage = (event) => {
254
- var _a2;
261
+ var _a2, _b;
255
262
  if (((_a2 = event.data) == null ? void 0 : _a2.type) === "OPENCODE_READY") {
256
263
  sendThemeToIframe();
257
264
  }
265
+ if (((_b = event.data) == null ? void 0 : _b.type) === "OPENCODE_KEYDOWN") {
266
+ if (event.data.key === "Escape" && selectMode.value) {
267
+ handleSelectModeChange(false);
268
+ }
269
+ if (event.data.ctrlKey && event.data.key.toLowerCase() === "p") {
270
+ toggleSelectMode();
271
+ }
272
+ }
258
273
  };
259
274
  window.addEventListener("message", handleIframeMessage);
260
275
  });
@@ -291,7 +306,12 @@ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
291
306
  showNotification("\u5DF2\u6E05\u9664\u6240\u6709\u9009\u4E2D\u5143\u7D20");
292
307
  };
293
308
  const handleSelectModeChange = (val) => {
309
+ var _a2;
294
310
  selectMode.value = val;
311
+ const isSplit = (_a2 = widgetRef.value) == null ? void 0 : _a2.isSplitMode;
312
+ if (val && !isSplit && open.value) {
313
+ open.value = false;
314
+ }
295
315
  if (!val && !open.value) {
296
316
  open.value = true;
297
317
  }
@@ -312,7 +332,7 @@ const __vue_sfc__ = /* @__PURE__ */ (0, import_vue.defineComponent)({
312
332
  const handleFrameLoaded = () => {
313
333
  iframeLoading.value = false;
314
334
  };
315
- const __returned__ = { props, open, selectMode, sessionListCollapsed, loading, widgetRef, retryingWarmup, initialTheme, autoOpen, hotkey, proxyPort, proxyHost, displayMode, splitMode, widgetTheme, splitPanelWidth, 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, handleSplitPanelWidthChange, handleRemoveSelectedNode, handleFrameLoaded, get OpenCodeWidget() {
335
+ const __returned__ = { props, open, selectMode, sessionListCollapsed, loading, widgetRef, retryingWarmup, initialTheme, autoOpen, hotkey, proxyPort, proxyHost, displayMode, splitMode, widgetTheme, splitPanelWidth, 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, toggleSelectMode, handleToggle, handleSelectNode, handleClearSelected, handleSelectModeChange, handleSessionListCollapsedChange, handleThemeChange, handleSplitPanelWidthChange, handleRemoveSelectedNode, handleFrameLoaded, get OpenCodeWidget() {
316
336
  return import_components.OpenCodeWidget;
317
337
  }, LoadingContent: import_LoadingContent_vue.default, ChromeWarmupError: import_ChromeWarmupError_vue.default };
318
338
  Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
@@ -1 +1 @@
1
- .opencode-chrome-warmup-error-details[data-v-798041da]{margin-top:8px;padding:12px;background:var(--oc-bg-tertiary);border-radius:6px;font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:12px;color:var(--oc-text-secondary);max-height:120px;overflow-y:auto;word-break:break-word}
1
+ .opencode-chrome-warmup-error-details[data-v-13778a4c]{margin-top:8px;padding:12px;background:var(--oc-bg-tertiary);border-radius:6px;font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:12px;color:var(--oc-text-secondary);max-height:120px;overflow-y:auto;word-break:break-word}
@@ -211,5 +211,5 @@ function __vue_render__(_ctx, _cache, $props, $setup, $data, $options) {
211
211
  ]);
212
212
  }
213
213
  __vue_sfc__.render = __vue_render__;
214
- __vue_sfc__.__scopeId = "data-v-798041da";
214
+ __vue_sfc__.__scopeId = "data-v-13778a4c";
215
215
  var ChromeWarmupError_vue_default = __vue_sfc__;
@@ -28,7 +28,7 @@ function parseHotkey(hotkeyStr) {
28
28
  const parts = hotkeyStr.toLowerCase().split("+");
29
29
  const key = parts.pop();
30
30
  return {
31
- ctrl: parts.includes("ctrl") || parts.includes("cmd") || parts.includes("meta"),
31
+ ctrl: parts.includes("ctrl") || parts.includes("meta"),
32
32
  shift: parts.includes("shift"),
33
33
  alt: parts.includes("alt"),
34
34
  key: key || "k"