zcode-pro 1.6.2 → 1.8.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/inject.js CHANGED
@@ -109,8 +109,8 @@
109
109
  }
110
110
  return res.error || "";
111
111
  }
112
- function h(tag, attrs, ...children) {
113
- const el = document.createElement(tag);
112
+ function h(tag2, attrs, ...children) {
113
+ const el = document.createElement(tag2);
114
114
  if (attrs) {
115
115
  for (const [k, v] of Object.entries(attrs)) {
116
116
  if (k === "class") el.className = v;
@@ -185,23 +185,29 @@
185
185
  switchAttention: "r"
186
186
  // 打开运行中 / 未查看
187
187
  };
188
- STATUS_SESSION_IDS = /* @__PURE__ */ new Set(["ctx", "questions", "tokRate"]);
188
+ STATUS_SESSION_IDS = /* @__PURE__ */ new Set(["ctx", "questions", "tokRate", "inOut", "avgHit"]);
189
189
  STATUS_GLOBAL_IDS = /* @__PURE__ */ new Set(["todayTokens", "totalTokens", "tasks"]);
190
190
  DEFAULT_TURN_ITEMS = [
191
191
  { id: "turnIn", on: true },
192
192
  // 输入
193
193
  { id: "turnOut", on: true },
194
194
  // 输出
195
+ { id: "turnTps", on: true },
196
+ // TPS(输出 ÷ 净生成秒数,官方口径)
195
197
  { id: "turnCache", on: true }
196
198
  // 缓存命中率
197
199
  ];
198
200
  DEFAULT_STATUS_ITEMS = [
199
201
  { id: "tokRate", on: true },
200
202
  // 最近输出 tokens/s(60 秒窗口,本会话)
203
+ { id: "avgHit", on: true },
204
+ // 平均缓存命中率(本会话)
205
+ { id: "inOut", on: true },
206
+ // 累计输入/输出(本会话主轮请求)
201
207
  { id: "ctx", on: true },
202
208
  // 上下文占用
203
209
  { id: "questions", on: true },
204
- // 提问次数
210
+ // 主请求数(官方 model_usage 口径)
205
211
  { id: "todayTokens", on: true },
206
212
  // 今日 token(今天的会话记录完整,数据准确)
207
213
  { id: "totalTokens", on: true },
@@ -259,7 +265,7 @@
259
265
  proxyPlaceholder: "http://127.0.0.1:7890",
260
266
  proxySave: "\u4FDD\u5B58",
261
267
  proxySaved: "\u4EE3\u7406\u8BBE\u7F6E\u5DF2\u4FDD\u5B58",
262
- proxyHint: "\u7559\u7A7A\u4FDD\u5B58\u5373\u6E05\u9664\u4EE3\u7406\u3002",
268
+ proxyHint: "\u7559\u7A7A\u4FDD\u5B58\u5373\u6E05\u9664\u624B\u586B\u4EE3\u7406\uFF1AWindows \u8DDF\u968F\u7CFB\u7EDF\u4EE3\u7406\uFF0C\u5176\u4ED6\u5E73\u53F0\u76F4\u8FDE\u3002",
263
269
  proxyTest: "\u68C0\u6D4B",
264
270
  proxyTesting: "\u68C0\u6D4B\u4E2D\u2026",
265
271
  proxyTestEmpty: "\u8BF7\u5148\u8F93\u5165\u4EE3\u7406\u5730\u5740",
@@ -271,7 +277,34 @@
271
277
  proxyScopeSync: "\u540C\u6B65",
272
278
  proxyScopeSyncDesc: "WebDAV \u4E0A\u4F20\u4E0E\u4E0B\u8F7D\u8D70\u4EE3\u7406\u3002",
273
279
  tabSync: "\u540C\u6B65",
280
+ tabImport: "\u5BFC\u5165\u4F1A\u8BDD",
274
281
  tabDebug: "\u8C03\u8BD5",
282
+ importDesc: "\u628A Codex\u3001Claude Code\u3001dsh\u3001pi \u7684\u5386\u53F2\u4F1A\u8BDD\u590D\u5236\u6210 ZCode \u4EFB\u52A1\u3002\u5BFC\u5165\u662F\u5FEB\u7167\uFF0C\u4E4B\u540E\u6E90\u4F1A\u8BDD\u7684\u53D8\u5316\u4E0D\u4F1A\u518D\u540C\u6B65\u3002",
283
+ importSearch: "\u641C\u7D22\u6807\u9898\u6216\u76EE\u5F55",
284
+ importRefresh: "\u5237\u65B0",
285
+ importShowAll: "\u663E\u793A\u5168\u90E8",
286
+ importShowAllTip: "\u663E\u793A\u5B50\u4EE3\u7406\u4F1A\u8BDD\u3001pi \u91CC\u4ECE Codex \u5BFC\u5165\u7684\u526F\u672C\uFF0C\u4EE5\u53CA\u6CA1\u6709\u771F\u5B9E\u5BF9\u8BDD\u7684 Claude \u4F1A\u8BDD\uFF1B\u5DF2\u5F52\u6863\u59CB\u7EC8\u663E\u793A",
287
+ importOnlyProject: "\u53EA\u770B\u6240\u9009\u9879\u76EE",
288
+ importSelectAll: "\u5168\u9009",
289
+ importSelected: "\u5BFC\u5165\u6240\u9009\uFF08{n}\uFF09",
290
+ importImporting: "\u5BFC\u5165\u4E2D\u2026",
291
+ importLoading: "\u52A0\u8F7D\u4E2D\u2026",
292
+ importNoSessions: "\u6CA1\u6709\u53EF\u5BFC\u5165\u7684\u4F1A\u8BDD",
293
+ importNoSource: "\u6CA1\u6709\u627E\u5230\u8BE5\u5DE5\u5177\u7684\u4F1A\u8BDD\u76EE\u5F55",
294
+ importSourceMissing: "\u6CA1\u6709\u68C0\u6D4B\u5230\u4F1A\u8BDD\u76EE\u5F55",
295
+ importAlready: "\u5DF2\u5BFC\u5165",
296
+ importAlreadyArchived: "\u5DF2\u5BFC\u5165\uFF08\u4EFB\u52A1\u5DF2\u5F52\u6863\uFF09",
297
+ importArchivedTaskTip: "\u5BFC\u5165\u7684\u4EFB\u52A1\u5DF2\u5F52\u6863\uFF1B\u53D6\u6D88\u5F52\u6863\u6216\u5220\u9664\u540E\u624D\u80FD\u91CD\u65B0\u5BFC\u5165",
298
+ importArchived: "\u5DF2\u5F52\u6863",
299
+ importSubagent: "\u5B50\u4EE3\u7406",
300
+ importCodexCopy: "Codex \u526F\u672C",
301
+ importLarge: "\u5927\u6587\u4EF6",
302
+ importCwdMissing: "\u539F\u76EE\u5F55\u4E0D\u5B58\u5728",
303
+ importProjectNone: "\u4E0D\u9009\u9879\u76EE\uFF08\u5F52\u5230\u201C\u4EFB\u52A1\u201D\uFF09",
304
+ importProjectHint: "\u9879\u76EE\u53EA\u51B3\u5B9A\u4FA7\u8FB9\u680F\u5F52\u7C7B\uFF0C\u4E0D\u6539\u53D8\u4F1A\u8BDD\u539F\u6765\u7684\u5DE5\u4F5C\u76EE\u5F55",
305
+ importConfirmLarge: "\u6240\u9009\u4F1A\u8BDD\u91CC\u6709\u8D85\u8FC7 20MB \u7684\u5927\u6587\u4EF6\uFF0C\u5BFC\u5165\u53EF\u80FD\u9700\u8981\u4E00\u4E9B\u65F6\u95F4\uFF0C\u7EE7\u7EED\u5417\uFF1F",
306
+ importDone: "\u5BFC\u5165\u5B8C\u6210\uFF1A\u6210\u529F {ok}\uFF0C\u8DF3\u8FC7 {skip}\uFF0C\u5931\u8D25 {fail}",
307
+ importFailed: "\u5BFC\u5165\u5931\u8D25",
275
308
  testNoSessionHint: "\u9009\u62E9\u201C\u8DDF\u968F\u5F53\u524D\u4F1A\u8BDD[\u5F53\u524D\u6A21\u578B]\u201D\u65F6\uFF0C\u9009\u62E9\u4E0A\u6B21\u4F1A\u8BDD\u4E2D\u4F7F\u7528\u7684\u4F9B\u5E94\u5546[\u6A21\u578B]",
276
309
  syncDesc: "\u624B\u52A8\u628A ZCode Pro \u8BBE\u7F6E\u4E0E\u6A21\u578B\u8BBE\u7F6E\u5907\u4EFD\u5230 WebDAV\uFF0C\u6216\u5728\u65B0\u7535\u8111\u4E0A\u6062\u590D\u3002\u4E24\u9879\u5404\u81EA\u72EC\u7ACB\u6210\u6587\u4EF6\uFF0C\u53EF\u53EA\u4E0A\u4F20\u6216\u53EA\u8986\u76D6\u5176\u4E2D\u4E00\u9879\uFF1B\u6BCF\u6B21\u4E0A\u4F20\u4F1A\u989D\u5916\u4FDD\u7559\u4E00\u4EFD\u5E26\u65F6\u95F4\u6233\u7684\u5386\u53F2\u7248\u672C\uFF08\u4FDD\u7559\u591A\u5C11\u4E2A\u89C1\u201C\u5386\u53F2\u7248\u672C\u201D\u4E00\u884C\uFF0C\u4E0A\u4F20\u540E\u81EA\u52A8\u5220\u9664\u8D85\u51FA\u7684\u6700\u65E7\u7248\u672C\uFF09\uFF0C\u4E0B\u8F7D\u65F6\u4EFB\u9009\u4E00\u4E2A\u7248\u672C\u6062\u590D\uFF1B\u4EC5\u5728\u70B9\u51FB\u6309\u94AE\u65F6\u4F20\u8F93\uFF0C\u4E0D\u505A\u81EA\u52A8\u540C\u6B65\u3002",
277
310
  syncUrlPlaceholder: "https://dav.jianguoyun.com/dav/",
@@ -331,6 +364,8 @@
331
364
  devReload: "\u91CD\u8F7D ZCode Pro",
332
365
  devReloading: "\u91CD\u8F7D\u4E2D\u2026",
333
366
  devReloadDesc: "\u70B9\u51FB\u540E\u7EA6 2-3 \u79D2\u5185\u6240\u6709 ZCode \u7A97\u53E3\u81EA\u52A8\u5237\u65B0\u4E00\u6B21\u5E76\u52A0\u8F7D\u65B0\u811A\u672C\u3002",
367
+ devToolsSwitch: "\u5F00\u53D1\u8005\u5DE5\u5177",
368
+ devToolsSwitchDesc: "\u5B98\u65B9\u4FA7\u680F\u7684\u201C\u5F00\u53D1\u8005\u5DE5\u5177\u201D\u9762\u677F\uFF08Token \u8C03\u8BD5 / \u7F51\u7EDC\u72B6\u6001\uFF09\uFF0C\u9ED8\u8BA4\u5173\u95ED\u3002\u6539\u52A8\u5199\u5165\u5B98\u65B9\u6BCF\u79D2\u8F6E\u8BE2\u7684\u5F00\u5173\uFF0C1 \u79D2\u5185\u751F\u6548\u3002",
334
369
  rowGapName: "\u6BB5\u843D\u95F4\u8DDD",
335
370
  rowGapDesc: "\u4F1A\u8BDD\u4E2D\u6BB5\u843D\u7B49\u6587\u672C\u5757\u4E4B\u95F4\u7684\u5782\u76F4\u95F4\u8DDD\uFF08\u56DE\u5408\u4E4B\u95F4\u3001\u7B54\u6848\u5185\u90E8\uFF09\u3002",
336
371
  listSpacingName: "\u5217\u8868\u4E0A\u4E0B\u8FB9\u8DDD",
@@ -400,6 +435,10 @@
400
435
  autoRenameDone: "\u5DF2\u91CD\u547D\u540D\uFF1A",
401
436
  featureWsRunning: "\u6298\u53E0\u65F6\u4EFB\u52A1\u8FD0\u884C\u4E2D\u63D0\u793A",
402
437
  featureWsRunningDesc: "\u6709\u4F1A\u8BDD\u8FD0\u884C\u65F6\uFF0C\u6298\u53E0\u7684\u9879\u76EE\u4E0E\u4EFB\u52A1\u5206\u533A\u5934\u663E\u793A\u52A0\u8F7D\u56FE\u6807\uFF0C\u5168\u90E8\u7ED3\u675F\u6D88\u5931\u3002",
438
+ featureSubagentIcon: "\u5B50\u4EE3\u7406\u8FD0\u884C\u4E2D\u63D0\u793A",
439
+ featureSubagentIconDesc: "\u540E\u53F0\u5B50\u4EE3\u7406\u5728\u8DD1\u663E\u673A\u5668\u4EBA\u3001\u540E\u53F0\u7EC8\u7AEF\u547D\u4EE4\u5728\u8DD1\u663E\u7EC8\u7AEF\u56FE\u6807\uFF08\u540C\u65F6\u5728\u8DD1\u673A\u5668\u4EBA\u4F18\u5148\uFF09\uFF1B\u672A\u8BFB\u5706\u70B9\u8BA9\u4F4D\u5230\u884C\u5C3E\u5E38\u663E\uFF1B\u4F1A\u8BDD\u8FD0\u884C\u4E2D\u59CB\u7EC8\u663E\u793A\u8F6C\u5708\u56FE\u6807\uFF1B\u9879\u76EE\u672A\u8BFB\u5FBD\u6807\u5FFD\u7565\u9519\u8BEF\u884C\u3002",
440
+ subagentRobotTip: "\u5B50\u4EE3\u7406\u8FD0\u884C\u4E2D",
441
+ subagentTermTip: "\u540E\u53F0\u547D\u4EE4\u8FD0\u884C\u4E2D",
403
442
  tabPerformance: "\u6027\u80FD",
404
443
  perfDesc: "ZCode \u4E3A\u6BCF\u4E2A\u6253\u5F00\u8FC7\u7684\u9879\u76EE\u5E38\u9A7B\u4E00\u4E2A\u4F1A\u8BDD\u8FDB\u7A0B\uFF0C\u5E94\u7528\u81EA\u8EAB\u4E0D\u4F1A\u56DE\u6536\uFF0C\u9879\u76EE\u591A\u4E86\u5185\u5B58\u5360\u7528\u5C31\u9AD8\u3002\u5F00\u542F\u540E\uFF0C\u957F\u65F6\u95F4\u672A\u4F7F\u7528\u4E14\u6CA1\u6709\u4EFB\u52A1\u5728\u8DD1\u7684\u9879\u76EE\u4F1A\u88AB\u81EA\u52A8\u91CA\u653E\uFF1A\u4F1A\u8BDD\u8BB0\u5F55\u4E0D\u53D7\u5F71\u54CD\uFF0C\u518D\u6B21\u6253\u5F00\u65F6\u81EA\u52A8\u6062\u590D\uFF0C\u4EC5\u9996\u6B21\u56DE\u590D\u6709\u51E0\u79D2\u7B49\u5F85\u3002\u6B63\u5728\u4F7F\u7528\u7684\u9879\u76EE\u3001\u8FD0\u884C\u4E2D\u7684\u4F1A\u8BDD\u4E0E\u540E\u53F0\u547D\u4EE4\u3001\u5B9A\u65F6\u4EFB\u52A1\u90FD\u4E0D\u4F1A\u88AB\u56DE\u6536\u3002\u540E\u53F0\u547D\u4EE4\u68C0\u6D4B\u4F9D\u8D56\u7CFB\u7EDF\u8FDB\u7A0B\u4FE1\u606F\uFF08Linux / macOS / Windows \u5404\u8D70\u7CFB\u7EDF\u81EA\u5E26\u5DE5\u5177\uFF09\uFF0C\u68C0\u6D4B\u4E0D\u53EF\u7528\u65F6\u529F\u80FD\u81EA\u52A8\u505C\u7528\u3002",
405
444
  featureIdleReclaim: "\u7A7A\u95F2\u9879\u76EE\u5185\u5B58\u56DE\u6536",
@@ -451,7 +490,7 @@
451
490
  tabStatusPane: "\u72B6\u6001\u680F",
452
491
  themeColorsPane: "\u4E3B\u9898",
453
492
  themeBgRegions: "\u5206\u533A\u80CC\u666F",
454
- themeBgRegionFollow: "\u8DDF\u968F\u5168\u5C40\u58C1\u7EB8",
493
+ themeBgRegionFollow: "\u9ED8\u8BA4\uFF08\u5168\u5C40\u58C1\u7EB8\uFF09",
455
494
  themeBgRegionLeft: "\u5DE6\u4FA7\u8FB9\u680F",
456
495
  themeBgRegionCenter: "\u4E2D\u95F4\u533A\u57DF",
457
496
  themeBgRegionRight: "\u53F3\u4FA7\u8FB9\u680F",
@@ -504,7 +543,7 @@
504
543
  themeBgDialogFrost: "\u8BBE\u7F6E\u5F39\u7A97\u78E8\u7802",
505
544
  themeBgMisc: "\u5176\u4ED6",
506
545
  themeBgFollowGlobal: "\u8DDF\u968F\u5168\u5C40",
507
- themeBgRegionsHint: "\u6BCF\u884C\u7684\u7F29\u653E\u3001\u906E\u7F69\u53EF\u5355\u72EC\u8BBE\u7F6E\uFF0C\u9009\u201C\u8DDF\u968F\u5168\u5C40\u201D\u5373\u8DDF\u968F\u201C\u753B\u9762\u201D\u7684\u503C\uFF1B\u6A21\u7CCA\u3001\u8F6C\u573A\u3001\u64AD\u653E\u4EC5\u4F5C\u7528\u4E8E\u5168\u5C40\u58C1\u7EB8\uFF08\u5206\u533A\u53EA\u80FD\u94FA\u56FE\uFF0C\u4E0D\u80FD\u64AD\u89C6\u9891\uFF09\u3002\u5206\u533A\u7528\u6587\u4EF6\u5939\u65F6\uFF0C\u8F6E\u6362\u95F4\u9694\u4E0E\u968F\u673A\u987A\u5E8F\u6CBF\u7528\u5168\u5C40\u8BBE\u7F6E\u3002",
546
+ themeBgRegionsHint: "\u6765\u6E90\u9009\u201C\u9ED8\u8BA4\uFF08\u5168\u5C40\u58C1\u7EB8\uFF09\u201D\u5373\u8BE5\u533A\u4E0D\u5355\u72EC\u8BBE\u7F6E\u3001\u76F4\u63A5\u663E\u793A\u5168\u5C40\u58C1\u7EB8\uFF1B\u6BCF\u884C\u7684\u7F29\u653E\u3001\u906E\u7F69\u53EF\u5355\u72EC\u8BBE\u7F6E\uFF0C\u9009\u201C\u8DDF\u968F\u5168\u5C40\u201D\u5373\u8DDF\u968F\u201C\u753B\u9762\u201D\u7684\u503C\uFF1B\u6A21\u7CCA\u3001\u8F6C\u573A\u3001\u64AD\u653E\u4EC5\u4F5C\u7528\u4E8E\u5168\u5C40\u58C1\u7EB8\uFF08\u5206\u533A\u53EA\u80FD\u94FA\u56FE\uFF0C\u4E0D\u80FD\u64AD\u89C6\u9891\uFF09\u3002\u5206\u533A\u7528\u6587\u4EF6\u5939\u65F6\uFF0C\u8F6E\u6362\u95F4\u9694\u4E0E\u968F\u673A\u987A\u5E8F\u6CBF\u7528\u5168\u5C40\u8BBE\u7F6E\u3002",
508
547
  themeBgPlayback: "\u64AD\u653E\uFF08\u89C6\u9891\u58C1\u7EB8\uFF09",
509
548
  themeBgVolume: "\u97F3\u91CF",
510
549
  themeBgVolumeHint: "\u89C6\u9891\u58C1\u7EB8\u7684\u97F3\u8F68\u97F3\u91CF\uFF0C0 = \u9759\u97F3\uFF08\u9ED8\u8BA4\uFF09",
@@ -524,7 +563,9 @@
524
563
  tableCopied: "\u8868\u683C\u5DF2\u590D\u5236",
525
564
  sbItemCtx: "\u4E0A\u4E0B\u6587\u5360\u7528",
526
565
  sbItemTokRate: "\u6700\u8FD1\u8F93\u51FA tokens/s",
527
- sbItemQuestions: "\u63D0\u95EE\u6B21\u6570",
566
+ sbItemQuestions: "\u4E3B\u8BF7\u6C42\u6570\uFF08\u672C\u4F1A\u8BDD\uFF09",
567
+ sbItemInOut: "\u7D2F\u8BA1\u8F93\u5165/\u8F93\u51FA\uFF08\u672C\u4F1A\u8BDD\u4E3B\u8F6E\u8BF7\u6C42\uFF09",
568
+ sbItemHit: "\u5E73\u5747\u7F13\u5B58\u547D\u4E2D\u7387\uFF08\u672C\u4F1A\u8BDD\uFF09",
528
569
  sbMaster: "\u542F\u7528\u7EDF\u8BA1",
529
570
  sbMasterDesc: "\u603B\u5F00\u5173\uFF1A\u5173\u95ED\u540E\u8F93\u5165\u6846\u53F3\u4E0B\u89D2\u7684\u7EDF\u8BA1\u884C\u4E0E\u6BCF\u8F6E\u56DE\u7B54\u7684\u7528\u91CF\u6807\u6CE8\u4E00\u8D77\u505C\u7528\u3002",
530
571
  sbGroupSession: "\u4F1A\u8BDD\u7EDF\u8BA1\uFF08\u8DDF\u968F\u5F53\u524D\u4F1A\u8BDD\uFF09",
@@ -533,8 +574,11 @@
533
574
  sbLabelIn: "\u8F93\u5165",
534
575
  sbLabelOut: "\u8F93\u51FA",
535
576
  sbLabelCache: "\u7F13\u5B58",
577
+ sbLabelTps: "\u8F93\u51FA tok/s",
578
+ sbLabelInOut: "\u8F93\u5165/\u8F93\u51FA",
579
+ sbLabelHit: "\u5E73\u5747\u547D\u4E2D",
536
580
  turnUsageTitle: "\u672C\u8F6E token",
537
- sbLabelQuestions: "\u63D0\u95EE",
581
+ sbLabelQuestions: "\u4E3B\u8BF7\u6C42\u6570",
538
582
  sbItemTodayTokens: "\u4ECA\u65E5 token",
539
583
  sbItemTasks: "\u4EFB\u52A1\u603B\u6570",
540
584
  sbLabelCtx: "\u4E0A\u4E0B\u6587",
@@ -580,6 +624,8 @@
580
624
  featureSessionLink: "\u4F1A\u8BDD ID \u663E\u793A\u4E3A\u4EFB\u52A1\u540D\u94FE\u63A5",
581
625
  featureSessionLinkDesc: "\u63D0\u95EE\u4E0E\u56DE\u7B54\u91CC\u7684\u4F1A\u8BDD ID\uFF08sess_ / session_ \u5F00\u5934\uFF09\u663E\u793A\u4E3A\u4EFB\u52A1\u540D\uFF0C\u70B9\u51FB\u5207\u6362\u5230\u8BE5\u4F1A\u8BDD\uFF0C\u60AC\u505C\u53EF\u770B\u539F\u59CB ID\u3002",
582
626
  featureComposerProviderDesc: "\u6A21\u578B\u540D\u524D\u663E\u793A\u4F9B\u5E94\u5546\u540D\uFF08\u5982 BigModel-Max1 / glm-5.3\uFF09\uFF0C\u533A\u5206\u540C\u540D\u6A21\u578B\u3002",
627
+ featureSessionImport: "\u5BFC\u5165\u4F1A\u8BDD",
628
+ featureSessionImportDesc: "\u5728\u8BBE\u7F6E\u5F39\u7A97\u91CC\u628A Codex\u3001Claude Code\u3001dsh\u3001pi \u7684\u5386\u53F2\u4F1A\u8BDD\u5BFC\u5165\u6210 ZCode \u4EFB\u52A1\u3002",
583
629
  imageCopy: "\u590D\u5236\u56FE\u7247",
584
630
  imageCopied: "\u56FE\u7247\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F",
585
631
  imageCopyFailed: "\u590D\u5236\u56FE\u7247\u5931\u8D25",
@@ -723,6 +769,10 @@
723
769
  headroomInterval: "\u76D1\u89C6\u95F4\u9694",
724
770
  headroomIntervalDesc: "\u7701\u7535\u76D1\u89C6\u5668\u8F6E\u8BE2\u7535\u6E90\u72B6\u6001\u7684\u95F4\u9694\uFF0810\u20133600 \u79D2\uFF0C\u9ED8\u8BA4 60\uFF09\uFF1B\u4FDD\u5B58\u540E\u4ECE\u4E0B\u4E00\u8F6E\u5DE1\u68C0\u8D77\u751F\u6548\u3002",
725
771
  headroomSecUnit: "\u79D2",
772
+ serenaSwitch: "Serena \u8BED\u4E49\u68C0\u7D22",
773
+ serenaSwitchDesc: "\u6CE8\u518C Serena MCP\uFF1A\u7528\u7B26\u53F7\u5B9A\u4F4D\u3001\u5F15\u7528\u67E5\u627E\u7B49\u8BED\u4E49\u5DE5\u5177\u4EE3\u66FF\u6574\u6587\u4EF6\u8BFB\u53D6\uFF0C\u7701 token\u3002\u5199\u5165 ZCode MCP \u914D\u7F6E\uFF0C\u91CD\u542F\u4F1A\u8BDD\u540E\u751F\u6548\u3002",
774
+ serenaEnabled: "\u5DF2\u5F00\u542F Serena\uFF0C\u91CD\u542F\u4F1A\u8BDD\u540E\u751F\u6548",
775
+ serenaDisabled: "\u5DF2\u5173\u95ED Serena\uFF0C\u91CD\u542F\u4F1A\u8BDD\u540E\u79FB\u9664",
726
776
  upgradeCheck: "\u68C0\u67E5\u66F4\u65B0",
727
777
  upgradeChecking: "\u68C0\u67E5\u4E2D\u2026",
728
778
  upgradeUpToDate: "\u5DF2\u662F\u6700\u65B0\uFF08{v}\uFF09",
@@ -845,7 +895,7 @@
845
895
  proxyPlaceholder: "http://127.0.0.1:7890",
846
896
  proxySave: "Save",
847
897
  proxySaved: "Proxy settings saved.",
848
- proxyHint: "Save empty to clear the proxy.",
898
+ proxyHint: "Save empty to clear the manual proxy; Windows then follows the system proxy, other platforms connect directly.",
849
899
  proxyTest: "Test",
850
900
  proxyTesting: "Testing\u2026",
851
901
  proxyTestEmpty: "Enter a proxy address first",
@@ -857,7 +907,34 @@
857
907
  proxyScopeSync: "Sync",
858
908
  proxyScopeSyncDesc: "WebDAV upload and download go through the proxy.",
859
909
  tabSync: "Sync",
910
+ tabImport: "Session import",
860
911
  tabDebug: "Debug",
912
+ importDesc: "Copy sessions from Codex, Claude Code, dsh and pi into ZCode tasks. The copy is a snapshot; later changes in the source session are not synced.",
913
+ importSearch: "Search title or folder",
914
+ importRefresh: "Refresh",
915
+ importShowAll: "Show all",
916
+ importShowAllTip: "Show subagent sessions, pi copies imported from Codex, and Claude sessions without real conversation; archived sessions are always shown",
917
+ importOnlyProject: "Only the selected project",
918
+ importSelectAll: "Select all",
919
+ importSelected: "Import selected ({n})",
920
+ importImporting: "Importing\u2026",
921
+ importLoading: "Loading\u2026",
922
+ importNoSessions: "No sessions to import",
923
+ importNoSource: "The session folder for this tool was not found",
924
+ importSourceMissing: "No session folder detected",
925
+ importAlready: "Imported",
926
+ importAlreadyArchived: "Imported (task archived)",
927
+ importArchivedTaskTip: "The imported task is archived; unarchive or delete it before importing again",
928
+ importArchived: "Archived",
929
+ importSubagent: "Subagent",
930
+ importCodexCopy: "Codex copy",
931
+ importLarge: "Large",
932
+ importCwdMissing: "Original folder missing",
933
+ importProjectNone: "No project (Tasks section)",
934
+ importProjectHint: "The project only controls the sidebar group; the session keeps its original working folder",
935
+ importConfirmLarge: "The selection includes files larger than 20MB. Importing may take a while. Continue?",
936
+ importDone: "Import finished: {ok} imported, {skip} skipped, {fail} failed",
937
+ importFailed: "Import failed",
861
938
  testNoSessionHint: 'With "Follow current session" selected, the provider and model of the last session are used (the label shows the model name in brackets).',
862
939
  syncDesc: 'Manually back up ZCode Pro settings and model settings to WebDAV, or restore them on a new computer. The two items are stored as separate files, so you can upload or overwrite either one alone; every upload also keeps a timestamped history version (how many to keep is set in the "History" row; older ones are removed automatically after upload) and download lets you pick any of them. Data moves only when you click, never automatically.',
863
940
  syncUrlPlaceholder: "https://dav.example.com/dav/",
@@ -915,6 +992,8 @@
915
992
  syncVerSaved: "Saved to",
916
993
  devModeDesc: 'For development: after changing zcode-pro code, click "Reload ZCode Pro" instead of restarting ZCode. It builds automatically (when running from the source repo), restarts the ZCode Pro launcher process (fresh helper and injected script), and every ZCode window refreshes and re-injects. The ZCode app itself and all sessions stay untouched.',
917
994
  devReload: "Reload ZCode Pro",
995
+ devToolsSwitch: "Developer tools",
996
+ devToolsSwitchDesc: 'The official "Developer tools" side pane (Token debug / Network status), off by default. The change goes to the flag the official app polls every second.',
918
997
  devReloading: "Reloading\u2026",
919
998
  devReloadDesc: "Every ZCode window refreshes automatically within 2-3 seconds to load the new script.",
920
999
  rowGapName: "Paragraph spacing",
@@ -985,6 +1064,10 @@
985
1064
  autoRenameDone: "Renamed: ",
986
1065
  featureWsRunning: "Running indicator when collapsed",
987
1066
  featureWsRunningDesc: "Collapsed project and task headers show a loader while sessions run.",
1067
+ featureSubagentIcon: "Subagent running indicator",
1068
+ featureSubagentIconDesc: "Task rows show a robot icon while subagents run and a terminal icon while background commands run (robot wins when both); the unread dot moves to the row end; running sessions always show a spinner; project unread badges ignore error rows.",
1069
+ subagentRobotTip: "Subagents running",
1070
+ subagentTermTip: "Background commands running",
988
1071
  tabPerformance: "Performance",
989
1072
  perfDesc: "ZCode keeps a session process resident for every project you have opened and never reclaims it, so memory grows with projects. When enabled, projects unused for a while with nothing running release their memory automatically: sessions are untouched and reload when reopened, with a few seconds' wait on the first reply. The project in use, running sessions, background commands and scheduled tasks are never reclaimed. Background-command detection reads system process info via built-in tools (Linux / macOS / Windows); when unavailable, the feature disables itself.",
990
1073
  featureIdleReclaim: "Idle project memory reclaim",
@@ -1036,7 +1119,7 @@
1036
1119
  tabStatusPane: "Status bar",
1037
1120
  themeColorsPane: "Theme",
1038
1121
  themeBgRegions: "Regional backgrounds",
1039
- themeBgRegionFollow: "Follow global",
1122
+ themeBgRegionFollow: "Default (global)",
1040
1123
  themeBgRegionLeft: "Left sidebar",
1041
1124
  themeBgRegionCenter: "Center area",
1042
1125
  themeBgRegionRight: "Right sidebar",
@@ -1089,7 +1172,7 @@
1089
1172
  themeBgDialogFrost: "Frosted settings window",
1090
1173
  themeBgMisc: "Other",
1091
1174
  themeBgFollowGlobal: "Follow global",
1092
- themeBgRegionsHint: 'Fit and mask can be set per row; "Follow global" uses the Display values. Blur, transition and playback apply only to the global wallpaper (regions are static images, no video). Region folders reuse the global rotation interval and order settings.',
1175
+ themeBgRegionsHint: '"Default (global)" means the region is not set on its own and just shows the global wallpaper. Fit and mask can be set per row; "Follow global" uses the Display values. Blur, transition and playback apply only to the global wallpaper (regions are static images, no video). Region folders reuse the global rotation interval and order settings.',
1093
1176
  themeBgPlayback: "Playback (video)",
1094
1177
  themeBgVolume: "Volume",
1095
1178
  themeBgVolumeHint: "Audio track volume of video wallpapers, 0 = muted (default)",
@@ -1109,7 +1192,9 @@
1109
1192
  tableCopied: "Table copied",
1110
1193
  sbItemCtx: "Context usage",
1111
1194
  sbItemTokRate: "Recent output tokens/s",
1112
- sbItemQuestions: "Questions asked",
1195
+ sbItemQuestions: "Main requests (this session)",
1196
+ sbItemInOut: "Total input/output (main requests, this session)",
1197
+ sbItemHit: "Average cache hit rate (this session)",
1113
1198
  sbMaster: "Enable statistics",
1114
1199
  sbMasterDesc: "Master switch: turning this off disables both the input-box statistics and per-turn labels.",
1115
1200
  sbGroupSession: "Session statistics (follows the current session)",
@@ -1118,8 +1203,11 @@
1118
1203
  sbLabelIn: "in",
1119
1204
  sbLabelOut: "out",
1120
1205
  sbLabelCache: "cache",
1206
+ sbLabelTps: "out tok/s",
1207
+ sbLabelInOut: "in/out",
1208
+ sbLabelHit: "avg hit",
1121
1209
  turnUsageTitle: "Turn tokens",
1122
- sbLabelQuestions: "asks",
1210
+ sbLabelQuestions: "reqs",
1123
1211
  sbItemTodayTokens: "Tokens today",
1124
1212
  sbItemTasks: "Tasks",
1125
1213
  sbLabelCtx: "ctx",
@@ -1165,6 +1253,8 @@
1165
1253
  featureSessionLink: "Session ID links",
1166
1254
  featureSessionLinkDesc: "Shows session IDs (sess_ / session_) in chat as task names; click to switch to that session, hover for the raw ID.",
1167
1255
  featureComposerProviderDesc: "Shows the provider before the model name (e.g. BigModel-Max1 / glm-5.3).",
1256
+ featureSessionImport: "Session import",
1257
+ featureSessionImportDesc: "Import sessions from Codex, Claude Code, dsh and pi as ZCode tasks from the settings dialog.",
1168
1258
  imageCopy: "Copy image",
1169
1259
  imageCopied: "Image copied to the clipboard.",
1170
1260
  imageCopyFailed: "Failed to copy the image.",
@@ -1308,6 +1398,10 @@
1308
1398
  headroomInterval: "Watch interval",
1309
1399
  headroomIntervalDesc: "Seconds between power checks (10\u20133600, default 60); applies from the next round.",
1310
1400
  headroomSecUnit: "s",
1401
+ serenaSwitch: "Serena semantic search",
1402
+ serenaSwitchDesc: "Registers the Serena MCP: symbol lookup and reference search instead of reading whole files, saving tokens. Written to the ZCode MCP config; takes effect after restarting the session.",
1403
+ serenaEnabled: "Serena enabled; takes effect after restarting the session",
1404
+ serenaDisabled: "Serena disabled; removed after restarting the session",
1311
1405
  upgradeCheck: "Check for updates",
1312
1406
  upgradeChecking: "Checking\u2026",
1313
1407
  upgradeUpToDate: "Up to date ({v})",
@@ -1400,6 +1494,17 @@
1400
1494
  "index-remap-failed": "Failed to update the task index (config changes rolled back)",
1401
1495
  "index-error": "Task index error",
1402
1496
  "index-busy": "The task index is busy. Please retry shortly.",
1497
+ "bad-source": "Unknown session source",
1498
+ "source-unavailable": "No session folder found for this tool",
1499
+ "bad-request": "Invalid import request",
1500
+ "too-many-items": "At most 1000 sessions per import; split the selection",
1501
+ "project-not-found": "Project not found or has no folder",
1502
+ "bad-source-path": "The session file is outside the source folder or no longer exists",
1503
+ "session-mismatch": "The session id does not match the file content",
1504
+ "empty-session": "No messages to import",
1505
+ "db-missing": "The ZCode session database or task index is missing",
1506
+ "import-failed": "Import failed",
1507
+ "zstd-unavailable": "This Node build cannot read dsh sessions (zstd support is missing)",
1403
1508
  "vision-invalid": "Invalid vision config",
1404
1509
  "vision-read": "Failed to read zcode-vision.json",
1405
1510
  "vision-write": "Failed to write zcode-vision.json",
@@ -1417,9 +1522,12 @@
1417
1522
  "headroom-action": "The headroom action failed",
1418
1523
  "headroom-status": "Failed to read the headroom status",
1419
1524
  "headroom-update": "headroom update failed",
1525
+ "serena-config-unreadable": "ZCode config is unparseable; aborted writing",
1420
1526
  "ZCODE_NOT_FOUND": "ZCode executable not found",
1421
1527
  "plugins-status": "Failed to read the plugin list",
1422
1528
  "plugins-update": "Failed to update plugins",
1529
+ "plugins-market-git": "Git is missing and GitHub is unreachable. Install Git or set a proxy in ZCode Pro \u2192 Proxy, then retry.",
1530
+ "plugins-market-network": "Cannot reach GitHub. If your network needs a proxy, set it in ZCode Pro \u2192 Proxy, then retry.",
1423
1531
  "sync-invalid": "Invalid sync settings",
1424
1532
  "sync-not-configured": "Set the sync type to WebDAV and save the config first",
1425
1533
  "sync-remote-missing": "No synced data on the server yet; upload from another computer first",
@@ -2210,6 +2318,8 @@
2210
2318
  pointer-events: none;
2211
2319
  }
2212
2320
  .zcodepro-statusbar span[data-tone='warn'] { color: var(--color-amber-500, #f59e0b); }
2321
+ /* \u5B50\u9879\u4E0D\u538B\u7F29\uFF1A\u8D85\u5BBD\u65F6\u6309 HIDE_ORDER \u9690\u85CF\u6761\u76EE\uFF08status-bar.js\uFF09\uFF0C\u4E0D\u9760\u6324\u538B\u6587\u5B57 */
2322
+ .zcodepro-statusbar > * { flex-shrink: 0; }
2213
2323
  .zcodepro-statusbar span[data-tone='danger'] { color: var(--color-red-500, #ef4444); }
2214
2324
  .zcodepro-statusbar-sep { opacity: 0.45; }
2215
2325
  /* \u4F1A\u8BDD\u7EC4\u4E0E\u5168\u5C40\u7EC4\u4E4B\u95F4\u7684\u5206\u754C\u7AD6\u7EBF */
@@ -2270,6 +2380,14 @@
2270
2380
  /* \u6298\u53E0\u9879\u76EE\u8FD0\u884C\u63D0\u793A\uFF1Afolder \u56FE\u6807\u8BA9\u4F4D\u7ED9 loader\uFF08loader \u7531\u811A\u672C\u63D2\u5165\uFF0C
2271
2381
  folder \u53EF\u80FD\u88AB React \u968F\u65F6\u91CD\u5EFA\uFF0C\u9760\u7C7B\u9009\u62E9\u5668\u7EDF\u4E00\u9690\u85CF\uFF0C\u540E\u4EE3\u5199\u6CD5\u517C\u5BB9\u5305\u88C5\u5C42\uFF09 */
2272
2382
  span.zcodepro-ws-running svg:not(.zcodepro-ws-loader) { display: none !important; }
2383
+ /* \u5B50\u4EE3\u7406\u8FD0\u884C\u63D0\u793A\uFF08subagent-icon.js\uFF09\uFF1A\u6298\u53E0\u9879\u76EE folder \u8BA9\u4F4D\u7ED9\u673A\u5668\u4EBA/\u7EC8\u7AEF\uFF0C
2384
+ loader \u5728\u8F6C\u65F6\uFF08zcodepro-ws-loader\uFF09\u4F18\u5148\u663E\u793A\uFF0C\u4E0D\u8DDF\u673A\u5668\u4EBA\u4E92\u76F8\u85CF */
2385
+ span.zcodepro-subagent-on svg:not(.zcodepro-subagent-icon):not(.zcodepro-terminal-icon):not(.zcodepro-ws-loader) { display: none !important; }
2386
+ /* \u672A\u8BFB\u5706\u70B9\u8BA9\u4F4D\u673A\u5668\u4EBA\uFF1A\u539F\u70B9\u9690\u85CF\uFF0C\u884C\u5C3E\u590D\u5236\u54C1\u5E38\u663E\uFF08\u4E0D\u8DDF\u60AC\u6D6E\u64CD\u4F5C\u56FE\u6807\u4E00\u8D77\u9690\u85CF\uFF09 */
2387
+ li.zcodepro-subagent-unread-moved [data-unread-indicator] { display: none !important; }
2388
+ .zcodepro-subagent-unread-tail { display: inline-flex; align-items: center; align-self: center; }
2389
+ /* \u9879\u76EE\u84DD\u8272\u672A\u8BFB\u5FBD\u6807\u5FFD\u7565\u9519\u8BEF\u884C\uFF1A\u9879\u76EE\u91CC\u672A\u8BFB\u5168\u662F\u9519\u8BEF\u6001\uFF08\u7EA2\u70B9\uFF09\u65F6\u4E0D\u4EAE\u84DD\u5FBD\u6807 */
2390
+ .zcodepro-unread-error-only [data-workspace-unread-indicator] { display: none !important; }
2273
2391
  /* \u65E0\u611F\u63A2\u67E5\u671F\u95F4\u76D6\u5728\u9879\u76EE\u884C\u4E0A\u7684\u51BB\u7ED3\u514B\u9686\uFF1A\u56FA\u5B9A\u5B9A\u4F4D\u3001\u4E0D\u54CD\u5E94\u6307\u9488 */
2274
2392
  .zcodepro-ws-frozen {
2275
2393
  position: fixed;
@@ -2546,6 +2664,30 @@
2546
2664
  return null;
2547
2665
  }
2548
2666
  }
2667
+ function listActiveIdsCached(base) {
2668
+ const key = String(base).replace(/[\\/]+$/, "");
2669
+ const now = Date.now();
2670
+ const hit = activeIdsCache.get(key);
2671
+ if (hit && hit.pending) return hit.pending;
2672
+ if (hit && now - hit.doneAt < ACTIVE_IDS_TTL_MS) return Promise.resolve(hit.ids);
2673
+ const services = findServices();
2674
+ const ts = services && services.zcodeTaskService;
2675
+ if (!ts || typeof ts.listActiveTaskIds !== "function") return Promise.resolve(null);
2676
+ const one = (w) => new Promise((resolve) => {
2677
+ const timer = setTimeout(() => resolve([]), ACTIVE_IDS_TIMEOUT_MS);
2678
+ Promise.resolve().then(() => ts.listActiveTaskIds({ workspacePath: w })).then(
2679
+ (r) => resolve(Array.isArray(r) ? r.map(String) : []),
2680
+ () => resolve([])
2681
+ ).finally(() => clearTimeout(timer));
2682
+ });
2683
+ const pending = Promise.all([one(key), one(key + "/")]).then(([a, b]) => {
2684
+ const ids = [...a, ...b];
2685
+ activeIdsCache.set(key, { ids, doneAt: Date.now(), pending: null });
2686
+ return ids;
2687
+ });
2688
+ activeIdsCache.set(key, { ids: hit && hit.ids || [], doneAt: hit ? hit.doneAt : 0, pending });
2689
+ return pending;
2690
+ }
2549
2691
  async function authoritativeIdle(ws) {
2550
2692
  const services = findServices();
2551
2693
  const ts = services && services.zcodeTaskService;
@@ -2747,13 +2889,7 @@
2747
2889
  }
2748
2890
  projectPaths.set(proj.name, names);
2749
2891
  }
2750
- const pairs = await Promise.all([...scanPaths].map(async (base) => {
2751
- const [a, b] = await Promise.all([
2752
- ts.listActiveTaskIds({ workspacePath: base }),
2753
- ts.listActiveTaskIds({ workspacePath: base + "/" })
2754
- ]);
2755
- return [base, [...Array.isArray(a) ? a : [], ...Array.isArray(b) ? b : []].map(String)];
2756
- }));
2892
+ const pairs = await Promise.all([...scanPaths].map(async (base) => [base, await listActiveIdsCached(base) || []]));
2757
2893
  for (const [base, ids] of pairs) {
2758
2894
  if (!ids.length) continue;
2759
2895
  byKindByPath.set(base, ids);
@@ -3094,8 +3230,8 @@
3094
3230
  }, pollMs);
3095
3231
  }
3096
3232
  function startWsRunningSpin() {
3097
- if (installed2 || typeof document === "undefined") return;
3098
- installed2 = true;
3233
+ if (installed || typeof document === "undefined") return;
3234
+ installed = true;
3099
3235
  const st = document.createElement("style");
3100
3236
  st.id = "__zcodepro_ws_style__";
3101
3237
  st.textContent = ".zcodepro-ws-loader{color:color-mix(in srgb, currentColor 85%, black) !important}";
@@ -3126,12 +3262,12 @@
3126
3262
  if (row) wsTouchAt.set(row, Date.now());
3127
3263
  }, true);
3128
3264
  }
3129
- var installed2, enabled2, SCAN_DEBOUNCE_MS, SCAN_FALLBACK_MS, PEEK_FIRST_MS, PEEK_REPEAT_MS, PEEK_SETTLE_MS, PEEK_MAX_MS, PEEK_UNMOUNT_WAIT_MS, CONFIG_POLL_MIN_MS, CONFIG_POLL_MAX_MS, TASK_SEL, WS_SEL, LOADER_FALLBACK_PATHS, runningByWs, peekTimers, activePeeks, peekedWs, wsWithRows, servicesRef, servicesMissAt, synthClick, headInfoCache, PROJECT_HEAD_TEXTS, TASK_HEAD_TEXTS, SEC_SPIN_CLASS, anyActiveCache, sectionActive, activeProjectPaths, authActiveByWs, peekChain, PEEK_EXEMPT_CLASS, cssAttr, TOUCH_WINDOW_MS, wsTouchAt, pollMs, scanDebounce;
3265
+ var installed, enabled2, SCAN_DEBOUNCE_MS, SCAN_FALLBACK_MS, PEEK_FIRST_MS, PEEK_REPEAT_MS, PEEK_SETTLE_MS, PEEK_MAX_MS, PEEK_UNMOUNT_WAIT_MS, CONFIG_POLL_MIN_MS, CONFIG_POLL_MAX_MS, TASK_SEL, WS_SEL, LOADER_FALLBACK_PATHS, runningByWs, peekTimers, activePeeks, peekedWs, wsWithRows, servicesRef, servicesMissAt, ACTIVE_IDS_TTL_MS, ACTIVE_IDS_TIMEOUT_MS, activeIdsCache, synthClick, headInfoCache, PROJECT_HEAD_TEXTS, TASK_HEAD_TEXTS, SEC_SPIN_CLASS, anyActiveCache, sectionActive, activeProjectPaths, authActiveByWs, peekChain, PEEK_EXEMPT_CLASS, cssAttr, TOUCH_WINDOW_MS, wsTouchAt, pollMs, scanDebounce;
3130
3266
  var init_ws_running = __esm({
3131
3267
  "src/inject/features/ws-running.js"() {
3132
3268
  init_core();
3133
3269
  init_ws_rows();
3134
- installed2 = false;
3270
+ installed = false;
3135
3271
  enabled2 = true;
3136
3272
  SCAN_DEBOUNCE_MS = 150;
3137
3273
  SCAN_FALLBACK_MS = 5e3;
@@ -3161,6 +3297,9 @@
3161
3297
  wsWithRows = /* @__PURE__ */ new Set();
3162
3298
  servicesRef = null;
3163
3299
  servicesMissAt = 0;
3300
+ ACTIVE_IDS_TTL_MS = 25e3;
3301
+ ACTIVE_IDS_TIMEOUT_MS = 6e3;
3302
+ activeIdsCache = /* @__PURE__ */ new Map();
3164
3303
  synthClick = (el) => {
3165
3304
  try {
3166
3305
  el.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
@@ -3556,13 +3695,15 @@
3556
3695
  return;
3557
3696
  }
3558
3697
  if (k === hotkeys.switchRecent) {
3559
- if (!e.repeat && !popupEl && !openPopupInflight) {
3560
- if (!mru.length) {
3561
- showToast(t().switcherEmpty, "warning");
3562
- return;
3563
- }
3564
- await openPopup("mru");
3698
+ if (e.repeat) return;
3699
+ if (openPopupInflight) await openPopupInflight;
3700
+ if (popupEl && popupMode !== "attention") return;
3701
+ if (!mru.length) {
3702
+ showToast(t().switcherEmpty, "warning");
3703
+ return;
3565
3704
  }
3705
+ if (popupEl) closePopup(false);
3706
+ await openPopup("mru");
3566
3707
  return;
3567
3708
  }
3568
3709
  if (openPopupInflight) {
@@ -4654,10 +4795,10 @@
4654
4795
  function startImageMenu() {
4655
4796
  if (typeof window === "undefined") return;
4656
4797
  if (typeof navigator.clipboard?.write !== "function" || typeof window.ClipboardItem === "undefined") return;
4657
- let enabled14 = true;
4798
+ let enabled15 = true;
4658
4799
  const refresh = () => {
4659
4800
  void getConfig().then((c) => {
4660
- enabled14 = !(c.features && c.features.imageCopy === false);
4801
+ enabled15 = !(c.features && c.features.imageCopy === false);
4661
4802
  });
4662
4803
  };
4663
4804
  refresh();
@@ -4666,7 +4807,7 @@
4666
4807
  const img = copyTargetOf(e.target, e.clientX, e.clientY);
4667
4808
  if (!img) return;
4668
4809
  e.preventDefault();
4669
- if (enabled14) showMenu(e.clientX, e.clientY, img);
4810
+ if (enabled15) showMenu(e.clientX, e.clientY, img);
4670
4811
  refresh();
4671
4812
  }, true);
4672
4813
  }
@@ -4735,7 +4876,7 @@
4735
4876
  function waitFor(getter, timeoutMs, step) {
4736
4877
  const start = Date.now();
4737
4878
  return new Promise((resolve, reject) => {
4738
- const tick6 = () => {
4879
+ const tick7 = () => {
4739
4880
  let v = null;
4740
4881
  try {
4741
4882
  v = getter();
@@ -4749,9 +4890,9 @@
4749
4890
  reject(new Error(step));
4750
4891
  return;
4751
4892
  }
4752
- setTimeout(tick6, 120);
4893
+ setTimeout(tick7, 120);
4753
4894
  };
4754
- tick6();
4895
+ tick7();
4755
4896
  });
4756
4897
  }
4757
4898
  function setReactInputValue(input, value) {
@@ -6260,9 +6401,9 @@
6260
6401
  clearWallpaper();
6261
6402
  return;
6262
6403
  }
6263
- const tick6 = () => showFile(files[nextIdx(files.length)], "folder");
6264
- wpTickFn = tick6;
6265
- tick6();
6404
+ const tick7 = () => showFile(files[nextIdx(files.length)], "folder");
6405
+ wpTickFn = tick7;
6406
+ tick7();
6266
6407
  armRotateTimer(bg);
6267
6408
  return;
6268
6409
  }
@@ -6357,8 +6498,8 @@
6357
6498
  clearInterval(st.timer);
6358
6499
  st.timer = null;
6359
6500
  }
6360
- const setState = (image, tick6) => {
6361
- regionState[region] = { sig, image, tick: tick6, timer: null, interval: 0 };
6501
+ const setState = (image, tick7) => {
6502
+ regionState[region] = { sig, image, tick: tick7, timer: null, interval: 0 };
6362
6503
  if (image) addRule(region, image);
6363
6504
  };
6364
6505
  const drop = () => {
@@ -6461,6 +6602,475 @@
6461
6602
  }
6462
6603
  }
6463
6604
 
6605
+ // src/inject/features/plugin-updates.js
6606
+ init_core();
6607
+ init_ui();
6608
+ var NOTIFIED_KEY = "zcodepro-plugin-updates-notified";
6609
+ var AUTO_UPDATE_LAUNCH_KEY = "zcodepro-plugin-autoupdate-launch";
6610
+ var AUTO_UPDATE_SESSION_KEY = "zcodepro-plugin-autoupdate-session-claim";
6611
+ function autoUpdateLaunchMark() {
6612
+ try {
6613
+ const raw = new URLSearchParams(location.search).get("zcodeLaunchMarks");
6614
+ if (raw) {
6615
+ const createdAt = JSON.parse(raw)?.createdAt;
6616
+ if (createdAt != null) return `launch:${createdAt}`;
6617
+ }
6618
+ } catch {
6619
+ }
6620
+ try {
6621
+ let id = sessionStorage.getItem("zcodepro-plugin-autoupdate-session");
6622
+ if (!id) {
6623
+ id = `session:${Date.now()}:${Math.random().toString(36).slice(2)}`;
6624
+ sessionStorage.setItem("zcodepro-plugin-autoupdate-session", id);
6625
+ }
6626
+ return id;
6627
+ } catch {
6628
+ return `memory:${Date.now()}:${Math.random().toString(36).slice(2)}`;
6629
+ }
6630
+ }
6631
+ var memoryClaimed = false;
6632
+ var LAUNCH_MARK = autoUpdateLaunchMark();
6633
+ function claimIn(storage, key, mark) {
6634
+ try {
6635
+ if (storage.getItem(key) === mark) return false;
6636
+ storage.setItem(key, mark);
6637
+ return true;
6638
+ } catch {
6639
+ return null;
6640
+ }
6641
+ }
6642
+ function claimAutoUpdateRun() {
6643
+ const mark = LAUNCH_MARK;
6644
+ const local = typeof localStorage === "undefined" ? null : localStorage;
6645
+ const viaLocal = local ? claimIn(local, AUTO_UPDATE_LAUNCH_KEY, mark) : null;
6646
+ if (viaLocal !== null) return viaLocal;
6647
+ const session = typeof sessionStorage === "undefined" ? null : sessionStorage;
6648
+ const viaSession = session ? claimIn(session, AUTO_UPDATE_SESSION_KEY, mark) : null;
6649
+ if (viaSession !== null) return viaSession;
6650
+ if (memoryClaimed) return false;
6651
+ memoryClaimed = true;
6652
+ return true;
6653
+ }
6654
+ async function startPluginUpdateCheck() {
6655
+ const status = await rpc("/plugins/status");
6656
+ if (!status.ok || !Array.isArray(status.updates)) return;
6657
+ const L = t();
6658
+ if (status.updates.length === 0) return;
6659
+ const config = await getConfig();
6660
+ if ((config.features || {}).autoUpdatePlugins === true) {
6661
+ if (!claimAutoUpdateRun()) return;
6662
+ const res = await rpc("/plugins/update", { method: "POST", body: {} });
6663
+ if (res.ok) showToast(L.pluginsAutoUpdated, "success");
6664
+ else showToast(L.pluginsUpdateFailed + ": " + (res.error || ""), "error");
6665
+ return;
6666
+ }
6667
+ const sig = status.updates.map((u) => `${u.name}:${u.installed}>${u.latest}`).join(",");
6668
+ let seen2 = "";
6669
+ try {
6670
+ seen2 = window.localStorage.getItem(NOTIFIED_KEY) || "";
6671
+ } catch {
6672
+ }
6673
+ if (seen2 === sig) return;
6674
+ try {
6675
+ window.localStorage.setItem(NOTIFIED_KEY, sig);
6676
+ } catch {
6677
+ }
6678
+ showToast(L.pluginsUpdatesAvailable.replaceAll("{n}", String(status.updates.length)), "info");
6679
+ }
6680
+
6681
+ // src/inject/features/session-import.js
6682
+ init_core();
6683
+ init_ui();
6684
+ init_ws_running();
6685
+ var INPUT_CLS = "h-8 w-full rounded-lg border border-border bg-input px-2.5 text-ui-sm text-foreground outline-none transition-shadow placeholder:text-foreground-subtle focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40";
6686
+ function tag(text, title = "") {
6687
+ return h("span", { class: "shrink-0 rounded border border-border px-1 text-ui-xs text-foreground-subtle", title: title || void 0 }, text);
6688
+ }
6689
+ function when(ms) {
6690
+ if (!ms) return "";
6691
+ try {
6692
+ return new Date(ms).toLocaleString();
6693
+ } catch {
6694
+ return "";
6695
+ }
6696
+ }
6697
+ function createSessionImportPane() {
6698
+ const L = t();
6699
+ const root = h("div", { role: "tabpanel", style: "display:none" });
6700
+ let sources = [];
6701
+ let active = "";
6702
+ let sessions = [];
6703
+ let selected = /* @__PURE__ */ new Set();
6704
+ let projects = [];
6705
+ let projectId = "";
6706
+ let showAll = false;
6707
+ let onlyProject = false;
6708
+ let search = "";
6709
+ let loading = false;
6710
+ let importing = false;
6711
+ let loaded = false;
6712
+ let pendingReload = false;
6713
+ let searchTimer = null;
6714
+ const statusEl = h("div", { class: "mt-2 min-h-4 text-ui-xs/relaxed text-foreground-subtle" });
6715
+ const listEl = h("div", { class: "max-h-80 overflow-auto divide-y divide-border" });
6716
+ const sourceTabs = h("div", { role: "tablist", "aria-orientation": "horizontal", class: "zcodepro-tablist" });
6717
+ const searchInput = h("input", {
6718
+ type: "text",
6719
+ class: INPUT_CLS + " min-w-0 flex-1",
6720
+ placeholder: L.importSearch,
6721
+ spellcheck: "false",
6722
+ autocomplete: "off"
6723
+ });
6724
+ const projectSelect = h("select", { class: INPUT_CLS + " min-w-0 max-w-56" });
6725
+ const onlyProjectBox = h("input", { type: "checkbox" });
6726
+ const showAllBox = h("input", { type: "checkbox", title: L.importShowAllTip });
6727
+ const selectAllBox = h("input", { type: "checkbox" });
6728
+ const refreshBtn = btnSmall(L.importRefresh, () => {
6729
+ void loadList();
6730
+ });
6731
+ const importBtn = btnSmall(L.importSelected.replace("{n}", "0"), () => {
6732
+ void doImport();
6733
+ }, "shrink-0", "primary");
6734
+ importBtn.disabled = true;
6735
+ const setStatus = (text, kind = "") => {
6736
+ statusEl.textContent = text || "";
6737
+ statusEl.className = "mt-2 min-h-4 text-ui-xs/relaxed " + (kind === "error" ? "text-destructive" : "text-foreground-subtle");
6738
+ };
6739
+ const selectedProject = () => projects.find((p) => p.id === projectId) || null;
6740
+ const projectRoots = () => (selectedProject()?.roots || []).map((r) => r.path).filter(Boolean);
6741
+ const refreshTaskTree = async () => {
6742
+ const rootEl = document.getElementById("root");
6743
+ const containerKey = rootEl && Object.keys(rootEl).find((k) => k.startsWith("__reactContainer$"));
6744
+ if (!containerKey) return false;
6745
+ const seen2 = /* @__PURE__ */ new Set();
6746
+ let found = null;
6747
+ const scan6 = (o) => {
6748
+ if (!o || typeof o !== "object" || seen2.has(o) || found) return;
6749
+ seen2.add(o);
6750
+ try {
6751
+ if (typeof o.refresh === "function" && "factTree" in o && "tree" in o) found = o;
6752
+ } catch {
6753
+ }
6754
+ };
6755
+ let visited = 0;
6756
+ const visit = (f) => {
6757
+ if (!f || found || visited > 6e4) return;
6758
+ visited++;
6759
+ for (const h2 of [f.memoizedProps, f.memoizedState]) {
6760
+ if (!h2 || typeof h2 !== "object") continue;
6761
+ scan6(h2);
6762
+ for (const v of Object.values(h2)) if (v && typeof v === "object") scan6(v);
6763
+ }
6764
+ visit(f.child);
6765
+ visit(f.sibling);
6766
+ };
6767
+ visit(rootEl[containerKey]);
6768
+ if (!found) return false;
6769
+ try {
6770
+ await found.refresh();
6771
+ return true;
6772
+ } catch {
6773
+ return false;
6774
+ }
6775
+ };
6776
+ const prepareWorkspaces = async (imported) => {
6777
+ const ag = findServices()?.zcodeAgentService;
6778
+ if (!ag || typeof ag.resumeSession !== "function") return;
6779
+ const seen2 = /* @__PURE__ */ new Set();
6780
+ for (const item of imported) {
6781
+ if (!item.workspace || seen2.has(item.workspace)) continue;
6782
+ seen2.add(item.workspace);
6783
+ try {
6784
+ await ag.resumeSession({ workspacePath: item.workspace, sessionId: item.taskId });
6785
+ } catch {
6786
+ }
6787
+ }
6788
+ };
6789
+ const renderSources = () => {
6790
+ sourceTabs.replaceChildren(...sources.filter((s) => s.available).map((s) => h("button", {
6791
+ type: "button",
6792
+ role: "tab",
6793
+ class: "zcodepro-tab",
6794
+ "aria-selected": String(active === s.id),
6795
+ "data-state": active === s.id ? "active" : "inactive",
6796
+ disabled: !s.available,
6797
+ title: s.available ? "" : L.importSourceMissing,
6798
+ onClick: () => {
6799
+ if (!s.available || active === s.id) return;
6800
+ active = s.id;
6801
+ selected = /* @__PURE__ */ new Set();
6802
+ sessions = [];
6803
+ renderSources();
6804
+ void loadList();
6805
+ }
6806
+ }, s.label)));
6807
+ };
6808
+ const selectable = () => sessions.filter((s) => !s.imported);
6809
+ const allSelected = () => {
6810
+ const list = selectable();
6811
+ return list.length > 0 && list.every((s) => selected.has(s.sessionId));
6812
+ };
6813
+ const renderList = () => {
6814
+ selectAllBox.checked = allSelected();
6815
+ selectAllBox.disabled = importing || !selectable().length;
6816
+ importBtn.textContent = L.importSelected.replace("{n}", String(selected.size));
6817
+ importBtn.disabled = importing || !selected.size;
6818
+ if (loading) {
6819
+ listEl.replaceChildren(h("div", { class: "px-3 py-6 text-center text-ui-sm text-foreground-subtle" }, L.importLoading));
6820
+ return;
6821
+ }
6822
+ if (!sessions.length) {
6823
+ listEl.replaceChildren(h("div", { class: "px-3 py-6 text-center text-ui-sm text-foreground-subtle" }, L.importNoSessions));
6824
+ return;
6825
+ }
6826
+ listEl.replaceChildren(...sessions.map((s) => {
6827
+ const checked = selected.has(s.sessionId);
6828
+ const box = h("input", {
6829
+ type: "checkbox",
6830
+ class: "mt-0.5 shrink-0",
6831
+ checked,
6832
+ disabled: importing || s.imported,
6833
+ onChange: () => {
6834
+ if (box.checked) selected.add(s.sessionId);
6835
+ else selected.delete(s.sessionId);
6836
+ renderList();
6837
+ }
6838
+ });
6839
+ const tags = [];
6840
+ if (s.imported) {
6841
+ tags.push(tag(
6842
+ s.importedArchived ? L.importAlreadyArchived : L.importAlready,
6843
+ s.importedArchived ? L.importArchivedTaskTip : ""
6844
+ ));
6845
+ }
6846
+ if (s.archived) tags.push(tag(L.importArchived));
6847
+ if (s.subagent) tags.push(tag(L.importSubagent));
6848
+ if (s.codexImport) tags.push(tag(L.importCodexCopy));
6849
+ if (s.large) tags.push(tag(L.importLarge));
6850
+ if (s.cwdExists === false) tags.push(tag(L.importCwdMissing));
6851
+ return h(
6852
+ "label",
6853
+ {
6854
+ class: "flex cursor-pointer items-start gap-2 px-3 py-2 transition-colors hover:bg-surface-hover",
6855
+ title: s.cwd || ""
6856
+ },
6857
+ box,
6858
+ h(
6859
+ "div",
6860
+ { class: "min-w-0 flex-1" },
6861
+ h("div", { class: "truncate text-ui-sm" }, s.title || s.sessionId),
6862
+ h(
6863
+ "div",
6864
+ { class: "mt-0.5 flex items-center gap-2 overflow-hidden" },
6865
+ h("span", { class: "min-w-0 flex-1 truncate text-ui-xs text-foreground-subtle" }, s.cwd || s.sourcePath || ""),
6866
+ h("span", { class: "shrink-0 text-ui-xs text-foreground-subtle" }, when(s.updatedAt)),
6867
+ ...tags
6868
+ )
6869
+ )
6870
+ );
6871
+ }));
6872
+ };
6873
+ const loadProjects = async () => {
6874
+ const res = await rpc("/projects-v2");
6875
+ projects = res.ok && Array.isArray(res.projects) ? res.projects : [];
6876
+ const current2 = projectId;
6877
+ projectSelect.replaceChildren(
6878
+ h("option", { value: "" }, L.importProjectNone),
6879
+ ...projects.map((p) => h("option", { value: p.id }, p.name || p.id))
6880
+ );
6881
+ projectSelect.value = projects.some((p) => p.id === current2) ? current2 : "";
6882
+ projectId = projectSelect.value;
6883
+ onlyProjectBox.disabled = !projectId;
6884
+ if (!projectId) {
6885
+ onlyProjectBox.checked = false;
6886
+ onlyProject = false;
6887
+ }
6888
+ };
6889
+ const loadList = async () => {
6890
+ if (loading || importing) {
6891
+ pendingReload = true;
6892
+ return;
6893
+ }
6894
+ loading = true;
6895
+ renderList();
6896
+ const done = () => {
6897
+ loading = false;
6898
+ if (pendingReload) {
6899
+ pendingReload = false;
6900
+ queueMicrotask(() => {
6901
+ void loadList();
6902
+ });
6903
+ }
6904
+ };
6905
+ if (!sources.length || !sources.some((s) => s.id === active && s.available)) {
6906
+ const meta = await rpc("/import/list", { method: "POST", body: { source: "" } });
6907
+ if (meta.ok && Array.isArray(meta.sources)) sources = meta.sources;
6908
+ if (!sources.some((s) => s.id === active && s.available)) {
6909
+ active = (sources.find((s) => s.available) || {}).id || "";
6910
+ }
6911
+ renderSources();
6912
+ if (!active) {
6913
+ sessions = [];
6914
+ done();
6915
+ renderList();
6916
+ setStatus(L.importNoSource);
6917
+ return;
6918
+ }
6919
+ }
6920
+ const res = await rpc("/import/list", {
6921
+ method: "POST",
6922
+ body: {
6923
+ source: active,
6924
+ showAll,
6925
+ search,
6926
+ roots: onlyProject && projectId ? projectRoots() : []
6927
+ }
6928
+ });
6929
+ if (!res.ok) {
6930
+ sessions = [];
6931
+ done();
6932
+ renderList();
6933
+ setStatus(errText(res), "error");
6934
+ return;
6935
+ }
6936
+ sources = res.sources || sources;
6937
+ sessions = res.sessions || [];
6938
+ const usable = new Set(selectable().map((s) => s.sessionId));
6939
+ selected = new Set([...selected].filter((id) => usable.has(id)));
6940
+ if (!active || !sources.some((s) => s.id === active)) {
6941
+ active = (sources.find((s) => s.available) || {}).id || "";
6942
+ }
6943
+ done();
6944
+ renderSources();
6945
+ renderList();
6946
+ setStatus(res.unavailable ? L.importNoSource : "");
6947
+ };
6948
+ const doImport = async () => {
6949
+ if (importing || !selected.size) return;
6950
+ const chosen = sessions.filter((s) => selected.has(s.sessionId));
6951
+ if (!chosen.length) return;
6952
+ if (chosen.some((s) => s.large)) {
6953
+ if (!window.confirm(L.importConfirmLarge)) return;
6954
+ }
6955
+ importing = true;
6956
+ renderList();
6957
+ setStatus(L.importImporting);
6958
+ let summary = "";
6959
+ let summaryKind = "";
6960
+ try {
6961
+ const res = await rpc("/import/run", {
6962
+ method: "POST",
6963
+ body: {
6964
+ source: active,
6965
+ projectId: projectId || null,
6966
+ items: chosen.map((s) => ({
6967
+ sessionId: s.sessionId,
6968
+ sourcePath: s.sourcePath,
6969
+ title: s.title,
6970
+ cwd: s.cwd
6971
+ }))
6972
+ }
6973
+ });
6974
+ if (!res.ok) {
6975
+ setStatus(errText(res), "error");
6976
+ showToast(L.importFailed + ": " + errText(res), "error");
6977
+ return;
6978
+ }
6979
+ const imported = Array.isArray(res.imported) ? res.imported : [];
6980
+ const skipped = Array.isArray(res.skipped) ? res.skipped : [];
6981
+ const failed = Array.isArray(res.failed) ? res.failed : [];
6982
+ const msg = L.importDone.replace("{ok}", String(imported.length)).replace("{skip}", String(skipped.length)).replace("{fail}", String(failed.length));
6983
+ const detail = failed.slice(0, 3).map((f) => `${f.sessionId}: ${f.error}`).join("; ");
6984
+ summary = msg + (detail ? " \xB7 " + detail : "");
6985
+ summaryKind = failed.length ? "error" : "";
6986
+ showToast(msg, failed.length ? "error" : "success");
6987
+ if (imported.length) {
6988
+ void (async () => {
6989
+ await prepareWorkspaces(imported);
6990
+ await refreshTaskTree().catch(() => {
6991
+ });
6992
+ })();
6993
+ }
6994
+ selected = /* @__PURE__ */ new Set();
6995
+ } finally {
6996
+ importing = false;
6997
+ }
6998
+ await loadList();
6999
+ setStatus(summary, summaryKind);
7000
+ };
7001
+ searchInput.addEventListener("input", () => {
7002
+ search = searchInput.value;
7003
+ clearTimeout(searchTimer);
7004
+ searchTimer = setTimeout(() => {
7005
+ void loadList();
7006
+ }, 250);
7007
+ });
7008
+ projectSelect.addEventListener("change", () => {
7009
+ projectId = projectSelect.value;
7010
+ onlyProjectBox.disabled = !projectId;
7011
+ if (!projectId) {
7012
+ onlyProjectBox.checked = false;
7013
+ onlyProject = false;
7014
+ }
7015
+ void loadList();
7016
+ });
7017
+ onlyProjectBox.addEventListener("change", () => {
7018
+ onlyProject = onlyProjectBox.checked;
7019
+ void loadList();
7020
+ });
7021
+ showAllBox.addEventListener("change", () => {
7022
+ showAll = showAllBox.checked;
7023
+ selected = /* @__PURE__ */ new Set();
7024
+ void loadList();
7025
+ });
7026
+ selectAllBox.addEventListener("change", () => {
7027
+ if (selectAllBox.checked) selected = new Set(selectable().map((s) => s.sessionId));
7028
+ else selected = /* @__PURE__ */ new Set();
7029
+ renderList();
7030
+ });
7031
+ const checkLabel = (box, text, title = "") => h("label", { class: "flex shrink-0 items-center gap-1.5 text-ui-xs text-foreground-subtle", title: title || void 0 }, box, text);
7032
+ root.append(
7033
+ h("p", { class: "text-ui-sm/relaxed text-foreground-subtle" }, L.importDesc),
7034
+ h("div", { class: "mt-3" }, sourceTabs),
7035
+ h(
7036
+ "div",
7037
+ { class: "mt-2 flex flex-wrap items-center gap-2" },
7038
+ searchInput,
7039
+ projectSelect,
7040
+ checkLabel(onlyProjectBox, L.importOnlyProject),
7041
+ checkLabel(showAllBox, L.importShowAll, L.importShowAllTip),
7042
+ refreshBtn
7043
+ ),
7044
+ h(
7045
+ "div",
7046
+ { class: "mt-2 flex items-center justify-between gap-2" },
7047
+ h(
7048
+ "div",
7049
+ { class: "flex items-center gap-2" },
7050
+ checkLabel(selectAllBox, L.importSelectAll),
7051
+ h("span", { class: "text-ui-xs text-foreground-subtle" }, L.importProjectHint)
7052
+ ),
7053
+ importBtn
7054
+ ),
7055
+ h("div", { class: "mt-2 rounded-xl border border-border" }, listEl),
7056
+ statusEl
7057
+ );
7058
+ root.__onShow = () => {
7059
+ if (importing) return;
7060
+ if (!loaded) {
7061
+ loaded = true;
7062
+ setStatus(L.importLoading);
7063
+ void (async () => {
7064
+ await loadProjects();
7065
+ await loadList();
7066
+ })();
7067
+ } else {
7068
+ void loadList();
7069
+ }
7070
+ };
7071
+ return root;
7072
+ }
7073
+
6464
7074
  // src/inject/features/settings-dialog.js
6465
7075
  function openExternal(url) {
6466
7076
  try {
@@ -6546,7 +7156,7 @@
6546
7156
  setState(L.upgradeFound.replaceAll("{v}", res.latest || ""));
6547
7157
  btn.textContent = L.upgradeNow;
6548
7158
  };
6549
- const tick6 = async () => {
7159
+ const tick7 = async () => {
6550
7160
  const res = await rpc(endpoint + "/upgrade");
6551
7161
  if (!res.ok) {
6552
7162
  stopPoll();
@@ -6586,9 +7196,9 @@
6586
7196
  btn.textContent = L.upgradeStop;
6587
7197
  setState(L.upgradeRunning);
6588
7198
  timer = setInterval(() => {
6589
- void tick6();
7199
+ void tick7();
6590
7200
  }, 1500);
6591
- void tick6();
7201
+ void tick7();
6592
7202
  };
6593
7203
  void (async () => {
6594
7204
  const res = await rpc(endpoint + "/upgrade");
@@ -6731,11 +7341,11 @@
6731
7341
  const cfg = await getConfig(true).catch(() => null);
6732
7342
  const res = await rpc("/plugins/status");
6733
7343
  if (!res.ok) {
6734
- setPluginsStatus("");
7344
+ setPluginsStatus(errText(res));
6735
7345
  return;
6736
7346
  }
6737
7347
  const n = (res.updates || []).length;
6738
- if (cfg && (cfg.features || {}).autoUpdatePlugins === true && n > 0) {
7348
+ if (cfg && (cfg.features || {}).autoUpdatePlugins === true && n > 0 && claimAutoUpdateRun()) {
6739
7349
  void runPluginsUpdate();
6740
7350
  return;
6741
7351
  }
@@ -6822,6 +7432,11 @@
6822
7432
  if (await setFeature("composerProvider", next)) f.composerProvider = next;
6823
7433
  refreshRows();
6824
7434
  }),
7435
+ settingRow(L.featureSessionImport, L.featureSessionImportDesc, f.sessionImport !== false, async () => {
7436
+ const next = !(f.sessionImport !== false);
7437
+ if (await setFeature("sessionImport", next)) f.sessionImport = next;
7438
+ refreshRows();
7439
+ }),
6825
7440
  settingRow(L.featureSandboxReclaim, L.featureSandboxReclaimDesc, f.sandboxReclaim !== false, async () => {
6826
7441
  const next = !(f.sandboxReclaim !== false);
6827
7442
  if (await setFeature("sandboxReclaim", next)) f.sandboxReclaim = next;
@@ -6837,6 +7452,11 @@
6837
7452
  if (await setFeature("wsRunningSpin", next)) f.wsRunningSpin = next;
6838
7453
  refreshRows();
6839
7454
  }),
7455
+ settingRow(L.featureSubagentIcon, L.featureSubagentIconDesc, f.subagentIcon !== false, async () => {
7456
+ const next = !(f.subagentIcon !== false);
7457
+ if (await setFeature("subagentIcon", next)) f.subagentIcon = next;
7458
+ refreshRows();
7459
+ }),
6840
7460
  settingRow(L.featureNewtabPanels, L.featureNewtabPanelsDesc, f.newtabPanels !== false, async () => {
6841
7461
  const next = !(f.newtabPanels !== false);
6842
7462
  if (await setFeature("newtabPanels", next)) f.newtabPanels = next;
@@ -7052,12 +7672,13 @@
7052
7672
  const paneAgents = h("div", { role: "tabpanel", style: "display:none" });
7053
7673
  const paneProxy = h("div", { role: "tabpanel", style: "display:none" });
7054
7674
  const paneSync = h("div", { role: "tabpanel", style: "display:none" });
7675
+ const paneImport = createSessionImportPane();
7055
7676
  const paneVision = h("div", { role: "tabpanel", style: "display:none" });
7056
7677
  const paneRtk = h("div", { role: "tabpanel", style: "display:none" });
7057
7678
  const paneHeadroom = h("div", { role: "tabpanel", style: "display:none" });
7058
7679
  const paneTitleGen = h("div", { role: "tabpanel", style: "display:none" });
7059
7680
  const paneDebug = h("div", { role: "tabpanel", style: "display:none" });
7060
- const panes = { features: paneFeatures, shortcuts: paneShortcuts, styles: paneStyles, perf: panePerf, agents: paneAgents, proxy: paneProxy, sync: paneSync, vision: paneVision, headroom: paneHeadroom, rtk: paneRtk, debug: paneDebug };
7681
+ const panes = { features: paneFeatures, shortcuts: paneShortcuts, styles: paneStyles, perf: panePerf, agents: paneAgents, proxy: paneProxy, sync: paneSync, import: paneImport, vision: paneVision, headroom: paneHeadroom, rtk: paneRtk, debug: paneDebug };
7061
7682
  const tabDefs = [
7062
7683
  ["features", L.tabFeatures],
7063
7684
  ["styles", L.tabStyles],
@@ -7066,6 +7687,7 @@
7066
7687
  ["shortcuts", L.tabShortcuts],
7067
7688
  ["proxy", L.tabProxy],
7068
7689
  ["sync", L.tabSync],
7690
+ ...config.features.sessionImport !== false ? [["import", L.tabImport]] : [],
7069
7691
  ["vision", L.tabVision],
7070
7692
  ["headroom", L.tabHeadroom],
7071
7693
  ["rtk", L.tabRtk],
@@ -7087,6 +7709,7 @@
7087
7709
  if (name !== "shortcuts" && hkRecording) stopHkRecording();
7088
7710
  for (const [id, pane] of Object.entries(panes)) pane.style.display = id === name ? "" : "none";
7089
7711
  for (const [id, bar] of Object.entries(subTabBars)) bar.style.display = id === name ? "" : "none";
7712
+ if (name === "import") paneImport.__onShow?.();
7090
7713
  renderTabs();
7091
7714
  };
7092
7715
  renderTabs();
@@ -7313,7 +7936,7 @@
7313
7936
  };
7314
7937
  const sbList = h("div", { class: "divide-y divide-border rounded-xl border border-border" });
7315
7938
  const sbGlobalList = h("div", { class: "divide-y divide-border rounded-xl border border-border" });
7316
- const TURN_NAMES = { turnIn: "sbLabelIn", turnOut: "sbLabelOut", turnCache: "sbLabelCache" };
7939
+ const TURN_NAMES = { turnIn: "sbLabelIn", turnOut: "sbLabelOut", turnTps: "sbLabelTps", turnCache: "sbLabelCache" };
7317
7940
  const turnItems = () => {
7318
7941
  const saved = config.statusBar && Array.isArray(config.statusBar.turnItems) ? config.statusBar.turnItems : null;
7319
7942
  if (!saved) return DEFAULT_TURN_ITEMS.map((x) => ({ ...x }));
@@ -8453,11 +9076,6 @@
8453
9076
  }, "shrink-0");
8454
9077
  const runProxyTest = async () => {
8455
9078
  if (proxyTesting) return;
8456
- if (!proxyInput.value.trim()) {
8457
- proxyTestState.className = "mt-2 text-ui-xs/relaxed text-amber-500";
8458
- proxyTestState.textContent = L.proxyTestEmpty;
8459
- return;
8460
- }
8461
9079
  proxyTesting = true;
8462
9080
  proxyTestBtn.disabled = true;
8463
9081
  proxyTestBtn.textContent = L.proxyTesting;
@@ -9004,11 +9622,53 @@
9004
9622
  }
9005
9623
  }, 2e3);
9006
9624
  };
9625
+ const DT_KEYS = ["zcode:developer-tools:enabled", "zcode:token-debug:enabled"];
9626
+ const dtRead = (v) => v !== null && !["0", "false", "off", "no"].includes(v.trim().toLowerCase());
9627
+ const dtOn = () => DT_KEYS.some((k) => dtRead(localStorage.getItem(k)));
9628
+ const dtSet = (on) => {
9629
+ for (const k of DT_KEYS) {
9630
+ if (on) localStorage.setItem(k, "true");
9631
+ else localStorage.removeItem(k);
9632
+ }
9633
+ };
9634
+ const dtSwitchBtn = (checked) => h("button", {
9635
+ type: "button",
9636
+ role: "switch",
9637
+ "aria-checked": String(checked),
9638
+ class: "relative inline-flex shrink-0 cursor-pointer items-center"
9639
+ }, h(
9640
+ "span",
9641
+ { class: "zcodepro-switch", "data-zcodepro-switch": "", "data-state": checked ? "on" : "off" },
9642
+ h("span", { class: "zcodepro-switch-knob" })
9643
+ ));
9644
+ const devToolsRow = () => {
9645
+ const sw = dtSwitchBtn(dtOn());
9646
+ return h(
9647
+ "div",
9648
+ {
9649
+ class: "flex cursor-pointer items-center justify-between gap-2 px-2 py-1.5",
9650
+ onClick: () => {
9651
+ dtSet(!dtOn());
9652
+ const n = dtOn();
9653
+ sw.setAttribute("aria-checked", String(n));
9654
+ sw.firstElementChild.setAttribute("data-state", n ? "on" : "off");
9655
+ }
9656
+ },
9657
+ h(
9658
+ "div",
9659
+ { class: "min-w-0" },
9660
+ h("div", { class: "text-ui-sm font-medium text-foreground" }, L.devToolsSwitch),
9661
+ h("div", { class: "mt-0.5 text-ui-xs/relaxed text-foreground-subtle" }, L.devToolsSwitchDesc)
9662
+ ),
9663
+ sw
9664
+ );
9665
+ };
9007
9666
  paneDebug.append(
9008
9667
  h("p", { class: "text-ui-sm/relaxed text-foreground-subtle" }, L.devModeDesc),
9009
9668
  h(
9010
9669
  "div",
9011
- { class: "mt-3 rounded-xl border border-border" },
9670
+ { class: "mt-3 divide-y divide-border rounded-xl border border-border" },
9671
+ devToolsRow(),
9012
9672
  h(
9013
9673
  "div",
9014
9674
  { class: "flex items-center justify-between gap-2 px-2 py-1.5" },
@@ -9022,7 +9682,13 @@
9022
9682
  )
9023
9683
  )
9024
9684
  );
9025
- const VISION_DEFAULT_PROMPT = "\u8BF7\u8BE6\u7EC6\u63CF\u8FF0\u8FD9\u5F20\u56FE\u7247\u7684\u5168\u90E8\u5185\u5BB9\u3002\u82E5\u662F\u754C\u9762\u6216\u56FE\u8868\u622A\u56FE\uFF0C\u8BF7\u5148\u628A\u6240\u6709\u9519\u8BEF\u3001\u8B66\u544A\u3001\u5F02\u5E38\u72B6\u6001\u9010\u5B57\u5F15\u7528\u51FA\u6765\uFF08\u542B\u5B8C\u6574\u539F\u6587\uFF09\uFF0C\u518D\u63CF\u8FF0\u6574\u4F53\u5E03\u5C40\u3001\u6587\u5B57\u4E0E\u5173\u952E\u6570\u636E\u3002";
9685
+ const VISION_DEFAULT_PROMPT_ZH = "\u8BF7\u8BE6\u7EC6\u63CF\u8FF0\u8FD9\u5F20\u56FE\u7247\u7684\u5168\u90E8\u5185\u5BB9\u3002\u82E5\u662F\u754C\u9762\u6216\u56FE\u8868\u622A\u56FE\uFF0C\u8BF7\u5148\u628A\u6240\u6709\u9519\u8BEF\u3001\u8B66\u544A\u3001\u5F02\u5E38\u72B6\u6001\u9010\u5B57\u5F15\u7528\u51FA\u6765\uFF08\u542B\u5B8C\u6574\u539F\u6587\uFF09\uFF0C\u518D\u63CF\u8FF0\u6574\u4F53\u5E03\u5C40\u3001\u6587\u5B57\u4E0E\u5173\u952E\u6570\u636E\u3002";
9686
+ const VISION_DEFAULT_PROMPT_EN = "Describe the entire content of this image in detail. If it is a UI or chart screenshot, first quote every error, warning, and abnormal state verbatim (including the full text), then describe the overall layout, text, and key data.";
9687
+ const VISION_DEFAULT_PROMPT = isZhLocale() ? VISION_DEFAULT_PROMPT_ZH : VISION_DEFAULT_PROMPT_EN;
9688
+ const isBuiltinVisionPrompt = (p) => {
9689
+ const text = String(p || "").trim();
9690
+ return text === VISION_DEFAULT_PROMPT_ZH || text === VISION_DEFAULT_PROMPT_EN;
9691
+ };
9026
9692
  const VISION_DEFAULT_CFG = {
9027
9693
  enabled: true,
9028
9694
  chainMode: "fallback",
@@ -9039,6 +9705,11 @@
9039
9705
  // forceIntercept 不写:缺省 = 自动(跟随宿主「模型设置」图片开关,zcode-vision ≥1.7.9)
9040
9706
  };
9041
9707
  let visionCfg = visionRes.ok && visionRes.config && typeof visionRes.config === "object" ? structuredClone(visionRes.config) : null;
9708
+ if (visionCfg && Array.isArray(visionCfg.proxies)) {
9709
+ for (const proxy of visionCfg.proxies) {
9710
+ if (isBuiltinVisionPrompt(proxy.prompt)) proxy.prompt = VISION_DEFAULT_PROMPT;
9711
+ }
9712
+ }
9042
9713
  let visionAutoInitTried = false;
9043
9714
  let visionSaveTimer = null;
9044
9715
  const persistVision = async () => {
@@ -9868,6 +10539,24 @@
9868
10539
  );
9869
10540
  };
9870
10541
  renderHrUsageSwitch();
10542
+ const hrSerenaRow = h("div");
10543
+ const renderSerenaSwitch = () => {
10544
+ const serenaOn = !!(headroomRes.serena && headroomRes.serena.enabled);
10545
+ hrSerenaRow.replaceChildren(
10546
+ settingRow(L.serenaSwitch, L.serenaSwitchDesc, serenaOn, async () => {
10547
+ const next = !serenaOn;
10548
+ const res = await rpc("/headroom", { method: "POST", body: { serena: next } });
10549
+ if (!res.ok) {
10550
+ showToast(L.failed + ": " + errText(res), "error");
10551
+ return;
10552
+ }
10553
+ if (res.serena) headroomRes.serena = res.serena;
10554
+ renderSerenaSwitch();
10555
+ showToast(next ? L.serenaEnabled : L.serenaDisabled, "success");
10556
+ })
10557
+ );
10558
+ };
10559
+ renderSerenaSwitch();
9871
10560
  const hrRefreshBtn = btnSmall(L.headroomRefresh, () => {
9872
10561
  void hrRefresh();
9873
10562
  });
@@ -10062,7 +10751,8 @@
10062
10751
  )
10063
10752
  ),
10064
10753
  hrPwrHint
10065
- )
10754
+ ),
10755
+ h("div", { class: "mt-2 rounded-xl border border-border p-1" }, hrSerenaRow)
10066
10756
  );
