codexmate 0.1.32 → 0.1.34

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.
Files changed (109) hide show
  1. package/README.md +18 -2
  2. package/README.vi.md +18 -2
  3. package/README.zh.md +18 -2
  4. package/cli/claude-proxy.js +2 -2
  5. package/cli/local-bridge.js +10 -6
  6. package/cli/openai-chat-routing.js +38 -0
  7. package/cli/prompt-history.js +2 -0
  8. package/cli/routing-bridge.js +143 -0
  9. package/cli/system-prompt-files.js +75 -53
  10. package/cli.js +325 -215
  11. package/lib/cli-config-engine.js +6 -1
  12. package/lib/cli-file-utils.js +6 -1
  13. package/lib/config-change-fs.js +132 -0
  14. package/lib/config-changes.js +293 -0
  15. package/lib/file-sharing-lan.js +111 -0
  16. package/lib/file-sharing.js +196 -0
  17. package/lib/handoff-mcp.js +18 -2
  18. package/lib/local-feature-store.js +39 -0
  19. package/lib/model-test-client.js +61 -0
  20. package/lib/model-test.js +126 -0
  21. package/lib/routing-groups.js +161 -0
  22. package/lib/session-bookmarks.js +72 -0
  23. package/lib/session-context-health.js +23 -3
  24. package/lib/session-diagnostics.js +75 -0
  25. package/lib/session-feature-settings.js +21 -0
  26. package/lib/session-features.js +63 -0
  27. package/lib/session-handoff-draft.js +43 -0
  28. package/lib/session-projects.js +76 -0
  29. package/lib/session-search-index.js +188 -0
  30. package/lib/thread-handoff.js +8 -0
  31. package/lib/web-server.js +216 -0
  32. package/package.json +1 -1
  33. package/plugins/file-sharing/manifest.mjs +10 -0
  34. package/plugins/file-sharing/methods.mjs +101 -0
  35. package/plugins/file-sharing/overview.mjs +3 -0
  36. package/plugins/file-sharing/ownership.mjs +5 -0
  37. package/plugins/registry.mjs +3 -0
  38. package/web-ui/app.js +22 -3
  39. package/web-ui/index.html +4 -2
  40. package/web-ui/logic.context-window.mjs +15 -0
  41. package/web-ui/modules/api.mjs +72 -39
  42. package/web-ui/modules/app.computed.main-tabs.mjs +3 -0
  43. package/web-ui/modules/app.methods.agents.mjs +17 -0
  44. package/web-ui/modules/app.methods.claude-config.mjs +2 -0
  45. package/web-ui/modules/app.methods.codex-config.mjs +9 -0
  46. package/web-ui/modules/app.methods.config-changes.mjs +124 -0
  47. package/web-ui/modules/app.methods.install.mjs +23 -3
  48. package/web-ui/modules/app.methods.kilocode-config.mjs +2 -0
  49. package/web-ui/modules/app.methods.navigation.mjs +2 -0
  50. package/web-ui/modules/app.methods.openclaw-persist.mjs +2 -0
  51. package/web-ui/modules/app.methods.opencode-config.mjs +2 -0
  52. package/web-ui/modules/app.methods.pi-config.mjs +12 -3
  53. package/web-ui/modules/app.methods.prompts-editor.mjs +7 -4
  54. package/web-ui/modules/app.methods.provider-cache.mjs +9 -3
  55. package/web-ui/modules/app.methods.providers.mjs +6 -0
  56. package/web-ui/modules/app.methods.session-actions.mjs +2 -2
  57. package/web-ui/modules/app.methods.startup-claude.mjs +8 -47
  58. package/web-ui/modules/app.methods.system-prompt.mjs +88 -17
  59. package/web-ui/modules/app.methods.theme.mjs +4 -3
  60. package/web-ui/modules/app.methods.web-ui-preferences.mjs +7 -0
  61. package/web-ui/modules/config-change-actions.mjs +9 -0
  62. package/web-ui/modules/i18n/locales/en.mjs +254 -8
  63. package/web-ui/modules/i18n/locales/ja.mjs +254 -8
  64. package/web-ui/modules/i18n/locales/vi.mjs +254 -8
  65. package/web-ui/modules/i18n/locales/zh-tw.mjs +254 -8
  66. package/web-ui/modules/i18n/locales/zh.mjs +254 -8
  67. package/web-ui/modules/model-test.mjs +82 -0
  68. package/web-ui/modules/plugins.methods.mjs +3 -1
  69. package/web-ui/modules/prompt-ecosystem.methods.mjs +4 -3
  70. package/web-ui/modules/request-deadline.mjs +33 -0
  71. package/web-ui/modules/routing.mjs +206 -0
  72. package/web-ui/modules/session-features.mjs +279 -0
  73. package/web-ui/modules/thread-handoff.mjs +1 -1
  74. package/web-ui/partials/index/config-changes.html +25 -0
  75. package/web-ui/partials/index/context-window-reference.html +17 -0
  76. package/web-ui/partials/index/layout-header.html +40 -42
  77. package/web-ui/partials/index/modal-openclaw-config.html +0 -2
  78. package/web-ui/partials/index/modal-skills.html +0 -1
  79. package/web-ui/partials/index/modals-basic.html +15 -8
  80. package/web-ui/partials/index/modals-pi-provider.html +0 -1
  81. package/web-ui/partials/index/panel-config-codex.html +0 -3
  82. package/web-ui/partials/index/panel-config-openclaw.html +16 -13
  83. package/web-ui/partials/index/panel-dashboard.html +0 -2
  84. package/web-ui/partials/index/panel-plugins.html +3 -10
  85. package/web-ui/partials/index/panel-prompts.html +13 -8
  86. package/web-ui/partials/index/panel-routing.html +3 -0
  87. package/web-ui/partials/index/panel-sessions.html +9 -0
  88. package/web-ui/partials/index/panel-settings.html +12 -13
  89. package/web-ui/partials/index/panel-trash.html +0 -1
  90. package/web-ui/partials/index/plugin-file-sharing.html +47 -0
  91. package/web-ui/partials/index/routing-model-test.html +53 -0
  92. package/web-ui/partials/index/session-diagnostics.html +32 -0
  93. package/web-ui/partials/index/session-features.html +107 -0
  94. package/web-ui/partials/index/thread-handoff.html +6 -3
  95. package/web-ui/res/web-ui-render.precompiled.js +1689 -246
  96. package/web-ui/styles/base-theme.css +1 -1
  97. package/web-ui/styles/config-changes.css +30 -0
  98. package/web-ui/styles/modals-core.css +6 -5
  99. package/web-ui/styles/navigation-panels.css +4 -0
  100. package/web-ui/styles/openclaw-structured.css +205 -189
  101. package/web-ui/styles/plugins-panel.css +40 -1
  102. package/web-ui/styles/responsive.css +10 -5
  103. package/web-ui/styles/routing.css +78 -0
  104. package/web-ui/styles/session-features.css +258 -0
  105. package/web-ui/styles/settings-panel.css +30 -0
  106. package/web-ui/styles/system-prompt.css +8 -7
  107. package/web-ui/styles/theme-violet-tokens.css +52 -0
  108. package/web-ui/styles/theme-violet.css +1736 -0
  109. package/web-ui/styles.css +5 -1
