zcode-pro 1.8.1 → 1.9.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.
@@ -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'),
@@ -396,6 +397,11 @@ export function openSettingsDialog() {
396
397
  if (await setFeature('composerProvider', next)) f.composerProvider = next;
397
398
  refreshRows();
398
399
  }),
400
+ settingRow(L.featureComposerEditModel, L.featureComposerEditModelDesc, f.composerEditModel !== false, async () => {
401
+ const next = !(f.composerEditModel !== false);
402
+ if (await setFeature('composerEditModel', next)) f.composerEditModel = next;
403
+ refreshRows();
404
+ }),
399
405
  settingRow(L.featureSessionImport, L.featureSessionImportDesc, f.sessionImport !== false, async () => {
400
406
  const next = !(f.sessionImport !== false);
401
407
  if (await setFeature('sessionImport', next)) f.sessionImport = next;
@@ -607,6 +613,7 @@ export function openSettingsDialog() {
607
613
  const paneVision = h('div', { role: 'tabpanel', style: 'display:none' });
608
614
  const paneRtk = h('div', { role: 'tabpanel', style: 'display:none' });
609
615
  const paneHeadroom = h('div', { role: 'tabpanel', style: 'display:none' });
616
+ const paneAutoContinue = h('div', { role: 'tabpanel', style: 'display:none' });
610
617
  const paneTitleGen = h('div', { role: 'tabpanel', style: 'display:none' });
611
618
  const paneDebug = h('div', { role: 'tabpanel', style: 'display:none' });
612
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 };
@@ -729,10 +736,11 @@ export function openSettingsDialog() {
729
736
  styleCell(L.sidebarProjectSpacingName, L.sidebarProjectSpacingDesc, 'sidebarProjectSpacing', { max: 24 }),
730
737
  styleCell(L.sidebarTaskSpacingName, L.sidebarTaskSpacingDesc, 'sidebarTaskSpacing', { max: 24 }),
731
738
  widthCell,
732
- styleCell(L.rowGapName, L.rowGapDesc, 'rowGap'),
733
739
  styleCell(L.userLineHeightName, L.userLineHeightDesc, 'userLineHeight', { min: 1, max: 3, step: 0.05, unit: 'x' }),
734
- styleCell(L.lineHeightName, L.lineHeightDesc, 'lineHeight', { min: 1, max: 3, step: 0.05, unit: 'x' }),
735
740
  styleCell(L.thinkingLineHeightName, L.thinkingLineHeightDesc, 'thinkingLineHeight', { min: 1, max: 3, step: 0.05, unit: 'x' }),
741
+ styleCell(L.thinkingRowGapName, L.thinkingRowGapDesc, 'thinkingRowGap'),
742
+ styleCell(L.lineHeightName, L.lineHeightDesc, 'lineHeight', { min: 1, max: 3, step: 0.05, unit: 'x' }),
743
+ styleCell(L.answerRowGapName, L.answerRowGapDesc, 'answerRowGap'),
736
744
  styleCell(L.codeLineHeightName, L.codeLineHeightDesc, 'codeLineHeight', { min: 1, max: 3, step: 0.05, unit: 'x' }),
737
745
  styleCell(L.listSpacingName, L.listSpacingDesc, 'listSpacing'),
738
746
  styleCell(L.listItemSpacingName, L.listItemSpacingDesc, 'listItemSpacing'),
@@ -1097,7 +1105,8 @@ export function openSettingsDialog() {
1097
1105
  },
1098
1106
  h('div', { class: 'zcodepro-skin-swatches' },
1099
1107
  ...skin.preview.map((c) => h('span', { style: `background:${c}` }))),
1100
- 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)))),
1101
1110
  h('button', {
1102
1111
  type: 'button', class: 'zcodepro-skin-card',
1103
1112
  'data-state': themeCfg.skin === 'custom' ? 'active' : 'inactive',
@@ -1674,13 +1683,14 @@ export function openSettingsDialog() {
1674
1683
  h('div', { class: 'mt-3 flex justify-end' }, agentsSaveBtn),
1675
1684
  );
1676
1685
  let agentsSubTab = 'zcode';
1677
- const agentsSubPanes = { zcode: paneZcode, prompt: agentsPromptPane, titleGen: paneTitleGen };
1686
+ const agentsSubPanes = { zcode: paneZcode, prompt: agentsPromptPane, titleGen: paneTitleGen, autoContinue: paneAutoContinue };
1678
1687
  const agentsSubList = h('div', { role: 'tablist', 'aria-orientation': 'horizontal', class: 'zcodepro-tablist' });
1679
1688
  const renderAgentsSubTabs = () => {
1680
1689
  agentsSubList.replaceChildren(...[
1681
1690
  ['zcode', L.tabZcode],
1682
1691
  ['prompt', L.tabAgents],
1683
1692
  ['titleGen', L.tabTitleGen],
1693
+ ['autoContinue', L.tabAutoContinue],
1684
1694
  ].map(([id, label]) => h('button', {
1685
1695
  type: 'button', role: 'tab', class: 'zcodepro-tab',
1686
1696
  'aria-selected': String(agentsSubTab === id),
@@ -1695,7 +1705,7 @@ export function openSettingsDialog() {
1695
1705
  for (const [pid, pane] of Object.entries(agentsSubPanes)) pane.style.display = pid === agentsSubTab ? '' : 'none';
1696
1706
  renderAgentsSubTabs();
1697
1707
  subTabBars.agents = agentsSubList;
1698
- paneAgents.append(paneZcode, agentsPromptPane, paneTitleGen);
1708
+ paneAgents.append(paneZcode, agentsPromptPane, paneTitleGen, paneAutoContinue);
1699
1709
 
1700
1710
  // “代理”:为 helper 发起的网络访问(插件市场更新/安装、headroom 本体升级)设
1701
1711
  // HTTP 代理;保存即生效(helper 子进程环境变量注入),不影响 ZCode 应用与模型请求。
@@ -1744,7 +1754,7 @@ export function openSettingsDialog() {
1744
1754
  `${t.name} ${t.ok ? '✓ ' + (t.ms != null ? t.ms + 'ms' : '') : '✗ ' + (t.error || t.httpCode || '')}`.trim());
1745
1755
  const allOk = (res.targets || []).length > 0 && (res.targets || []).every((t) => t.ok);
1746
1756
  proxyTestState.className = 'mt-2 text-ui-xs/relaxed ' + (allOk ? 'text-foreground-subtle' : 'text-amber-500');
1747
- proxyTestState.textContent = `${res.proxy}:${parts.join(' · ')}`;
1757
+ proxyTestState.textContent = `${res.proxy}${isCjkLocale() ? ':' : ': '}${parts.join(' · ')}`;
1748
1758
  };
1749
1759
  // 代理生效范围(即时保存,每个开关只改自己那项):插件市场更新与插件依赖
1750
1760
  // 软件默认开,同步默认关——国内网盘直连即可,代理停了同步会跟着失败
@@ -1950,8 +1960,10 @@ export function openSettingsDialog() {
1950
1960
  let host = syncUrlInput.value.trim();
1951
1961
  try { host = new URL(host).host; } catch { /* 非法输入保留原文 */ }
1952
1962
  syncTestState.className = 'mt-2 text-ui-xs/relaxed ' + (allOk ? 'text-foreground-subtle' : 'text-amber-500');
1953
- syncTestState.textContent = `${host}:${parts.join(' · ')}`
1954
- + (allOk && res.fileCount != null ? `(${L.syncTestFilesFound.replace('{n}', res.fileCount)})` : '');
1963
+ syncTestState.textContent = `${host}${isCjkLocale() ? ':' : ': '}${parts.join(' · ')}`
1964
+ + (allOk && res.fileCount != null
1965
+ ? `${isCjkLocale() ? '(' : ' ('}${L.syncTestFilesFound.replace('{n}', res.fileCount)}${isCjkLocale() ? ')' : ')'}`
1966
+ : '');
1955
1967
  };
1956
1968
  // 坚果云推荐行:外链经宿主 openExternal 打开系统浏览器(无该能力时只出纯文字)
1957
1969
  const JIANGUO_HELP = 'https://help.jianguoyun.com/?p=2064';
@@ -2072,7 +2084,7 @@ export function openSettingsDialog() {
2072
2084
  const history = group.filter((f) => f !== latest)
2073
2085
  .sort((a, b) => ((b.lastModified || 0) - (a.lastModified || 0)) || b.name.localeCompare(a.name));
2074
2086
  parts.push(h('div', { class: 'px-1 pt-2 text-ui-xs font-medium text-foreground-subtle' },
2075
- `${label}${isZhLocale() ? '(' : ' ('}${group.length}${isZhLocale() ? ')' : ')'}`));
2087
+ `${label}${isCjkLocale() ? '(' : ' ('}${group.length}${isCjkLocale() ? ')' : ')'}`));
2076
2088
  for (const f of [latest, ...history]) {
2077
2089
  if (f) parts.push(versionRow(f));
2078
2090
  }
@@ -2116,8 +2128,10 @@ export function openSettingsDialog() {
2116
2128
  renderToolbarSwitch();
2117
2129
  const names = (res.applied || [])
2118
2130
  .map((k) => (k === 'model' ? L.syncIncludeModel : L.syncIncludeZcp))
2119
- .join(isZhLocale() ? '、' : ', ');
2120
- showToast(names ? `${L.syncDownloaded}(${names})` : L.syncDownloaded, 'success');
2131
+ .join(isCjkLocale() ? '、' : ', ');
2132
+ showToast(names
2133
+ ? `${L.syncDownloaded}${isCjkLocale() ? '(' : ' ('}${names}${isCjkLocale() ? ')' : ')'}`
2134
+ : L.syncDownloaded, 'success');
2121
2135
  };
2122
2136
  const confirmDelete = (f, rowBtns, isLatest) => {
2123
2137
  openDialog({
@@ -2182,7 +2196,7 @@ export function openSettingsDialog() {
2182
2196
  return;
2183
2197
  }
2184
2198
  renderSyncStatus(res.sync || {});
2185
- showToast(res.pruned ? L.syncUploaded + (isZhLocale() ? ';' : '; ') + L.syncPruned.replace('{n}', res.pruned) : L.syncUploaded, 'success');
2199
+ showToast(res.pruned ? L.syncUploaded + (isCjkLocale() ? ';' : '; ') + L.syncPruned.replace('{n}', res.pruned) : L.syncUploaded, 'success');
2186
2200
  };
2187
2201
  paneSync.append(
2188
2202
  h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.syncDesc),
@@ -2274,15 +2288,16 @@ export function openSettingsDialog() {
2274
2288
  // 默认单级链与 zcode-vision 插件 DEFAULT_CONFIG 保持一致:session(跟随会话供应商、
2275
2289
  // 模型留空=会话当前模型)。需要兜底级可手动加 GLM 订阅直连。
2276
2290
  // 赠送额度级 trust-build 暂不进默认:ZCode 网关不放行无人值守调用(ADR-0002)。
2277
- const VISION_DEFAULT_PROMPT_ZH = '请详细描述这张图片的全部内容。若是界面或图表截图,请先把所有错误、警告、异常状态逐字引用出来(含完整原文),再描述整体布局、文字与关键数据。';
2278
- 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.';
2279
- const VISION_DEFAULT_PROMPT = isZhLocale() ? VISION_DEFAULT_PROMPT_ZH : VISION_DEFAULT_PROMPT_EN;
2280
- // 已保存的配置里如果是内置默认提示词(旧版固定中文),按当前语言重新取:
2281
- // 否则切到英文后老配置仍然发中文提示词。用户自己改过的提示词不动。
2282
- const isBuiltinVisionPrompt = (p) => {
2283
- const text = String(p || '').trim();
2284
- return text === VISION_DEFAULT_PROMPT_ZH || text === VISION_DEFAULT_PROMPT_EN;
2285
- };
2291
+ // 默认识别提示词跟着 ZCode 的界面语言走(官方支持 zh-CN / en-US / ja-JP / ko-KR / ru-RU),
2292
+ // 与 zcode-vision 插件的 DEFAULT_PROMPT 保持一致
2293
+ const VISION_DEFAULT_PROMPTS = {
2294
+ 'zh-CN': '请详细描述这张图片的全部内容。若是界面或图表截图,请先把所有错误、警告、异常状态逐字引用出来(含完整原文),再描述整体布局、文字与关键数据。',
2295
+ '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.',
2296
+ 'ja-JP': 'この画像の内容を詳しく説明してください。UI やグラフのスクリーンショットの場合は、まずエラー、警告、異常状態をすべて原文のまま(全文を含めて)引用し、そのうえで全体のレイアウト、文字、主要なデータを説明してください。',
2297
+ 'ko-KR': '이 이미지의 전체 내용을 자세히 설명해 주세요. UI나 차트 스크린샷이라면 먼저 모든 오류, 경고, 비정상 상태를 원문 그대로(전체 문구 포함) 인용한 다음, 전체 레이아웃과 텍스트, 핵심 데이터를 설명해 주세요.',
2298
+ 'ru-RU': 'Подробно опишите всё содержимое этого изображения. Если это скриншот интерфейса или графика, сначала дословно процитируйте все ошибки, предупреждения и аномальные состояния (включая полный текст), а затем опишите общую компоновку, текст и ключевые данные.',
2299
+ };
2300
+ const VISION_DEFAULT_PROMPT = VISION_DEFAULT_PROMPTS[uiLocale()] || VISION_DEFAULT_PROMPTS['en-US'];
2286
2301
  const VISION_DEFAULT_CFG = {
2287
2302
  enabled: true,
2288
2303
  chainMode: 'fallback',
@@ -2300,11 +2315,6 @@ export function openSettingsDialog() {
2300
2315
  let visionCfg = visionRes.ok && visionRes.config && typeof visionRes.config === 'object'
2301
2316
  ? structuredClone(visionRes.config)
2302
2317
  : null;
2303
- if (visionCfg && Array.isArray(visionCfg.proxies)) {
2304
- for (const proxy of visionCfg.proxies) {
2305
- if (isBuiltinVisionPrompt(proxy.prompt)) proxy.prompt = VISION_DEFAULT_PROMPT;
2306
- }
2307
- }
2308
2318
  // 自动初始化只试一次(每次打开弹窗):写盘失败回退手动“添加代理”卡
2309
2319
  let visionAutoInitTried = false;
2310
2320
  let visionSaveTimer = null;
@@ -2901,10 +2911,10 @@ export function openSettingsDialog() {
2901
2911
  const doneMsg = isStart ? L.hrStarted : L.hrStopped;
2902
2912
  const timeoutMs = isStart ? 90 * 1000 : 30 * 1000;
2903
2913
  const t0 = Date.now();
2904
- const timerSpan = h('span', { class: 'text-ui-sm text-foreground-subtle/70' }, msg + (isZhLocale() ? '(0s)' : ' (0s)'));
2914
+ const timerSpan = h('span', { class: 'text-ui-sm text-foreground-subtle/70' }, msg + (isCjkLocale() ? '(0s)' : ' (0s)'));
2905
2915
  hrStatusLine.replaceChildren(timerSpan);
2906
2916
  timerIv = setInterval(() => {
2907
- timerSpan.textContent = msg + (isZhLocale() ? `(${Math.round((Date.now() - t0) / 1000)}s)` : ` (${Math.round((Date.now() - t0) / 1000)}s)`);
2917
+ timerSpan.textContent = msg + (isCjkLocale() ? `(${Math.round((Date.now() - t0) / 1000)}s)` : ` (${Math.round((Date.now() - t0) / 1000)}s)`);
2908
2918
  }, 1000);
2909
2919
  // RPC 完成后进入轮询(RPC 执行实际的 stop/start,可能要 3-10 秒)。
2910
2920
  // 轮询出结果前 hrBusy 一直占着:期间再点开关或按钮直接忽略,否则
@@ -2975,7 +2985,7 @@ export function openSettingsDialog() {
2975
2985
  ...(s.port ? [h('span', { class: 'text-ui-xs text-foreground-subtle' }, `127.0.0.1:${s.port}`)] : []),
2976
2986
  );
2977
2987
  const fact = (label, value) => h('div', { class: 'min-w-0 truncate text-ui-xs text-foreground-subtle' },
2978
- h('span', { class: 'text-foreground-subtle/70' }, label + ':'),
2988
+ h('span', { class: 'text-foreground-subtle/70' }, label + (isCjkLocale() ? ':' : ': ')),
2979
2989
  String(value ?? '—'));
2980
2990
  hrFacts.replaceChildren(
2981
2991
  fact(L.headroomCurrentBackend, hrDevLabel(s.backend)),
@@ -3294,10 +3304,17 @@ export function openSettingsDialog() {
3294
3304
  promptArea.value = titleGenCfg.prompt || '';
3295
3305
  promptArea.addEventListener('input', () => { titleGenCfg.prompt = promptArea.value; saveTitleGenSoon(); });
3296
3306
  // 测试:用示例首条消息实际生成一次(不写库),验证供应商/模型/提示词
3297
- // 连通;示例文本随界面语言取中英文版
3298
- const sampleText = isZhLocale()
3307
+ // 连通;示例文本随界面语言取对应版本
3308
+ const sampleLocale = uiLocale();
3309
+ const sampleText = sampleLocale === 'zh-CN'
3299
3310
  ? '帮我看下这个报错是什么原因:NullPointerException at com.example.OrderService.calculate(OrderService.java:87)'
3300
- : 'Why does my Spring Boot app throw NullPointerException intermittently in OrderService.calculate?';
3311
+ : sampleLocale === 'ja-JP'
3312
+ ? 'このエラーの原因を教えてください:NullPointerException at com.example.OrderService.calculate(OrderService.java:87)'
3313
+ : sampleLocale === 'ko-KR'
3314
+ ? '이 오류의 원인을 알려 주세요: NullPointerException at com.example.OrderService.calculate(OrderService.java:87)'
3315
+ : sampleLocale === 'ru-RU'
3316
+ ? 'Помогите понять причину этой ошибки: NullPointerException at com.example.OrderService.calculate(OrderService.java:87)'
3317
+ : 'Why does my Spring Boot app throw NullPointerException intermittently in OrderService.calculate?';
3301
3318
  const sampleInput = h('input', {
3302
3319
  type: 'text', class: inputCls + ' min-w-0 flex-1',
3303
3320
  value: sampleText,
@@ -3310,7 +3327,7 @@ export function openSettingsDialog() {
3310
3327
  testState.textContent = L.titleGenTesting;
3311
3328
  const res = await rpc('/title-gen/run', {
3312
3329
  method: 'POST',
3313
- body: { text: sampleInput.value, test: true },
3330
+ body: { text: sampleInput.value, test: true, locale: uiLocale() },
3314
3331
  });
3315
3332
  testBtn.disabled = false;
3316
3333
  testBtn.textContent = L.titleGenTest;
@@ -3380,6 +3397,79 @@ export function openSettingsDialog() {
3380
3397
  };
3381
3398
  renderTitleGenPane();
3382
3399
 
3400
+ // —— auto-continue(自动继续)设置页:回合失败/截断自动续接的开关与文案,
3401
+ // 配置在 ~/.zcode/auto-continue.json ——
3402
+ let acRes = null;
3403
+ let acCfg = null;
3404
+ let acSaveTimer = null;
3405
+ const persistAc = async () => {
3406
+ const res = await rpc('/auto-continue', { method: 'POST', body: { config: acCfg } });
3407
+ if (!res.ok) showToast(L.failed + ': ' + errText(res), 'error');
3408
+ };
3409
+ const saveAcSoon = () => {
3410
+ clearTimeout(acSaveTimer);
3411
+ acSaveTimer = setTimeout(() => { void persistAc(); }, 500);
3412
+ };
3413
+ const renderAutoContinue = () => {
3414
+ if (!acRes || !acRes.ok) {
3415
+ paneAutoContinue.replaceChildren(
3416
+ h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.acDesc),
3417
+ h('p', { class: 'mt-2 text-ui-sm text-destructive' }, L.acLoadFailed + (acRes ? ': ' + errText(acRes) : '')),
3418
+ );
3419
+ return;
3420
+ }
3421
+ if (!acCfg) {
3422
+ const raw = acRes.config && typeof acRes.config === 'object' ? acRes.config : {};
3423
+ acCfg = {
3424
+ enabled: raw.enabled !== false,
3425
+ // 空的已保存值保持为空:改其它开关时不能把当前语言的默认提示词写进配置,
3426
+ // 否则之后切换语言就不会再跟随(运行时空值才取当前语言默认)
3427
+ continueText: typeof raw.continueText === 'string' && raw.continueText.trim() ? raw.continueText : '',
3428
+ maxRetries: Number.isFinite(raw.maxRetries) ? raw.maxRetries : 8,
3429
+ cooldownBaseSec: Number.isFinite(raw.cooldownBaseSec) ? raw.cooldownBaseSec : 10,
3430
+ stuckAfterMin: Number.isFinite(raw.stuckAfterMin) ? raw.stuckAfterMin : 30,
3431
+ failedAfterMin: Number.isFinite(raw.failedAfterMin) ? raw.failedAfterMin : 3,
3432
+ };
3433
+ }
3434
+ // numberField 返回 { el, set, reset, get },取 .el 嵌入
3435
+ const numRow = (labelText, hint, value, min, max, commit) => h('label', {
3436
+ class: 'flex shrink-0 items-center gap-1.5', title: hint,
3437
+ }, h('span', { class: 'text-ui-xs text-foreground-subtle' }, labelText),
3438
+ numberField({
3439
+ value, fallback: min, min, max,
3440
+ onCommit: (v) => { commit(v); saveAcSoon(); },
3441
+ }).el);
3442
+ const area = h('textarea', { class: 'zcodepro-textarea zcodepro-textarea-sm', rows: '3', placeholder: L.acPrompt, title: L.acPrompt });
3443
+ area.value = acCfg.continueText || defaultContinueText(); // 空值显示当前语言默认,但保存时仍为空
3444
+ area.addEventListener('input', () => { acCfg.continueText = area.value; saveAcSoon(); });
3445
+
3446
+ const parts = [
3447
+ // 信息卡:一句话简介在左,启用开关右对齐(与自动重命名页同款)
3448
+ h('div', { class: 'mt-3 flex items-center justify-between gap-2 rounded-xl border border-border p-2' },
3449
+ h('span', { class: 'min-w-0 text-ui-sm/relaxed text-foreground-subtle' }, L.acDesc),
3450
+ h('div', { class: 'shrink-0' }, settingRow(L.acEnabled, '', acCfg.enabled !== false, () => {
3451
+ acCfg.enabled = !(acCfg.enabled !== false);
3452
+ saveAcSoon();
3453
+ renderAutoContinue();
3454
+ }))),
3455
+ ];
3456
+ parts.push(
3457
+ h('div', { class: 'mt-3 rounded-xl border border-border p-2' },
3458
+ h('div', { class: 'mb-1 text-ui-xs font-medium text-foreground-subtle' }, L.acPrompt),
3459
+ area),
3460
+ h('div', { class: 'mt-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 rounded-xl border border-border p-2' },
3461
+ numRow(L.acMaxRetries, L.acMaxRetriesHint, acCfg.maxRetries, 1, 50, (v) => { acCfg.maxRetries = v; }),
3462
+ numRow(L.acCooldown, L.acCooldownHint, acCfg.cooldownBaseSec, 0, 600, (v) => { acCfg.cooldownBaseSec = v; }),
3463
+ numRow(L.acStuckAfterMin, L.acStuckAfterMinHint, acCfg.stuckAfterMin, 5, 720, (v) => { acCfg.stuckAfterMin = v; }),
3464
+ numRow(L.acFailedAfterMin, L.acFailedAfterMinHint, acCfg.failedAfterMin, 1, 60, (v) => { acCfg.failedAfterMin = v; })),
3465
+ );
3466
+ paneAutoContinue.replaceChildren(...parts);
3467
+ };
3468
+ void (async () => {
3469
+ acRes = await rpc('/auto-continue');
3470
+ renderAutoContinue();
3471
+ })();
3472
+
3383
3473
  // 一级 / 二级 tab 放到滚动区(body)之上的固定区:内容滚动时标题、
3384
3474
  // 版本行(已并入标题行)与两级 tab 始终可见
3385
3475
  const subTabHost = h('div', { class: 'mt-2' });
@@ -3,12 +3,16 @@
3
3
  // 全局项(今日 / 累计 token、任务总数)优先取官方使用统计(云端,5 分钟刷新),
4
4
  // 回退本地聚合。数据 2 秒刷新一次;上下文占用读官方输入框工具栏的窗口显示
5
5
  //(“已用 497,101 / 总量 1,000,000”),按官方同款格式渲染。
6
- import { t, rpc, getConfig, isZhLocale, DEFAULT_STATUS_ITEMS } from '../core.js';
6
+ import { t, rpc, getConfig, isZhLocale, isCjkLocale, DEFAULT_STATUS_ITEMS } from '../core.js';
7
7
  import { ensureStyle } from '../ui.js';
8
8
 
9
9
  let enabled = true;
10
10
  let items = DEFAULT_STATUS_ITEMS.map((x) => ({ ...x }));
11
11
  let barEl = null;
12
+ let liftedPane = null; // 为状态栏让出底部空间而加过 margin-bottom 的滚动容器
13
+ // 状态栏区域只有输入框下的官方留白时上下一共 3px,太挤:把滚动容器底再抬
14
+ // 10px(输入框随之上移),状态栏上下留白各约 8px
15
+ const BAR_LIFT = 10;
12
16
  let lastStats = null; // /stats/usage 响应缓存(失败保旧值)
13
17
  let lastSid = null; // 上次取数的会话 id:切换会话即作废缓存,不显示上个会话的速率
14
18
  let statsSid = null; // lastStats 取数时的会话 id:渲染时对不上就不用(切会话瞬间不顶旧值)
@@ -63,21 +67,27 @@ function selectedSessionId() {
63
67
 
64
68
  // 官方输入框工具栏的上下文显示:title 形如“上下文已用 61,400 / 总量 1,000,000”,
65
69
  // 解析出已用与总量;读不到返回 null(ctx 项回退按会话记录估算 token 数)。
70
+ // 各语言模板不同:en“Context usage 61,400 of 1,000,000”、ja“コンテキスト使用量
71
+ // 61,400 / 1,000,000”、ko 总量在前“컨텍스트 사용량 1,000,000 중 61,400”、
72
+ // ru“Использование контекста: 61,400 из 1,000,000”。模板只有两个数,按大小
73
+ // 取小的为已用,兼容韩语的倒序。
74
+ function parseCtxTitle(text) {
75
+ if (!/上下文|context|コンテキスト|컨텍스트|контекст/i.test(text)) return null;
76
+ // 数字分隔符跟随 Intl.NumberFormat:en/zh/ja 用逗号,ru/ko 用空格(含 NBSP)
77
+ const nums = [...String(text).matchAll(/\d[\d,\s\u00A0\u202F\u2009']*/g)]
78
+ .map((m) => Number(m[0].replace(/[^\d]/g, '')));
79
+ if (nums.length < 2) return null;
80
+ const used = Math.min(nums[0], nums[1]);
81
+ const size = Math.max(nums[0], nums[1]);
82
+ return used > 0 && size >= used ? { used, size } : null;
83
+ }
84
+
66
85
  // 直接在全文档找(该显示全局唯一),排除自己渲染的 title。
67
86
  // 命中过的元素记下来:每轮全文档扫 [title] 太贵,元素还在就直接读它
68
87
  let ctxEl = null;
69
88
  let ctxMissAt = 0; // 全档扫落空后的时刻:30 秒内不再扫(每 2 秒一轮照扫太贵)
70
89
  function readCtx() {
71
- const parse = (el) => {
72
- const text = el.getAttribute('title') || el.getAttribute('aria-label') || '';
73
- if (!/上下文|context/i.test(text)) return null;
74
- // 格式为“已用 497,101 / 总量 1,000,000”:斜杠后可能带“总量”等文字再接数字
75
- const m = text.match(/([\d][\d,]*)\s*\/[^0-9]*([\d][\d,]*)/);
76
- if (!m) return null;
77
- const used = Number(m[1].replace(/,/g, ''));
78
- const size = Number(m[2].replace(/,/g, ''));
79
- return used > 0 && size > used ? { used, size } : null;
80
- };
90
+ const parse = (el) => parseCtxTitle(el.getAttribute('title') || el.getAttribute('aria-label') || '');
81
91
  if (ctxEl && ctxEl.isConnected) {
82
92
  const hit = parse(ctxEl);
83
93
  if (hit) return hit;
@@ -231,16 +241,15 @@ function itemContent(id, L) {
231
241
  const useEst = streaming && est != null;
232
242
  const shown = useEst ? est : (tps != null ? tps : est);
233
243
  if (shown == null) return null;
234
- const zh = isZhLocale();
235
244
  const estMark = useEst || tps == null ? '≈' : '';
236
245
  const detail = useEst
237
- ? (zh ? '流式生成中,按文本增长估算(约 2 字符/token)' : 'streaming; estimated from text growth (~2 chars/token)')
246
+ ? L.sbTokRateStreaming
238
247
  : tps != null
239
- ? `${L.sbLabelOut} ${tps.toLocaleString()} tok/s${zh ? '(官方净生成口径,本会话树)' : ' (net generation, session tree)'}`
240
- : (zh ? '无 usage 数据,按文本增长估算' : 'no usage data, estimated from text growth');
248
+ ? `${L.sbLabelOut} ${tps.toLocaleString()} tok/s${L.sbTokRateNet}`
249
+ : L.sbTokRateNoData;
241
250
  return {
242
251
  html: sbIcon('tokRate') + label(L.sbLabelOut) + `<b>${estMark}${fmtNum(Math.round(shown * 10) / 10)} tok/s</b>`,
243
- title: `${L.sbItemTokRate}${zh ? '(本会话):' : ' (this session): '}${detail}`,
252
+ title: `${L.sbItemTokRate}${L.sbTokRateSessionSuffix}${detail}`,
244
253
  tone: '',
245
254
  };
246
255
  }
@@ -250,8 +259,8 @@ function itemContent(id, L) {
250
259
  const pct = Math.round((dom.used / dom.size) * 1000) / 10;
251
260
  const tone = pct >= 95 ? 'danger' : pct >= 80 ? 'warn' : '';
252
261
  return {
253
- html: sbIcon('ctx') + label(L.sbLabelCtx) + `<b>${fmtNum(dom.used)}/${fmtNum(dom.size)}${isZhLocale() ? '(' : '('}${pct}%${isZhLocale() ? ')' : ')'}</b>`,
254
- title: `${L.sbItemCtx}${isZhLocale() ? ':' : ': '}${dom.used.toLocaleString()} / ${dom.size.toLocaleString()}`,
262
+ html: sbIcon('ctx') + label(L.sbLabelCtx) + `<b>${fmtNum(dom.used)}/${fmtNum(dom.size)}${isCjkLocale() ? '(' : '('}${pct}%${isCjkLocale() ? ')' : ')'}</b>`,
263
+ title: `${L.sbItemCtx}${isCjkLocale() ? ':' : ': '}${dom.used.toLocaleString()} / ${dom.size.toLocaleString()}`,
255
264
  tone,
256
265
  };
257
266
  }
@@ -266,14 +275,14 @@ function itemContent(id, L) {
266
275
  const s = (lastStats && statsSid === selectedSessionId()) ? lastStats.sessionSummary : null;
267
276
  return s && s.totalIn + s.totalOut > 0 ? {
268
277
  html: sbIcon('inOut') + label(L.sbLabelInOut) + `${fmtNum(s.totalIn)}/${fmtNum(s.totalOut)}`,
269
- title: `${L.sbItemInOut}${isZhLocale() ? ':' : ': '}${s.totalIn.toLocaleString()} / ${s.totalOut.toLocaleString()}`,
278
+ title: `${L.sbItemInOut}${isCjkLocale() ? ':' : ': '}${s.totalIn.toLocaleString()} / ${s.totalOut.toLocaleString()}`,
270
279
  } : null;
271
280
  }
272
281
  case 'avgHit': {
273
282
  const s = (lastStats && statsSid === selectedSessionId()) ? lastStats.sessionSummary : null;
274
283
  return s && s.hitRate != null ? {
275
284
  html: sbIcon('hit') + label(L.sbLabelHit) + `${(s.hitRate * 100).toFixed(2)}%`,
276
- title: `${L.sbItemHit}${isZhLocale() ? ':' : ': '}${(s.hitRate * 100).toFixed(2)}%`,
285
+ title: `${L.sbItemHit}${isCjkLocale() ? ':' : ': '}${(s.hitRate * 100).toFixed(2)}%`,
277
286
  } : null;
278
287
  }
279
288
  case 'todayTokens': {
@@ -293,6 +302,15 @@ function itemContent(id, L) {
293
302
  }
294
303
  }
295
304
 
305
+ // 输入框所在的滚动容器:会话视图里输入框区是 sticky 在聊天滚动容器底部的,
306
+ // 容器下边缘之外的像素会被裁掉。状态栏挤在输入框后面时,滚一下就被裁没。
307
+ function clipPane(el) {
308
+ for (let n = el.parentElement; n && n !== document.body; n = n.parentElement) {
309
+ if (/(auto|scroll|hidden)/.test(getComputedStyle(n).overflowY)) return n;
310
+ }
311
+ return null;
312
+ }
313
+
296
314
  function renderBar() {
297
315
  // 3.16.1 的输入框是 contenteditable(旧版是 textarea),两种都认
298
316
  const ta = composerEl();
@@ -300,23 +318,61 @@ function renderBar() {
300
318
  if (!enabled || !host || !host.parentElement) {
301
319
  if (barEl) barEl.remove();
302
320
  barEl = null;
321
+ if (liftedPane) { liftedPane.style.marginBottom = ''; liftedPane = null; }
303
322
  lastRenderedHtml = null; // 元素没了,去重基线同步清空,重建后首渲染不被跳过
304
323
  return;
305
324
  }
306
- if (!barEl || !barEl.isConnected) {
325
+ // 会话视图:状态栏挪到滚动容器外(容器父级带定位),按输入框的横向位置绝对
326
+ // 定位、贴容器底,滚动裁不到它;新建会话视图没有滚动裁剪,仍在输入框后面排
327
+ // (下方是官方功能按钮区,不能往下压)。
328
+ // 按选中会话判定视图(按钮区与状态条不在同一父容器,兄弟判断不可用)
329
+ const hasSession = !!selectedSessionId();
330
+ const pane = hasSession ? clipPane(host) : null;
331
+ const mount = pane && pane.parentElement && getComputedStyle(pane.parentElement).position !== 'static'
332
+ ? pane.parentElement
333
+ : host.parentElement;
334
+ if (!barEl || !barEl.isConnected || barEl.parentElement !== mount) {
307
335
  if (!barEl) {
308
336
  barEl = document.createElement('div');
309
337
  barEl.className = 'zcodepro-statusbar';
310
338
  lastRenderedHtml = null; // 新元素:内容基线作废
311
339
  }
312
- host.parentElement.insertBefore(barEl, host.nextSibling);
340
+ if (mount === host.parentElement) mount.insertBefore(barEl, host.nextSibling);
341
+ else mount.append(barEl);
342
+ }
343
+ if (mount !== host.parentElement) {
344
+ // 给状态栏让出上下留白:滚动容器底抬 BAR_LIFT,输入框随之上移
345
+ if (liftedPane && liftedPane !== pane) liftedPane.style.marginBottom = '';
346
+ liftedPane = pane;
347
+ liftedPane.style.marginBottom = `${BAR_LIFT}px`;
348
+ const hr = host.getBoundingClientRect();
349
+ const mr = mount.getBoundingClientRect();
350
+ // 横跨输入框底到窗口底,内容垂直居中:上下留白相等
351
+ barEl.style.position = 'absolute';
352
+ // 绝对定位以父级 padding box 为参照,减去边框宽度
353
+ barEl.style.left = `${Math.round(hr.left - mr.left - mount.clientLeft)}px`;
354
+ barEl.style.width = `${Math.round(hr.width)}px`;
355
+ barEl.style.top = `${Math.round(hr.bottom - mr.top - mount.clientTop)}px`;
356
+ // 紧挨窗底(下方只剩几像素留白)才补到窗口底;下方还有终端等面板时只贴
357
+ // 到列底,否则整条会伸进面板区被盖住,只剩上面那截留白
358
+ const below = innerHeight - mr.bottom;
359
+ barEl.style.bottom = `${below >= 0 && below <= 8 ? Math.round(mr.bottom - innerHeight) : 0}px`;
360
+ barEl.style.zIndex = '20';
361
+ barEl.style.marginBottom = '0';
362
+ barEl.style.paddingTop = '0';
363
+ barEl.style.paddingBottom = '0';
364
+ } else {
365
+ if (liftedPane) { liftedPane.style.marginBottom = ''; liftedPane = null; }
366
+ barEl.style.position = '';
367
+ barEl.style.left = '';
368
+ barEl.style.width = '';
369
+ barEl.style.top = '';
370
+ barEl.style.bottom = '';
371
+ barEl.style.zIndex = '';
372
+ barEl.style.paddingTop = '';
373
+ barEl.style.marginBottom = hasSession ? '-14px' : '0';
374
+ barEl.style.paddingBottom = hasSession ? '0' : '7px';
313
375
  }
314
- // 新建会话视图(无选中会话)下方是官方的功能按钮区,不能往下压:上下对称
315
- // 留 7px;普通会话视图下方是窗口底的官方留白,压进去贴底(同为约 7px)。
316
- // 按选中会话判定视图(按钮区与状态条不在同一父容器,兄弟判断不可用)
317
- const hasSession = !!selectedSessionId();
318
- barEl.style.marginBottom = hasSession ? '-14px' : '0';
319
- barEl.style.paddingBottom = hasSession ? '0' : '7px';
320
376
  const L = t();
321
377
  const entries = [];
322
378
  for (const it of items) {