10067
10757
  };
10068
10758
  renderHeadroomPane();
@@ -10298,6 +10988,7 @@
10298
10988
  panePerf,
10299
10989
  paneProxy,
10300
10990
  paneSync,
10991
+ paneImport,
10301
10992
  paneVision,
10302
10993
  paneHeadroom,
10303
10994
  paneRtk,
@@ -10326,7 +11017,7 @@
10326
11017
  init_core();
10327
11018
  init_ui();
10328
11019
  init_core();
10329
- var installed = false;
11020
+ var installed2 = false;
10330
11021
  var dragKey = null;
10331
11022
  var lastOverRow = null;
10332
11023
  var lastOverBefore = false;
@@ -10352,8 +11043,8 @@
10352
11043
  });
10353
11044
  }
10354
11045
  function startTaskOrderWatcher() {
10355
- if (installed || typeof document === "undefined") return;
10356
- installed = true;
11046
+ if (installed2 || typeof document === "undefined") return;
11047
+ installed2 = true;
10357
11048
  ensureStyle();
10358
11049
  document.addEventListener("dragstart", (e) => {
10359
11050
  const row = e.target.closest && e.target.closest("[data-task-item-key]");
@@ -10643,6 +11334,9 @@
10643
11334
  }
10644
11335
  var lastRenderedHtml = null;
10645
11336
  function selectedSessionId() {
11337
+ const pane = document.querySelector("[data-session-id]");
11338
+ const pid = pane ? pane.getAttribute("data-session-id") : "";
11339
+ if (pid && /^(?:sess|session)_/.test(pid)) return pid;
10646
11340
  const row = document.querySelector("[data-task-item-key].bg-selected");
10647
11341
  const key = row ? row.getAttribute("data-task-item-key") : "";
10648
11342
  const i = key.lastIndexOf(":sess");
@@ -10752,12 +11446,14 @@
10752
11446
  }
10753
11447
  var GLOBAL_GROUP = /* @__PURE__ */ new Set(["todayTokens", "totalTokens", "tasks"]);
10754
11448
  var SB_ICONS = {
10755
- tokRate: '<path d="m12 14 4-4"/><path d="M3.34 19a10 10 0 1 1 17.32 0"/>',
11449
+ tokRate: '<path d="m12 11 4-4"/><path d="M3.34 16a10 10 0 1 1 17.32 0"/>',
10756
11450
  ctx: '<path d="M21.21 15.89A10 10 0 1 1 8 2.83"/><path d="M22 12A10 10 0 0 0 12 2v10z"/>',
10757
11451
  asks: '<path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/>',
10758
11452
  today: '<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>',
10759
11453
  total: '<ellipse cx="12" cy="5" rx="9" ry="3"/><path d="M3 5V19A9 3 0 0 0 21 19V5"/><path d="M3 12A9 3 0 0 0 21 12"/>',
10760
11454
  tasks: '<rect x="3" y="5" width="6" height="6" rx="1"/><path d="m3 17 2 2 4-4"/><path d="M13 6h8"/><path d="M13 12h8"/><path d="M13 18h8"/>',
11455
+ inOut: '<path d="m21 16-4 4-4-4"/><path d="M17 20V4"/><path d="m3 8 4-4 4 4"/><path d="M7 4v16"/>',
11456
+ hit: '<path d="m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a2 2 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a2 2 0 0 0 0-1.83Z"/><path d="m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"/><path d="m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"/>',
10761
11457
  coins: '<circle cx="8" cy="8" r="6"/><path d="M18.09 10.37A6 6 0 1 1 10.34 18"/><path d="M7 6h1v4"/><path d="m16.71 13.88.7.71-2.82 2.82"/>'
10762
11458
  };
10763
11459
  var sbIcon = (name) => `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="zcodepro-sb-icon">${SB_ICONS[name]}</svg>`;
@@ -10785,15 +11481,16 @@
10785
11481
  case "tokRate": {
10786
11482
  const sid = selectedSessionId();
10787
11483
  if (!sid) return null;
10788
- const streaming = streamEst && Date.now() - streamEst.at < 6e3;
10789
- const r = g && g.rate60 && statsSid === sid ? g.rate60 : null;
11484
+ const s = lastStats && statsSid === sid ? lastStats.sessionSummary : null;
11485
+ const tps = s && s.tps != null ? s.tps : null;
10790
11486
  const est = streamEst ? streamEst.value : null;
10791
- const useEst = !!streaming || !(r && r.out > 0);
10792
- const shown = useEst ? est : r.out;
11487
+ const streaming = !!(streamEst && Date.now() - streamEst.at < 5e3);
11488
+ const useEst = streaming && est != null;
11489
+ const shown = useEst ? est : tps != null ? tps : est;
10793
11490
  if (shown == null) return null;
10794
11491
  const zh2 = isZhLocale();
10795
- const estMark = useEst && est != null ? "\u2248" : "";
10796
- const detail = r ? `${L.sbLabelOut} ${r.out.toLocaleString()} tok/s \xB7 ${zh2 ? "\u603B\u91CF" : "total"} ${r.total.toLocaleString()} tok/s` : zh2 ? "\u65E0 usage \u6570\u636E\uFF0C\u6309\u6587\u672C\u589E\u957F\u4F30\u7B97" : "no usage data, estimated from text growth";
11492
+ const estMark = useEst || tps == null ? "\u2248" : "";
11493
+ const detail = useEst ? zh2 ? "\u6D41\u5F0F\u751F\u6210\u4E2D\uFF0C\u6309\u6587\u672C\u589E\u957F\u4F30\u7B97\uFF08\u7EA6 2 \u5B57\u7B26/token\uFF09" : "streaming; estimated from text growth (~2 chars/token)" : tps != null ? `${L.sbLabelOut} ${tps.toLocaleString()} tok/s${zh2 ? "\uFF08\u5B98\u65B9\u51C0\u751F\u6210\u53E3\u5F84\uFF0C\u672C\u4F1A\u8BDD\u6811\uFF09" : " (net generation, session tree)"}` : zh2 ? "\u65E0 usage \u6570\u636E\uFF0C\u6309\u6587\u672C\u589E\u957F\u4F30\u7B97" : "no usage data, estimated from text growth";
10797
11494
  return {
10798
11495
  html: sbIcon("tokRate") + label(L.sbLabelOut) + `<b>${estMark}${fmtNum(Math.round(shown * 10) / 10)} tok/s</b>`,
10799
11496
  title: `${L.sbItemTokRate}${zh2 ? "\uFF08\u672C\u4F1A\u8BDD\uFF09\uFF1A" : " (this session): "}${detail}`,
@@ -10814,9 +11511,22 @@
10814
11511
  return null;
10815
11512
  }
10816
11513
  case "questions": {
10817
- const nav = document.querySelector('[data-testid="v4-turn-navigator"]');
10818
- const n = nav ? Number(nav.getAttribute("data-item-count")) : 0;
10819
- return n > 0 ? { html: sbIcon("asks") + label(L.sbLabelQuestions) + String(n), title: L.sbItemQuestions } : null;
11514
+ const s = lastStats && statsSid === selectedSessionId() ? lastStats.sessionSummary : null;
11515
+ return s && s.requests > 0 ? { html: sbIcon("asks") + label(L.sbLabelQuestions) + String(s.requests), title: L.sbItemQuestions } : null;
11516
+ }
11517
+ case "inOut": {
11518
+ const s = lastStats && statsSid === selectedSessionId() ? lastStats.sessionSummary : null;
11519
+ return s && s.totalIn + s.totalOut > 0 ? {
11520
+ html: sbIcon("inOut") + label(L.sbLabelInOut) + `${fmtNum(s.totalIn)}/${fmtNum(s.totalOut)}`,
11521
+ title: `${L.sbItemInOut}${isZhLocale() ? "\uFF1A" : ": "}${s.totalIn.toLocaleString()} / ${s.totalOut.toLocaleString()}`
11522
+ } : null;
11523
+ }
11524
+ case "avgHit": {
11525
+ const s = lastStats && statsSid === selectedSessionId() ? lastStats.sessionSummary : null;
11526
+ return s && s.hitRate != null ? {
11527
+ html: sbIcon("hit") + label(L.sbLabelHit) + `${(s.hitRate * 100).toFixed(2)}%`,
11528
+ title: `${L.sbItemHit}${isZhLocale() ? "\uFF1A" : ": "}${(s.hitRate * 100).toFixed(2)}%`
11529
+ } : null;
10820
11530
  }
10821
11531
  case "todayTokens": {
10822
11532
  const n = official && official.todayTokens != null ? official.todayTokens : g ? g.todayTokens : 0;
@@ -10851,33 +11561,52 @@
10851
11561
  }
10852
11562
  host.parentElement.insertBefore(barEl, host.nextSibling);
10853
11563
  }
10854
- const hasSession = !!document.querySelector("[data-task-item-key].bg-selected");
11564
+ const hasSession = !!selectedSessionId();
10855
11565
  barEl.style.marginBottom = hasSession ? "-14px" : "0";
10856
11566
  barEl.style.paddingBottom = hasSession ? "0" : "7px";
10857
11567
  const L = t();
10858
- const parts = [];
10859
- let lastGroup = "";
11568
+ const entries = [];
10860
11569
  for (const it of items) {
10861
11570
  if (!it.on) continue;
10862
11571
  const c = itemContent(it.id, L);
10863
11572
  if (!c) continue;
10864
- const group = GLOBAL_GROUP.has(it.id) ? "g" : "s";
10865
- if (lastGroup && group !== lastGroup) parts.push('<span class="zcodepro-statusbar-groupsep"></span>');
10866
- lastGroup = group;
10867
- parts.push(`<span title="${c.title.replace(/"/g, "&quot;")}"${c.tone ? ` data-tone="${c.tone}"` : ""}>${c.html}</span>`);
11573
+ entries.push({ id: it.id, group: GLOBAL_GROUP.has(it.id) ? "g" : "s", ...c });
10868
11574
  }
10869
11575
  const SEP = '<span class="zcodepro-statusbar-sep">\xB7</span>';
10870
11576
  const GROUPSEP = '<span class="zcodepro-statusbar-groupsep"></span>';
10871
- const html = parts.reduce((acc, p, i) => {
10872
- if (i === 0) return p;
10873
- if (p === GROUPSEP || parts[i - 1] === GROUPSEP) return acc + p;
10874
- return acc + SEP + p;
10875
- }, "");
10876
- barEl.style.display = parts.length ? "" : "none";
10877
- if (html === lastRenderedHtml) return;
10878
- lastRenderedHtml = html;
10879
- barEl.innerHTML = html;
10880
- }
11577
+ const buildHtml = (hidden2) => {
11578
+ const parts = [];
11579
+ let lastGroup = "";
11580
+ for (const e of entries) {
11581
+ if (hidden2.has(e.id)) continue;
11582
+ if (lastGroup && e.group !== lastGroup) parts.push(GROUPSEP);
11583
+ lastGroup = e.group;
11584
+ parts.push(`<span title="${e.title.replace(/"/g, "&quot;")}"${e.tone ? ` data-tone="${e.tone}"` : ""}>${e.html}</span>`);
11585
+ }
11586
+ return parts.reduce((acc, p, i) => {
11587
+ if (i === 0) return p;
11588
+ if (p === GROUPSEP || parts[i - 1] === GROUPSEP) return acc + p;
11589
+ return acc + SEP + p;
11590
+ }, "");
11591
+ };
11592
+ const hidden = /* @__PURE__ */ new Set();
11593
+ for (let guard = 0; guard <= HIDE_ORDER.length; guard++) {
11594
+ const html = buildHtml(hidden);
11595
+ barEl.style.display = html ? "" : "none";
11596
+ if (html !== lastRenderedHtml) {
11597
+ lastRenderedHtml = html;
11598
+ barEl.innerHTML = html;
11599
+ }
11600
+ const gap = 8;
11601
+ let sum = 0;
11602
+ for (const c of barEl.children) sum += c.getBoundingClientRect().width + gap;
11603
+ if (sum - gap <= host.clientWidth + 2) break;
11604
+ const next = HIDE_ORDER.find((id) => !hidden.has(id));
11605
+ if (!next) break;
11606
+ hidden.add(next);
11607
+ }
11608
+ }
11609
+ var HIDE_ORDER = ["tasks", "questions", "totalTokens", "todayTokens", "inOut"];
10881
11610
  async function tick() {
10882
11611
  if (!enabled4 || document.hidden) return;
10883
11612
  refreshOfficial();
@@ -10946,11 +11675,13 @@
10946
11675
  // src/inject/features/turn-usage.js
10947
11676
  init_core();
10948
11677
  var enabled5 = true;
10949
- var recentTurns = [];
11678
+ var rounds = [];
11679
+ var liveRounds = [];
10950
11680
  var scanTimer = 0;
10951
11681
  var turnCfg = [
10952
11682
  { id: "turnIn", on: true },
10953
11683
  { id: "turnOut", on: true },
11684
+ { id: "turnTps", on: true },
10954
11685
  { id: "turnCache", on: true }
10955
11686
  ];
10956
11687
  var refreshTurnItems = () => {
@@ -10966,10 +11697,12 @@
10966
11697
  };
10967
11698
  var ICONS = {
10968
11699
  up: '<path d="m5 12 7-7 7 7"/><path d="M12 19V5"/>',
10969
- down: '<path d="M12 5v14"/><path d="m19 12-7 7-7-7"/>',
10970
- cache: '<path d="m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"/><path d="m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"/><path d="m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"/>'
11700
+ cache: '<path d="m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"/><path d="m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"/><path d="m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"/>',
11701
+ // 与状态栏“输出”同款(gauge):计数段与速度段共用
11702
+ // 墨迹在 24 格视图里垂直居中且不出框(旧字形 U 弧画到框底,描边被裁看着偏下)
11703
+ out: '<path d="m12 11 4-4"/><path d="M3.34 16a10 10 0 1 1 17.32 0"/>'
10971
11704
  };
10972
- var icon = (name) => `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:11px;height:11px;vertical-align:-1.5px;opacity:.6">${ICONS[name]}</svg>`;
11705
+ var icon = (name) => `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:11px;height:11px;opacity:.6">${ICONS[name]}</svg>`;
10973
11706
  function fmt(n) {
10974
11707
  if (!isZhLocale()) {
10975
11708
  if (n >= 1e9) return (n / 1e9).toFixed(1) + "B";
@@ -11002,6 +11735,9 @@
11002
11735
  return rows;
11003
11736
  }
11004
11737
  function currentSessionId() {
11738
+ const pane = document.querySelector("[data-session-id]");
11739
+ const pid = pane ? pane.getAttribute("data-session-id") : "";
11740
+ if (pid && /^(?:sess|session)_/.test(pid)) return pid;
11005
11741
  const rows = [...document.querySelectorAll("[data-task-item-key]")];
11006
11742
  const cur = rows.find((e) => (e.className + "").includes("bg-selected")) || rows[rows.length - 1];
11007
11743
  const key = cur ? cur.getAttribute("data-task-item-key") : "";
@@ -11012,6 +11748,7 @@
11012
11748
  if (!bucket || bucket.in + bucket.out <= 0) return;
11013
11749
  const L = t();
11014
11750
  const cachePct = bucket.in > 0 && bucket.cacheRead > 0 ? (bucket.cacheRead / bucket.in * 100).toFixed(2) : "";
11751
+ const tps = bucket.genMs > 0 ? bucket.tpsOut / (bucket.genMs / 1e3) : null;
11015
11752
  const group = (html2) => `<span style="display:inline-flex;align-items:center;gap:2px">${html2}</span>`;
11016
11753
  const em = (text) => `<em style="font-style:normal;opacity:.75">${text}</em>`;
11017
11754
  const DOT = '<span style="opacity:.45">\xB7</span>';
@@ -11019,7 +11756,8 @@
11019
11756
  for (const s of turnCfg) {
11020
11757
  if (!s.on) continue;
11021
11758
  if (s.id === "turnIn") sections.push(group(icon("up") + em(L.sbLabelIn) + fmt(bucket.in)));
11022
- else if (s.id === "turnOut") sections.push(group(icon("down") + em(L.sbLabelOut) + fmt(bucket.out)));
11759
+ else if (s.id === "turnOut") sections.push(group(icon("out") + em(L.sbLabelOut) + fmt(bucket.out)));
11760
+ else if (s.id === "turnTps" && tps != null) sections.push(group(icon("out") + em(L.sbLabelOut) + Math.round(tps * 10) / 10 + " tok/s"));
11023
11761
  else if (s.id === "turnCache" && cachePct) sections.push(group(icon("cache") + em(L.sbLabelCache) + cachePct + "%"));
11024
11762
  }
11025
11763
  const old = row.querySelector("[data-zcodepro-turn-span]");
@@ -11044,7 +11782,7 @@
11044
11782
  el.style.gap = "4px";
11045
11783
  el.style.marginLeft = "10px";
11046
11784
  el.innerHTML = html;
11047
- el.title = `${L.turnUsageTitle}${isZhLocale() ? "\uFF1A" : ": "}${L.sbLabelIn} ${bucket.in.toLocaleString()} / ${L.sbLabelOut} ${bucket.out.toLocaleString()}` + (bucket.cacheRead > 0 ? ` / ${L.sbLabelCache} ${bucket.cacheRead.toLocaleString()}` : "");
11785
+ el.title = `${L.turnUsageTitle}${isZhLocale() ? "\uFF1A" : ": "}${L.sbLabelIn} ${bucket.in.toLocaleString()} / ${L.sbLabelOut} ${bucket.out.toLocaleString()}` + (tps != null ? ` / ${L.sbLabelOut} ${Math.round(tps * 10) / 10} tok/s` : "") + (bucket.cacheRead > 0 ? ` / ${L.sbLabelCache} ${bucket.cacheRead.toLocaleString()}` : "");
11048
11786
  row.dataset.zcodeproTurn = "1";
11049
11787
  row.append(el);
11050
11788
  }
@@ -11079,31 +11817,80 @@
11079
11817
  const sid = currentSessionId();
11080
11818
  if (sid !== lastSid2) {
11081
11819
  lastSid2 = sid;
11082
- recentTurns = [];
11820
+ rounds = [];
11821
+ liveRounds = [];
11083
11822
  for (const r of rows) clearRow(r.row);
11084
11823
  void tick2();
11085
11824
  return;
11086
11825
  }
11087
- if (document.hidden || !recentTurns.length) {
11826
+ if (document.hidden || !rounds.length) {
11088
11827
  for (const r of rows) clearRow(r.row);
11089
11828
  return;
11090
11829
  }
11091
- const agg = rows.map(() => ({ in: 0, out: 0, cacheRead: 0 }));
11092
- const dayOf = (t2) => {
11093
- const d = new Date(t2);
11094
- return d.getFullYear() * 1e4 + (d.getMonth() + 1) * 100 + d.getDate();
11095
- };
11096
- for (const b of recentTurns) {
11097
- let owner = -1;
11098
- for (let i = 0; i < rows.length; i++) {
11099
- if (rows[i].ts <= b.ts) owner = i;
11100
- else break;
11101
- }
11102
- if (owner < 0) continue;
11103
- if (dayOf(rows[owner].ts) !== dayOf(b.ts)) continue;
11104
- agg[owner].in += b.in;
11105
- agg[owner].out += b.out;
11106
- agg[owner].cacheRead += b.cacheRead;
11830
+ const agg = rows.map(() => ({ in: 0, out: 0, cacheRead: 0, tpsOut: 0, genMs: 0 }));
11831
+ if (rounds.some((r) => r.startAt != null)) {
11832
+ const used = /* @__PURE__ */ new Set();
11833
+ for (const b of rounds) {
11834
+ const startMin = Math.floor((b.startAt ?? b.at) / 6e4);
11835
+ const endMin = Math.floor(b.at / 6e4);
11836
+ let owner = -1;
11837
+ let bestDist = Infinity;
11838
+ for (let i = 0; i < rows.length; i++) {
11839
+ if (used.has(i)) continue;
11840
+ const m = Math.floor(rows[i].ts / 6e4);
11841
+ if (m < startMin || m > endMin) continue;
11842
+ const dist = Math.abs(rows[i].ts - b.at);
11843
+ if (dist < bestDist) {
11844
+ owner = i;
11845
+ bestDist = dist;
11846
+ }
11847
+ }
11848
+ if (owner < 0) continue;
11849
+ used.add(owner);
11850
+ agg[owner].in += b.in;
11851
+ agg[owner].out += b.out;
11852
+ agg[owner].cacheRead += b.cacheRead;
11853
+ if (b.genMs) {
11854
+ agg[owner].tpsOut += b.out;
11855
+ agg[owner].genMs += b.genMs;
11856
+ }
11857
+ }
11858
+ if (liveRounds.length && rows.length) {
11859
+ const owner = rows.length - 1;
11860
+ const lastTurnAt = rounds.length ? rounds[rounds.length - 1].at : 0;
11861
+ if (!used.has(owner) && rows[owner].ts >= lastTurnAt - 6e4) {
11862
+ for (const b of liveRounds) {
11863
+ agg[owner].in += b.in;
11864
+ agg[owner].out += b.out;
11865
+ agg[owner].cacheRead += b.cacheRead;
11866
+ if (b.genMs) {
11867
+ agg[owner].tpsOut += b.out;
11868
+ agg[owner].genMs += b.genMs;
11869
+ }
11870
+ }
11871
+ }
11872
+ }
11873
+ } else {
11874
+ const dayOf = (t2) => {
11875
+ const d = new Date(t2);
11876
+ return d.getFullYear() * 1e4 + (d.getMonth() + 1) * 100 + d.getDate();
11877
+ };
11878
+ for (const b of rounds) {
11879
+ let owner = -1;
11880
+ for (let i = 0; i < rows.length; i++) {
11881
+ if (rows[i].ts <= b.at) owner = i;
11882
+ else break;
11883
+ }
11884
+ if (owner < 0) continue;
11885
+ if (dayOf(rows[owner].ts) !== dayOf(b.at)) continue;
11886
+ agg[owner].in += b.in;
11887
+ agg[owner].out += b.out;
11888
+ agg[owner].cacheRead += b.cacheRead;
11889
+ if (b.genMs) {
11890
+ agg[owner].tpsOut += b.out;
11891
+ agg[owner].genMs += b.genMs;
11892
+ }
11893
+ }
11107
11894
  }
11108
11895
  for (let i = 0; i < rows.length; i++) {
11109
11896
  if (agg[i].in + agg[i].out > 0) injectRow(rows[i].row, agg[i]);
@@ -11115,10 +11902,11 @@
11115
11902
  if (!enabled5 || document.hidden) return;
11116
11903
  const sid = currentSessionId();
11117
11904
  const seq = ++tickSeq2;
11118
- const res = await rpc("/stats/usage" + (sid ? "?session=" + encodeURIComponent(sid) : "")).catch(() => null);
11119
- if (res && res.ok && Array.isArray(res.recentTurns)) {
11905
+ const res = await rpc("/stats/turns" + (sid ? "?session=" + encodeURIComponent(sid) : "")).catch(() => null);
11906
+ if (res && res.ok && Array.isArray(res.rounds)) {
11120
11907
  if (seq !== tickSeq2 || sid !== currentSessionId()) return;
11121
- recentTurns = res.recentTurns;
11908
+ rounds = res.rounds;
11909
+ liveRounds = Array.isArray(res.live) ? res.live : [];
11122
11910
  scan3();
11123
11911
  }
11124
11912
  }
@@ -11304,9 +12092,9 @@
11304
12092
  var mapRefreshTimer = 0;
11305
12093
  function refreshMapSoon() {
11306
12094
  if (mapRefreshTimer) return;
11307
- const tick6 = () => {
12095
+ const tick7 = () => {
11308
12096
  if (document.hidden) {
11309
- mapRefreshTimer = setTimeout(tick6, 1e4);
12097
+ mapRefreshTimer = setTimeout(tick7, 1e4);
11310
12098
  return;
11311
12099
  }
11312
12100
  mapRefreshTimer = 0;
@@ -11314,7 +12102,7 @@
11314
12102
  if (m) scan4();
11315
12103
  });
11316
12104
  };
11317
- mapRefreshTimer = setTimeout(tick6, MAP_REFRESH_MS);
12105
+ mapRefreshTimer = setTimeout(tick7, MAP_REFRESH_MS);
11318
12106
  }
11319
12107
  var editingKey = null;
11320
12108
  var bootDelay = 0;
@@ -11644,11 +12432,11 @@
11644
12432
  async function injectHoverButtons() {
11645
12433
  const cfg = await getConfig();
11646
12434
  if (!cfg || !cfg.titleGen) return;
11647
- const enabled14 = cfg.titleGen.hoverBtn !== false;
12435
+ const enabled15 = cfg.titleGen.hoverBtn !== false;
11648
12436
  const L = t();
11649
12437
  for (const area of document.querySelectorAll(ACTIONS_SEL)) {
11650
12438
  const existing = area.querySelector('[data-zcodepro-item="auto-rename"]');
11651
- if (!enabled14) {
12439
+ if (!enabled15) {
11652
12440
  existing?.remove();
11653
12441
  continue;
11654
12442
  }
@@ -11738,6 +12526,408 @@
11738
12526
  // src/inject/index.js
11739
12527
  init_ws_running();
11740
12528
 
12529
+ // src/inject/features/subagent-icon.js
12530
+ init_core();
12531
+ init_ws_running();
12532
+ init_ws_rows();
12533
+ var installed6 = false;
12534
+ var enabled7 = true;
12535
+ var POLL_MS = 2e4;
12536
+ var ACTIVITY_FRESH_MS = 60 * 6e4;
12537
+ var WS_CANDIDATES_TTL_MS = 5 * 6e4;
12538
+ var APPLY_DEBOUNCE_MS = 300;
12539
+ var CALL_TIMEOUT_MS = 6e3;
12540
+ var TICK_GUARD_MS = 3e4;
12541
+ var TASK_SEL5 = "[data-task-item-key]";
12542
+ var ROBOT_CLASS = "zcodepro-subagent-icon";
12543
+ var TERMINAL_CLASS = "zcodepro-terminal-icon";
12544
+ var ROBOT_ON_CLASS = "zcodepro-subagent-on";
12545
+ var UNREAD_MOVED_CLASS = "zcodepro-subagent-unread-moved";
12546
+ var UNREAD_TAIL_CLASS = "zcodepro-subagent-unread-tail";
12547
+ var UNREAD_IGNORE_CLASS = "zcodepro-unread-error-only";
12548
+ var BUSY_LOADER_CLASS = "zcodepro-busy-loader";
12549
+ var BOT_FALLBACK = [
12550
+ ["path", { d: "M12 8V4H8" }],
12551
+ ["rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }],
12552
+ ["path", { d: "M2 14h2" }],
12553
+ ["path", { d: "M20 14h2" }],
12554
+ ["path", { d: "M15 13v2" }],
12555
+ ["path", { d: "M9 13v2" }]
12556
+ ];
12557
+ function makeBotSvg(baseClass) {
12558
+ const ns = "http://www.w3.org/2000/svg";
12559
+ const proto = document.querySelector(`svg.lucide-bot:not(.${ROBOT_CLASS})`);
12560
+ if (proto) {
12561
+ const clone = proto.cloneNode(true);
12562
+ const orig = proto.getAttribute("class") || "";
12563
+ const keep = orig.split(/\s+/).filter((c) => /^(size-|text-)/.test(c)).join(" ");
12564
+ clone.setAttribute("class", ((keep || baseClass || "size-4") + " " + ROBOT_CLASS).trim());
12565
+ clone.setAttribute("title", t().subagentRobotTip);
12566
+ return clone;
12567
+ }
12568
+ const svg = document.createElementNS(ns, "svg");
12569
+ svg.setAttribute("viewBox", "0 0 24 24");
12570
+ svg.setAttribute("fill", "none");
12571
+ svg.setAttribute("stroke", "currentColor");
12572
+ svg.setAttribute("stroke-width", "2");
12573
+ svg.setAttribute("stroke-linecap", "round");
12574
+ svg.setAttribute("stroke-linejoin", "round");
12575
+ svg.setAttribute("class", ((baseClass || "size-4") + " " + ROBOT_CLASS).trim());
12576
+ svg.setAttribute("title", t().subagentRobotTip);
12577
+ for (const [tag2, attrs] of BOT_FALLBACK) {
12578
+ const el = document.createElementNS(ns, tag2);
12579
+ for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, v);
12580
+ svg.append(el);
12581
+ }
12582
+ return svg;
12583
+ }
12584
+ function rowIconSlot(row) {
12585
+ return row.firstElementChild && row.firstElementChild.querySelector(":scope > span[aria-hidden]");
12586
+ }
12587
+ var LOADER_FALLBACK_PATHS2 = [
12588
+ "M12 2v4",
12589
+ "m16.2 7.8 2.9-2.9",
12590
+ "M18 12h4",
12591
+ "m19.8 16.2-2.9 2.9",
12592
+ "M12 18v4",
12593
+ "m7.8 19.8-2.9-2.9",
12594
+ "M6 12H2",
12595
+ "m4.2 7.8 2.9-2.9"
12596
+ ];
12597
+ var TERMINAL_FALLBACK = [
12598
+ ["path", { d: "m4 17 6-6-6-6" }],
12599
+ ["path", { d: "M12 19h8" }]
12600
+ ];
12601
+ function makeTerminalIcon() {
12602
+ const ns = "http://www.w3.org/2000/svg";
12603
+ const proto = document.querySelector(`svg.lucide-terminal:not(.${TERMINAL_CLASS}), svg.lucide-square-terminal:not(.${TERMINAL_CLASS})`);
12604
+ if (proto) {
12605
+ const clone = proto.cloneNode(true);
12606
+ const orig = proto.getAttribute("class") || "";
12607
+ const keep = orig.split(/\s+/).filter((c) => /^(size-|text-)/.test(c)).join(" ");
12608
+ clone.setAttribute("class", ((keep || "size-4 text-foreground-subtle") + " " + TERMINAL_CLASS).trim());
12609
+ clone.setAttribute("title", t().subagentTermTip);
12610
+ return clone;
12611
+ }
12612
+ const svg = document.createElementNS(ns, "svg");
12613
+ svg.setAttribute("viewBox", "0 0 24 24");
12614
+ svg.setAttribute("fill", "none");
12615
+ svg.setAttribute("stroke", "currentColor");
12616
+ svg.setAttribute("stroke-width", "2");
12617
+ svg.setAttribute("stroke-linecap", "round");
12618
+ svg.setAttribute("stroke-linejoin", "round");
12619
+ svg.setAttribute("class", `size-4 text-foreground-subtle ${TERMINAL_CLASS}`);
12620
+ svg.setAttribute("title", t().subagentTermTip);
12621
+ for (const [tag2, attrs] of TERMINAL_FALLBACK) {
12622
+ const el = document.createElementNS(ns, tag2);
12623
+ for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, v);
12624
+ svg.append(el);
12625
+ }
12626
+ return svg;
12627
+ }
12628
+ function makeBusyLoader() {
12629
+ const ns = "http://www.w3.org/2000/svg";
12630
+ const proto = document.querySelector(`svg.lucide-loader:not(.${BUSY_LOADER_CLASS})`);
12631
+ if (proto) {
12632
+ const clone = proto.cloneNode(true);
12633
+ const orig = proto.getAttribute("class") || "";
12634
+ const keep = orig.split(/\s+/).filter((c) => /^(size-|text-)/.test(c)).join(" ");
12635
+ clone.setAttribute("class", ((keep || "size-4 text-foreground-subtle") + ` animate-spin ${BUSY_LOADER_CLASS}`).trim());
12636
+ return clone;
12637
+ }
12638
+ const svg = document.createElementNS(ns, "svg");
12639
+ svg.setAttribute("viewBox", "0 0 24 24");
12640
+ svg.setAttribute("fill", "none");
12641
+ svg.setAttribute("stroke", "currentColor");
12642
+ svg.setAttribute("stroke-width", "2");
12643
+ svg.setAttribute("stroke-linecap", "round");
12644
+ svg.setAttribute("stroke-linejoin", "round");
12645
+ svg.setAttribute("class", `size-4 text-foreground-subtle animate-spin ${BUSY_LOADER_CLASS}`);
12646
+ for (const d of LOADER_FALLBACK_PATHS2) {
12647
+ const path = document.createElementNS(ns, "path");
12648
+ path.setAttribute("d", d);
12649
+ svg.append(path);
12650
+ }
12651
+ return svg;
12652
+ }
12653
+ function updateRow(row, sub, busy, term) {
12654
+ const slot = rowIconSlot(row);
12655
+ if (!slot) return;
12656
+ const unread = !!slot.querySelector("[data-unread-indicator]");
12657
+ const hasBlocking = [...slot.children].some(
12658
+ (c) => !c.classList.contains(ROBOT_CLASS) && !c.classList.contains(BUSY_LOADER_CLASS) && !c.classList.contains(TERMINAL_CLASS) && !c.hasAttribute("data-unread-indicator")
12659
+ );
12660
+ const hidden = slot.classList.contains("hidden") || slot.classList.contains("invisible");
12661
+ const ok = !hasBlocking && !hidden;
12662
+ const wantLoader = ok && busy && unread;
12663
+ const wantRobot = ok && sub && !busy;
12664
+ const wantTerm = ok && term && !busy && !wantRobot;
12665
+ const curRobot = slot.querySelector(`:scope > svg.${ROBOT_CLASS}`);
12666
+ if (wantRobot && !curRobot) slot.append(makeBotSvg("size-4 text-foreground-subtle"));
12667
+ else if (!wantRobot && curRobot) curRobot.remove();
12668
+ const curTerm = slot.querySelector(`:scope > svg.${TERMINAL_CLASS}`);
12669
+ if (wantTerm && !curTerm) slot.append(makeTerminalIcon());
12670
+ else if (!wantTerm && curTerm) curTerm.remove();
12671
+ const curLoader = slot.querySelector(`:scope > svg.${BUSY_LOADER_CLASS}`);
12672
+ if (wantLoader && !curLoader) slot.append(makeBusyLoader());
12673
+ else if (!wantLoader && curLoader) curLoader.remove();
12674
+ const moveUnread = (wantRobot || wantLoader || wantTerm) && unread;
12675
+ row.classList.toggle(UNREAD_MOVED_CLASS, moveUnread);
12676
+ let tail = row.querySelector(`:scope > .${UNREAD_TAIL_CLASS}`);
12677
+ if (moveUnread) {
12678
+ if (!tail) {
12679
+ tail = document.createElement("span");
12680
+ tail.className = UNREAD_TAIL_CLASS;
12681
+ tail.setAttribute("aria-hidden", "true");
12682
+ const dot = document.createElement("span");
12683
+ dot.className = "size-[7px] rounded-full bg-icon-blue";
12684
+ tail.append(dot);
12685
+ }
12686
+ row.insertBefore(tail, row.querySelector(":scope > [data-task-row-actions]") || null);
12687
+ } else if (tail) {
12688
+ tail.remove();
12689
+ }
12690
+ }
12691
+ function setProjectIcon(row, robotOn, termOn) {
12692
+ const icon2 = iconHolderOf(row);
12693
+ if (!icon2) return;
12694
+ const loaderSpins = icon2.classList.contains("zcodepro-ws-running") || !!icon2.querySelector(":scope > svg.zcodepro-ws-loader");
12695
+ const wantRobot = robotOn && !loaderSpins;
12696
+ const wantTerm = termOn && !loaderSpins && !wantRobot;
12697
+ icon2.classList.toggle(ROBOT_ON_CLASS, wantRobot || wantTerm);
12698
+ const curRobot = icon2.querySelector(`:scope > svg.${ROBOT_CLASS}`);
12699
+ if (wantRobot && !curRobot) icon2.append(makeBotSvg());
12700
+ else if (!wantRobot && curRobot) curRobot.remove();
12701
+ const curTerm = icon2.querySelector(`:scope > svg.${TERMINAL_CLASS}`);
12702
+ if (wantTerm && !curTerm) icon2.append(makeTerminalIcon());
12703
+ else if (!wantTerm && curTerm) curTerm.remove();
12704
+ }
12705
+ var ticking = false;
12706
+ var liveSessions = /* @__PURE__ */ new Set();
12707
+ var liveByWs = /* @__PURE__ */ new Set();
12708
+ var busySessions = /* @__PURE__ */ new Set();
12709
+ var liveTermSessions = /* @__PURE__ */ new Set();
12710
+ var liveTermByWs = /* @__PURE__ */ new Set();
12711
+ var projectTrueUnread = /* @__PURE__ */ new Map();
12712
+ var wsCandidatesCache = /* @__PURE__ */ new Map();
12713
+ var projRootsCache = { at: 0, map: null };
12714
+ function normWs(v) {
12715
+ return String(v || "").replace(/[\\/]+$/, "");
12716
+ }
12717
+ function withTimeout(p, ms, fallback) {
12718
+ const guarded = Promise.resolve(p).catch(() => fallback);
12719
+ return Promise.race([guarded, new Promise((resolve) => setTimeout(() => resolve(fallback), ms))]);
12720
+ }
12721
+ async function projRoots() {
12722
+ if (projRootsCache.map && Date.now() - projRootsCache.at < WS_CANDIDATES_TTL_MS) return projRootsCache.map;
12723
+ const res = await withTimeout(rpc("/projects-v2"), CALL_TIMEOUT_MS, null);
12724
+ const map = /* @__PURE__ */ new Map();
12725
+ if (res && res.ok && res.available !== false && Array.isArray(res.projects)) {
12726
+ for (const proj of res.projects) {
12727
+ const id = String(proj.id || "");
12728
+ const paths = (proj.roots || []).map((r) => String(r.path || "")).filter(Boolean);
12729
+ if (id && paths.length) map.set(id, paths);
12730
+ }
12731
+ }
12732
+ projRootsCache = { at: Date.now(), map };
12733
+ return map;
12734
+ }
12735
+ function projectPathsOf(row, roots) {
12736
+ const id = row.getAttribute && row.getAttribute("data-project-id");
12737
+ const byId = id && roots && roots.get(id);
12738
+ if (byId && byId.length) return byId;
12739
+ const p = rowPath(row);
12740
+ return p ? [p] : [];
12741
+ }
12742
+ async function wsCandidates(ws) {
12743
+ const c = wsCandidatesCache.get(ws);
12744
+ if (c && Date.now() - c.at < WS_CANDIDATES_TTL_MS) return c.ids;
12745
+ const res = await withTimeout(rpc("/workspace-sessions?path=" + encodeURIComponent(ws)), CALL_TIMEOUT_MS, null);
12746
+ const ids = res && res.ok && Array.isArray(res.ids) ? res.ids : [];
12747
+ wsCandidatesCache.set(ws, { at: Date.now(), ids });
12748
+ return ids;
12749
+ }
12750
+ async function tick3() {
12751
+ if (!enabled7 || document.hidden || ticking) return;
12752
+ ticking = true;
12753
+ const guard = setTimeout(() => {
12754
+ ticking = false;
12755
+ }, TICK_GUARD_MS);
12756
+ try {
12757
+ const services = findServices();
12758
+ const ag = services && services.zcodeAgentService;
12759
+ if (!ag) return;
12760
+ const candidates = /* @__PURE__ */ new Map();
12761
+ for (const el of document.querySelectorAll(TASK_SEL5)) {
12762
+ const key = el.getAttribute("data-task-item-key") || "";
12763
+ const cut = key.lastIndexOf(":");
12764
+ if (cut > 1) candidates.set(key.slice(cut + 1), key.slice(0, cut));
12765
+ }
12766
+ const roots = await projRoots();
12767
+ const collapsedRows = projectRows().filter((row) => {
12768
+ const head = wsHead(row);
12769
+ return !!head && head.getAttribute("aria-expanded") === "false";
12770
+ });
12771
+ const wsPaths = collapsedRows.flatMap((row) => projectPathsOf(row, roots));
12772
+ const wsLists = await Promise.all(wsPaths.map((p) => wsCandidates(p)));
12773
+ wsLists.forEach((ids, i) => {
12774
+ for (const id of ids) {
12775
+ if (!candidates.has(id)) candidates.set(id, wsPaths[i]);
12776
+ }
12777
+ });
12778
+ const childRes = await withTimeout(
12779
+ rpc("/subagent-children?ids=" + encodeURIComponent([...candidates.keys()].join(","))),
12780
+ CALL_TIMEOUT_MS,
12781
+ null
12782
+ );
12783
+ const rootsWithKids = new Set((childRes && childRes.children || []).map((c) => c.root));
12784
+ const endedLists = await Promise.all([...candidates].filter(([sid]) => rootsWithKids.has(sid)).map(async ([sid, ws]) => {
12785
+ const r = await withTimeout(
12786
+ ag.listSessionSubagents({ workspacePath: ws, sessionId: sid, endedLimit: 20 }),
12787
+ CALL_TIMEOUT_MS,
12788
+ null
12789
+ );
12790
+ return r && r.ended && r.ended.items || [];
12791
+ }));
12792
+ const endedAt = /* @__PURE__ */ new Map();
12793
+ for (const items2 of endedLists) {
12794
+ for (const e of items2) {
12795
+ const id = e && e.childSessionId;
12796
+ if (id) endedAt.set(id, Math.max(endedAt.get(id) || 0, Number(e.endedAt) || 0));
12797
+ }
12798
+ }
12799
+ const now = Date.now();
12800
+ const live = /* @__PURE__ */ new Set();
12801
+ const liveWs = /* @__PURE__ */ new Set();
12802
+ for (const c of childRes && childRes.children || []) {
12803
+ const at = Number(c.at) || 0;
12804
+ if (!(at > 0 && now - at <= ACTIVITY_FRESH_MS)) continue;
12805
+ const end = endedAt.get(c.id) || 0;
12806
+ if (end && end >= at) continue;
12807
+ live.add(c.root);
12808
+ const ws = candidates.get(c.root);
12809
+ if (ws) liveWs.add(normWs(ws));
12810
+ }
12811
+ liveSessions = live;
12812
+ liveByWs = liveWs;
12813
+ const busy = /* @__PURE__ */ new Set();
12814
+ const needBusyWs = /* @__PURE__ */ new Set();
12815
+ for (const el of document.querySelectorAll(TASK_SEL5)) {
12816
+ const key = el.getAttribute("data-task-item-key") || "";
12817
+ const cut = key.lastIndexOf(":");
12818
+ const sid = cut > 1 ? key.slice(cut + 1) : "";
12819
+ const slot = rowIconSlot(el);
12820
+ const unread = slot && slot.querySelector("[data-unread-indicator]");
12821
+ if (live.has(sid) || unread) needBusyWs.add(normWs(key.slice(0, cut)));
12822
+ }
12823
+ await Promise.all([...needBusyWs].map(async (ws) => {
12824
+ const ids = await withTimeout(listActiveIdsCached(ws), CALL_TIMEOUT_MS, null);
12825
+ if (ids) for (const id of ids) busy.add(id);
12826
+ }));
12827
+ busySessions = busy;
12828
+ const term = /* @__PURE__ */ new Set();
12829
+ const termWs = /* @__PURE__ */ new Set();
12830
+ const bbRes = await withTimeout(rpc("/background-bash"), CALL_TIMEOUT_MS, null);
12831
+ for (const j of bbRes && bbRes.jobs || []) {
12832
+ const sid = j && j.sessionId;
12833
+ if (!sid || !candidates.has(sid)) continue;
12834
+ term.add(sid);
12835
+ const ws = candidates.get(sid);
12836
+ if (ws) termWs.add(normWs(ws));
12837
+ }
12838
+ liveTermSessions = term;
12839
+ liveTermByWs = termWs;
12840
+ const projIds = [...new Set(projectRows().map((r) => r.getAttribute("data-project-id")).filter(Boolean))];
12841
+ if (projIds.length) {
12842
+ const pu = await withTimeout(
12843
+ rpc("/project-unread?ids=" + encodeURIComponent(projIds.join(","))),
12844
+ CALL_TIMEOUT_MS,
12845
+ null
12846
+ );
12847
+ if (pu && pu.ok && pu.unread) projectTrueUnread = new Map(Object.entries(pu.unread));
12848
+ }
12849
+ apply2();
12850
+ } finally {
12851
+ clearTimeout(guard);
12852
+ ticking = false;
12853
+ }
12854
+ }
12855
+ function apply2() {
12856
+ for (const el of document.querySelectorAll(TASK_SEL5)) {
12857
+ const key = el.getAttribute("data-task-item-key") || "";
12858
+ const cut = key.lastIndexOf(":");
12859
+ const sid = cut > 1 ? key.slice(cut + 1) : "";
12860
+ updateRow(el, enabled7 && liveSessions.has(sid), busySessions.has(sid), enabled7 && liveTermSessions.has(sid));
12861
+ }
12862
+ const roots = projRootsCache.map;
12863
+ for (const row of projectRows()) {
12864
+ const head = wsHead(row);
12865
+ const collapsed = !!head && head.getAttribute("aria-expanded") === "false";
12866
+ const paths = projectPathsOf(row, roots);
12867
+ setProjectIcon(
12868
+ row,
12869
+ enabled7 && collapsed && paths.some((p) => liveByWs.has(normWs(p))),
12870
+ enabled7 && collapsed && paths.some((p) => liveTermByWs.has(normWs(p)))
12871
+ );
12872
+ const pid = row.getAttribute("data-project-id");
12873
+ row.classList.toggle(UNREAD_IGNORE_CLASS, enabled7 && pid !== null && projectTrueUnread.get(pid) === 0);
12874
+ }
12875
+ }
12876
+ async function refreshConfig2() {
12877
+ try {
12878
+ const cfg = await getConfig();
12879
+ const next = !!(cfg && cfg.features && cfg.features.subagentIcon !== false);
12880
+ if (next !== enabled7) {
12881
+ enabled7 = next;
12882
+ apply2();
12883
+ }
12884
+ } catch {
12885
+ }
12886
+ }
12887
+ var applyDebounce = 0;
12888
+ var tickThrottle = 0;
12889
+ function startSubagentIcon() {
12890
+ if (installed6 || typeof document === "undefined") return;
12891
+ installed6 = true;
12892
+ void refreshConfig2();
12893
+ void tick3();
12894
+ setInterval(() => {
12895
+ void refreshConfig2();
12896
+ void tick3();
12897
+ }, POLL_MS);
12898
+ document.addEventListener("visibilitychange", () => {
12899
+ if (!document.hidden) {
12900
+ void refreshConfig2();
12901
+ void tick3();
12902
+ }
12903
+ });
12904
+ const observer2 = new MutationObserver((muts) => {
12905
+ let rowHit = false;
12906
+ let rowAdded = false;
12907
+ for (const m of muts) {
12908
+ if (m.type !== "childList") continue;
12909
+ const t2 = m.target instanceof Element ? m.target : null;
12910
+ const added = [...m.addedNodes].filter((n) => n instanceof Element);
12911
+ if (added.some((n) => n.matches(TASK_SEL5) || n.querySelector(TASK_SEL5))) rowAdded = true;
12912
+ const touched = t2 && t2.closest(TASK_SEL5) || added.some((n) => n.matches(TASK_SEL5) || n.querySelector(TASK_SEL5)) || [...m.removedNodes].some((n) => n instanceof Element && (n.matches(TASK_SEL5) || n.querySelector(TASK_SEL5)));
12913
+ if (touched) rowHit = true;
12914
+ }
12915
+ if (rowAdded) apply2();
12916
+ if (rowHit && !tickThrottle) {
12917
+ tickThrottle = setTimeout(() => {
12918
+ tickThrottle = 0;
12919
+ void tick3();
12920
+ }, 5e3);
12921
+ }
12922
+ if (applyDebounce) return;
12923
+ applyDebounce = setTimeout(() => {
12924
+ applyDebounce = 0;
12925
+ apply2();
12926
+ }, APPLY_DEBOUNCE_MS);
12927
+ });
12928
+ observer2.observe(document.body, { childList: true, subtree: true });
12929
+ }
12930
+
11741
12931
  // src/inject/features/idle-reclaim.js
11742
12932
  init_core();
11743
12933
  init_ws_running();
@@ -11749,7 +12939,7 @@
11749
12939
  var scanDisabledLogged = false;
11750
12940
  var bootAt = Date.now();
11751
12941
  var startupSweepDone = false;
11752
- var enabled7 = true;
12942
+ var enabled8 = true;
11753
12943
  var normP = (v) => String(v || "").replace(/[\\/]+$/, "");
11754
12944
  async function sidebarWorkspaces() {
11755
12945
  const out = /* @__PURE__ */ new Set();
@@ -11801,14 +12991,46 @@
11801
12991
  await reclaim(ws);
11802
12992
  blockUntil.set(ws, Date.now() + cooldownMs);
11803
12993
  }
11804
- async function tick3() {
11805
- if (!enabled7) {
12994
+ function dueForReclaim(workspaces, busy, idleSince2, blockUntil2, now, threshold, startupDue) {
12995
+ const due = [];
12996
+ const seen2 = /* @__PURE__ */ new Set();
12997
+ const add = (ws) => {
12998
+ if (!seen2.has(ws)) {
12999
+ seen2.add(ws);
13000
+ due.push(ws);
13001
+ }
13002
+ };
13003
+ if (startupDue) {
13004
+ for (const ws of workspaces) {
13005
+ if (busy.has(ws) || (blockUntil2.get(ws) || 0) > now) continue;
13006
+ add(ws);
13007
+ }
13008
+ }
13009
+ for (const ws of workspaces) {
13010
+ if (busy.has(ws)) {
13011
+ idleSince2.delete(ws);
13012
+ continue;
13013
+ }
13014
+ if (!idleSince2.has(ws)) {
13015
+ idleSince2.set(ws, now);
13016
+ continue;
13017
+ }
13018
+ if (now - idleSince2.get(ws) < threshold) continue;
13019
+ if ((blockUntil2.get(ws) || 0) > now) continue;
13020
+ if (seen2.has(ws)) continue;
13021
+ idleSince2.delete(ws);
13022
+ add(ws);
13023
+ }
13024
+ return due;
13025
+ }
13026
+ async function tick4() {
13027
+ if (!enabled8) {
11806
13028
  idleSince.clear();
11807
13029
  return;
11808
13030
  }
11809
13031
  const cfg = await getConfig();
11810
- enabled7 = !cfg.features || cfg.features.idleReclaim !== false;
11811
- if (!enabled7) {
13032
+ enabled8 = !cfg.features || cfg.features.idleReclaim !== false;
13033
+ if (!enabled8) {
11812
13034
  idleSince.clear();
11813
13035
  return;
11814
13036
  }
@@ -11831,51 +13053,43 @@
11831
13053
  blockUntil.delete(ws);
11832
13054
  }
11833
13055
  }
11834
- const candidates = [...workspaces].filter((ws) => !busy.has(normP(ws)));
11835
- const res = candidates.length ? await rpc("/idle-busy", { method: "POST", body: { paths: candidates } }) : { ok: true, scan: true, busy: [] };
13056
+ const now = Date.now();
13057
+ const startupDue = !startupSweepDone && now - bootAt >= startupMinutes * 6e4;
13058
+ const due = dueForReclaim(workspaces, busy, idleSince, blockUntil, now, threshold, startupDue);
13059
+ if (!due.length) {
13060
+ if (startupDue) startupSweepDone = true;
13061
+ return;
13062
+ }
13063
+ const res = await rpc("/idle-busy", { method: "POST", body: { paths: due } });
11836
13064
  if (!res.ok || res.scan === false) {
11837
13065
  if (!scanDisabledLogged) {
11838
13066
  scanDisabledLogged = true;
11839
13067
  console.info("[zcodepro] idle-reclaim: \u540E\u53F0\u547D\u4EE4\u626B\u63CF\u4E0D\u53EF\u7528\uFF0C\u7A7A\u95F2\u56DE\u6536\u505C\u7528");
11840
13068
  }
13069
+ if (startupDue) startupSweepDone = true;
11841
13070
  idleSince.clear();
11842
13071
  return;
11843
13072
  }
13073
+ if (startupDue) startupSweepDone = true;
11844
13074
  const procBusy = new Set(res.busy || []);
11845
- const idleCandidates = candidates.filter((ws) => !procBusy.has(ws));
11846
- const now = Date.now();
11847
- if (!startupSweepDone && now - bootAt >= startupMinutes * 6e4) {
11848
- startupSweepDone = true;
11849
- for (const ws of idleCandidates) {
11850
- if ((blockUntil.get(ws) || 0) > now) continue;
11851
- await tryReclaim(ws, threshold);
11852
- }
11853
- }
11854
- for (const ws of workspaces) {
11855
- if (busy.has(ws) || procBusy.has(ws)) {
13075
+ for (const ws of due) {
13076
+ if (procBusy.has(ws)) {
11856
13077
  idleSince.delete(ws);
11857
13078
  continue;
11858
13079
  }
11859
- if (!idleSince.has(ws)) {
11860
- idleSince.set(ws, now);
11861
- continue;
11862
- }
11863
- if (now - idleSince.get(ws) < threshold) continue;
11864
- if ((blockUntil.get(ws) || 0) > now) continue;
11865
- idleSince.delete(ws);
11866
13080
  await tryReclaim(ws, threshold);
11867
13081
  }
11868
13082
  }
11869
13083
  function startIdleReclaim() {
11870
13084
  window.addEventListener("zcodepro:config-changed", () => {
11871
13085
  void getConfig(true).then((cfg) => {
11872
- enabled7 = !cfg.features || cfg.features.idleReclaim !== false;
11873
- if (!enabled7) idleSince.clear();
13086
+ enabled8 = !cfg.features || cfg.features.idleReclaim !== false;
13087
+ if (!enabled8) idleSince.clear();
11874
13088
  }).catch(() => {
11875
13089
  });
11876
13090
  });
11877
13091
  const loop = () => {
11878
- tick3().catch(() => {
13092
+ tick4().catch(() => {
11879
13093
  });
11880
13094
  };
11881
13095
  loop();
@@ -11914,7 +13128,7 @@
11914
13128
  }
11915
13129
  var cooldown = /* @__PURE__ */ new Map();
11916
13130
  var disabledLogged = false;
11917
- var enabled8 = true;
13131
+ var enabled9 = true;
11918
13132
  function onPortsMessage(e) {
11919
13133
  const d = e.data;
11920
13134
  if (!d || d.type !== "zcode:plugin-sandbox-ports" || typeof d.sandboxId !== "string") return;
@@ -11931,14 +13145,14 @@
11931
13145
  if (!root.getClientRects().length) return false;
11932
13146
  return Number(getComputedStyle(root).opacity) > 0.5;
11933
13147
  }
11934
- async function tick4() {
11935
- if (!enabled8) {
13148
+ async function tick5() {
13149
+ if (!enabled9) {
11936
13150
  seen.clear();
11937
13151
  return;
11938
13152
  }
11939
13153
  const cfg = await getConfig();
11940
- enabled8 = !cfg.features || cfg.features.sandboxReclaim !== false;
11941
- if (!enabled8) {
13154
+ enabled9 = !cfg.features || cfg.features.sandboxReclaim !== false;
13155
+ if (!enabled9) {
11942
13156
  seen.clear();
11943
13157
  return;
11944
13158
  }
@@ -11995,13 +13209,13 @@
11995
13209
  window.addEventListener("message", onPortsMessage);
11996
13210
  window.addEventListener("zcodepro:config-changed", () => {
11997
13211
  void getConfig(true).then((cfg) => {
11998
- enabled8 = !cfg.features || cfg.features.sandboxReclaim !== false;
11999
- if (!enabled8) seen.clear();
13212
+ enabled9 = !cfg.features || cfg.features.sandboxReclaim !== false;
13213
+ if (!enabled9) seen.clear();
12000
13214
  }).catch(() => {
12001
13215
  });
12002
13216
  });
12003
13217
  const loop = () => {
12004
- tick4().catch(() => {
13218
+ tick5().catch(() => {
12005
13219
  });
12006
13220
  };
12007
13221
  loop();
@@ -12032,7 +13246,7 @@
12032
13246
  }
12033
13247
  return out;
12034
13248
  }
12035
- async function tick5() {
13249
+ async function tick6() {
12036
13250
  const cfg = await getConfig();
12037
13251
  if ((cfg.features || {}).pluginCardRetry === false) return;
12038
13252
  const now = Date.now();
@@ -12046,7 +13260,7 @@
12046
13260
  }
12047
13261
  function startPluginCardRetry() {
12048
13262
  setInterval(() => {
12049
- tick5().catch(() => {
13263
+ tick6().catch(() => {
12050
13264
  });
12051
13265
  }, SCAN_MS);
12052
13266
  }
@@ -12059,7 +13273,7 @@
12059
13273
  var SCAN_FALLBACK_MS5 = 5e3;
12060
13274
  var ROW_SEL = "[data-task-item-key]";
12061
13275
  var MENU_SEL = '[data-testid="task-new-button"], [data-testid="automations-open"], [data-testid="plugin-store-sidebar-open"], [data-testid="sidebar-search-open"], [data-slot="command"], [data-testid="desktop-top-nav-back"]';
12062
- var enabled9 = true;
13276
+ var enabled10 = true;
12063
13277
  var rowEl = null;
12064
13278
  var origs = null;
12065
13279
  var syncTimer = 0;
@@ -12202,7 +13416,7 @@
12202
13416
  return scroll.getBoundingClientRect().width < NARROW_SIDEBAR_PX;
12203
13417
  }
12204
13418
  function sync() {
12205
- if (!enabled9) return;
13419
+ if (!enabled10) return;
12206
13420
  const parts = findParts();
12207
13421
  if (!parts) {
12208
13422
  if (rowEl) rowEl.style.display = "none";
@@ -12262,18 +13476,18 @@
12262
13476
  origs = null;
12263
13477
  }
12264
13478
  }
12265
- async function refreshConfig2() {
13479
+ async function refreshConfig3() {
12266
13480
  const cfg = await getConfig(true).catch(() => null);
12267
- enabled9 = !cfg || !cfg.features || cfg.features.toolbarIcons !== false;
12268
- if (enabled9) sync();
13481
+ enabled10 = !cfg || !cfg.features || cfg.features.toolbarIcons !== false;
13482
+ if (enabled10) sync();
12269
13483
  else teardown();
12270
13484
  }
12271
13485
  function startToolbarIcons() {
12272
13486
  ensureStyle();
12273
13487
  window.addEventListener("zcodepro:config-changed", () => {
12274
- void refreshConfig2();
13488
+ void refreshConfig3();
12275
13489
  });
12276
- void refreshConfig2();
13490
+ void refreshConfig3();
12277
13491
  new MutationObserver((muts) => {
12278
13492
  if (relevantMutations(muts)) scheduleSync();
12279
13493
  }).observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ["class", "aria-pressed"] });
@@ -12293,7 +13507,7 @@
12293
13507
  var STORE_KEY = "zcodepro:pinned-collapsed";
12294
13508
  var SYNC_DEBOUNCE_MS2 = 300;
12295
13509
  var SCAN_FALLBACK_MS6 = 5e3;
12296
- var enabled10 = true;
13510
+ var enabled11 = true;
12297
13511
  var syncTimer2 = 0;
12298
13512
  function findPinnedHeader() {
12299
13513
  for (const h3 of document.querySelectorAll("h3")) {
@@ -12336,9 +13550,9 @@
12336
13550
  localStorage.setItem(STORE_KEY, isCollapsed() ? "0" : "1");
12337
13551
  } catch {
12338
13552
  }
12339
- apply2();
13553
+ apply3();
12340
13554
  }
12341
- function apply2() {
13555
+ function apply3() {
12342
13556
  const h3 = findPinnedHeader();
12343
13557
  if (!h3) return false;
12344
13558
  const sect = h3.parentElement;
@@ -12353,7 +13567,7 @@
12353
13567
  if (!h3.dataset.zcodeproPinHead) {
12354
13568
  h3.dataset.zcodeproPinHead = "1";
12355
13569
  h3.addEventListener("click", () => {
12356
- if (enabled10) toggle();
13570
+ if (enabled11) toggle();
12357
13571
  });
12358
13572
  }
12359
13573
  const btn = h("button", {
@@ -12363,7 +13577,7 @@
12363
13577
  "aria-expanded": collapsed ? "false" : "true",
12364
13578
  onClick: (e) => {
12365
13579
  e.stopPropagation();
12366
- if (enabled10) toggle();
13580
+ if (enabled11) toggle();
12367
13581
  }
12368
13582
  });
12369
13583
  btn.append(chevronSvg());
@@ -12371,7 +13585,7 @@
12371
13585
  return true;
12372
13586
  }
12373
13587
  function sync2() {
12374
- if (enabled10) apply2();
13588
+ if (enabled11) apply3();
12375
13589
  }
12376
13590
  function scheduleSync2() {
12377
13591
  if (syncTimer2) return;
@@ -12398,18 +13612,18 @@
12398
13612
  h3.parentElement?.classList.remove(COLLAPSED_CLASS);
12399
13613
  }
12400
13614
  }
12401
- async function refreshConfig3() {
13615
+ async function refreshConfig4() {
12402
13616
  const cfg = await getConfig(true).catch(() => null);
12403
- enabled10 = !cfg || !cfg.features || cfg.features.pinnedCollapse !== false;
12404
- if (enabled10) sync2();
13617
+ enabled11 = !cfg || !cfg.features || cfg.features.pinnedCollapse !== false;
13618
+ if (enabled11) sync2();
12405
13619
  else teardown2();
12406
13620
  }
12407
13621
  function startPinnedCollapse() {
12408
13622
  ensureStyle();
12409
13623
  window.addEventListener("zcodepro:config-changed", () => {
12410
- void refreshConfig3();
13624
+ void refreshConfig4();
12411
13625
  });
12412
- void refreshConfig3();
13626
+ void refreshConfig4();
12413
13627
  new MutationObserver((muts) => {
12414
13628
  if (relevantMutations2(muts)) scheduleSync2();
12415
13629
  }).observe(document.body, { childList: true, subtree: true });
@@ -12424,8 +13638,8 @@
12424
13638
  // src/inject/features/table-copy.js
12425
13639
  init_ui();
12426
13640
  init_core();
12427
- var installed6 = false;
12428
- var enabled11 = true;
13641
+ var installed7 = false;
13642
+ var enabled12 = true;
12429
13643
  function cleanTable(table) {
12430
13644
  const clone = table.cloneNode(false);
12431
13645
  const walk = (src, dst) => {
@@ -12435,9 +13649,9 @@
12435
13649
  continue;
12436
13650
  }
12437
13651
  if (node.nodeType !== Node.ELEMENT_NODE) continue;
12438
- const tag = node.tagName;
12439
- const el = document.createElement(tag.toLowerCase());
12440
- if (tag === "TD" || tag === "TH") {
13652
+ const tag2 = node.tagName;
13653
+ const el = document.createElement(tag2.toLowerCase());
13654
+ if (tag2 === "TD" || tag2 === "TH") {
12441
13655
  for (const a of ["colspan", "rowspan"]) {
12442
13656
  const v = node.getAttribute(a);
12443
13657
  if (v && v !== "1") el.setAttribute(a, v);
@@ -12516,8 +13730,8 @@
12516
13730
  return btn;
12517
13731
  }
12518
13732
  function startTableCopy() {
12519
- if (installed6 || typeof document === "undefined") return;
12520
- installed6 = true;
13733
+ if (installed7 || typeof document === "undefined") return;
13734
+ installed7 = true;
12521
13735
  ensureStyle();
12522
13736
  const tableOf = (bar) => {
12523
13737
  let scope = bar.parentElement;
@@ -12542,12 +13756,12 @@
12542
13756
  };
12543
13757
  scan6();
12544
13758
  void getConfig().then((cfg) => {
12545
- enabled11 = cfg.features ? cfg.features.tableCopy !== false : true;
13759
+ enabled12 = cfg.features ? cfg.features.tableCopy !== false : true;
12546
13760
  }).catch(() => {
12547
13761
  });
12548
13762
  window.addEventListener("zcodepro:config-changed", () => {
12549
13763
  void getConfig(true).then((cfg) => {
12550
- enabled11 = cfg.features ? cfg.features.tableCopy !== false : true;
13764
+ enabled12 = cfg.features ? cfg.features.tableCopy !== false : true;
12551
13765
  }).catch(() => {
12552
13766
  });
12553
13767
  });
@@ -12556,7 +13770,7 @@
12556
13770
  if (scanTimer2) return;
12557
13771
  scanTimer2 = setTimeout(() => {
12558
13772
  scanTimer2 = 0;
12559
- if (enabled11) scan6();
13773
+ if (enabled12) scan6();
12560
13774
  }, 300);
12561
13775
  };
12562
13776
  const maybeTable = (muts) => {
@@ -12569,7 +13783,7 @@
12569
13783
  return false;
12570
13784
  };
12571
13785
  const observer2 = new MutationObserver((muts) => {
12572
- if (enabled11 && maybeTable(muts)) scheduleScan4();
13786
+ if (enabled12 && maybeTable(muts)) scheduleScan4();
12573
13787
  });
12574
13788
  observer2.observe(document.body, { childList: true, subtree: true });
12575
13789
  }
@@ -12578,7 +13792,7 @@
12578
13792
  init_core();
12579
13793
  init_ui();
12580
13794
  var CONV3 = '[class*="@md/conversation"]';
12581
- var SKIP_SEL = "pre, code, a, button, input, textarea, select, [data-zcodepro-sess]";
13795
+ var SKIP_SEL = "pre, code, a, button, input, textarea, select, [contenteditable], [data-zcodepro-sess]";
12582
13796
  var SESS_RE = /(?<![A-Za-z0-9_])(?:session|sess)_[A-Za-z0-9][A-Za-z0-9_-]*[A-Za-z0-9]/g;
12583
13797
  function matchIds(text) {
12584
13798
  SESS_RE.lastIndex = 0;
@@ -12588,8 +13802,8 @@
12588
13802
  }
12589
13803
  return out;
12590
13804
  }
12591
- var installed7 = false;
12592
- var enabled12 = true;
13805
+ var installed8 = false;
13806
+ var enabled13 = true;
12593
13807
  var titleCache = /* @__PURE__ */ new Map();
12594
13808
  var TITLE_CACHE_MAX = 500;
12595
13809
  var pendingIds = /* @__PURE__ */ new Set();
@@ -12694,14 +13908,14 @@
12694
13908
  }
12695
13909
  function setEnabled(cfg) {
12696
13910
  const next = cfg.features ? cfg.features.sessionLink !== false : true;
12697
- if (enabled12 && !next) unwrapAll();
12698
- enabled12 = next;
13911
+ if (enabled13 && !next) unwrapAll();
13912
+ enabled13 = next;
12699
13913
  if (next) scan5();
12700
13914
  }
12701
13915
  var inConv = (el) => !!(el && el.closest && el.closest(CONV3));
12702
13916
  function startSessionLink() {
12703
- if (installed7 || typeof document === "undefined") return;
12704
- installed7 = true;
13917
+ if (installed8 || typeof document === "undefined") return;
13918
+ installed8 = true;
12705
13919
  ensureStyle();
12706
13920
  void getConfig().then(setEnabled).catch(() => {
12707
13921
  });
@@ -12716,11 +13930,11 @@
12716
13930
  for (const m of muts) {
12717
13931
  if (m.type === "characterData") {
12718
13932
  doneNodes.delete(m.target);
12719
- if (enabled12 && inConv(m.target.parentElement)) texts.push(m.target);
13933
+ if (enabled13 && inConv(m.target.parentElement)) texts.push(m.target);
12720
13934
  continue;
12721
13935
  }
12722
13936
  for (const n of m.addedNodes) {
12723
- if (!enabled12) continue;
13937
+ if (!enabled13) continue;
12724
13938
  if (n.nodeType === Node.TEXT_NODE) {
12725
13939
  if (inConv(n.parentElement)) texts.push(n);
12726
13940
  continue;
@@ -12733,7 +13947,7 @@
12733
13947
  if (inConv(n) && !n.closest(SKIP_SEL)) walkTexts(n, texts);
12734
13948
  }
12735
13949
  }
12736
- if (!enabled12) return;
13950
+ if (!enabled13) return;
12737
13951
  if (structural) {
12738
13952
  scan5();
12739
13953
  return;
@@ -12744,7 +13958,7 @@
12744
13958
  }).observe(document.body, { childList: true, subtree: true, characterData: true });
12745
13959
  document.addEventListener("click", (e) => {
12746
13960
  const span = e.target instanceof Element && e.target.closest("[data-zcodepro-sess]");
12747
- if (!span || !enabled12) return;
13961
+ if (!span || !enabled13) return;
12748
13962
  e.preventDefault();
12749
13963
  e.stopPropagation();
12750
13964
  const id = span.getAttribute("data-zcodepro-sess") || "";
@@ -12758,8 +13972,8 @@
12758
13972
 
12759
13973
  // src/inject/features/composer-provider.js
12760
13974
  init_core();
12761
- var installed8 = false;
12762
- var enabled13 = true;
13975
+ var installed9 = false;
13976
+ var enabled14 = true;
12763
13977
  var TRIGGER_SEL = '[data-testid="chat-model-select-trigger"]';
12764
13978
  function labelParts(label) {
12765
13979
  const text = (label || "").trim();
@@ -12790,12 +14004,12 @@
12790
14004
  if (node && node.nodeType === 3 && !node.nextSibling) node.nodeValue = text;
12791
14005
  else el.textContent = text;
12792
14006
  }
12793
- function apply3() {
14007
+ function apply4() {
12794
14008
  for (const btn of document.querySelectorAll(TRIGGER_SEL)) {
12795
14009
  const parts = labelParts(btn.getAttribute("aria-label") || "");
12796
14010
  if (!parts) continue;
12797
14011
  const holders = holdersOf(btn, parts.model);
12798
- if (enabled13) {
14012
+ if (enabled14) {
12799
14013
  if (!parts.provider || !holders.length) continue;
12800
14014
  const target = `${parts.provider} / ${parts.model}`;
12801
14015
  for (const el of holders) {
@@ -12815,8 +14029,8 @@
12815
14029
  }
12816
14030
  }
12817
14031
  function startComposerProvider() {
12818
- if (installed8 || typeof document === "undefined") return;
12819
- installed8 = true;
14032
+ if (installed9 || typeof document === "undefined") return;
14033
+ installed9 = true;
12820
14034
  const COMPOSER_SEL = '[data-composer-layout], [data-composer-leading-actions], [data-composer-leading-content], [data-testid="chat-model-select-trigger"]';
12821
14035
  const relevant2 = (muts) => {
12822
14036
  for (const m of muts) {
@@ -12835,24 +14049,24 @@
12835
14049
  };
12836
14050
  const schedule = () => {
12837
14051
  clearTimeout(schedule.t);
12838
- schedule.t = setTimeout(apply3, 120);
14052
+ schedule.t = setTimeout(apply4, 120);
12839
14053
  };
12840
14054
  void getConfig().then((cfg) => {
12841
- enabled13 = cfg.features ? cfg.features.composerProvider !== false : true;
14055
+ enabled14 = cfg.features ? cfg.features.composerProvider !== false : true;
12842
14056
  }).catch(() => {
12843
14057
  });
12844
14058
  window.addEventListener("zcodepro:config-changed", () => {
12845
14059
  void getConfig(true).then((cfg) => {
12846
14060
  const next = cfg.features ? cfg.features.composerProvider !== false : true;
12847
- if (next !== enabled13) {
12848
- enabled13 = next;
12849
- apply3();
14061
+ if (next !== enabled14) {
14062
+ enabled14 = next;
14063
+ apply4();
12850
14064
  }
12851
14065
  }).catch(() => {
12852
14066
  });
12853
14067
  });
12854
14068
  const observer2 = new MutationObserver((muts) => {
12855
- if (enabled13 && relevant2(muts)) schedule();
14069
+ if (enabled14 && relevant2(muts)) schedule();
12856
14070
  });
12857
14071
  observer2.observe(document.body, {
12858
14072
  childList: true,
@@ -12862,37 +14076,7 @@
12862
14076
  attributeFilter: ["aria-label", "data-model-current-value"]
12863
14077
  // 这两个只有应用会写,不认 title,避免自己改 title 叫醒自己
12864
14078
  });
12865
- apply3();
12866
- }
12867
-
12868
- // src/inject/features/plugin-updates.js
12869
- init_core();
12870
- init_ui();
12871
- var NOTIFIED_KEY = "zcodepro-plugin-updates-notified";
12872
- async function startPluginUpdateCheck() {
12873
- const status = await rpc("/plugins/status");
12874
- if (!status.ok || !Array.isArray(status.updates)) return;
12875
- const L = t();
12876
- if (status.updates.length === 0) return;
12877
- const config = await getConfig();
12878
- if ((config.features || {}).autoUpdatePlugins === true) {
12879
- const res = await rpc("/plugins/update", { method: "POST", body: {} });
12880
- if (res.ok) showToast(L.pluginsAutoUpdated, "success");
12881
- else showToast(L.pluginsUpdateFailed + ": " + (res.error || ""), "error");
12882
- return;
12883
- }
12884
- const sig = status.updates.map((u) => `${u.name}:${u.installed}>${u.latest}`).join(",");
12885
- let seen2 = "";
12886
- try {
12887
- seen2 = window.localStorage.getItem(NOTIFIED_KEY) || "";
12888
- } catch {
12889
- }
12890
- if (seen2 === sig) return;
12891
- try {
12892
- window.localStorage.setItem(NOTIFIED_KEY, sig);
12893
- } catch {
12894
- }
12895
- showToast(L.pluginsUpdatesAvailable.replaceAll("{n}", String(status.updates.length)), "info");
14079
+ apply4();
12896
14080
  }
12897
14081
 
12898
14082
  // src/inject/index.js
@@ -12983,6 +14167,10 @@
12983
14167
  startWsRunningSpin();
12984
14168
  } catch {
12985
14169
  }
14170
+ try {
14171
+ startSubagentIcon();
14172
+ } catch {
14173
+ }
12986
14174
  try {
12987
14175
  startIdleReclaim();
12988
14176
  } catch {