@@ -3,6 +3,7 @@ export function createMainTabsComputed() {
3
3
  mainTabKicker() {
4
4
  if (this.mainTab === 'dashboard') return this.t('kicker.dashboard');
5
5
  if (this.mainTab === 'config') return this.t('kicker.config');
6
+ if (this.mainTab === 'routing') return '';
6
7
  if (this.mainTab === 'sessions') return this.t('kicker.sessions');
7
8
  if (this.mainTab === 'usage') return this.t('kicker.usage');
8
9
  if (this.mainTab === 'market') return this.t('kicker.market');
@@ -15,6 +16,7 @@ export function createMainTabsComputed() {
15
16
  mainTabTitle() {
16
17
  if (this.mainTab === 'dashboard') return this.t('title.dashboard');
17
18
  if (this.mainTab === 'config') return this.t('title.config');
19
+ if (this.mainTab === 'routing') return this.t('title.routing');
18
20
  if (this.mainTab === 'sessions') return this.t('title.sessions');
19
21
  if (this.mainTab === 'usage') return this.t('title.usage');
20
22
  if (this.mainTab === 'market') return this.t('title.market');
@@ -27,6 +29,7 @@ export function createMainTabsComputed() {
27
29
  mainTabSubtitle() {
28
30
  if (this.mainTab === 'dashboard') return this.t('subtitle.dashboard');
29
31
  if (this.mainTab === 'config') return this.t('subtitle.config');
32
+ if (this.mainTab === 'routing') return '';
30
33
  if (this.mainTab === 'sessions') return this.t('subtitle.sessions');
31
34
  if (this.mainTab === 'usage') return this.t('subtitle.usage');
32
35
  if (this.mainTab === 'market') return this.t('subtitle.market');
@@ -285,9 +285,24 @@ export function createAgentsMethods(options = {}) {
285
285
  }
286
286
  },
287
287
  handleGlobalKeydown(event) {
288
+ if (this.configChangePreview) {
289
+ if (event.key === 'Escape') { event.preventDefault(); this.closeConfigChangePreview(); }
290
+ else if (event.key === 'Tab') this.trapModalFocus(event);
291
+ return;
292
+ }
288
293
  if (!event) {
289
294
  return;
290
295
  }
296
+ if (this.showAppUpdateModal && !this.showConfirmDialog) {
297
+ if (event.key === 'Escape') {
298
+ event.preventDefault();
299
+ event.stopPropagation();
300
+ this.closeAppUpdateModal();
301
+ } else if (event.key === 'Tab') {
302
+ this.trapModalFocus(event);
303
+ }
304
+ return;
305
+ }
291
306
  const isCmdLike = !!(event.metaKey || event.ctrlKey);
292
307
  const key = typeof event.key === 'string' ? event.key : '';
293
308
  const isSearchHotkey = isCmdLike && !event.altKey && (key === 'k' || key === 'K');
@@ -1075,6 +1090,8 @@ export function createAgentsMethods(options = {}) {
1075
1090
  loadPromptsTabContent() {
1076
1091
  if (typeof this.loadPromptsPathReferences === "function") this.loadPromptsPathReferences();
1077
1092
  if (this.promptsSubTab === 'system') {
1093
+ if (typeof this.loadSystemPromptFiles === 'function') this.loadSystemPromptFiles();
1094
+ if (this.sysPromptLoading || this.sysPromptSaving || this.sysPromptDiffVisible || this.hasSysPromptContentChanged()) return;
1078
1095
  if (typeof this.loadSystemPrompt === 'function') this.loadSystemPrompt();
1079
1096
  } else {
1080
1097
  if (this.promptsSubTab === 'claude-project' && !this.projectPathOptions.length && !this.projectPathOptionsLoading && typeof this.loadProjectPathOptions === 'function') {
@@ -391,6 +391,7 @@ export function createClaudeConfigMethods(options = {}) {
391
391
  const _claudeKey = `${name}|${config.apiKey || ""}|${config.providerCacheRef || ""}|${config.baseUrl || ""}|${config.model || ""}|${config.targetApi || "responses"}`;
392
392
  try {
393
393
  const res = await api('apply-claude-config', { config: { ...config, name } });
394
+ if (res && res.canceled) return;
394
395
  if (res.error || res.success === false) {
395
396
  this.showMessage(res.error || this.t('toast.apply.fail'), 'error');
396
397
  } else {
@@ -512,6 +513,7 @@ export function createClaudeConfigMethods(options = {}) {
512
513
  const _claudeKey2 = `${name}|${config.apiKey || ""}|${config.providerCacheRef || ""}|${config.baseUrl || ""}|${config.model || ""}|${config.targetApi || "responses"}`;
513
514
  try {
514
515
  const res = await api('apply-claude-config', { config: { ...config, name } });
516
+ if (res && res.canceled) return;
515
517
  if (res.error || res.success === false) {
516
518
  if (!silentError) this.showMessage(res.error || this.t('toast.apply.fail'), 'error');
517
519
  return false;
@@ -636,6 +636,7 @@ export function createCodexConfigMethods(options = {}) {
636
636
 
637
637
  for (const item of codexItems) {
638
638
  const res = await api('delete-provider', { name: item.name });
639
+ if (res && res.canceled) return;
639
640
  if (res && res.error) {
640
641
  throw new Error(res.error);
641
642
  }
@@ -861,6 +862,7 @@ export function createCodexConfigMethods(options = {}) {
861
862
  const applyRes = await api('apply-config-template', {
862
863
  template: tplRes.template
863
864
  });
865
+ if (applyRes && applyRes.canceled) return;
864
866
  if (applyRes.error) {
865
867
  this.showMessage(
866
868
  (typeof applyRes.error === 'string' && applyRes.error.trim())
@@ -1048,10 +1050,12 @@ export function createCodexConfigMethods(options = {}) {
1048
1050
  res = await api('apply-claude-settings-raw', {
1049
1051
  content: this.configTemplateContent
1050
1052
  });
1053
+ if (res && res.canceled) return;
1051
1054
  } else {
1052
1055
  res = await api('apply-config-template', {
1053
1056
  template: this.configTemplateContent
1054
1057
  });
1058
+ if (res && res.canceled) return;
1055
1059
  }
1056
1060
  if (res.error) {
1057
1061
  this.showMessage(res.error, 'error');
@@ -1071,6 +1075,11 @@ export function createCodexConfigMethods(options = {}) {
1071
1075
  }
1072
1076
  };
1073
1077
 
1078
+ if (this._configChangeApiHandler) {
1079
+ await performApply();
1080
+ return;
1081
+ }
1082
+
1074
1083
  // One-step mode: apply immediately unless user explicitly entered the diff preview state.
1075
1084
  if (!shouldUseTwoStepConfirm && !this.configTemplateDiffVisible) {
1076
1085
  await performApply();
@@ -0,0 +1,124 @@
1
+ import { CONFIG_CHANGE_ACTIONS } from './config-change-actions.mjs';
2
+ import { api, setConfigChangeHandler, getConfigChangeBaseline } from './api.mjs';
3
+
4
+ export const configChangeMixin = {
5
+ methods: createConfigChangeMethods(),
6
+ data() {
7
+ return { configChangePreview: null, configChangeBusy: false, configChangeApplying: false, configChangeError: '', lastConfigChange: null };
8
+ }
9
+ };
10
+
11
+ export function createConfigChangeMethods() {
12
+ return {
13
+ installConfigChangePreview() {
14
+ this._configChangeApiHandler = (action, params) => this.requestConfigChange(action, params);
15
+ setConfigChangeHandler(this._configChangeApiHandler);
16
+ this.refreshLastConfigChange();
17
+ },
18
+ uninstallConfigChangePreview() {
19
+ setConfigChangeHandler(null, this._configChangeApiHandler);
20
+ this.closeConfigChangePreview({ force: true });
21
+ },
22
+ async requestConfigChange(action, params) {
23
+ if (this.configChangePreview || this.configChangeBusy) return { error: this.t('changes.busy'), success: false };
24
+ this.configChangeBusy = true;
25
+ try {
26
+ const preview = await api('preview-config-change', { action, params, baseline: getConfigChangeBaseline(CONFIG_CHANGE_ACTIONS[action]) });
27
+ if (preview.error) return { ...preview, error: this.configChangeErrorText(preview) };
28
+ if (!preview.hasChanges || this.configTemplateDiffConfirmEnabled === false) {
29
+ const result = await api('apply-config-change', { previewId: preview.previewId });
30
+ if (!result.error) await this.refreshLastConfigChange();
31
+ return result.error ? { ...result, error: this.configChangeErrorText(result) } : result;
32
+ }
33
+ this._configChangeReturnFocus = typeof document !== 'undefined' ? document.activeElement : null;
34
+ this.configChangePreview = preview;
35
+ this.configChangeError = '';
36
+ const pending = new Promise(resolve => { this._configChangeResolve = resolve; });
37
+ if (typeof this.$nextTick === 'function') this.$nextTick(() => this.$refs.configChangeCancel && this.$refs.configChangeCancel.focus());
38
+ return await pending;
39
+ } finally { this.configChangeBusy = false; }
40
+ },
41
+ configChangeErrorText(result) {
42
+ const key = `changes.error.${result.errorCode || ''}`;
43
+ const translated = this.t(key);
44
+ return translated === key ? this.t('changes.failed') : translated;
45
+ },
46
+ closeConfigChangePreview({ force = false } = {}) {
47
+ if (this.configChangeApplying && !force) return;
48
+ const resolve = this._configChangeResolve;
49
+ this._configChangeResolve = null;
50
+ this.configChangePreview = null;
51
+ this.configChangeError = '';
52
+ if (resolve) resolve({ canceled: true, success: false, error: this.t('changes.cancelled') });
53
+ const focus = this._configChangeReturnFocus;
54
+ this._configChangeReturnFocus = null;
55
+ if (focus && typeof focus.focus === 'function') focus.focus();
56
+ },
57
+ async confirmConfigChange() {
58
+ if (!this.configChangePreview || this.configChangeApplying) return;
59
+ this.configChangeApplying = true;
60
+ try {
61
+ const result = await api('apply-config-change', { previewId: this.configChangePreview.previewId });
62
+ if (result.error) {
63
+ this.configChangeError = this.configChangeErrorText(result);
64
+ if (result.rollbackFailed && result.rollbackFailed.length) this.configChangeError += ' ' + this.t('changes.restoreFailed', { paths: result.rollbackFailed.join(', ') });
65
+ return;
66
+ }
67
+ const resolve = this._configChangeResolve;
68
+ this._configChangeResolve = null;
69
+ this.closeConfigChangePreview({ force: true });
70
+ if (resolve) resolve(result);
71
+ await this.refreshLastConfigChange();
72
+ } catch (_) {
73
+ this.configChangeError = this.t('changes.failed');
74
+ } finally { this.configChangeApplying = false; }
75
+ },
76
+ async refreshLastConfigChange() {
77
+ const target = this.configMode;
78
+ try {
79
+ const result = await api('get-last-config-change', { target });
80
+ if (this.configMode === target) this.lastConfigChange = result.change || null;
81
+ } catch (_) {
82
+ if (this.configMode === target) this.lastConfigChange = null;
83
+ }
84
+ },
85
+ async undoLastConfigChange() {
86
+ const change = this.lastConfigChange;
87
+ if (!change || this.configChangeBusy || this.configChangeApplying || !this.isToolConfigWriteAllowed(change.target)) return;
88
+ const confirmed = await this.requestConfirmDialog({
89
+ title: this.t('changes.undo'), message: this.t('changes.undoConfirm', { paths: change.files.map(file => file.path).join('\n') }),
90
+ confirmText: this.t('changes.undo'), cancelText: this.t('common.cancel'), danger: true
91
+ });
92
+ if (!confirmed) return;
93
+ this.configChangeBusy = true;
94
+ try {
95
+ const result = await api('undo-config-change', { target: change.target, changeId: change.id });
96
+ if (result.error) {
97
+ let message = this.configChangeErrorText(result);
98
+ if (result.rollbackFailed && result.rollbackFailed.length) message += ' ' + this.t('changes.restoreFailed', { paths: result.rollbackFailed.join(', ') });
99
+ this.showMessage(message, 'error');
100
+ return;
101
+ }
102
+ this.showMessage(this.t('changes.undone'), 'success');
103
+ await this.refreshLastConfigChange();
104
+ if (change.target === 'codex' || change.target === 'claude') await this.loadAll();
105
+ if (change.target === 'claude') this._lastAppliedClaudeKey = '';
106
+ if (change.target === 'openclaw') await this.syncDefaultOpenclawConfigEntry();
107
+ if (change.target === 'opencode') await this.loadOpencodeConfig();
108
+ if (change.target === 'kilocode') await this.loadKilocodeConfig();
109
+ if (change.target === 'pi') await this.loadPiSources();
110
+ } catch (_) { this.showMessage(this.t('changes.refreshFailed'), 'error'); }
111
+ finally { this.configChangeBusy = false; }
112
+ },
113
+ handleConfigChangeKeydown(event) {
114
+ if (event.key === 'Escape') { event.stopPropagation(); this.closeConfigChangePreview(); return; }
115
+ if (event.key !== 'Tab') return;
116
+ event.stopPropagation();
117
+ const items = [...event.currentTarget.querySelectorAll('button:not(:disabled), [tabindex="0"]')];
118
+ const first = items[0];
119
+ const last = items[items.length - 1];
120
+ if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); }
121
+ else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); }
122
+ }
123
+ };
124
+ }
@@ -1,3 +1,5 @@
1
+ const APP_UPDATE_COMMAND = 'codexmate update';
2
+
1
3
  export function createInstallMethods(options = {}) {
2
4
  const { api } = options;
3
5
  return {
@@ -91,14 +93,32 @@ export function createInstallMethods(options = {}) {
91
93
  return suffix ? `${meta} · ${suffix}` : meta;
92
94
  },
93
95
 
94
- handleAppVersionStatusClick() {
95
- if (this.isAppUpdateAvailable()) {
96
- this.openAppUpdateDocs();
96
+ handleAppVersionStatusClick(event) {
97
+ if (this.appVersionStatusLoading) return;
98
+ if (!this.appVersionStatusError && this.isAppUpdateAvailable()) {
99
+ this.openAppUpdateModal(event?.currentTarget);
97
100
  return;
98
101
  }
99
102
  void this.loadAppVersionStatus({ silent: false, force: true });
100
103
  },
101
104
 
105
+ appUpdateCommand() {
106
+ return APP_UPDATE_COMMAND;
107
+ },
108
+
109
+ openAppUpdateModal(trigger) {
110
+ this._appUpdateTrigger = trigger || document.activeElement;
111
+ this.showAppUpdateModal = true;
112
+ this.$nextTick(() => document.getElementById('app-update-command')?.focus());
113
+ },
114
+
115
+ closeAppUpdateModal() {
116
+ const trigger = this._appUpdateTrigger;
117
+ this._appUpdateTrigger = null;
118
+ this.showAppUpdateModal = false;
119
+ this.$nextTick(() => trigger?.focus());
120
+ },
121
+
102
122
  async loadAppVersionStatus(options = {}) {
103
123
  if (typeof api !== 'function') return false;
104
124
  if (this.appVersionStatusLoading) return false;
@@ -109,6 +109,7 @@ export function createKilocodeConfigMethods(options = {}) {
109
109
  this.kilocodeError = '';
110
110
  try {
111
111
  const res = await api('apply-kilocode-config', { provider, url, model, apiKey });
112
+ if (res && res.canceled) return;
112
113
  if (res && res.error) {
113
114
  this.kilocodeError = res.error;
114
115
  this.showMessage(res.error, 'error');
@@ -145,6 +146,7 @@ export function createKilocodeConfigMethods(options = {}) {
145
146
  apiKey: this.kilocodeApiKey
146
147
  } : {};
147
148
  const res = await api('start-kilocode', payload);
149
+ if (res && res.canceled) return;
148
150
  if (res && res.error) {
149
151
  this.kilocodeError = res.error;
150
152
  this.showMessage(res.error, 'error');
@@ -7,6 +7,7 @@
7
7
  const MAIN_TAB_ORDER = [
8
8
  'dashboard',
9
9
  'config',
10
+ 'routing',
10
11
  'sessions',
11
12
  'usage',
12
13
  'market',
@@ -120,6 +121,7 @@
120
121
  settingsTab: settingsTab === 'data' ? 'data' : 'general',
121
122
  mainTab: resolveSelectableMainTab(mainTab),
122
123
  configMode: configModeSet && configModeSet.has(configMode) ? configMode : 'codex',
124
+ modelTestTarget: vm.modelTestTarget === 'pi' ? 'pi' : 'codex',
123
125
  skillsTargetApp,
124
126
  promptTemplatesMode,
125
127
  pluginsActiveId: pluginsActiveId || 'prompt-templates'
@@ -294,6 +294,7 @@ export function createOpenclawPersistMethods(options = {}) {
294
294
  lineEnding: this.openclawLineEnding,
295
295
  authProfileUpdates: Object.values(this.openclawPendingAuthProfileUpdates || {})
296
296
  });
297
+ if (res && res.canceled) return;
297
298
  if (res.error || res.success === false) {
298
299
  this.showMessage(res.error || '应用配置失败', 'error');
299
300
  return;
@@ -352,6 +353,7 @@ export function createOpenclawPersistMethods(options = {}) {
352
353
  lineEnding: this.openclawLineEnding,
353
354
  authProfileUpdates: Object.values(this.openclawPendingAuthProfileUpdates || {})
354
355
  });
356
+ if (res && res.canceled) return;
355
357
  if (res.error || res.success === false) {
356
358
  this.showMessage(res.error || '应用配置失败', 'error');
357
359
  } else {
@@ -160,6 +160,7 @@ export function createOpencodeConfigMethods(options = {}) {
160
160
  this.opencodeError = '';
161
161
  try {
162
162
  const res = await api('apply-opencode-config', { content: this.opencodeContent });
163
+ if (res && res.canceled) return;
163
164
  if (res && res.error) {
164
165
  this.opencodeError = res.error;
165
166
  this.showMessage(res.error, 'error');
@@ -205,6 +206,7 @@ export function createOpencodeConfigMethods(options = {}) {
205
206
  maxTokens: this.opencodeMaxTokens,
206
207
  reasoningEffort: this.opencodeReasoningEffort
207
208
  });
209
+ if (res && res.canceled) return;
208
210
  if (res && res.error) {
209
211
  this.opencodeError = res.error;
210
212
  this.showMessage(res.error, 'error');
@@ -58,6 +58,7 @@ export function createPiConfigMethods({ api: apiClient }) {
58
58
  else updates.defaultModel = '';
59
59
  try {
60
60
  const result = await apiClient('write-pi-settings', updates);
61
+ if (result && result.canceled) return;
61
62
  if (result && result.error) throw new Error(result.error);
62
63
  await this.loadPiSettings();
63
64
  this.message = '已切换为使用该供应商';
@@ -75,7 +76,8 @@ export function createPiConfigMethods({ api: apiClient }) {
75
76
  const existing = providers[providerId] || {};
76
77
  const updated = { ...providers };
77
78
  delete updated[providerId];
78
- await this.savePiProviders(updated);
79
+ const result = await this.savePiProviders(updated);
80
+ if (result && (result.canceled || result.error)) return result;
79
81
  return { success: true, provider: existing };
80
82
  },
81
83
  async persistPiProvider(providerId, values) {
@@ -137,7 +139,9 @@ export function createPiConfigMethods({ api: apiClient }) {
137
139
  merged.id = providerId;
138
140
  if (merged.name === undefined) merged.name = providerId;
139
141
  }
140
- await this.persistPiProvider(providerId, merged);
142
+ const result = await this.persistPiProvider(providerId, merged);
143
+ if (result && result.canceled) return;
144
+ if (result && result.error) throw new Error(result.error);
141
145
  this.piProviders = { ...this.piProviders, [providerId]: merged };
142
146
  this.piProviderIds = Object.keys(this.piProviders).sort();
143
147
  this.resetPiProviderEditing();
@@ -421,7 +425,9 @@ export function createPiConfigMethods({ api: apiClient }) {
421
425
  danger: true
422
426
  });
423
427
  if (!confirmed) return;
424
- await this.removePiProvider(providerId);
428
+ const result = await this.removePiProvider(providerId);
429
+ if (result && result.canceled) return;
430
+ if (result && result.error) { this.message = result.error; this.messageType = 'error'; return; }
425
431
  const updated = { ...this.piProviders };
426
432
  delete updated[providerId];
427
433
  this.piProviders = updated;
@@ -486,6 +492,7 @@ export function createPiConfigMethods({ api: apiClient }) {
486
492
  this.piFileJsonSaving = true;
487
493
  try {
488
494
  const result = await apiClient('write-pi-settings', { settings: parsed.value });
495
+ if (result && result.canceled) return;
489
496
  if (result && result.error) throw new Error(result.error);
490
497
  this.piSettingsJsonError = '';
491
498
  this.piSettingsJsonDraft = JSON.stringify(parsed.value, null, 2);
@@ -511,6 +518,7 @@ export function createPiConfigMethods({ api: apiClient }) {
511
518
  this.piFileJsonSaving = true;
512
519
  try {
513
520
  const result = await apiClient('write-pi-models', { file: parsed.value });
521
+ if (result && result.canceled) return;
514
522
  if (result && result.error) throw new Error(result.error);
515
523
  await this.loadPiSources();
516
524
  this.message = 'models.json 已保存';
@@ -640,6 +648,7 @@ export function createPiConfigMethods({ api: apiClient }) {
640
648
  this.piHistoryApplying = true;
641
649
  try {
642
650
  const res = await api('apply-pi-config-history', { target: this.piHistoryTarget, id: this.piHistoryPreviewId });
651
+ if (res && res.canceled) return;
643
652
  if (res && res.error) {
644
653
  this.showMessage(res.error, 'error');
645
654
  return;
@@ -204,7 +204,7 @@ export function createPromptsEditorMethods(options = {}) {
204
204
  (this.projectClaudeMdPath || '').trim(),
205
205
  this.sysPromptScope || 'global',
206
206
  this.sysPromptMode || 'system'
207
- ].join('|');
207
+ ].concat(this.sysPromptFileName ? [this.sysPromptFileName] : []).join('|');
208
208
  },
209
209
 
210
210
  // Lazy loader for the path-reference dropdown. Fetches the OTHER tabs'
@@ -220,7 +220,7 @@ export function createPromptsEditorMethods(options = {}) {
220
220
  if (this.promptsPathReferenceCacheKey === cacheKey && !this.promptsPathReferenceLoading) {
221
221
  return Promise.resolve();
222
222
  }
223
- if (this.promptsPathReferenceLoading && this._promptsPathReferencePromise) {
223
+ if (this.promptsPathReferenceLoading && this._promptsPathReferencePromise && this.promptsPathReferenceCacheKey === cacheKey) {
224
224
  return this._promptsPathReferencePromise;
225
225
  }
226
226
  if (typeof api !== 'function') {
@@ -245,6 +245,7 @@ export function createPromptsEditorMethods(options = {}) {
245
245
  }
246
246
  };
247
247
  this.promptsPathReferenceLoading = true;
248
+ this.promptsPathReferenceCacheKey = cacheKey;
248
249
  const promise = Promise.all([
249
250
  fetchEntry('get-agents-file', { metaOnly: true }),
250
251
  fetchEntry('get-opencode-agents-file', { metaOnly: true }),
@@ -252,8 +253,9 @@ export function createPromptsEditorMethods(options = {}) {
252
253
  projectPath
253
254
  ? fetchEntry('get-claude-md-file', { baseDir: projectPath, metaOnly: true })
254
255
  : Promise.resolve(null),
255
- fetchEntry('get-system-prompt', { scope, mode })
256
+ fetchEntry('get-system-prompt', { scope, mode, ...(this.sysPromptFileName ? { fileName: this.sysPromptFileName } : {}) })
256
257
  ]).then((results) => {
258
+ if (cacheKey !== this.buildPromptsPathReferenceCacheKey()) return;
257
259
  this.promptsPathReferencePaths = {
258
260
  codex: results[0],
259
261
  opencode: results[1],
@@ -263,6 +265,7 @@ export function createPromptsEditorMethods(options = {}) {
263
265
  };
264
266
  this.promptsPathReferenceCacheKey = cacheKey;
265
267
  }).finally(() => {
268
+ if (this._promptsPathReferencePromise !== promise) return;
266
269
  this.promptsPathReferenceLoading = false;
267
270
  this._promptsPathReferencePromise = null;
268
271
  });
@@ -275,7 +278,7 @@ export function createPromptsEditorMethods(options = {}) {
275
278
  currentTab: this.promptsSubTab,
276
279
  paths: this.promptsPathReferencePaths || {},
277
280
  t: (key, params) => (typeof this.t === 'function' ? this.t(key, params) : key),
278
- systemFile: (this.sysPromptMode || 'system') === 'append' ? 'APPEND_SYSTEM.md' : 'SYSTEM.md'
281
+ systemFile: this.sysPromptFileName || ((this.sysPromptMode || 'system') === 'append' ? 'APPEND_SYSTEM.md' : 'SYSTEM.md')
279
282
  });
280
283
  },
281
284
 
@@ -1,5 +1,7 @@
1
+ import { withRequestDeadline } from './request-deadline.mjs';
2
+
1
3
  export function createProviderCacheMethods(options = {}) {
2
- const { api } = options;
4
+ const { api, cacheLoadTimeoutMs = 6000 } = options;
3
5
 
4
6
  return {
5
7
  async openProviderCacheModal(options = {}) {
@@ -41,7 +43,10 @@ export function createProviderCacheMethods(options = {}) {
41
43
  }
42
44
  this.providerCacheError = '';
43
45
  try {
44
- const res = await api('get-provider-cache-records');
46
+ const res = await withRequestDeadline(
47
+ signal => api('get-provider-cache-records', {}, { signal }),
48
+ { timeoutMs: cacheLoadTimeoutMs }
49
+ );
45
50
  if (!isLatestRequest()) return;
46
51
  if (res && res.error) {
47
52
  this.providerCacheError = res.error;
@@ -52,7 +57,8 @@ export function createProviderCacheMethods(options = {}) {
52
57
  this.providerCacheLoadedAt = this.providerCacheRecords.generatedAt || new Date().toISOString();
53
58
  } catch (e) {
54
59
  if (!isLatestRequest()) return;
55
- this.providerCacheError = e && e.message ? e.message : this.t('modal.providerCache.loadFailed');
60
+ this.providerCacheError = e && e.message && e.name !== 'TimeoutError'
61
+ ? e.message : this.t('modal.providerCache.loadFailed');
56
62
  } finally {
57
63
  if (isLatestRequest() && !background) {
58
64
  this.providerCacheLoading = false;
@@ -189,6 +189,7 @@ export function createProvidersMethods(options = {}) {
189
189
  }
190
190
  const suggestedModel = validation.model;
191
191
  const res = await api('add-provider', payload);
192
+ if (res && res.canceled) return;
192
193
  if (res.error) {
193
194
  this.showMessage(res.error, 'error');
194
195
  return;
@@ -284,6 +285,7 @@ export function createProvidersMethods(options = {}) {
284
285
  }
285
286
  try {
286
287
  const res = await api('delete-provider', { name });
288
+ if (res && res.canceled) return;
287
289
  if (res.error) {
288
290
  this.showMessage(res.error, 'error');
289
291
  return;
@@ -438,6 +440,7 @@ export function createProvidersMethods(options = {}) {
438
440
  }
439
441
  try {
440
442
  const res = await api('update-provider', params);
443
+ if (res && res.canceled) return;
441
444
  if (res.error) {
442
445
  this.showMessage(res.error, 'error');
443
446
  return;
@@ -490,6 +493,7 @@ export function createProvidersMethods(options = {}) {
490
493
  this.resetConfigLoading = true;
491
494
  try {
492
495
  const res = await api('reset-config');
496
+ if (res && res.canceled) return;
493
497
  if (res.error) {
494
498
  this.showMessage(res.error, 'error');
495
499
  return;
@@ -511,6 +515,7 @@ export function createProvidersMethods(options = {}) {
511
515
  try {
512
516
  const modelName = this.newModelName.trim();
513
517
  const res = await api('add-model', { model: modelName });
518
+ if (res && res.canceled) return;
514
519
  if (res.error) {
515
520
  this.showMessage(res.error, 'error');
516
521
  } else {
@@ -538,6 +543,7 @@ export function createProvidersMethods(options = {}) {
538
543
  async removeModel(model) {
539
544
  try {
540
545
  const res = await api('delete-model', { model });
546
+ if (res && res.canceled) return;
541
547
  if (res.error) {
542
548
  this.showMessage(res.error, 'error');
543
549
  } else {
@@ -539,13 +539,13 @@ export function createSessionActionMethods(options = {}) {
539
539
  try {
540
540
  if (navigator.clipboard && window.isSecureContext) {
541
541
  await navigator.clipboard.writeText(text);
542
- this.showMessage('已复制命令', 'success');
542
+ this.showMessage(this.t('toast.copy.ok'), 'success');
543
543
  return;
544
544
  }
545
545
  } catch (_) {}
546
546
  const ok = this.fallbackCopyText(text);
547
547
  if (ok) {
548
- this.showMessage('已复制命令', 'success');
548
+ this.showMessage(this.t('toast.copy.ok'), 'success');
549
549
  return;
550
550
  }
551
551
  this.showMessage(this.t('toast.copy.fail'), 'error');