zcode-pro 1.7.0 → 1.8.1

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;
@@ -277,7 +277,34 @@
277
277
  proxyScopeSync: "\u540C\u6B65",
278
278
  proxyScopeSyncDesc: "WebDAV \u4E0A\u4F20\u4E0E\u4E0B\u8F7D\u8D70\u4EE3\u7406\u3002",
279
279
  tabSync: "\u540C\u6B65",
280
+ tabImport: "\u5BFC\u5165\u4F1A\u8BDD",
280
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",
281
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]",
282
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",
283
310
  syncUrlPlaceholder: "https://dav.jianguoyun.com/dav/",
@@ -514,6 +541,8 @@
514
541
  themeBgBlur: "\u753B\u9762\u6A21\u7CCA",
515
542
  themeBgPanel: "\u9762\u677F\u4E0D\u900F\u660E\u5EA6",
516
543
  themeBgDialogFrost: "\u8BBE\u7F6E\u5F39\u7A97\u78E8\u7802",
544
+ themeBgCardVeil: "\u63D2\u4EF6\u5361\u7247\u906E\u7F69",
545
+ themeBgCardVeilHint: "\u58C1\u7EB8\u5F00\u7740\u65F6\u57AB\u5728\u63D2\u4EF6\u5361\u7247\u5E95\u4E0B\u7684\u4E3B\u9898\u8272\u906E\u7F69\uFF1A0 \u4E0D\u906E\uFF08\u58C1\u7EB8\u539F\u6837\u900F\u51FA\uFF09\uFF0C\u8D8A\u5927\u5361\u7247\u8D8A\u5B9E\u5728\u3001\u8D8A\u6697\u3002",
517
546
  themeBgMisc: "\u5176\u4ED6",
518
547
  themeBgFollowGlobal: "\u8DDF\u968F\u5168\u5C40",
519
548
  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",
@@ -597,6 +626,8 @@
597
626
  featureSessionLink: "\u4F1A\u8BDD ID \u663E\u793A\u4E3A\u4EFB\u52A1\u540D\u94FE\u63A5",
598
627
  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",
599
628
  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",
629
+ featureSessionImport: "\u5BFC\u5165\u4F1A\u8BDD",
630
+ 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",
600
631
  imageCopy: "\u590D\u5236\u56FE\u7247",
601
632
  imageCopied: "\u56FE\u7247\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F",
602
633
  imageCopyFailed: "\u590D\u5236\u56FE\u7247\u5931\u8D25",
@@ -878,7 +909,34 @@
878
909
  proxyScopeSync: "Sync",
879
910
  proxyScopeSyncDesc: "WebDAV upload and download go through the proxy.",
880
911
  tabSync: "Sync",
912
+ tabImport: "Session import",
881
913
  tabDebug: "Debug",
914
+ 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.",
915
+ importSearch: "Search title or folder",
916
+ importRefresh: "Refresh",
917
+ importShowAll: "Show all",
918
+ importShowAllTip: "Show subagent sessions, pi copies imported from Codex, and Claude sessions without real conversation; archived sessions are always shown",
919
+ importOnlyProject: "Only the selected project",
920
+ importSelectAll: "Select all",
921
+ importSelected: "Import selected ({n})",
922
+ importImporting: "Importing\u2026",
923
+ importLoading: "Loading\u2026",
924
+ importNoSessions: "No sessions to import",
925
+ importNoSource: "The session folder for this tool was not found",
926
+ importSourceMissing: "No session folder detected",
927
+ importAlready: "Imported",
928
+ importAlreadyArchived: "Imported (task archived)",
929
+ importArchivedTaskTip: "The imported task is archived; unarchive or delete it before importing again",
930
+ importArchived: "Archived",
931
+ importSubagent: "Subagent",
932
+ importCodexCopy: "Codex copy",
933
+ importLarge: "Large",
934
+ importCwdMissing: "Original folder missing",
935
+ importProjectNone: "No project (Tasks section)",
936
+ importProjectHint: "The project only controls the sidebar group; the session keeps its original working folder",
937
+ importConfirmLarge: "The selection includes files larger than 20MB. Importing may take a while. Continue?",
938
+ importDone: "Import finished: {ok} imported, {skip} skipped, {fail} failed",
939
+ importFailed: "Import failed",
882
940
  testNoSessionHint: 'With "Follow current session" selected, the provider and model of the last session are used (the label shows the model name in brackets).',
883
941
  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.',
884
942
  syncUrlPlaceholder: "https://dav.example.com/dav/",
@@ -1114,6 +1172,8 @@
1114
1172
  themeBgBlur: "Wallpaper blur",
1115
1173
  themeBgPanel: "Panel opacity",
1116
1174
  themeBgDialogFrost: "Frosted settings window",
1175
+ themeBgCardVeil: "Plugin card veil",
1176
+ themeBgCardVeilHint: "Theme-colored veil behind plugin cards while a wallpaper is on: 0 shows the wallpaper as-is; higher makes cards more solid and darker.",
1117
1177
  themeBgMisc: "Other",
1118
1178
  themeBgFollowGlobal: "Follow global",
1119
1179
  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.',
@@ -1197,6 +1257,8 @@
1197
1257
  featureSessionLink: "Session ID links",
1198
1258
  featureSessionLinkDesc: "Shows session IDs (sess_ / session_) in chat as task names; click to switch to that session, hover for the raw ID.",
1199
1259
  featureComposerProviderDesc: "Shows the provider before the model name (e.g. BigModel-Max1 / glm-5.3).",
1260
+ featureSessionImport: "Session import",
1261
+ featureSessionImportDesc: "Import sessions from Codex, Claude Code, dsh and pi as ZCode tasks from the settings dialog.",
1200
1262
  imageCopy: "Copy image",
1201
1263
  imageCopied: "Image copied to the clipboard.",
1202
1264
  imageCopyFailed: "Failed to copy the image.",
@@ -1436,6 +1498,17 @@
1436
1498
  "index-remap-failed": "Failed to update the task index (config changes rolled back)",
1437
1499
  "index-error": "Task index error",
1438
1500
  "index-busy": "The task index is busy. Please retry shortly.",
1501
+ "bad-source": "Unknown session source",
1502
+ "source-unavailable": "No session folder found for this tool",
1503
+ "bad-request": "Invalid import request",
1504
+ "too-many-items": "At most 1000 sessions per import; split the selection",
1505
+ "project-not-found": "Project not found or has no folder",
1506
+ "bad-source-path": "The session file is outside the source folder or no longer exists",
1507
+ "session-mismatch": "The session id does not match the file content",
1508
+ "empty-session": "No messages to import",
1509
+ "db-missing": "The ZCode session database or task index is missing",
1510
+ "import-failed": "Import failed",
1511
+ "zstd-unavailable": "This Node build cannot read dsh sessions (zstd support is missing)",
1439
1512
  "vision-invalid": "Invalid vision config",
1440
1513
  "vision-read": "Failed to read zcode-vision.json",
1441
1514
  "vision-write": "Failed to write zcode-vision.json",
@@ -2136,6 +2209,16 @@
2136
2209
  .zcodepro-textarea.zcodepro-textarea-sm { min-height: 0; }
2137
2210
  /* \u5168\u5C40\u63D0\u793A\u8BCD\u5927\u7F16\u8F91\u6846\uFF1A\u9ED8\u8BA4/\u6700\u5927\u9AD8\u5EA6\u90FD\u6BD4\u9ED8\u8BA4\u6587\u672C\u57DF\u66F4\u9AD8 */
2138
2211
  .zcodepro-textarea.zcodepro-textarea-lg { min-height: 16rem; max-height: 40rem; }
