zcode-pro 1.8.2 → 1.10.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.
@@ -5,11 +5,17 @@
5
5
  // openSidePane(App 层注入 Context Provider 的 handleOpenPluginUi,从 React
6
6
  // fiber 里按函数源码特征串挖出)在侧边面板打开 tab——与插件市场页“打开”同一条
7
7
  // 调用路径,不绕开官方逻辑。
8
- import { t, getConfig, isZhLocale } from '../core.js';
8
+ import { t, getConfig, uiLocale } from '../core.js';
9
9
  import { ensureStyle, showToast } from '../ui.js';
10
10
 
11
- // 官方“新标签页”终端模块的描述片段(界面中英文),作为网格识别特征
12
- const GRID_HINTS = ['运行命令和查看输出', 'Run commands and view output'];
11
+ // 官方“新标签页”终端模块的描述片段(ZCode 支持的五种界面语言),作为网格识别特征
12
+ const GRID_HINTS = [
13
+ '运行命令和查看输出',
14
+ 'Run commands and view output',
15
+ 'コマンドを実行して出力を確認します',
16
+ '명령을 실행하고 출력을 확인합니다',
17
+ 'Выполнять команды и смотреть вывод',
18
+ ];
13
19
  // 官方市场的 pluginId 后缀:这些面板已有云端推荐入口,不注入
14
20
  const OFFICIAL_SUFFIX = '@zcode-plugins-official';
15
21
  // handleOpenPluginUi(useCallback 产物)源码里的 logger 字符串,压缩不改动
