zcode-pro 1.6.1 → 1.7.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/README.en.md +31 -21
- package/README.md +20 -12
- package/dist/inject.js +10431 -8836
- package/package.json +2 -1
- package/src/host/cdp.mjs +13 -3
- package/src/host/helper.mjs +1287 -488
- package/src/host/main.mjs +368 -30
- package/src/host/paths.mjs +17 -9
- package/src/host/pickFolder.mjs +11 -4
- package/src/host/settings.mjs +15 -2
- package/src/host/setup.mjs +54 -15
- package/src/host/skill-stats.mjs +6 -1
- package/src/host/taskIndex.mjs +464 -66
- package/src/host/taskOrder.mjs +128 -57
- package/src/host/version.mjs +15 -7
- package/src/host/wallpaper.mjs +76 -59
- package/src/host/webdav.mjs +66 -10
- package/src/inject/core.js +228 -103
- package/src/inject/features/alias-migration.js +5 -1
- package/src/inject/features/auto-rename.js +166 -0
- package/src/inject/features/file-menu.js +6 -2
- package/src/inject/features/idle-reclaim.js +31 -8
- package/src/inject/features/newtab-panels.js +11 -1
- package/src/inject/features/pinned-collapse.js +11 -3
- package/src/inject/features/plugin-card-retry.js +18 -8
- package/src/inject/features/plugin-updates.js +58 -0
- package/src/inject/features/sandbox-reclaim.js +17 -1
- package/src/inject/features/session-link.js +202 -0
- package/src/inject/features/session-switch.js +67 -30
- package/src/inject/features/settings-dialog.js +323 -124
- package/src/inject/features/status-bar.js +150 -28
- package/src/inject/features/subagent-icon.js +473 -0
- package/src/inject/features/table-copy.js +18 -2
- package/src/inject/features/task-order.js +47 -13
- package/src/inject/features/theme.js +88 -31
- package/src/inject/features/title-gen.js +5 -4
- package/src/inject/features/title-lock.js +13 -8
- package/src/inject/features/turn-usage.js +99 -47
- package/src/inject/features/ws-running.js +28 -13
- package/src/inject/index.js +7 -0
- package/src/inject/provider-fields.js +2 -2
- package/src/inject/ui.js +14 -0
|
@@ -95,7 +95,7 @@ function setRunningIcon(holder, on) {
|
|
|
95
95
|
|
|
96
96
|
// 行首图标容器(旋转图标的挂点):
|
|
97
97
|
// 旧结构:行.firstElementChild 里的 span;新结构:virtual-project-toggle 的首个 span(folder 图标容器)
|
|
98
|
-
function iconHolderOf(row) {
|
|
98
|
+
export function iconHolderOf(row) {
|
|
99
99
|
if (row.hasAttribute && row.hasAttribute('data-project-id')) {
|
|
100
100
|
const toggle = row.querySelector('[data-testid="virtual-project-toggle"]');
|
|
101
101
|
return toggle ? toggle.querySelector(':scope > span') : null;
|
|
@@ -124,8 +124,10 @@ let wsWithRows = new Set(); // 最近一次扫描时仍有会话行在 DOM
|
|
|
124
124
|
// 应用内部服务对象(含 zcodeTaskService.releaseWorkspacePreparation):从 React
|
|
125
125
|
// fiber 树上找持有它的组件(file-menu.js 同款取 fiber 的思路),找到后缓存
|
|
126
126
|
let servicesRef = null;
|
|
127
|
+
let servicesMissAt = 0; // 找不到服务也记时刻:fiber 全遍历(上限 6 万节点)代价高,60 秒内不重走
|
|
127
128
|
export function findServices() {
|
|
128
129
|
if (servicesRef) return servicesRef;
|
|
130
|
+
if (servicesMissAt && Date.now() - servicesMissAt < 60_000) return null;
|
|
129
131
|
try {
|
|
130
132
|
const rootEl = document.getElementById('root');
|
|
131
133
|
const containerKey = rootEl && Object.keys(rootEl).find((k) => k.startsWith('__reactContainer$'));
|
|
@@ -154,8 +156,10 @@ export function findServices() {
|
|
|
154
156
|
};
|
|
155
157
|
visit(rootEl[containerKey]);
|
|
156
158
|
if (found) servicesRef = found;
|
|
159
|
+
else servicesMissAt = Date.now();
|
|
157
160
|
return found;
|
|
158
161
|
} catch {
|
|
162
|
+
servicesMissAt = Date.now();
|
|
159
163
|
return null;
|
|
160
164
|
}
|
|
161
165
|
}
|
|
@@ -201,7 +205,7 @@ function workspaceOf(key) {
|
|
|
201
205
|
return i > 0 ? key.slice(0, i) : key;
|
|
202
206
|
}
|
|
203
207
|
|
|
204
|
-
function wsHead(row) {
|
|
208
|
+
export function wsHead(row) {
|
|
205
209
|
// 旧结构行容器自身带 aria-expanded;新结构在 virtual-project-toggle 按钮上
|
|
206
210
|
return row.matches('[aria-expanded]') ? row : row.querySelector('[aria-expanded]');
|
|
207
211
|
}
|
|
@@ -356,7 +360,12 @@ function sectionHeads() {
|
|
|
356
360
|
const btn = sv.closest('button');
|
|
357
361
|
if (btn) heads.push(btn);
|
|
358
362
|
}
|
|
359
|
-
for (const h3 of document.querySelectorAll('h3'))
|
|
363
|
+
for (const h3 of document.querySelectorAll('h3')) {
|
|
364
|
+
// 聊天正文里的 markdown 标题不是分区头:不排除会把转圈图标插进聊天内容
|
|
365
|
+
//(顺带省掉流式渲染期新标题节点的解析与强制布局开销)
|
|
366
|
+
if (h3.closest('main')) continue;
|
|
367
|
+
heads.push(h3);
|
|
368
|
+
}
|
|
360
369
|
return heads.map((head) => {
|
|
361
370
|
const cached = headInfoCache.get(head);
|
|
362
371
|
if (cached) return { head, cont: cached.cont, kind: cached.kind };
|
|
@@ -375,7 +384,7 @@ function sectionHeads() {
|
|
|
375
384
|
const SEC_SPIN_CLASS = 'zcodepro-ws-sec-spin';
|
|
376
385
|
|
|
377
386
|
// 全局权威扫描:listActiveTaskIds 遍历侧栏全部项目(/projects-v2 提供路径,
|
|
378
|
-
// 尾斜杠两种形式各查一次),任一非终态会话即“有任务在跑”。
|
|
387
|
+
// 尾斜杠两种形式各查一次),任一非终态会话即“有任务在跑”。30 秒节流缓存;
|
|
379
388
|
// 接口不可用(≤3.15.x)时无缓存,分区头退回 DOM 检测
|
|
380
389
|
let anyActiveCache = { at: 0, value: null, busy: false };
|
|
381
390
|
// 活跃按分区归属:task = “任务”分区(非项目工作区),project = “项目”分区,
|
|
@@ -390,12 +399,13 @@ let activeProjectPaths = new Set();
|
|
|
390
399
|
let authActiveByWs = new Map();
|
|
391
400
|
// 周期复查:缓存到期就无条件重扫(不看当前值)——只在 true 时扫会有两个缺口:
|
|
392
401
|
// 空闲后新任务启动无人触发(折叠分区头不亮);任务结束但数据库完成状态尚未
|
|
393
|
-
// 写入的过渡窗口里旧值一直被沿用。每
|
|
402
|
+
// 写入的过渡窗口里旧值一直被沿用。每 30 秒全量一次,扫描本身是内存级过滤
|
|
394
403
|
setInterval(() => {
|
|
395
|
-
if (
|
|
396
|
-
|
|
404
|
+
if (document.hidden || !enabled) return; // 后台/功能关闭不扫,回前台下一轮补上
|
|
405
|
+
if (!anyActiveCache.busy && Date.now() - anyActiveCache.at >= 30_000) globalAnyActive();
|
|
406
|
+
}, 30_000);
|
|
397
407
|
function globalAnyActive() {
|
|
398
|
-
if (anyActiveCache.value !== null && Date.now() - anyActiveCache.at <
|
|
408
|
+
if (anyActiveCache.value !== null && Date.now() - anyActiveCache.at < 30_000) return anyActiveCache.value;
|
|
399
409
|
if (anyActiveCache.busy) return anyActiveCache.value === true;
|
|
400
410
|
anyActiveCache.busy = true;
|
|
401
411
|
sectionActive.task = false;
|
|
@@ -444,10 +454,15 @@ function globalAnyActive() {
|
|
|
444
454
|
}
|
|
445
455
|
projectPaths.set(proj.name, names);
|
|
446
456
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
const b = await
|
|
450
|
-
|
|
457
|
+
// 各工作区并行查(串行 await 在几十个工作区时要跑数秒):每区两种尾斜杠各查一次
|
|
458
|
+
const pairs = await Promise.all([...scanPaths].map(async (base) => {
|
|
459
|
+
const [a, b] = await Promise.all([
|
|
460
|
+
ts.listActiveTaskIds({ workspacePath: base }),
|
|
461
|
+
ts.listActiveTaskIds({ workspacePath: base + '/' }),
|
|
462
|
+
]);
|
|
463
|
+
return [base, [...(Array.isArray(a) ? a : []), ...(Array.isArray(b) ? b : [])].map(String)];
|
|
464
|
+
}));
|
|
465
|
+
for (const [base, ids] of pairs) {
|
|
451
466
|
if (!ids.length) continue;
|
|
452
467
|
byKindByPath.set(base, ids);
|
|
453
468
|
const kind = projPaths.has(base) ? 'project' : 'task';
|
|
@@ -558,7 +573,7 @@ function applySectionSpin() {
|
|
|
558
573
|
const list = head.nextElementSibling;
|
|
559
574
|
expanded = !list || list.offsetHeight > 0;
|
|
560
575
|
}
|
|
561
|
-
if (!kind)
|
|
576
|
+
if (!kind) continue; // 折叠后解析不到归属且无缓存:跳过这个分区头(不动现有图标),继续处理其余分区头
|
|
562
577
|
// 已置顶标题(h3)单独看 pinned scope,不复用 task 的
|
|
563
578
|
const scoped = head.tagName === 'H3' ? sectionActive.pinned
|
|
564
579
|
: kind === 'project' ? sectionActive.project : sectionActive.task;
|
package/src/inject/index.js
CHANGED
|
@@ -15,7 +15,9 @@ import { startStatusBar } from './features/status-bar.js';
|
|
|
15
15
|
import { startTurnUsage } from './features/turn-usage.js';
|
|
16
16
|
import { startTitleLock } from './features/title-lock.js';
|
|
17
17
|
import { startTitleGen } from './features/title-gen.js';
|
|
18
|
+
import { startAutoRename, handleTaskRowMenu } from './features/auto-rename.js';
|
|
18
19
|
import { startWsRunningSpin } from './features/ws-running.js';
|
|
20
|
+
import { startSubagentIcon } from './features/subagent-icon.js';
|
|
19
21
|
import { startIdleReclaim } from './features/idle-reclaim.js';
|
|
20
22
|
import { startSandboxReclaim } from './features/sandbox-reclaim.js';
|
|
21
23
|
import { startPluginCardRetry } from './features/plugin-card-retry.js';
|
|
@@ -24,6 +26,7 @@ import { startPinnedCollapse } from './features/pinned-collapse.js';
|
|
|
24
26
|
import { startStyleAdjustments } from './features/styles.js';
|
|
25
27
|
import { startTheme } from './features/theme.js';
|
|
26
28
|
import { startTableCopy } from './features/table-copy.js';
|
|
29
|
+
import { startSessionLink } from './features/session-link.js';
|
|
27
30
|
import { startComposerProvider } from './features/composer-provider.js';
|
|
28
31
|
import { startPluginUpdateCheck } from './features/plugin-updates.js';
|
|
29
32
|
import { ensureStyle } from './ui.js';
|
|
@@ -66,6 +69,7 @@ import { ensureStyle } from './ui.js';
|
|
|
66
69
|
observeRadixPopups((content) => {
|
|
67
70
|
try { handleProjectMenu(content); } catch { /* 单个功能失败不影响其他 */ }
|
|
68
71
|
try { handleFileMenu(content); } catch { /* ignore */ }
|
|
72
|
+
try { handleTaskRowMenu(content); } catch { /* ignore */ }
|
|
69
73
|
});
|
|
70
74
|
try { void startAliasWatcher(); } catch { /* ignore */ }
|
|
71
75
|
// 别名迁移弹窗(3.16.1+ 且仍有存量别名时才动作),内部自带等待与窗口聚焦判断
|
|
@@ -74,8 +78,10 @@ import { ensureStyle } from './ui.js';
|
|
|
74
78
|
try { startSessionSwitch(); } catch { /* ignore */ }
|
|
75
79
|
try { startTitleLock(); } catch { /* ignore */ }
|
|
76
80
|
try { startTitleGen(); } catch { /* ignore */ }
|
|
81
|
+
try { startAutoRename(); } catch { /* ignore */ }
|
|
77
82
|
try { startImageMenu(); } catch { /* ignore */ }
|
|
78
83
|
try { startWsRunningSpin(); } catch { /* ignore */ }
|
|
84
|
+
try { startSubagentIcon(); } catch { /* ignore */ }
|
|
79
85
|
try { startIdleReclaim(); } catch { /* ignore */ }
|
|
80
86
|
try { startSandboxReclaim(); } catch { /* ignore */ }
|
|
81
87
|
try { startPluginCardRetry(); } catch { /* ignore */ }
|
|
@@ -87,6 +93,7 @@ import { ensureStyle } from './ui.js';
|
|
|
87
93
|
try { startStyleAdjustments(); } catch { /* ignore */ }
|
|
88
94
|
try { startTheme(); } catch { /* ignore */ }
|
|
89
95
|
try { startTableCopy(); } catch { /* ignore */ }
|
|
96
|
+
try { startSessionLink(); } catch { /* ignore */ }
|
|
90
97
|
try { startComposerProvider(); } catch { /* ignore */ }
|
|
91
98
|
try { startSettingsEntry(); } catch { /* ignore */ }
|
|
92
99
|
// 插件更新检查慢(可能 git pull),异步进行,不阻塞其他功能
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// - 'session':跟随当前会话(连接由会话侧解析,不存地址密钥);
|
|
5
5
|
// - 其余:供应商 id;已删的 id 保留为“已删除”选项,调用方靠保存的地址/
|
|
6
6
|
// 密钥副本继续直连。
|
|
7
|
-
import { h } from './core.js';
|
|
7
|
+
import { h, t } from './core.js';
|
|
8
8
|
|
|
9
9
|
export const PROVIDER_FIELD_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';
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ export const PROVIDER_FIELD_CLS = 'h-8 w-full rounded-lg border border-border bg
|
|
|
12
12
|
// 输入;当前值不在列表里(条目被删或手输 id)时保留为带 staleLabel 标注的
|
|
13
13
|
// 选项,不清空、不跳值;当前值为空时插入一个 emptyLabel 空选项,避免下拉框
|
|
14
14
|
// 假装选中第一项而配置里其实没选
|
|
15
|
-
export function comboField(current, options, onChange, { disabled = false, placeholder = '', staleLabel =
|
|
15
|
+
export function comboField(current, options, onChange, { disabled = false, placeholder = '', staleLabel = t().manualInput, emptyLabel = '' } = {}) {
|
|
16
16
|
const sel = h('select', { class: PROVIDER_FIELD_CLS, disabled: disabled || undefined });
|
|
17
17
|
const input = h('input', { type: 'text', value: current, placeholder, class: PROVIDER_FIELD_CLS, disabled: disabled || undefined });
|
|
18
18
|
const sync = () => {
|
package/src/inject/ui.js
CHANGED
|
@@ -430,6 +430,12 @@ export function ensureStyle() {
|
|
|
430
430
|
if (!root) return;
|
|
431
431
|
root.append(h('style', { id: '__zcodepro_style__' }, `
|
|
432
432
|
@keyframes zcodepro-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
|
|
433
|
+
/* 会话 ID 显示为任务名链接(session-link.js):观感贴近正文链接,主题变量缺失时回退字面量 */
|
|
434
|
+
.zcodepro-sess-link {
|
|
435
|
+
color: var(--color-link, var(--color-primary, #4a9eff));
|
|
436
|
+
cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
|
|
437
|
+
}
|
|
438
|
+
.zcodepro-sess-link:hover { opacity: .8; }
|
|
433
439
|
/* 提示条四态(成功/警告/失败/信息):配色用主题变量加字面量兜底,
|
|
434
440
|
不依赖宿主 Tailwind 生成配色工具类 */
|
|
435
441
|
.zcodepro-toast {
|
|
@@ -813,6 +819,14 @@ export function ensureStyle() {
|
|
|
813
819
|
/* 折叠项目运行提示:folder 图标让位给 loader(loader 由脚本插入,
|
|
814
820
|
folder 可能被 React 随时重建,靠类选择器统一隐藏,后代写法兼容包装层) */
|
|
815
821
|
span.zcodepro-ws-running svg:not(.zcodepro-ws-loader) { display: none !important; }
|
|
822
|
+
/* 子代理运行提示(subagent-icon.js):折叠项目 folder 让位给机器人/终端,
|
|
823
|
+
loader 在转时(zcodepro-ws-loader)优先显示,不跟机器人互相藏 */
|
|
824
|
+
span.zcodepro-subagent-on svg:not(.zcodepro-subagent-icon):not(.zcodepro-terminal-icon):not(.zcodepro-ws-loader) { display: none !important; }
|
|
825
|
+
/* 未读圆点让位机器人:原点隐藏,行尾复制品常显(不跟悬浮操作图标一起隐藏) */
|
|
826
|
+
li.zcodepro-subagent-unread-moved [data-unread-indicator] { display: none !important; }
|
|
827
|
+
.zcodepro-subagent-unread-tail { display: inline-flex; align-items: center; align-self: center; }
|
|
828
|
+
/* 项目蓝色未读徽标忽略错误行:项目里未读全是错误态(红点)时不亮蓝徽标 */
|
|
829
|
+
.zcodepro-unread-error-only [data-workspace-unread-indicator] { display: none !important; }
|
|
816
830
|
/* 无感探查期间盖在项目行上的冻结克隆:固定定位、不响应指针 */
|
|
817
831
|
.zcodepro-ws-frozen {
|
|
818
832
|
position: fixed;
|