2212
+ /* \u8BBE\u7F6E\u9875\u4E0B\u62C9\u6846\uFF1A\u58C1\u7EB8\u5F00\u7740\u65F6\u8868\u9762 token \u88AB\u6362\u6210 color-mix \u534A\u900F\u660E\uFF0C\u539F\u751F\u4E0B\u62C9\u5217\u8868
2213
+ \u4F1A\u6E32\u67D3\u6210\u9ED1\u5E95 + \u9ED8\u8BA4\u9ED1\u5B57\uFF08\u6DF1\u8272\u6A21\u5F0F\u770B\u4E0D\u6E05\uFF09\u3002\u7ED9\u9009\u9879\u5199\u6B7B\u4E3B\u9898\u7684\u4E0D\u900F\u660E\u5E95\u8272\u4E0E
2214
+ \u6B63\u6587\u8272\uFF0C\u5E76\u6309\u660E\u6697\u7ED9 select \u4E00\u4E2A color-scheme\uFF0C\u5217\u8868\u5728\u4E24\u79CD\u6A21\u5F0F\u4E0B\u90FD\u53EF\u8BFB */
2215
+ [data-zcodepro-settings] select { color-scheme: light; }
2216
+ html.theme-zai-dark [data-zcodepro-settings] select,
2217
+ html.dark [data-zcodepro-settings] select { color-scheme: dark; }
2218
+ [data-zcodepro-settings] select option {
2219
+ background-color: var(--color-popover, #fff);
2220
+ color: var(--color-foreground, #111);
2221
+ }
2139
2222
  /* \u884C\u9AD8\u6ED1\u6746\uFF08\u6837\u5F0F\u8C03\u6574\u6807\u7B7E\u9875\uFF09 */
2140
2223
  .zcodepro-range {
2141
2224
  -webkit-appearance: none;
@@ -2249,6 +2332,8 @@
2249
2332
  pointer-events: none;
2250
2333
  }
2251
2334
  .zcodepro-statusbar span[data-tone='warn'] { color: var(--color-amber-500, #f59e0b); }
2335
+ /* \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 */
2336
+ .zcodepro-statusbar > * { flex-shrink: 0; }
2252
2337
  .zcodepro-statusbar span[data-tone='danger'] { color: var(--color-red-500, #ef4444); }
2253
2338
  .zcodepro-statusbar-sep { opacity: 0.45; }
2254
2339
  /* \u4F1A\u8BDD\u7EC4\u4E0E\u5168\u5C40\u7EC4\u4E4B\u95F4\u7684\u5206\u754C\u7AD6\u7EBF */
@@ -2593,6 +2678,30 @@
2593
2678
  return null;
2594
2679
  }
2595
2680
  }
2681
+ function listActiveIdsCached(base) {
2682
+ const key = String(base).replace(/[\\/]+$/, "");
2683
+ const now = Date.now();
2684
+ const hit = activeIdsCache.get(key);
2685
+ if (hit && hit.pending) return hit.pending;
2686
+ if (hit && now - hit.doneAt < ACTIVE_IDS_TTL_MS) return Promise.resolve(hit.ids);
2687
+ const services = findServices();
2688
+ const ts = services && services.zcodeTaskService;
2689
+ if (!ts || typeof ts.listActiveTaskIds !== "function") return Promise.resolve(null);
2690
+ const one = (w) => new Promise((resolve) => {
2691
+ const timer = setTimeout(() => resolve([]), ACTIVE_IDS_TIMEOUT_MS);
2692
+ Promise.resolve().then(() => ts.listActiveTaskIds({ workspacePath: w })).then(
2693
+ (r) => resolve(Array.isArray(r) ? r.map(String) : []),
2694
+ () => resolve([])
2695
+ ).finally(() => clearTimeout(timer));
2696
+ });
2697
+ const pending = Promise.all([one(key), one(key + "/")]).then(([a, b]) => {
2698
+ const ids = [...a, ...b];
2699
+ activeIdsCache.set(key, { ids, doneAt: Date.now(), pending: null });
2700
+ return ids;
2701
+ });
2702
+ activeIdsCache.set(key, { ids: hit && hit.ids || [], doneAt: hit ? hit.doneAt : 0, pending });
2703
+ return pending;
2704
+ }
2596
2705
  async function authoritativeIdle(ws) {
2597
2706
  const services = findServices();
2598
2707
  const ts = services && services.zcodeTaskService;
@@ -2794,13 +2903,7 @@
2794
2903
  }
2795
2904
  projectPaths.set(proj.name, names);
2796
2905
  }
2797
- const pairs = await Promise.all([...scanPaths].map(async (base) => {
2798
- const [a, b] = await Promise.all([
2799
- ts.listActiveTaskIds({ workspacePath: base }),
2800
- ts.listActiveTaskIds({ workspacePath: base + "/" })
2801
- ]);
2802
- return [base, [...Array.isArray(a) ? a : [], ...Array.isArray(b) ? b : []].map(String)];
2803
- }));
2906
+ const pairs = await Promise.all([...scanPaths].map(async (base) => [base, await listActiveIdsCached(base) || []]));
2804
2907
  for (const [base, ids] of pairs) {
2805
2908
  if (!ids.length) continue;
2806
2909
  byKindByPath.set(base, ids);
@@ -3141,8 +3244,8 @@
3141
3244
  }, pollMs);
3142
3245
  }
3143
3246
  function startWsRunningSpin() {
3144
- if (installed2 || typeof document === "undefined") return;
3145
- installed2 = true;
3247
+ if (installed || typeof document === "undefined") return;
3248
+ installed = true;
3146
3249
  const st = document.createElement("style");
3147
3250
  st.id = "__zcodepro_ws_style__";
3148
3251
  st.textContent = ".zcodepro-ws-loader{color:color-mix(in srgb, currentColor 85%, black) !important}";
@@ -3173,12 +3276,12 @@
3173
3276
  if (row) wsTouchAt.set(row, Date.now());
3174
3277
  }, true);
3175
3278
  }