@@ -150,7 +156,7 @@ async function injectPanels(grid) {
150
156
  if (!surfaces.length) { grid.dataset.zcodeproPanels = '1'; return; }
151
157
  grid.dataset.zcodeproPanels = '1';
152
158
  const L = t();
153
- const locale = isZhLocale() ? 'zh-CN' : 'en-US';
159
+ const locale = uiLocale();
154
160
  for (const s of surfaces) {
155
161
  // 官方卡片整卡即 button:克隆同款,去掉官方标识,挂我们的标识与点击
156
162
  const card = template.cloneNode(true);
@@ -7,6 +7,10 @@
7
7
  // 事件驱动扫描(会话行增删/选中标记移动才触发)+ 低频兜底轮询——
8
8
  // 点击、新建任务自动跳转等任何方式的切换都能捕捉,聊天区流式输出不产生扫描。
9
9
  // 目标条目在折叠项目下时先展开项目行再点击(展开先例见 pinned-expand.js)。
10
+ // 新建任务草稿(项目内或“任务”分区)没有会话行,单独记为伪键
11
+ // <工作区路径>:__new_task__;草稿属于哪个工作区从输入框工作区按钮的
12
+ // React fiber(workspacePath)读取,切回时点对应入口的“新建任务”按钮。
13
+ // 这样会话 ↔ 新建任务、不同项目 / 任务分区的新建任务之间都能用 alt+z 来回切。
10
14
  import { h, t, rpc, getConfig, DEFAULT_SHORTCUTS } from '../core.js';
11
15
  import { ensureStyle, showToast } from '../ui.js';
12
16
  import { findProjectRow } from './ws-rows.js';
@@ -18,6 +22,8 @@ const SCAN_FALLBACK_MS = 5000; // 兜底轮询周期:仅补观察器覆盖不
18
22
  const INITIAL_COUNT = 10; // 弹窗初始渲染条数(alt+e“最近 10 条”同此)
19
23
  const PAGE_SIZE = 5; // c 到底再按时加载的条数
20
24
  const UNSEEN_LIMIT = 50;
25
+ const NEW_TASK_ID = '__new_task__'; // 伪会话 id:新建任务草稿视图(项目内 / 任务分区)
26
+ const PROJECT_ROOTS_TTL_MS = 60_000; // /projects-v2 工作区→项目 id 映射的缓存时长
21
27
 
22
28
  let mru = []; // 会话键(data-task-item-key),最近使用的在最前
23
29
  let current = null; // 当前会话键
@@ -67,9 +73,116 @@ function findCurrent() {
67
73
 
68
74
  // 会话 id(键的最后一段):同一会话的键有“权威拼键/DOM 行键”两种形态,
69
75
  // unseen 的增删与当前会话比较都按 id,别按整键。入参容 null/undefined——
70
- // current 在新建任务视图(无选中行)时一直是 null
76
+ // current 在未知视图(面板等)里可能仍是上一次的键
71
77
  const idOf = (k) => { const s = String(k || ''); return s.slice(s.lastIndexOf(':') + 1); };
72
78
 
79
+ // 工作区路径归一(去尾分隔符):草稿键用归一后的路径拼,切换时两边都归一比较
80
+ const normWs = (ws) => String(ws || '').replace(/[\\/]+$/, '');
81
+ // 新建任务草稿伪键:<工作区路径>:__new_task__,与会话键同一套“前缀 + id”结构
82
+ const newTaskKeyOf = (ws) => normWs(ws) + ':' + NEW_TASK_ID;
83
+ const isNewTaskKey = (k) => idOf(k) === NEW_TASK_ID;
84
+
85
+ // 当前新建任务草稿属于哪个工作区。主面板的 data-session-id="draft" 是草稿
86
+ // 视图的稳定标记;工作区路径从输入框工作区按钮向上走 React fiber 取
87
+ // workspacePath(按钮上的文字是项目名,可能是别名/重名,不能拿来对路径)。
88
+ // 面板不可见或取不到路径时返回空串——调用方按“未知视图”处理,保持旧行为
89
+ function draftWorkspacePath() {
90
+ const focused = document.querySelector('[data-pane-id="workspace-main"][data-focused="true"]');
91
+ const pane = (focused && focused.querySelector('[data-testid="v4-session-pane-workspace-main"]'))
92
+ || document.querySelector('[data-testid="v4-session-pane-workspace-main"]');
93
+ if (!pane || pane.getAttribute('data-session-id') !== 'draft') return '';
94
+ if (!pane.getClientRects().length) return '';
95
+ const trig = pane.querySelector('[data-testid="composer-workspace-trigger"]');
96
+ const fk = trig && Object.keys(trig).find((k) => k.startsWith('__reactFiber$'));
97
+ let f = fk ? trig[fk] : null;
98
+ for (let i = 0; f && i < 40; i++, f = f.return) {
99
+ const p = f.memoizedProps;
100
+ if (p && typeof p.workspacePath === 'string' && p.workspacePath.trim()) {
101
+ return p.workspacePath.trim();
102
+ }
103
+ }
104
+ return '';
105
+ }
106
+
107
+ // 当前视图键:选中的会话行优先;没有选中行时看是不是新建任务草稿。
108
+ // 返回 null = 未知视图(自动化/插件面板等),此时不记录也不改 current
109
+ function currentViewKey() {
110
+ const row = findCurrent();
111
+ if (row) return row.getAttribute('data-task-item-key');
112
+ const ws = draftWorkspacePath();
113
+ return ws ? newTaskKeyOf(ws) : null;
114
+ }
115
+
116
+ // MRU 里除当前视图外最近的一条;没有当前视图(面板等)时沿用旧行为取最近一条
117
+ function switchTarget(list, viewKey) {
118
+ if (!viewKey) return list[0] || null;
119
+ return list.find((k) => k !== viewKey) || null;
120
+ }
121
+
122
+ // 工作区路径 → 项目 id(/projects-v2 的 roots 映射),用于折起/从未展开、
123
+ // DOM 里拿不到路径的项目行定位。失败沿用上一份映射,60 秒后再试
124
+ let projectRootsCache = { at: 0, map: new Map(), ok: false };
125
+ let projectRootsInflight = null;
126
+ async function loadProjectRoots() {
127
+ if (Date.now() - projectRootsCache.at <= PROJECT_ROOTS_TTL_MS) return projectRootsCache.map;
128
+ if (projectRootsInflight) return projectRootsInflight;
129
+ projectRootsInflight = (async () => {
130
+ const now = Date.now();
131
+ const res = await rpc('/projects-v2').catch(() => null);
132
+ if (res && res.ok && res.available && Array.isArray(res.projects)) {
133
+ const map = new Map();
134
+ // 同一目录可能同时是多个项目的 root(一个主目录、一个附加目录):
135
+ // 先收主 root,再补附加 root 且不覆盖,草稿才能落到项目的主归属上
136
+ for (const p of res.projects) {
137
+ for (const r of p.roots || []) {
138
+ const path = normWs(r && r.path);
139
+ if (path && p.id && r.primary) map.set(path, String(p.id));
140
+ }
141
+ }
142
+ for (const p of res.projects) {
143
+ for (const r of p.roots || []) {
144
+ const path = normWs(r && r.path);
145
+ if (path && p.id && !map.has(path)) map.set(path, String(p.id));
146
+ }
147
+ }
148
+ projectRootsCache = { at: now, map, ok: true };
149
+ } else {
150
+ projectRootsCache = { at: now, map: projectRootsCache.map, ok: projectRootsCache.ok };
151
+ }
152
+ return projectRootsCache.map;
153
+ })().finally(() => { projectRootsInflight = null; });
154
+ return projectRootsInflight;
155
+ }
156
+ async function projectIdOfRoot(ws) {
157
+ const want = normWs(ws);
158
+ if (!want) return '';
159
+ const map = await loadProjectRoots();
160
+ return map.get(want) || '';
161
+ }
162
+
163
+ // “任务”分区的草稿(不在任何项目里,工作区是 ~/.zcode/workspace/draft-*):
164
+ // 任务分区头的新建任务按钮会回到最近这一份草稿,没有别的入口能按路径打开它。
165
+ // 记住最近一次见到的任务草稿路径,目标不是它时不要乱点(按钮只会打开最近的)
166
+ let lastTaskDraftPath = '';
167
+ const isLocalPath = (p) => /^(?:[A-Za-z]:[\\/]|\/)/.test(String(p || ''));
168
+ async function noteDraftWorkspace(ws) {
169
+ const want = normWs(ws);
170
+ if (!want || !isLocalPath(want)) return;
171
+ await loadProjectRoots();
172
+ if (!projectRootsCache.ok) return; // 映射取不到:判断不了归属,不记
173
+ if (!projectRootsCache.map.has(want)) lastTaskDraftPath = want;
174
+ }
175
+
176
+ // 草稿键对应的项目行:先按任务行/缓存里的路径找;折叠且从未展开过的项目
177
+ // 拿不到路径,改查 /projects-v2 的 roots → 项目 id。没有别的猜测路径——
178
+ // 按目录名猜可能把“任务”分区的草稿误当同名项目,切到错误的视图
179
+ async function findProjectSection(ws) {
180
+ const row = findProjectRow(ws);
181
+ if (row) return row;
182
+ const id = await projectIdOfRoot(ws);
183
+ return id ? document.querySelector(`section[data-project-id="${CSS.escape(id)}"]`) : null;
184
+ }
185
+
73
186
  // 记录一次“切到 key”;顺带刷新在场条目的标题缓存。切入即视为已查看
74
187
  function record(key) {
75
188
  if (key) for (const k of unseen) if (idOf(k) === idOf(key)) unseen.delete(k);
@@ -105,6 +218,11 @@ function collectEndedUnseen(prevKeys, nowKeys, currentKey, unseenSet) {
105
218
  function scan() {
106
219
  const cur = findCurrent();
107
220
  if (cur) record(cur.getAttribute('data-task-item-key'));
221
+ else {
222
+ // 新建任务草稿没有选中行:按工作区记伪键,MRU 才能把草稿当作可切回的视图
223
+ const ws = draftWorkspacePath();
224
+ if (ws) { record(newTaskKeyOf(ws)); void noteDraftWorkspace(ws); }
225
+ }
108
226
  const seen = new Set();
109
227
  for (const el of document.querySelectorAll('[data-task-item-key]')) {
110
228
  const key = el.getAttribute('data-task-item-key');
@@ -149,6 +267,27 @@ function scheduleScan() {
149
267
  // 切到指定会话:条目不在 DOM(项目折叠)时先展开项目行,等条目出现再点击
150
268
  //(session-link.js 的会话 ID 链接也走这里切换)
151
269
  export async function switchTo(key) {
270
+ // 新建任务草稿:项目草稿点项目的“新建任务”按钮回到该项目草稿(项目行折叠
271
+ // 也可见);“任务”分区草稿没有项目行,点任务分区头的新建任务按钮(应用会
272
+ // 回到最近那一份任务草稿)。已经在这个草稿里时直接返回,避免重复点击清掉
273
+ // 已输入的内容
274
+ if (isNewTaskKey(key)) {
275
+ const ws = workspaceOf(key);
276
+ const curWs = draftWorkspacePath();
277
+ if (curWs && normWs(curWs) === normWs(ws)) return true;
278
+ const sec = await findProjectSection(ws);
279
+ const btn = sec && sec.querySelector('[data-testid="virtual-project-create-task"]');
280
+ if (btn) {
281
+ btn.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
282
+ return true;
283
+ }
284
+ // 任务草稿的按钮只会打开最近一份:目标不是它时没有可用的入口,别切错
285
+ if (!lastTaskDraftPath || lastTaskDraftPath !== normWs(ws)) return false;
286
+ const taskBtn = document.querySelector('[data-testid="virtual-project-new-task"]');
287
+ if (!taskBtn) return false;
288
+ taskBtn.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
289
+ return true;
290
+ }
152
291
  // 权威扫描拼出的键(工作区前缀无尾斜杠)可能与行键(可能带尾斜杠)不同形,
153
292
  // 精确匹配落空时按会话 id 后缀兜底(会话 id 全局唯一,不会命中别的会话)
154
293
  const id = key.slice(key.lastIndexOf(':') + 1);
@@ -186,13 +325,20 @@ function attentionList() {
186
325
  const listed = new Set();
187
326
  const head = [];
188
327
  for (const k of mru) {
328
+ if (isNewTaskKey(k)) continue; // 草稿视图不会运行,也不存在“未查看”
189
329
  const id = idOf(k);
190
330
  if (listed.has(id)) continue;
191
331
  const runForm = runKeyById.get(id);
192
332
  if (run.has(k) || unseen.has(k) || runForm) { head.push(runForm || k); listed.add(id); }
193
333
  }
194
334
  const tail = [];
195
- const push = (k) => { const id = idOf(k); if (listed.has(id)) return; listed.add(id); tail.push(k); };
335
+ const push = (k) => {
336
+ if (isNewTaskKey(k)) return;
337
+ const id = idOf(k);
338
+ if (listed.has(id)) return;
339
+ listed.add(id);
340
+ tail.push(k);
341
+ };
196
342
  for (const k of run) push(k);
197
343
  for (const k of unseen) push(k);
198
344
  return [...head, ...tail];
@@ -219,6 +365,8 @@ function closePopup(commit) {
219
365
  }
220
366
 
221
367
  function findTitle(key) {
368
+ // 草稿视图没有标题:显示固定文案,项目名由行下的工作区标签给出
369
+ if (isNewTaskKey(key)) return t().switcherNewTask;
222
370
  const item = document.querySelector(`[data-task-item-key="${CSS.escape(key)}"]`);
223
371
  if (item) titles.set(key, firstLineOf(item));
224
372
  const id = key.slice(key.lastIndexOf(':') + 1);
@@ -230,6 +378,7 @@ function findTitle(key) {
230
378
  async function fetchMissingTitles(keys) {
231
379
  const sessIdOf = (k) => k.slice(k.lastIndexOf(':') + 1);
232
380
  const missing = keys.filter((k) => {
381
+ if (isNewTaskKey(k)) return false; // 草稿标题是固定文案,不用查任务索引
233
382
  const id = sessIdOf(k);
234
383
  return id && !titles.get(k) && !document.querySelector(`[data-task-item-key$=":${CSS.escape(id)}"]`);
235
384
  });
@@ -246,6 +395,10 @@ async function fetchMissingTitles(keys) {
246
395
  function projLabelOf(key, aliases) {
247
396
  const ws = workspaceOf(key);
248
397
  if (!ws) return '';
398
+ // 任务分区的草稿不属于任何项目:显示固定文案,不显示 draft-<uuid> 目录名
399
+ if (isNewTaskKey(key) && projectRootsCache.ok && !projectRootsCache.map.has(normWs(ws))) {
400
+ return t().switcherTaskDraft;
401
+ }
249
402
  return aliases[ws] || ws.replace(/[\\/]+$/, '').split(/[\\/]/).pop();
250
403
  }
251
404
 
@@ -352,6 +505,8 @@ function moveDown() {
352
505
  export function startSessionSwitch() {
353
506
  scan();
354
507
  void loadHotkeys();
508
+ // 提前取工作区→项目映射:草稿归属判断(项目草稿 / 任务草稿)要用
509
+ void loadProjectRoots();
355
510
  window.addEventListener('zcodepro:config-changed', () => { void loadHotkeys(); });
356
511
  // 事件驱动为主:任务条目相关变动(去抖 150ms)立即重扫
357
512
  new MutationObserver((muts) => { if (taskRowMutations(muts)) scheduleScan(); })
@@ -374,7 +529,14 @@ export function startSessionSwitch() {
374
529
  // 点击兜底:bg-selected 标记不可用/未出现时,点条目(含本功能派发的合成点击)即记录
375
530
  document.addEventListener('click', (e) => {
376
531
  const item = e.target instanceof Element && e.target.closest('[data-task-item-key]');
377
- if (item) record(item.getAttribute('data-task-item-key'));
532
+ if (item) { record(item.getAttribute('data-task-item-key')); return; }
533
+ // 点“新建任务”(项目行按钮 / 顶栏入口)后主视图进草稿,这个变化不在任务行
534
+ // 变动过滤里:主动补扫两次,草稿挂载后立即记入 MRU(不等 5 秒兜底轮询)
535
+ if (e.target instanceof Element
536
+ && e.target.closest('[data-testid="virtual-project-create-task"], [data-testid="virtual-project-new-task"], [data-testid="task-new-button"]')) {
537
+ scheduleScan();
538
+ setTimeout(scan, 400);
539
+ }
378
540
  }, true);
379
541
 
380
542
  document.addEventListener('keydown', (e) => {
@@ -423,14 +585,11 @@ export function startSessionSwitch() {
423
585
  if (e.repeat) return;
424
586
  // 即时切换:关掉可能开着的弹窗,切到最近使用的会话(上次使用的会话)
425
587
  closePopup(false);
426
- // 先按侧栏选中标记实时识别当前会话:新建任务视图里没有选中行,
427
- // 此时“当前”视为空,直接回最近使用的会话(新开应用点开过一个会话、
428
- // 进了新建任务再按 alt+z 也能切回去)
429
- const live = findCurrent();
430
- if (live) record(live.getAttribute('data-task-item-key'));
431
- const target = live
432
- ? (mru[0] === current ? mru[1] : mru.find((mk) => mk !== current))
433
- : mru[0];
588
+ // 先按侧栏选中标记实时识别当前视图;新建任务草稿没有选中行,按草稿的
589
+ // 工作区识别。识别不出(面板等)时“当前视图”为空,直接回最近一条
590
+ const live = currentViewKey();
591
+ if (live) record(live);
592
+ const target = switchTarget(mru, live);
434
593
  if (!target) { showToast(t().switcherEmpty, 'warning'); return; }
435
594
  void switchTo(target).then((ok) => { if (!ok) showToast(t().switcherFailed, 'error'); });
436
595
  return;
@@ -1,6 +1,6 @@
1
1
  // “ZCode Pro 增强设置”弹窗:功能开关 + 外观 + 运行状态。
2
2
  // 顶部标签页切换(视觉参考侧栏“分组/项目”切换);配置写入 helper(~/.zcode/zcodepro.json)。
3
- import { h, t, rpc, getConfig, clearConfigCache, errText, HELPER_URL, liveBoot, isZhLocale, isNewProjectSidebar, DEFAULT_SHORTCUTS, DEFAULT_STATUS_ITEMS, DEFAULT_TURN_ITEMS, STATUS_SESSION_IDS, STATUS_GLOBAL_IDS } from '../core.js';
3
+ import { h, t, rpc, getConfig, clearConfigCache, errText, HELPER_URL, liveBoot, isZhLocale, uiLocale, isCjkLocale, isNewProjectSidebar, DEFAULT_SHORTCUTS, DEFAULT_STATUS_ITEMS, DEFAULT_TURN_ITEMS, STATUS_SESSION_IDS, STATUS_GLOBAL_IDS } from '../core.js';
4
4
  import { openDialog, dialogFooter, btnPrimary, btnSecondary, btnSmall, settingRow, ensureStyle, showToast, numberField, unitField } from '../ui.js';
5
5
  import { comboField, providerOptionsOf, modelOptionsOf, modelPlaceholderOf, isManualConn } from '../provider-fields.js';
6
6
  import { refreshAliases } from './alias.js';
@@ -9,6 +9,7 @@ import { applyStyles, STYLE_DEFAULTS, showStyleHighlight, hideStyleHighlight } f
9
9
  import { THEME_SKINS, CUSTOM_DEFAULTS } from './theme.js';
10
10
  import { copyToClipboard, hCopyIcon } from './copy-path.js';
11
11
  import { claimAutoUpdateRun } from './plugin-updates.js';
12
+ import { defaultContinueText } from './auto-continue.js';
12
13
  import { createSessionImportPane } from './session-import.js';
13
14
 
14
15
  // 调宿主桥在系统浏览器打开外链;宿主没暴露该能力时静默忽略
@@ -222,7 +223,7 @@ export function openSettingsDialog() {
222
223
  getConfig(true),
223
224
  rpc('/agents'),
224
225
  rpc('/vision'),
225
- rpc('/title-gen'),
226
+ rpc('/title-gen?locale=' + encodeURIComponent(uiLocale())),
226
227
  rpc('/title-gen/providers'),
227
228
  rpc('/rtk'),
228
229
  rpc('/headroom'),
@@ -612,6 +613,7 @@ export function openSettingsDialog() {
612
613
  const paneVision = h('div', { role: 'tabpanel', style: 'display:none' });
613
614
  const paneRtk = h('div', { role: 'tabpanel', style: 'display:none' });
614
615
  const paneHeadroom = h('div', { role: 'tabpanel', style: 'display:none' });
616
+ const paneAutoContinue = h('div', { role: 'tabpanel', style: 'display:none' });
615
617
  const paneTitleGen = h('div', { role: 'tabpanel', style: 'display:none' });
616
618
  const paneDebug = h('div', { role: 'tabpanel', style: 'display:none' });
617
619
  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 };
@@ -1103,7 +1105,8 @@ export function openSettingsDialog() {
1103
1105
  },
1104
1106
  h('div', { class: 'zcodepro-skin-swatches' },
1105
1107
  ...skin.preview.map((c) => h('span', { style: `background:${c}` }))),
1106
- h('span', { class: 'text-ui-xs text-foreground' }, isZhLocale() ? skin.zh : skin.en))),
1108
+ h('span', { class: 'text-ui-xs text-foreground' },
1109
+ isZhLocale() ? skin.zh : (skin.id === 'default' ? L.themeSkinDefault : skin.en)))),
1107
1110
  h('button', {
1108
1111
  type: 'button', class: 'zcodepro-skin-card',
1109
1112
  'data-state': themeCfg.skin === 'custom' ? 'active' : 'inactive',
@@ -1680,13 +1683,14 @@ export function openSettingsDialog() {
1680
1683
  h('div', { class: 'mt-3 flex justify-end' }, agentsSaveBtn),
1681
1684
  );
1682
1685
  let agentsSubTab = 'zcode';
1683
- const agentsSubPanes = { zcode: paneZcode, prompt: agentsPromptPane, titleGen: paneTitleGen };
1686
+ const agentsSubPanes = { zcode: paneZcode, prompt: agentsPromptPane, titleGen: paneTitleGen, autoContinue: paneAutoContinue };
1684
1687
  const agentsSubList = h('div', { role: 'tablist', 'aria-orientation': 'horizontal', class: 'zcodepro-tablist' });
1685
1688
  const renderAgentsSubTabs = () => {
1686
1689
  agentsSubList.replaceChildren(...[
1687
1690
  ['zcode', L.tabZcode],
1688
1691
  ['prompt', L.tabAgents],
1689
1692
  ['titleGen', L.tabTitleGen],
1693
+ ['autoContinue', L.tabAutoContinue],
1690
1694
  ].map(([id, label]) => h('button', {
1691
1695
  type: 'button', role: 'tab', class: 'zcodepro-tab',
1692
1696
  'aria-selected': String(agentsSubTab === id),
@@ -1701,7 +1705,7 @@ export function openSettingsDialog() {
1701
1705
  for (const [pid, pane] of Object.entries(agentsSubPanes)) pane.style.display = pid === agentsSubTab ? '' : 'none';
1702
1706
  renderAgentsSubTabs();
1703
1707
  subTabBars.agents = agentsSubList;
1704
- paneAgents.append(paneZcode, agentsPromptPane, paneTitleGen);
1708
+ paneAgents.append(paneZcode, agentsPromptPane, paneTitleGen, paneAutoContinue);
1705
1709
 
1706
1710
  // “代理”:为 helper 发起的网络访问(插件市场更新/安装、headroom 本体升级)设
1707
1711
  // HTTP 代理;保存即生效(helper 子进程环境变量注入),不影响 ZCode 应用与模型请求。
@@ -1750,7 +1754,7 @@ export function openSettingsDialog() {
1750
1754
  `${t.name} ${t.ok ? '✓ ' + (t.ms != null ? t.ms + 'ms' : '') : '✗ ' + (t.error || t.httpCode || '')}`.trim());
1751
1755
  const allOk = (res.targets || []).length > 0 && (res.targets || []).every((t) => t.ok);
1752
1756
  proxyTestState.className = 'mt-2 text-ui-xs/relaxed ' + (allOk ? 'text-foreground-subtle' : 'text-amber-500');
1753
- proxyTestState.textContent = `${res.proxy}:${parts.join(' · ')}`;
1757
+ proxyTestState.textContent = `${res.proxy}${isCjkLocale() ? ':' : ': '}${parts.join(' · ')}`;
1754
1758
  };
1755
1759
  // 代理生效范围(即时保存,每个开关只改自己那项):插件市场更新与插件依赖
1756
1760
  // 软件默认开,同步默认关——国内网盘直连即可,代理停了同步会跟着失败
@@ -1796,8 +1800,9 @@ export function openSettingsDialog() {
1796
1800
  h('div', { class: 'mt-3 divide-y divide-border rounded-xl border border-border' }, proxyScopeWrap),
1797
1801
  );
1798
1802
 
1799
- // “性能”:空闲项目内存回收(开关 + 两个时长)。idleReclaimStartupMinutes
1800
- // 允许 0(启动后立即回收一次),取值不能用“|| 默认值”的写法回退
1803
+ // “性能”:空闲项目内存回收(开关 + 两个时长)与子代理活动判定时长。
1804
+ // idleReclaimStartupMinutes 允许 0(启动后立即回收一次),取值不能用
1805
+ // “|| 默认值”的写法回退
1801
1806
  const perfToggleWrap = h('div');
1802
1807
  const renderPerfToggle = () => {
1803
1808
  const f = config.features || {};
@@ -1842,8 +1847,9 @@ export function openSettingsDialog() {
1842
1847
  h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.perfDesc),
1843
1848
  h('div', { class: 'mt-3 divide-y divide-border rounded-xl border border-border' },
1844
1849
  perfToggleWrap,
1845
- perfNumberRow(L.idleReclaimMinutesLabel, null, 'idleReclaimMinutes', 30, 1),
1846
- perfNumberRow(L.idleReclaimStartupLabel, L.idleReclaimStartupHint, 'idleReclaimStartupMinutes', 5, 0)),
1850
+ perfNumberRow(L.idleReclaimMinutesLabel, null, 'idleReclaimMinutes', 10, 1),
1851
+ perfNumberRow(L.idleReclaimStartupLabel, L.idleReclaimStartupHint, 'idleReclaimStartupMinutes', 5, 0),
1852
+ perfNumberRow(L.subagentFreshLabel, L.subagentFreshHint, 'subagentFreshMinutes', 60, 1)),
1847
1853
  );
1848
1854
 
1849
1855
  // “同步”:把 ZCode Pro 设置与模型设置手动备份到 WebDAV / 从 WebDAV 恢复
@@ -1956,8 +1962,10 @@ export function openSettingsDialog() {
1956
1962
  let host = syncUrlInput.value.trim();
1957
1963
  try { host = new URL(host).host; } catch { /* 非法输入保留原文 */ }
1958
1964
  syncTestState.className = 'mt-2 text-ui-xs/relaxed ' + (allOk ? 'text-foreground-subtle' : 'text-amber-500');
1959
- syncTestState.textContent = `${host}:${parts.join(' · ')}`
1960
- + (allOk && res.fileCount != null ? `(${L.syncTestFilesFound.replace('{n}', res.fileCount)})` : '');
1965
+ syncTestState.textContent = `${host}${isCjkLocale() ? ':' : ': '}${parts.join(' · ')}`
1966
+ + (allOk && res.fileCount != null
1967
+ ? `${isCjkLocale() ? '(' : ' ('}${L.syncTestFilesFound.replace('{n}', res.fileCount)}${isCjkLocale() ? ')' : ')'}`
1968
+ : '');
1961
1969
  };
1962
1970
  // 坚果云推荐行:外链经宿主 openExternal 打开系统浏览器(无该能力时只出纯文字)
1963
1971
  const JIANGUO_HELP = 'https://help.jianguoyun.com/?p=2064';
@@ -2078,7 +2086,7 @@ export function openSettingsDialog() {
2078
2086
  const history = group.filter((f) => f !== latest)
2079
2087
  .sort((a, b) => ((b.lastModified || 0) - (a.lastModified || 0)) || b.name.localeCompare(a.name));
2080
2088
  parts.push(h('div', { class: 'px-1 pt-2 text-ui-xs font-medium text-foreground-subtle' },
2081
- `${label}${isZhLocale() ? '(' : ' ('}${group.length}${isZhLocale() ? ')' : ')'}`));
2089
+ `${label}${isCjkLocale() ? '(' : ' ('}${group.length}${isCjkLocale() ? ')' : ')'}`));
2082
2090
  for (const f of [latest, ...history]) {
2083
2091
  if (f) parts.push(versionRow(f));
2084
2092
  }
@@ -2122,8 +2130,10 @@ export function openSettingsDialog() {
2122
2130
  renderToolbarSwitch();
2123
2131
  const names = (res.applied || [])
2124
2132
  .map((k) => (k === 'model' ? L.syncIncludeModel : L.syncIncludeZcp))
2125
- .join(isZhLocale() ? '、' : ', ');
2126
- showToast(names ? `${L.syncDownloaded}(${names})` : L.syncDownloaded, 'success');
2133
+ .join(isCjkLocale() ? '、' : ', ');
2134
+ showToast(names
2135
+ ? `${L.syncDownloaded}${isCjkLocale() ? '(' : ' ('}${names}${isCjkLocale() ? ')' : ')'}`
2136
+ : L.syncDownloaded, 'success');
2127
2137
  };
2128
2138
  const confirmDelete = (f, rowBtns, isLatest) => {
2129
2139
  openDialog({
@@ -2188,7 +2198,7 @@ export function openSettingsDialog() {
2188
2198
  return;
2189
2199
  }
2190
2200
  renderSyncStatus(res.sync || {});
2191
- showToast(res.pruned ? L.syncUploaded + (isZhLocale() ? ';' : '; ') + L.syncPruned.replace('{n}', res.pruned) : L.syncUploaded, 'success');
2201
+ showToast(res.pruned ? L.syncUploaded + (isCjkLocale() ? ';' : '; ') + L.syncPruned.replace('{n}', res.pruned) : L.syncUploaded, 'success');
2192
2202
  };
2193
2203
  paneSync.append(
2194
2204
  h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.syncDesc),
@@ -2280,15 +2290,16 @@ export function openSettingsDialog() {
2280
2290
  // 默认单级链与 zcode-vision 插件 DEFAULT_CONFIG 保持一致:session(跟随会话供应商、
2281
2291
  // 模型留空=会话当前模型)。需要兜底级可手动加 GLM 订阅直连。
2282
2292
  // 赠送额度级 trust-build 暂不进默认:ZCode 网关不放行无人值守调用(ADR-0002)。
2283
- const VISION_DEFAULT_PROMPT_ZH = '请详细描述这张图片的全部内容。若是界面或图表截图,请先把所有错误、警告、异常状态逐字引用出来(含完整原文),再描述整体布局、文字与关键数据。';
2284
- 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.';
2285
- const VISION_DEFAULT_PROMPT = isZhLocale() ? VISION_DEFAULT_PROMPT_ZH : VISION_DEFAULT_PROMPT_EN;
2286
- // 已保存的配置里如果是内置默认提示词(旧版固定中文),按当前语言重新取:
2287
- // 否则切到英文后老配置仍然发中文提示词。用户自己改过的提示词不动。
2288
- const isBuiltinVisionPrompt = (p) => {
2289
- const text = String(p || '').trim();
2290
- return text === VISION_DEFAULT_PROMPT_ZH || text === VISION_DEFAULT_PROMPT_EN;
2291
- };
2293
+ // 默认识别提示词跟着 ZCode 的界面语言走(官方支持 zh-CN / en-US / ja-JP / ko-KR / ru-RU),
2294
+ // 与 zcode-vision 插件的 DEFAULT_PROMPT 保持一致
2295
+ const VISION_DEFAULT_PROMPTS = {
2296
+ 'zh-CN': '请详细描述这张图片的全部内容。若是界面或图表截图,请先把所有错误、警告、异常状态逐字引用出来(含完整原文),再描述整体布局、文字与关键数据。',
2297
+ 'en-US': '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.',
2298
+ 'ja-JP': 'この画像の内容を詳しく説明してください。UI やグラフのスクリーンショットの場合は、まずエラー、警告、異常状態をすべて原文のまま(全文を含めて)引用し、そのうえで全体のレイアウト、文字、主要なデータを説明してください。',
2299
+ 'ko-KR': '이 이미지의 전체 내용을 자세히 설명해 주세요. UI나 차트 스크린샷이라면 먼저 모든 오류, 경고, 비정상 상태를 원문 그대로(전체 문구 포함) 인용한 다음, 전체 레이아웃과 텍스트, 핵심 데이터를 설명해 주세요.',
2300
+ 'ru-RU': 'Подробно опишите всё содержимое этого изображения. Если это скриншот интерфейса или графика, сначала дословно процитируйте все ошибки, предупреждения и аномальные состояния (включая полный текст), а затем опишите общую компоновку, текст и ключевые данные.',
2301
+ };
2302
+ const VISION_DEFAULT_PROMPT = VISION_DEFAULT_PROMPTS[uiLocale()] || VISION_DEFAULT_PROMPTS['en-US'];
2292
2303
  const VISION_DEFAULT_CFG = {
2293
2304
  enabled: true,
2294
2305
  chainMode: 'fallback',
@@ -2306,11 +2317,6 @@ export function openSettingsDialog() {
2306
2317
  let visionCfg = visionRes.ok && visionRes.config && typeof visionRes.config === 'object'
2307
2318
  ? structuredClone(visionRes.config)
2308
2319
  : null;
2309
- if (visionCfg && Array.isArray(visionCfg.proxies)) {
2310
- for (const proxy of visionCfg.proxies) {
2311
- if (isBuiltinVisionPrompt(proxy.prompt)) proxy.prompt = VISION_DEFAULT_PROMPT;
2312
- }
2313
- }
2314
2320
  // 自动初始化只试一次(每次打开弹窗):写盘失败回退手动“添加代理”卡
2315
2321
  let visionAutoInitTried = false;
2316
2322
  let visionSaveTimer = null;
@@ -2907,10 +2913,10 @@ export function openSettingsDialog() {
2907
2913
  const doneMsg = isStart ? L.hrStarted : L.hrStopped;
2908
2914
  const timeoutMs = isStart ? 90 * 1000 : 30 * 1000;
2909
2915
  const t0 = Date.now();
2910
- const timerSpan = h('span', { class: 'text-ui-sm text-foreground-subtle/70' }, msg + (isZhLocale() ? '(0s)' : ' (0s)'));
2916
+ const timerSpan = h('span', { class: 'text-ui-sm text-foreground-subtle/70' }, msg + (isCjkLocale() ? '(0s)' : ' (0s)'));
2911
2917
  hrStatusLine.replaceChildren(timerSpan);
2912
2918
  timerIv = setInterval(() => {
2913
- timerSpan.textContent = msg + (isZhLocale() ? `(${Math.round((Date.now() - t0) / 1000)}s)` : ` (${Math.round((Date.now() - t0) / 1000)}s)`);
2919
+ timerSpan.textContent = msg + (isCjkLocale() ? `(${Math.round((Date.now() - t0) / 1000)}s)` : ` (${Math.round((Date.now() - t0) / 1000)}s)`);
2914
2920
  }, 1000);
2915
2921
  // RPC 完成后进入轮询(RPC 执行实际的 stop/start,可能要 3-10 秒)。
2916
2922
  // 轮询出结果前 hrBusy 一直占着:期间再点开关或按钮直接忽略,否则
@@ -2981,7 +2987,7 @@ export function openSettingsDialog() {
2981
2987
  ...(s.port ? [h('span', { class: 'text-ui-xs text-foreground-subtle' }, `127.0.0.1:${s.port}`)] : []),
2982
2988
  );
2983
2989
  const fact = (label, value) => h('div', { class: 'min-w-0 truncate text-ui-xs text-foreground-subtle' },
2984
- h('span', { class: 'text-foreground-subtle/70' }, label + ':'),
2990
+ h('span', { class: 'text-foreground-subtle/70' }, label + (isCjkLocale() ? ':' : ': ')),
2985
2991
  String(value ?? '—'));
2986
2992
  hrFacts.replaceChildren(
2987
2993
  fact(L.headroomCurrentBackend, hrDevLabel(s.backend)),
@@ -3300,10 +3306,17 @@ export function openSettingsDialog() {
3300
3306
  promptArea.value = titleGenCfg.prompt || '';
3301
3307
  promptArea.addEventListener('input', () => { titleGenCfg.prompt = promptArea.value; saveTitleGenSoon(); });
3302
3308
  // 测试:用示例首条消息实际生成一次(不写库),验证供应商/模型/提示词
3303
- // 连通;示例文本随界面语言取中英文版
3304
- const sampleText = isZhLocale()
3309
+ // 连通;示例文本随界面语言取对应版本
3310
+ const sampleLocale = uiLocale();
3311
+ const sampleText = sampleLocale === 'zh-CN'
3305
3312
  ? '帮我看下这个报错是什么原因:NullPointerException at com.example.OrderService.calculate(OrderService.java:87)'
3306
- : 'Why does my Spring Boot app throw NullPointerException intermittently in OrderService.calculate?';
3313
+ : sampleLocale === 'ja-JP'
3314
+ ? 'このエラーの原因を教えてください:NullPointerException at com.example.OrderService.calculate(OrderService.java:87)'
3315
+ : sampleLocale === 'ko-KR'
3316
+ ? '이 오류의 원인을 알려 주세요: NullPointerException at com.example.OrderService.calculate(OrderService.java:87)'
3317
+ : sampleLocale === 'ru-RU'
3318
+ ? 'Помогите понять причину этой ошибки: NullPointerException at com.example.OrderService.calculate(OrderService.java:87)'
3319
+ : 'Why does my Spring Boot app throw NullPointerException intermittently in OrderService.calculate?';
3307
3320
  const sampleInput = h('input', {
3308
3321
  type: 'text', class: inputCls + ' min-w-0 flex-1',
3309
3322
  value: sampleText,
@@ -3316,7 +3329,7 @@ export function openSettingsDialog() {
3316
3329
  testState.textContent = L.titleGenTesting;
3317
3330
  const res = await rpc('/title-gen/run', {
3318
3331
  method: 'POST',
3319
- body: { text: sampleInput.value, test: true },
3332
+ body: { text: sampleInput.value, test: true, locale: uiLocale() },
3320
3333
  });
3321
3334
  testBtn.disabled = false;
3322
3335
  testBtn.textContent = L.titleGenTest;
@@ -3386,6 +3399,79 @@ export function openSettingsDialog() {
3386
3399
  };
3387
3400
  renderTitleGenPane();
3388
3401
 
3402
+ // —— auto-continue(自动继续)设置页:回合失败/截断自动续接的开关与文案,
3403
+ // 配置在 ~/.zcode/auto-continue.json ——
3404
+ let acRes = null;
3405
+ let acCfg = null;
3406
+ let acSaveTimer = null;
3407
+ const persistAc = async () => {
3408
+ const res = await rpc('/auto-continue', { method: 'POST', body: { config: acCfg } });
3409
+ if (!res.ok) showToast(L.failed + ': ' + errText(res), 'error');
3410
+ };
3411
+ const saveAcSoon = () => {
3412
+ clearTimeout(acSaveTimer);
3413
+ acSaveTimer = setTimeout(() => { void persistAc(); }, 500);
3414
+ };
3415
+ const renderAutoContinue = () => {
3416
+ if (!acRes || !acRes.ok) {
3417
+ paneAutoContinue.replaceChildren(
3418
+ h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.acDesc),
3419
+ h('p', { class: 'mt-2 text-ui-sm text-destructive' }, L.acLoadFailed + (acRes ? ': ' + errText(acRes) : '')),
3420
+ );
3421
+ return;
3422
+ }
3423
+ if (!acCfg) {
3424
+ const raw = acRes.config && typeof acRes.config === 'object' ? acRes.config : {};
3425
+ acCfg = {
3426
+ enabled: raw.enabled !== false,
3427
+ // 空的已保存值保持为空:改其它开关时不能把当前语言的默认提示词写进配置,
3428
+ // 否则之后切换语言就不会再跟随(运行时空值才取当前语言默认)
3429
+ continueText: typeof raw.continueText === 'string' && raw.continueText.trim() ? raw.continueText : '',
3430
+ maxRetries: Number.isFinite(raw.maxRetries) ? raw.maxRetries : 8,
3431
+ cooldownBaseSec: Number.isFinite(raw.cooldownBaseSec) ? raw.cooldownBaseSec : 10,
3432
+ stuckAfterMin: Number.isFinite(raw.stuckAfterMin) ? raw.stuckAfterMin : 30,
3433
+ failedAfterMin: Number.isFinite(raw.failedAfterMin) ? raw.failedAfterMin : 3,
3434
+ };
3435
+ }
3436
+ // numberField 返回 { el, set, reset, get },取 .el 嵌入
3437
+ const numRow = (labelText, hint, value, min, max, commit) => h('label', {
3438
+ class: 'flex shrink-0 items-center gap-1.5', title: hint,
3439
+ }, h('span', { class: 'text-ui-xs text-foreground-subtle' }, labelText),
3440
+ numberField({
3441
+ value, fallback: min, min, max,
3442
+ onCommit: (v) => { commit(v); saveAcSoon(); },
3443
+ }).el);
3444
+ const area = h('textarea', { class: 'zcodepro-textarea zcodepro-textarea-sm', rows: '3', placeholder: L.acPrompt, title: L.acPrompt });
3445
+ area.value = acCfg.continueText || defaultContinueText(); // 空值显示当前语言默认,但保存时仍为空
3446
+ area.addEventListener('input', () => { acCfg.continueText = area.value; saveAcSoon(); });
3447
+
3448
+ const parts = [
3449
+ // 信息卡:一句话简介在左,启用开关右对齐(与自动重命名页同款)
3450
+ h('div', { class: 'mt-3 flex items-center justify-between gap-2 rounded-xl border border-border p-2' },
3451
+ h('span', { class: 'min-w-0 text-ui-sm/relaxed text-foreground-subtle' }, L.acDesc),
3452
+ h('div', { class: 'shrink-0' }, settingRow(L.acEnabled, '', acCfg.enabled !== false, () => {
3453
+ acCfg.enabled = !(acCfg.enabled !== false);
3454
+ saveAcSoon();
3455
+ renderAutoContinue();
3456
+ }))),
3457
+ ];
3458
+ parts.push(
3459
+ h('div', { class: 'mt-3 rounded-xl border border-border p-2' },
3460
+ h('div', { class: 'mb-1 text-ui-xs font-medium text-foreground-subtle' }, L.acPrompt),
3461
+ area),
3462
+ h('div', { class: 'mt-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 rounded-xl border border-border p-2' },
3463
+ numRow(L.acMaxRetries, L.acMaxRetriesHint, acCfg.maxRetries, 1, 50, (v) => { acCfg.maxRetries = v; }),
3464
+ numRow(L.acCooldown, L.acCooldownHint, acCfg.cooldownBaseSec, 0, 600, (v) => { acCfg.cooldownBaseSec = v; }),
3465
+ numRow(L.acStuckAfterMin, L.acStuckAfterMinHint, acCfg.stuckAfterMin, 5, 720, (v) => { acCfg.stuckAfterMin = v; }),
3466
+ numRow(L.acFailedAfterMin, L.acFailedAfterMinHint, acCfg.failedAfterMin, 1, 60, (v) => { acCfg.failedAfterMin = v; })),
3467
+ );
3468
+ paneAutoContinue.replaceChildren(...parts);
3469
+ };
3470
+ void (async () => {
3471
+ acRes = await rpc('/auto-continue');
3472
+ renderAutoContinue();
3473
+ })();
3474
+
3389
3475
  // 一级 / 二级 tab 放到滚动区(body)之上的固定区:内容滚动时标题、
3390
3476
  // 版本行(已并入标题行)与两级 tab 始终可见
3391
3477
  const subTabHost = h('div', { class: 'mt-2' });