3176
- 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;
3279
+ 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;
3177
3280
  var init_ws_running = __esm({
3178
3281
  "src/inject/features/ws-running.js"() {
3179
3282
  init_core();
3180
3283
  init_ws_rows();
3181
- installed2 = false;
3284
+ installed = false;
3182
3285
  enabled2 = true;
3183
3286
  SCAN_DEBOUNCE_MS = 150;
3184
3287
  SCAN_FALLBACK_MS = 5e3;
@@ -3208,6 +3311,9 @@
3208
3311
  wsWithRows = /* @__PURE__ */ new Set();
3209
3312
  servicesRef = null;
3210
3313
  servicesMissAt = 0;
3314
+ ACTIVE_IDS_TTL_MS = 25e3;
3315
+ ACTIVE_IDS_TIMEOUT_MS = 6e3;
3316
+ activeIdsCache = /* @__PURE__ */ new Map();
3211
3317
  synthClick = (el) => {
3212
3318
  try {
3213
3319
  el.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
@@ -5298,7 +5404,16 @@
5298
5404
  `.history-message.flex.flex-col > * + *:not([data-slot="collapsible-content"]){margin-block-start:${n}px !important;margin-top:${n}px !important;}`,
5299
5405
  // 工具/状态卡片(“N 个文件已更改”等)上方间距下限 8px:
5300
5406
  // 段落间距调到 0 时也不至于贴死(gap 与 margin 在弹性布局里相加)
5301
- `${CONV} .flex.flex-col.gap-5 > [data-slot="collapsible"]{margin-block-start:max(0px, calc(8px - ${n}px)) !important;margin-top:max(0px, calc(8px - ${n}px)) !important;}`
5407
+ `${CONV} .flex.flex-col.gap-5 > [data-slot="collapsible"]{margin-block-start:max(0px, calc(8px - ${n}px)) !important;margin-top:max(0px, calc(8px - ${n}px)) !important;}`,
5408
+ // 3.18 的“工作中”槽位带 -8px 上边距(默认 gap 20 → 实际 12px);行间距调小后
5409
+ // 这层负边距会把槽位拉得贴住上面的内容(gap 7 → 实际 -1px)。清掉负边距,
5410
+ // 让它跟其它块一样按设置的行间距排
5411
+ `${CONV} .flex.flex-col.gap-5 > [data-zcode-chat-loading-slot]:not(:first-child){margin-block-start:0 !important;margin-top:0 !important;}`,
5412
+ // 过程视图(思考/工具摘要/过程正文)的行块:应用给容器 4px gap + 每行
5413
+ // 12px 上内边距(共 16px)。段落间距设置时直接接管:gap 归零、上内边距
5414
+ // 按设置值,总间距等于设置值(设 0 就完全贴紧)
5415
+ `${CONV} [data-conversation-work-items]{gap:0 !important;}`,
5416
+ `${CONV} [data-conversation-work-items] > * + *{padding-top:${n}px !important;}`
5302
5417
  );
5303
5418
  }
5304
5419
  const own = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : rowGapSet ? n : null;
@@ -5346,7 +5461,20 @@
5346
5461
  const tlh = styles.thinkingLineHeight;
5347
5462
  if (typeof tlh === "number" && Number.isFinite(tlh) && tlh >= 0.8) {
5348
5463
  parts.push(
5349
- `[data-testid^="chat-assistant-history-content"]{line-height:${tlh} !important;}`
5464
+ `[data-testid^="chat-assistant-history-content"]{line-height:${tlh} !important;}`,
5465
+ // 历史回合顶部的“已工作 N 秒”触发行在历史内容容器外,按钮自带 text-ui-base
5466
+ // 的行高,只靠容器继承改不到;直接覆盖,否则调“思考行高”时这行不变
5467
+ `[class~="group/history-message"]{line-height:${tlh} !important;}`,
5468
+ // 用户要求:“已工作”展开块内的内容算思考,块外的才算回答。
5469
+ // 历史视图整轮消息(含回答正文)都在历史内容容器里,容器内的 .space-y-4
5470
+ // 改用思考行高;正在回答的回合里,展开块外的回答正文仍用回答行高。
5471
+ // 放在回答行高规则之后(同特异性,后写的生效)
5472
+ `[data-testid^="chat-assistant-history-content"] .space-y-4{line-height:${tlh} !important;}`,
5473
+ `[data-conversation-work-items] .space-y-4{line-height:${tlh} !important;}`,
5474
+ // 3.18 实时回合的思考正文与“工作中”行在历史容器外,且自带 text-ui-base 的
5475
+ // 行高,只靠继承改不动;直接覆盖,调“思考行高”时正在生成的回合也生效
5476
+ `[data-testid="chat-reasoning-content"] .whitespace-pre-wrap{line-height:${tlh} !important;}`,
5477
+ `[data-testid="chat-loading"] *{line-height:${tlh} !important;}`
5350
5478
  );
5351
5479
  }
5352
5480
  const ulh = styles.userLineHeight;
@@ -5451,10 +5579,9 @@
5451
5579
  tableCellPaddingV: `${CONV} td, ${CONV} th`,
5452
5580
  tableCellPaddingH: `${CONV} td, ${CONV} th`,
5453
5581
  codeLineHeight: `${CONV} diffs-container, ${CONV} pre`,
5454
- lineHeight: `${CONV} .space-y-4:not([data-reasoning-content] *)`,
5455
- // 思考行高作用在“已工作/工作中”过程视图容器上;视图折叠未挂载时不标
5456
- // (触发行不属此设置范围,不额外描边)
5457
- thinkingLineHeight: `[data-testid^="chat-assistant-history-content"]`,
5582
+ lineHeight: `${CONV} .space-y-4:not([data-reasoning-content] *):not([data-testid^="chat-assistant-history-content"] *):not([data-conversation-work-items] *)`,
5583
+ // 思考行高作用在“已工作/工作中”过程视图、触发行与思考正文上;视图折叠未挂载时不标
5584
+ thinkingLineHeight: `[data-testid^="chat-assistant-history-content"], [class~="group/history-message"], [data-testid="chat-loading"], [data-testid="chat-reasoning-content"]`,
5458
5585
  userLineHeight: `${CONV} [class*="user-row"] .whitespace-pre-wrap`,
5459
5586
  contentWidth: "[data-v4-timeline-content-column]",
5460
5587
  // 双结构:新侧栏项目行 / 旧 testid 行
@@ -5882,18 +6009,24 @@
5882
6009
  }
5883
6010
  var webviewScanTimer = null;
5884
6011
  var wvStyled = [];
6012
+ function cardVeilCss() {
6013
+ const raw = Number((currentTheme.bg || {}).cardVeil);
6014
+ const veil = Number.isFinite(raw) ? raw : 0.2;
6015
+ const rgb = rgbTriple(resolvedColor("--color-background"), isDarkMode() ? "13,13,13" : "248,248,248");
6016
+ return `html,body{background:rgba(${rgb},${veil}) !important}`;
6017
+ }
5885
6018
  function applyWebviewTransparency() {
5886
- const css = "html,body{background:transparent !important}";
5887
- const hook = (w) => {
6019
+ const hook = (w, css) => {
5888
6020
  const on = document.documentElement.classList.contains("zcodepro-bg-on");
5889
6021
  const rec = wvStyled.find((r) => r.el === w);
5890
6022
  if (on && !rec) {
5891
- const entry = { el: w, key: null, handler: null };
6023
+ const entry = { el: w, key: null, css, handler: null };
5892
6024
  entry.handler = () => {
5893
6025
  if (!wvStyled.includes(entry)) return;
6026
+ const myCss = entry.css;
5894
6027
  try {
5895
- void w.insertCSS(css).then((k) => {
5896
- if (wvStyled.includes(entry)) entry.key = k;
6028
+ void w.insertCSS(myCss).then((k) => {
6029
+ if (wvStyled.includes(entry) && entry.css === myCss) entry.key = k;
5897
6030
  else {
5898
6031
  try {
5899
6032
  void w.removeCSS(k).catch(() => {
@@ -5909,6 +6042,32 @@
5909
6042
  w.addEventListener("dom-ready", entry.handler);
5910
6043
  wvStyled.push(entry);
5911
6044
  entry.handler();
6045
+ } else if (on && rec && rec.css !== css) {
6046
+ rec.css = css;
6047
+ const oldKey = rec.key;
6048
+ rec.key = null;
6049
+ if (oldKey) {
6050
+ try {
6051
+ void w.removeCSS(oldKey).catch(() => {
6052
+ });
6053
+ } catch {
6054
+ }
6055
+ }
6056
+ try {
6057
+ void w.insertCSS(css).then((k) => {
6058
+ if (wvStyled.includes(rec) && rec.css === css) rec.key = k;
6059
+ else {
6060
+ try {
6061
+ void w.removeCSS(k).catch(() => {
6062
+ });
6063
+ } catch {
6064
+ }
6065
+ }
6066
+ }).catch(() => {
6067
+ if (wvStyled.includes(rec) && rec.css === css) rec.css = "";
6068
+ });
6069
+ } catch {
6070
+ }
5912
6071
  } else if (!on && rec) {
5913
6072
  if (rec.handler) w.removeEventListener("dom-ready", rec.handler);
5914
6073
  if (rec.key) {
@@ -5921,7 +6080,10 @@
5921
6080
  wvStyled.splice(wvStyled.indexOf(rec), 1);
5922
6081
  }
5923
6082
  };
5924
- const scan6 = () => document.querySelectorAll("webview").forEach(hook);
6083
+ const scan6 = () => {
6084
+ const css = cardVeilCss();
6085
+ document.querySelectorAll("webview").forEach((w) => hook(w, css));
6086
+ };
5925
6087
  scan6();
5926
6088
  if (!webviewScanTimer) webviewScanTimer = setInterval(scan6, 2e3);
5927
6089
  }
@@ -6586,6 +6748,399 @@
6586
6748
  showToast(L.pluginsUpdatesAvailable.replaceAll("{n}", String(status.updates.length)), "info");
6587
6749
  }
6588
6750
 
6751
+ // src/inject/features/session-import.js
6752
+ init_core();
6753
+ init_ui();
6754
+ init_ws_running();
6755
+ 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";
6756
+ function tag(text, title = "") {
6757
+ return h("span", { class: "shrink-0 rounded border border-border px-1 text-ui-xs text-foreground-subtle", title: title || void 0 }, text);
6758
+ }
6759
+ function when(ms) {
6760
+ if (!ms) return "";
6761
+ try {
6762
+ return new Date(ms).toLocaleString();
6763
+ } catch {
6764
+ return "";
6765
+ }
6766
+ }
6767
+ function createSessionImportPane() {
6768
+ const L = t();
6769
+ const root = h("div", { role: "tabpanel", style: "display:none" });
6770
+ let sources = [];
6771
+ let active = "";
6772
+ let sessions = [];
6773
+ let selected = /* @__PURE__ */ new Set();
6774
+ let projects = [];
6775
+ let projectId = "";
6776
+ let showAll = false;
6777
+ let onlyProject = false;
6778
+ let search = "";
6779
+ let loading = false;
6780
+ let importing = false;
6781
+ let loaded = false;
6782
+ let pendingReload = false;
6783
+ let searchTimer = null;
6784
+ const statusEl = h("div", { class: "mt-2 min-h-4 text-ui-xs/relaxed text-foreground-subtle" });
6785
+ const listEl = h("div", { class: "max-h-80 overflow-auto divide-y divide-border" });
6786
+ const sourceTabs = h("div", { role: "tablist", "aria-orientation": "horizontal", class: "zcodepro-tablist" });
6787
+ const searchInput = h("input", {
6788
+ type: "text",
6789
+ class: INPUT_CLS + " min-w-0 flex-1",
6790
+ placeholder: L.importSearch,
6791
+ spellcheck: "false",
6792
+ autocomplete: "off"
6793
+ });
6794
+ const projectSelect = h("select", { class: INPUT_CLS + " min-w-0 max-w-56" });
6795
+ const onlyProjectBox = h("input", { type: "checkbox" });
6796
+ const showAllBox = h("input", { type: "checkbox", title: L.importShowAllTip });
6797
+ const selectAllBox = h("input", { type: "checkbox" });
6798
+ const refreshBtn = btnSmall(L.importRefresh, () => {
6799
+ void loadList();
6800
+ });
6801
+ const importBtn = btnSmall(L.importSelected.replace("{n}", "0"), () => {
6802
+ void doImport();
6803
+ }, "shrink-0", "primary");
6804
+ importBtn.disabled = true;
6805
+ const setStatus = (text, kind = "") => {
6806
+ statusEl.textContent = text || "";
6807
+ statusEl.className = "mt-2 min-h-4 text-ui-xs/relaxed " + (kind === "error" ? "text-destructive" : "text-foreground-subtle");
6808
+ };
6809
+ const selectedProject = () => projects.find((p) => p.id === projectId) || null;
6810
+ const projectRoots = () => (selectedProject()?.roots || []).map((r) => r.path).filter(Boolean);
6811
+ const refreshTaskTree = async () => {
6812
+ const rootEl = document.getElementById("root");
6813
+ const containerKey = rootEl && Object.keys(rootEl).find((k) => k.startsWith("__reactContainer$"));
6814
+ if (!containerKey) return false;
6815
+ const seen2 = /* @__PURE__ */ new Set();
6816
+ let found = null;
6817
+ const scan6 = (o) => {
6818
+ if (!o || typeof o !== "object" || seen2.has(o) || found) return;
6819
+ seen2.add(o);
6820
+ try {
6821
+ if (typeof o.refresh === "function" && "factTree" in o && "tree" in o) found = o;
6822
+ } catch {
6823
+ }
6824
+ };
6825
+ let visited = 0;
6826
+ const visit = (f) => {
6827
+ if (!f || found || visited > 6e4) return;
6828
+ visited++;
6829
+ for (const h2 of [f.memoizedProps, f.memoizedState]) {
6830
+ if (!h2 || typeof h2 !== "object") continue;
6831
+ scan6(h2);
6832
+ for (const v of Object.values(h2)) if (v && typeof v === "object") scan6(v);
6833
+ }
6834
+ visit(f.child);
6835
+ visit(f.sibling);
6836
+ };
6837
+ visit(rootEl[containerKey]);
6838
+ if (!found) return false;
6839
+ try {
6840
+ await found.refresh();
6841
+ return true;
6842
+ } catch {
6843
+ return false;
6844
+ }
6845
+ };
6846
+ const prepareWorkspaces = async (imported) => {
6847
+ const ag = findServices()?.zcodeAgentService;
6848
+ if (!ag || typeof ag.resumeSession !== "function") return;
6849
+ const seen2 = /* @__PURE__ */ new Set();
6850
+ for (const item of imported) {
6851
+ if (!item.workspace || seen2.has(item.workspace)) continue;
6852
+ seen2.add(item.workspace);
6853
+ try {
6854
+ await ag.resumeSession({ workspacePath: item.workspace, sessionId: item.taskId });
6855
+ } catch {
6856
+ }
6857
+ }
6858
+ };
6859
+ const renderSources = () => {
6860
+ sourceTabs.replaceChildren(...sources.filter((s) => s.available).map((s) => h("button", {
6861
+ type: "button",
6862
+ role: "tab",
6863
+ class: "zcodepro-tab",
6864
+ "aria-selected": String(active === s.id),
6865
+ "data-state": active === s.id ? "active" : "inactive",
6866
+ disabled: !s.available,
6867
+ title: s.available ? "" : L.importSourceMissing,
6868
+ onClick: () => {
6869
+ if (!s.available || active === s.id) return;
6870
+ active = s.id;
6871
+ selected = /* @__PURE__ */ new Set();
6872
+ sessions = [];
6873
+ renderSources();
6874
+ void loadList();
6875
+ }
6876
+ }, s.label)));
6877
+ };
6878
+ const selectable = () => sessions.filter((s) => !s.imported);
6879
+ const allSelected = () => {
6880
+ const list = selectable();
6881
+ return list.length > 0 && list.every((s) => selected.has(s.sessionId));
6882
+ };
6883
+ const renderList = () => {
6884
+ selectAllBox.checked = allSelected();
6885
+ selectAllBox.disabled = importing || !selectable().length;
6886
+ importBtn.textContent = L.importSelected.replace("{n}", String(selected.size));
6887
+ importBtn.disabled = importing || !selected.size;
6888
+ if (loading) {
6889
+ listEl.replaceChildren(h("div", { class: "px-3 py-6 text-center text-ui-sm text-foreground-subtle" }, L.importLoading));
6890
+ return;
6891
+ }
6892
+ if (!sessions.length) {
6893
+ listEl.replaceChildren(h("div", { class: "px-3 py-6 text-center text-ui-sm text-foreground-subtle" }, L.importNoSessions));
6894
+ return;
6895
+ }
6896
+ listEl.replaceChildren(...sessions.map((s) => {
6897
+ const checked = selected.has(s.sessionId);
6898
+ const box = h("input", {
6899
+ type: "checkbox",
6900
+ class: "mt-0.5 shrink-0",
6901
+ checked,
6902
+ disabled: importing || s.imported,
6903
+ onChange: () => {
6904
+ if (box.checked) selected.add(s.sessionId);
6905
+ else selected.delete(s.sessionId);
6906
+ renderList();
6907
+ }
6908
+ });
6909
+ const tags = [];
6910
+ if (s.imported) {
6911
+ tags.push(tag(
6912
+ s.importedArchived ? L.importAlreadyArchived : L.importAlready,
6913
+ s.importedArchived ? L.importArchivedTaskTip : ""
6914
+ ));
6915
+ }
6916
+ if (s.archived) tags.push(tag(L.importArchived));
6917
+ if (s.subagent) tags.push(tag(L.importSubagent));
6918
+ if (s.codexImport) tags.push(tag(L.importCodexCopy));
6919
+ if (s.large) tags.push(tag(L.importLarge));
6920
+ if (s.cwdExists === false) tags.push(tag(L.importCwdMissing));
6921
+ return h(
6922
+ "label",
6923
+ {
6924
+ class: "flex cursor-pointer items-start gap-2 px-3 py-2 transition-colors hover:bg-surface-hover",
6925
+ title: s.cwd || ""
6926
+ },
6927
+ box,
6928
+ h(
6929
+ "div",
6930
+ { class: "min-w-0 flex-1" },
6931
+ h("div", { class: "truncate text-ui-sm" }, s.title || s.sessionId),
6932
+ h(
6933
+ "div",
6934
+ { class: "mt-0.5 flex items-center gap-2 overflow-hidden" },
6935
+ h("span", { class: "min-w-0 flex-1 truncate text-ui-xs text-foreground-subtle" }, s.cwd || s.sourcePath || ""),
6936
+ h("span", { class: "shrink-0 text-ui-xs text-foreground-subtle" }, when(s.updatedAt)),
6937
+ ...tags
6938
+ )
6939
+ )
6940
+ );
6941
+ }));
6942
+ };
6943
+ const loadProjects = async () => {
6944
+ const res = await rpc("/projects-v2");
6945
+ projects = res.ok && Array.isArray(res.projects) ? res.projects : [];
6946
+ const current2 = projectId;
6947
+ projectSelect.replaceChildren(
6948
+ h("option", { value: "" }, L.importProjectNone),
6949
+ ...projects.map((p) => h("option", { value: p.id }, p.name || p.id))
6950
+ );
6951
+ projectSelect.value = projects.some((p) => p.id === current2) ? current2 : "";
6952
+ projectId = projectSelect.value;
6953
+ onlyProjectBox.disabled = !projectId;
6954
+ if (!projectId) {
6955
+ onlyProjectBox.checked = false;
6956
+ onlyProject = false;
6957
+ }
6958
+ };
6959
+ const loadList = async () => {
6960
+ if (loading || importing) {
6961
+ pendingReload = true;
6962
+ return;
6963
+ }
6964
+ loading = true;
6965
+ renderList();
6966
+ const done = () => {
6967
+ loading = false;
6968
+ if (pendingReload) {
6969
+ pendingReload = false;
6970
+ queueMicrotask(() => {
6971
+ void loadList();
6972
+ });
6973
+ }
6974
+ };
6975
+ if (!sources.length || !sources.some((s) => s.id === active && s.available)) {
6976
+ const meta = await rpc("/import/list", { method: "POST", body: { source: "" } });
6977
+ if (meta.ok && Array.isArray(meta.sources)) sources = meta.sources;
6978
+ if (!sources.some((s) => s.id === active && s.available)) {
6979
+ active = (sources.find((s) => s.available) || {}).id || "";
6980
+ }
6981
+ renderSources();
6982
+ if (!active) {
6983
+ sessions = [];
6984
+ done();
6985
+ renderList();
6986
+ setStatus(L.importNoSource);
6987
+ return;
6988
+ }
6989
+ }
6990
+ const res = await rpc("/import/list", {
6991
+ method: "POST",
6992
+ body: {
6993
+ source: active,
6994
+ showAll,
6995
+ search,
6996
+ roots: onlyProject && projectId ? projectRoots() : []
6997
+ }
6998
+ });
6999
+ if (!res.ok) {
7000
+ sessions = [];
7001
+ done();
7002
+ renderList();
7003
+ setStatus(errText(res), "error");
7004
+ return;
7005
+ }
7006
+ sources = res.sources || sources;
7007
+ sessions = res.sessions || [];
7008
+ const usable = new Set(selectable().map((s) => s.sessionId));
7009
+ selected = new Set([...selected].filter((id) => usable.has(id)));
7010
+ if (!active || !sources.some((s) => s.id === active)) {
7011
+ active = (sources.find((s) => s.available) || {}).id || "";
7012
+ }
7013
+ done();
7014
+ renderSources();
7015
+ renderList();
7016
+ setStatus(res.unavailable ? L.importNoSource : "");
7017
+ };
7018
+ const doImport = async () => {
7019
+ if (importing || !selected.size) return;
7020
+ const chosen = sessions.filter((s) => selected.has(s.sessionId));
7021
+ if (!chosen.length) return;
7022
+ if (chosen.some((s) => s.large)) {
7023
+ if (!window.confirm(L.importConfirmLarge)) return;
7024
+ }
7025
+ importing = true;
7026
+ renderList();
7027
+ setStatus(L.importImporting);
7028
+ let summary = "";
7029
+ let summaryKind = "";
7030
+ try {
7031
+ const res = await rpc("/import/run", {
7032
+ method: "POST",
7033
+ body: {
7034
+ source: active,
7035
+ projectId: projectId || null,
7036
+ items: chosen.map((s) => ({
7037
+ sessionId: s.sessionId,
7038
+ sourcePath: s.sourcePath,
7039
+ title: s.title,
7040
+ cwd: s.cwd
7041
+ }))
7042
+ }
7043
+ });
7044
+ if (!res.ok) {
7045
+ setStatus(errText(res), "error");
7046
+ showToast(L.importFailed + ": " + errText(res), "error");
7047
+ return;
7048
+ }
7049
+ const imported = Array.isArray(res.imported) ? res.imported : [];
7050
+ const skipped = Array.isArray(res.skipped) ? res.skipped : [];
7051
+ const failed = Array.isArray(res.failed) ? res.failed : [];
7052
+ const msg = L.importDone.replace("{ok}", String(imported.length)).replace("{skip}", String(skipped.length)).replace("{fail}", String(failed.length));
7053
+ const detail = failed.slice(0, 3).map((f) => `${f.sessionId}: ${f.error}`).join("; ");
7054
+ summary = msg + (detail ? " \xB7 " + detail : "");
7055
+ summaryKind = failed.length ? "error" : "";
7056
+ showToast(msg, failed.length ? "error" : "success");
7057
+ if (imported.length) {
7058
+ void (async () => {
7059
+ await prepareWorkspaces(imported);
7060
+ await refreshTaskTree().catch(() => {
7061
+ });
7062
+ })();
7063
+ }
7064
+ selected = /* @__PURE__ */ new Set();
7065
+ } finally {
7066
+ importing = false;
7067
+ }
7068
+ await loadList();
7069
+ setStatus(summary, summaryKind);
7070
+ };
7071
+ searchInput.addEventListener("input", () => {
7072
+ search = searchInput.value;
7073
+ clearTimeout(searchTimer);
7074
+ searchTimer = setTimeout(() => {
7075
+ void loadList();
7076
+ }, 250);
7077
+ });
7078
+ projectSelect.addEventListener("change", () => {
7079
+ projectId = projectSelect.value;
7080
+ onlyProjectBox.disabled = !projectId;
7081
+ if (!projectId) {
7082
+ onlyProjectBox.checked = false;
7083
+ onlyProject = false;
7084
+ }
7085
+ void loadList();
7086
+ });
7087
+ onlyProjectBox.addEventListener("change", () => {
7088
+ onlyProject = onlyProjectBox.checked;
7089
+ void loadList();
7090
+ });
7091
+ showAllBox.addEventListener("change", () => {
7092
+ showAll = showAllBox.checked;
7093
+ selected = /* @__PURE__ */ new Set();
7094
+ void loadList();
7095
+ });
7096
+ selectAllBox.addEventListener("change", () => {
7097
+ if (selectAllBox.checked) selected = new Set(selectable().map((s) => s.sessionId));
7098
+ else selected = /* @__PURE__ */ new Set();
7099
+ renderList();
7100
+ });
7101
+ 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);
7102
+ root.append(
7103
+ h("p", { class: "text-ui-sm/relaxed text-foreground-subtle" }, L.importDesc),
7104
+ h("div", { class: "mt-3" }, sourceTabs),
7105
+ h(
7106
+ "div",
7107
+ { class: "mt-2 flex flex-wrap items-center gap-2" },
7108
+ searchInput,
7109
+ projectSelect,
7110
+ checkLabel(onlyProjectBox, L.importOnlyProject),
7111
+ checkLabel(showAllBox, L.importShowAll, L.importShowAllTip),
7112
+ refreshBtn
7113
+ ),
7114
+ h(
7115
+ "div",
7116
+ { class: "mt-2 flex items-center justify-between gap-2" },
7117
+ h(
7118
+ "div",
7119
+ { class: "flex items-center gap-2" },
7120
+ checkLabel(selectAllBox, L.importSelectAll),
7121
+ h("span", { class: "text-ui-xs text-foreground-subtle" }, L.importProjectHint)
7122
+ ),
7123
+ importBtn
7124
+ ),
7125
+ h("div", { class: "mt-2 rounded-xl border border-border" }, listEl),
7126
+ statusEl
7127
+ );
7128
+ root.__onShow = () => {
7129
+ if (importing) return;
7130
+ if (!loaded) {
7131
+ loaded = true;
7132
+ setStatus(L.importLoading);
7133
+ void (async () => {
7134
+ await loadProjects();
7135
+ await loadList();
7136
+ })();
7137
+ } else {
7138
+ void loadList();
7139
+ }
7140
+ };
7141
+ return root;
7142
+ }
7143
+
6589
7144
  // src/inject/features/settings-dialog.js
6590
7145
  function openExternal(url) {
6591
7146
  try {
@@ -6947,6 +7502,11 @@
6947
7502
  if (await setFeature("composerProvider", next)) f.composerProvider = next;
6948
7503
  refreshRows();
6949
7504
  }),
7505
+ settingRow(L.featureSessionImport, L.featureSessionImportDesc, f.sessionImport !== false, async () => {
7506
+ const next = !(f.sessionImport !== false);
7507
+ if (await setFeature("sessionImport", next)) f.sessionImport = next;
7508
+ refreshRows();
7509
+ }),
6950
7510
  settingRow(L.featureSandboxReclaim, L.featureSandboxReclaimDesc, f.sandboxReclaim !== false, async () => {
6951
7511
  const next = !(f.sandboxReclaim !== false);
6952
7512
  if (await setFeature("sandboxReclaim", next)) f.sandboxReclaim = next;
@@ -7182,12 +7742,13 @@
7182
7742
  const paneAgents = h("div", { role: "tabpanel", style: "display:none" });
7183
7743
  const paneProxy = h("div", { role: "tabpanel", style: "display:none" });
7184
7744
  const paneSync = h("div", { role: "tabpanel", style: "display:none" });
7745
+ const paneImport = createSessionImportPane();
7185
7746
  const paneVision = h("div", { role: "tabpanel", style: "display:none" });
7186
7747
  const paneRtk = h("div", { role: "tabpanel", style: "display:none" });
7187
7748
  const paneHeadroom = h("div", { role: "tabpanel", style: "display:none" });
7188
7749
  const paneTitleGen = h("div", { role: "tabpanel", style: "display:none" });
7189
7750
  const paneDebug = h("div", { role: "tabpanel", style: "display:none" });
7190
- const panes = { features: paneFeatures, shortcuts: paneShortcuts, styles: paneStyles, perf: panePerf, agents: paneAgents, proxy: paneProxy, sync: paneSync, vision: paneVision, headroom: paneHeadroom, rtk: paneRtk, debug: paneDebug };
7751
+ 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 };
7191
7752
  const tabDefs = [
7192
7753
  ["features", L.tabFeatures],
7193
7754
  ["styles", L.tabStyles],
@@ -7196,6 +7757,7 @@
7196
7757
  ["shortcuts", L.tabShortcuts],
7197
7758
  ["proxy", L.tabProxy],
7198
7759
  ["sync", L.tabSync],
7760
+ ...config.features.sessionImport !== false ? [["import", L.tabImport]] : [],
7199
7761
  ["vision", L.tabVision],
7200
7762
  ["headroom", L.tabHeadroom],
7201
7763
  ["rtk", L.tabRtk],
@@ -7217,6 +7779,7 @@
7217
7779
  if (name !== "shortcuts" && hkRecording) stopHkRecording();
7218
7780
  for (const [id, pane] of Object.entries(panes)) pane.style.display = id === name ? "" : "none";
7219
7781
  for (const [id, bar] of Object.entries(subTabBars)) bar.style.display = id === name ? "" : "none";
7782
+ if (name === "import") paneImport.__onShow?.();
7220
7783
  renderTabs();
7221
7784
  };
7222
7785
  renderTabs();
@@ -8059,6 +8622,19 @@
8059
8622
  void saveTheme({ bg: { dialogFrost: !(themeCfg.bg.dialogFrost !== false) } });
8060
8623
  });
8061
8624
  };
8625
+ const cardVeilRow = () => sliderRow(
8626
+ L.themeBgCardVeil,
8627
+ "",
8628
+ 0,
8629
+ 100,
8630
+ 1,
8631
+ Math.round(numOr(themeCfg.bg.cardVeil, 0.2) * 100),
8632
+ "%",
8633
+ (v) => {
8634
+ void saveTheme({ bg: { cardVeil: v / 100 } });
8635
+ },
8636
+ L.themeBgCardVeilHint
8637
+ );
8062
8638
  const urlInput = h("input", { type: "url", value: themeCfg.bg.url, class: themeInputCls, placeholder: "https://..." });
8063
8639
  urlInput.addEventListener("change", () => {
8064
8640
  const v = urlInput.value.trim();
@@ -8310,6 +8886,7 @@
8310
8886
  pauseCheck("pauseOnBlur", L.themeBgPauseBlur),
8311
8887
  pauseCheck("pauseOnBattery", L.themeBgPauseBattery)
8312
8888
  ),
8889
+ themeCfg.bg.mode !== "none" ? cardVeilRow() : null,
8313
8890
  dialogFrostRow()
8314
8891
  )),
8315
8892
  bgInput
@@ -10495,6 +11072,7 @@
10495
11072
  panePerf,
10496
11073
  paneProxy,
10497
11074
  paneSync,
11075
+ paneImport,
10498
11076
  paneVision,
10499
11077
  paneHeadroom,
10500
11078
  paneRtk,
@@ -10523,7 +11101,7 @@
10523
11101
  init_core();
10524
11102
  init_ui();
10525
11103
  init_core();
10526
- var installed = false;
11104
+ var installed2 = false;
10527
11105
  var dragKey = null;
10528
11106
  var lastOverRow = null;
10529
11107
  var lastOverBefore = false;
@@ -10549,8 +11127,8 @@
10549
11127
  });
10550
11128
  }
10551
11129
  function startTaskOrderWatcher() {
10552
- if (installed || typeof document === "undefined") return;
10553
- installed = true;
11130
+ if (installed2 || typeof document === "undefined") return;
11131
+ installed2 = true;
10554
11132
  ensureStyle();
10555
11133
  document.addEventListener("dragstart", (e) => {
10556
11134
  const row = e.target.closest && e.target.closest("[data-task-item-key]");
@@ -10990,11 +11568,13 @@
10990
11568
  const s = lastStats && statsSid === sid ? lastStats.sessionSummary : null;
10991
11569
  const tps = s && s.tps != null ? s.tps : null;
10992
11570
  const est = streamEst ? streamEst.value : null;
10993
- const shown = tps != null ? tps : est;
11571
+ const streaming = !!(streamEst && Date.now() - streamEst.at < 5e3);
11572
+ const useEst = streaming && est != null;
11573
+ const shown = useEst ? est : tps != null ? tps : est;
10994
11574
  if (shown == null) return null;
10995
11575
  const zh2 = isZhLocale();
10996
- const estMark = tps == null && est != null ? "\u2248" : "";
10997
- const detail = 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";
11576
+ const estMark = useEst || tps == null ? "\u2248" : "";
11577
+ 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";
10998
11578
  return {
10999
11579
  html: sbIcon("tokRate") + label(L.sbLabelOut) + `<b>${estMark}${fmtNum(Math.round(shown * 10) / 10)} tok/s</b>`,
11000
11580
  title: `${L.sbItemTokRate}${zh2 ? "\uFF08\u672C\u4F1A\u8BDD\uFF09\uFF1A" : " (this session): "}${detail}`,
@@ -11069,29 +11649,48 @@
11069
11649
  barEl.style.marginBottom = hasSession ? "-14px" : "0";
11070
11650
  barEl.style.paddingBottom = hasSession ? "0" : "7px";
11071
11651
  const L = t();
11072
- const parts = [];
11073
- let lastGroup = "";
11652
+ const entries = [];
11074
11653
  for (const it of items) {
11075
11654
  if (!it.on) continue;
11076
11655
  const c = itemContent(it.id, L);
11077
11656
  if (!c) continue;
11078
- const group = GLOBAL_GROUP.has(it.id) ? "g" : "s";
11079
- if (lastGroup && group !== lastGroup) parts.push('<span class="zcodepro-statusbar-groupsep"></span>');
11080
- lastGroup = group;
11081
- parts.push(`<span title="${c.title.replace(/"/g, "&quot;")}"${c.tone ? ` data-tone="${c.tone}"` : ""}>${c.html}</span>`);
11657
+ entries.push({ id: it.id, group: GLOBAL_GROUP.has(it.id) ? "g" : "s", ...c });
11082
11658
  }
11083
11659
  const SEP = '<span class="zcodepro-statusbar-sep">\xB7</span>';
11084
11660
  const GROUPSEP = '<span class="zcodepro-statusbar-groupsep"></span>';
11085
- const html = parts.reduce((acc, p, i) => {
11086
- if (i === 0) return p;
11087
- if (p === GROUPSEP || parts[i - 1] === GROUPSEP) return acc + p;
11088
- return acc + SEP + p;
11089
- }, "");
11090
- barEl.style.display = parts.length ? "" : "none";
11091
- if (html === lastRenderedHtml) return;
11092
- lastRenderedHtml = html;
11093
- barEl.innerHTML = html;
11094
- }
11661
+ const buildHtml = (hidden2) => {
11662
+ const parts = [];
11663
+ let lastGroup = "";
11664
+ for (const e of entries) {
11665
+ if (hidden2.has(e.id)) continue;
11666
+ if (lastGroup && e.group !== lastGroup) parts.push(GROUPSEP);
11667
+ lastGroup = e.group;
11668
+ parts.push(`<span title="${e.title.replace(/"/g, "&quot;")}"${e.tone ? ` data-tone="${e.tone}"` : ""}>${e.html}</span>`);
11669
+ }
11670
+ return parts.reduce((acc, p, i) => {
11671
+ if (i === 0) return p;
11672
+ if (p === GROUPSEP || parts[i - 1] === GROUPSEP) return acc + p;
11673
+ return acc + SEP + p;
11674
+ }, "");
11675
+ };
11676
+ const hidden = /* @__PURE__ */ new Set();
11677
+ for (let guard = 0; guard <= HIDE_ORDER.length; guard++) {
11678
+ const html = buildHtml(hidden);
11679
+ barEl.style.display = html ? "" : "none";
11680
+ if (html !== lastRenderedHtml) {
11681
+ lastRenderedHtml = html;
11682
+ barEl.innerHTML = html;
11683
+ }
11684
+ const gap = 8;
11685
+ let sum = 0;
11686
+ for (const c of barEl.children) sum += c.getBoundingClientRect().width + gap;
11687
+ if (sum - gap <= host.clientWidth + 2) break;
11688
+ const next = HIDE_ORDER.find((id) => !hidden.has(id));
11689
+ if (!next) break;
11690
+ hidden.add(next);
11691
+ }
11692
+ }
11693
+ var HIDE_ORDER = ["tasks", "questions", "totalTokens", "todayTokens", "inOut"];
11095
11694
  async function tick() {
11096
11695
  if (!enabled4 || document.hidden) return;
11097
11696
  refreshOfficial();
@@ -11161,6 +11760,7 @@
11161
11760
  init_core();
11162
11761
  var enabled5 = true;
11163
11762
  var rounds = [];
11763
+ var liveRounds = [];
11164
11764
  var scanTimer = 0;
11165
11765
  var turnCfg = [
11166
11766
  { id: "turnIn", on: true },
@@ -11302,6 +11902,7 @@
11302
11902
  if (sid !== lastSid2) {
11303
11903
  lastSid2 = sid;
11304
11904
  rounds = [];
11905
+ liveRounds = [];
11305
11906
  for (const r of rows) clearRow(r.row);
11306
11907
  void tick2();
11307
11908
  return;
@@ -11311,24 +11912,68 @@
11311
11912
  return;
11312
11913
  }
11313
11914
  const agg = rows.map(() => ({ in: 0, out: 0, cacheRead: 0, tpsOut: 0, genMs: 0 }));
11314
- const dayOf = (t2) => {
11315
- const d = new Date(t2);
11316
- return d.getFullYear() * 1e4 + (d.getMonth() + 1) * 100 + d.getDate();
11317
- };
11318
- for (const b of rounds) {
11319
- let owner = -1;
11320
- for (let i = 0; i < rows.length; i++) {
11321
- if (rows[i].ts <= b.at) owner = i;
11322
- else break;
11323
- }
11324
- if (owner < 0) continue;
11325
- if (dayOf(rows[owner].ts) !== dayOf(b.at)) continue;
11326
- agg[owner].in += b.in;
11327
- agg[owner].out += b.out;
11328
- agg[owner].cacheRead += b.cacheRead;
11329
- if (b.genMs) {
11330
- agg[owner].tpsOut += b.out;
11331
- agg[owner].genMs += b.genMs;
11915
+ if (rounds.some((r) => r.startAt != null)) {
11916
+ const used = /* @__PURE__ */ new Set();
11917
+ for (const b of rounds) {
11918
+ const startMin = Math.floor((b.startAt ?? b.at) / 6e4);
11919
+ const endMin = Math.floor(b.at / 6e4);
11920
+ let owner = -1;
11921
+ let bestDist = Infinity;
11922
+ for (let i = 0; i < rows.length; i++) {
11923
+ if (used.has(i)) continue;
11924
+ const m = Math.floor(rows[i].ts / 6e4);
11925
+ if (m < startMin || m > endMin) continue;
11926
+ const dist = Math.abs(rows[i].ts - b.at);
11927
+ if (dist < bestDist) {
11928
+ owner = i;
11929
+ bestDist = dist;
11930
+ }
11931
+ }
11932
+ if (owner < 0) continue;
11933
+ used.add(owner);
11934
+ agg[owner].in += b.in;
11935
+ agg[owner].out += b.out;
11936
+ agg[owner].cacheRead += b.cacheRead;
11937
+ if (b.genMs) {
11938
+ agg[owner].tpsOut += b.out;
11939
+ agg[owner].genMs += b.genMs;
11940
+ }
11941
+ }
11942
+ if (liveRounds.length && rows.length) {
11943
+ const owner = rows.length - 1;
11944
+ const lastTurnAt = rounds.length ? rounds[rounds.length - 1].at : 0;
11945
+ if (!used.has(owner) && rows[owner].ts >= lastTurnAt - 6e4) {
11946
+ for (const b of liveRounds) {
11947
+ agg[owner].in += b.in;
11948
+ agg[owner].out += b.out;
11949
+ agg[owner].cacheRead += b.cacheRead;
11950
+ if (b.genMs) {
11951
+ agg[owner].tpsOut += b.out;
11952
+ agg[owner].genMs += b.genMs;
11953
+ }
11954
+ }
11955
+ }
11956
+ }
11957
+ } else {
11958
+ const dayOf = (t2) => {
11959
+ const d = new Date(t2);
11960
+ return d.getFullYear() * 1e4 + (d.getMonth() + 1) * 100 + d.getDate();
11961
+ };
11962
+ for (const b of rounds) {
11963
+ let owner = -1;
11964
+ for (let i = 0; i < rows.length; i++) {
11965
+ if (rows[i].ts <= b.at) owner = i;
11966
+ else break;
11967
+ }
11968
+ if (owner < 0) continue;
11969
+ if (dayOf(rows[owner].ts) !== dayOf(b.at)) continue;
11970
+ agg[owner].in += b.in;
11971
+ agg[owner].out += b.out;
11972
+ agg[owner].cacheRead += b.cacheRead;
11973
+ if (b.genMs) {
11974
+ agg[owner].tpsOut += b.out;
11975
+ agg[owner].genMs += b.genMs;
11976
+ }
11332
11977
  }
11333
11978
  }
11334
11979
  for (let i = 0; i < rows.length; i++) {
@@ -11345,6 +11990,7 @@
11345
11990
  if (res && res.ok && Array.isArray(res.rounds)) {
11346
11991
  if (seq !== tickSeq2 || sid !== currentSessionId()) return;
11347
11992
  rounds = res.rounds;
11993
+ liveRounds = Array.isArray(res.live) ? res.live : [];
11348
11994
  scan3();
11349
11995
  }
11350
11996
  }
@@ -12012,8 +12658,8 @@
12012
12658
  svg.setAttribute("stroke-linejoin", "round");
12013
12659
  svg.setAttribute("class", ((baseClass || "size-4") + " " + ROBOT_CLASS).trim());
12014
12660
  svg.setAttribute("title", t().subagentRobotTip);
12015
- for (const [tag, attrs] of BOT_FALLBACK) {
12016
- const el = document.createElementNS(ns, tag);
12661
+ for (const [tag2, attrs] of BOT_FALLBACK) {
12662
+ const el = document.createElementNS(ns, tag2);
12017
12663
  for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, v);
12018
12664
  svg.append(el);
12019
12665
  }
@@ -12056,8 +12702,8 @@
12056
12702
  svg.setAttribute("stroke-linejoin", "round");
12057
12703
  svg.setAttribute("class", `size-4 text-foreground-subtle ${TERMINAL_CLASS}`);
12058
12704
  svg.setAttribute("title", t().subagentTermTip);
12059
- for (const [tag, attrs] of TERMINAL_FALLBACK) {
12060
- const el = document.createElementNS(ns, tag);
12705
+ for (const [tag2, attrs] of TERMINAL_FALLBACK) {
12706
+ const el = document.createElementNS(ns, tag2);
12061
12707
  for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, v);
12062
12708
  svg.append(el);
12063
12709
  }
@@ -12248,23 +12894,20 @@
12248
12894
  }
12249
12895
  liveSessions = live;
12250
12896
  liveByWs = liveWs;
12251
- const ts = services && services.zcodeTaskService;
12252
12897
  const busy = /* @__PURE__ */ new Set();
12253
- if (ts && typeof ts.listActiveTaskIds === "function") {
12254
- const needBusyWs = /* @__PURE__ */ new Set();
12255
- for (const el of document.querySelectorAll(TASK_SEL5)) {
12256
- const key = el.getAttribute("data-task-item-key") || "";
12257
- const cut = key.lastIndexOf(":");
12258
- const sid = cut > 1 ? key.slice(cut + 1) : "";
12259
- const slot = rowIconSlot(el);
12260
- const unread = slot && slot.querySelector("[data-unread-indicator]");
12261
- if (live.has(sid) || unread) needBusyWs.add(normWs(key.slice(0, cut)));
12262
- }
12263
- await Promise.all([...needBusyWs].flatMap((ws) => [ws, ws + "/"].map(async (w) => {
12264
- const r = await withTimeout(ts.listActiveTaskIds({ workspacePath: w }), CALL_TIMEOUT_MS, null);
12265
- if (Array.isArray(r)) for (const id of r) busy.add(String(id));
12266
- })));
12267
- }
12898
+ const needBusyWs = /* @__PURE__ */ new Set();
12899
+ for (const el of document.querySelectorAll(TASK_SEL5)) {
12900
+ const key = el.getAttribute("data-task-item-key") || "";
12901
+ const cut = key.lastIndexOf(":");
12902
+ const sid = cut > 1 ? key.slice(cut + 1) : "";
12903
+ const slot = rowIconSlot(el);
12904
+ const unread = slot && slot.querySelector("[data-unread-indicator]");
12905
+ if (live.has(sid) || unread) needBusyWs.add(normWs(key.slice(0, cut)));
12906
+ }
12907
+ await Promise.all([...needBusyWs].map(async (ws) => {
12908
+ const ids = await withTimeout(listActiveIdsCached(ws), CALL_TIMEOUT_MS, null);
12909
+ if (ids) for (const id of ids) busy.add(id);
12910
+ }));
12268
12911
  busySessions = busy;
12269
12912
  const term = /* @__PURE__ */ new Set();
12270
12913
  const termWs = /* @__PURE__ */ new Set();
@@ -12432,6 +13075,38 @@
12432
13075
  await reclaim(ws);
12433
13076
  blockUntil.set(ws, Date.now() + cooldownMs);
12434
13077
  }
13078
+ function dueForReclaim(workspaces, busy, idleSince2, blockUntil2, now, threshold, startupDue) {
13079
+ const due = [];
13080
+ const seen2 = /* @__PURE__ */ new Set();
13081
+ const add = (ws) => {
13082
+ if (!seen2.has(ws)) {
13083
+ seen2.add(ws);
13084
+ due.push(ws);
13085
+ }
13086
+ };
13087
+ if (startupDue) {
13088
+ for (const ws of workspaces) {
13089
+ if (busy.has(ws) || (blockUntil2.get(ws) || 0) > now) continue;
13090
+ add(ws);
13091
+ }
13092
+ }
13093
+ for (const ws of workspaces) {
13094
+ if (busy.has(ws)) {
13095
+ idleSince2.delete(ws);
13096
+ continue;
13097
+ }
13098
+ if (!idleSince2.has(ws)) {
13099
+ idleSince2.set(ws, now);
13100
+ continue;
13101
+ }
13102
+ if (now - idleSince2.get(ws) < threshold) continue;
13103
+ if ((blockUntil2.get(ws) || 0) > now) continue;
13104
+ if (seen2.has(ws)) continue;
13105
+ idleSince2.delete(ws);
13106
+ add(ws);
13107
+ }
13108
+ return due;
13109
+ }
12435
13110
  async function tick4() {
12436
13111
  if (!enabled8) {
12437
13112
  idleSince.clear();
@@ -12462,38 +13137,30 @@
12462
13137
  blockUntil.delete(ws);
12463
13138
  }
12464
13139
  }
12465
- const candidates = [...workspaces].filter((ws) => !busy.has(normP(ws)));
12466
- const res = candidates.length ? await rpc("/idle-busy", { method: "POST", body: { paths: candidates } }) : { ok: true, scan: true, busy: [] };
13140
+ const now = Date.now();
13141
+ const startupDue = !startupSweepDone && now - bootAt >= startupMinutes * 6e4;
13142
+ const due = dueForReclaim(workspaces, busy, idleSince, blockUntil, now, threshold, startupDue);
13143
+ if (!due.length) {
13144
+ if (startupDue) startupSweepDone = true;
13145
+ return;
13146
+ }
13147
+ const res = await rpc("/idle-busy", { method: "POST", body: { paths: due } });
12467
13148
  if (!res.ok || res.scan === false) {
12468
13149
  if (!scanDisabledLogged) {
12469
13150
  scanDisabledLogged = true;
12470
13151
  console.info("[zcodepro] idle-reclaim: \u540E\u53F0\u547D\u4EE4\u626B\u63CF\u4E0D\u53EF\u7528\uFF0C\u7A7A\u95F2\u56DE\u6536\u505C\u7528");
12471
13152
  }
13153
+ if (startupDue) startupSweepDone = true;
12472
13154
  idleSince.clear();
12473
13155
  return;
12474
13156
  }
13157
+ if (startupDue) startupSweepDone = true;
12475
13158
  const procBusy = new Set(res.busy || []);
12476
- const idleCandidates = candidates.filter((ws) => !procBusy.has(ws));
12477
- const now = Date.now();
12478
- if (!startupSweepDone && now - bootAt >= startupMinutes * 6e4) {
12479
- startupSweepDone = true;
12480
- for (const ws of idleCandidates) {
12481
- if ((blockUntil.get(ws) || 0) > now) continue;
12482
- await tryReclaim(ws, threshold);
12483
- }
12484
- }
12485
- for (const ws of workspaces) {
12486
- if (busy.has(ws) || procBusy.has(ws)) {
13159
+ for (const ws of due) {
13160
+ if (procBusy.has(ws)) {
12487
13161
  idleSince.delete(ws);
12488
13162
  continue;
12489
13163
  }
12490
- if (!idleSince.has(ws)) {
12491
- idleSince.set(ws, now);
12492
- continue;
12493
- }
12494
- if (now - idleSince.get(ws) < threshold) continue;
12495
- if ((blockUntil.get(ws) || 0) > now) continue;
12496
- idleSince.delete(ws);
12497
13164
  await tryReclaim(ws, threshold);
12498
13165
  }
12499
13166
  }
@@ -13066,9 +13733,9 @@
13066
13733
  continue;
13067
13734
  }
13068
13735
  if (node.nodeType !== Node.ELEMENT_NODE) continue;
13069
- const tag = node.tagName;
13070
- const el = document.createElement(tag.toLowerCase());
13071
- if (tag === "TD" || tag === "TH") {
13736
+ const tag2 = node.tagName;
13737
+ const el = document.createElement(tag2.toLowerCase());
13738
+ if (tag2 === "TD" || tag2 === "TH") {
13072
13739
  for (const a of ["colspan", "rowspan"]) {
13073
13740
  const v = node.getAttribute(a);
13074
13741
  if (v && v !== "1") el.setAttribute(a, v);