codexmate 0.1.33 → 0.1.35

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 (91) hide show
  1. package/README.md +27 -2
  2. package/README.vi.md +27 -2
  3. package/README.zh.md +27 -2
  4. package/cli/analytics-export-args.js +7 -0
  5. package/cli/local-bridge.js +10 -6
  6. package/cli/openai-chat-routing.js +38 -0
  7. package/cli/routing-bridge.js +143 -0
  8. package/cli/session-usage.js +4 -1
  9. package/cli/system-prompt-files.js +75 -53
  10. package/cli.js +191 -9
  11. package/lib/data/model-prices.json +1868 -0
  12. package/lib/file-sharing-lan.js +111 -0
  13. package/lib/file-sharing.js +196 -0
  14. package/lib/model-test-client.js +61 -0
  15. package/lib/model-test.js +126 -0
  16. package/lib/routing-groups.js +161 -0
  17. package/lib/session-context-health.js +5 -1
  18. package/lib/session-evidence-collections.js +85 -0
  19. package/lib/session-features.js +15 -0
  20. package/lib/session-project-git.js +65 -0
  21. package/lib/session-projects.js +12 -1
  22. package/lib/session-stories.js +67 -0
  23. package/lib/session-usage-ledger.js +77 -0
  24. package/lib/session-usage-pricing.js +42 -0
  25. package/lib/session-usage-report.js +101 -0
  26. package/package.json +4 -1
  27. package/plugins/file-sharing/manifest.mjs +10 -0
  28. package/plugins/file-sharing/methods.mjs +101 -0
  29. package/plugins/file-sharing/overview.mjs +3 -0
  30. package/plugins/file-sharing/ownership.mjs +5 -0
  31. package/plugins/prompt-templates/computed.mjs +9 -0
  32. package/plugins/registry.mjs +3 -0
  33. package/web-ui/app.js +25 -2
  34. package/web-ui/index.html +3 -2
  35. package/web-ui/logic.session-artifacts.mjs +39 -0
  36. package/web-ui/modules/app.computed.main-tabs.mjs +3 -0
  37. package/web-ui/modules/app.methods.agents.mjs +14 -1
  38. package/web-ui/modules/app.methods.install.mjs +23 -3
  39. package/web-ui/modules/app.methods.navigation.mjs +2 -0
  40. package/web-ui/modules/app.methods.prompts-editor.mjs +7 -4
  41. package/web-ui/modules/app.methods.session-actions.mjs +2 -2
  42. package/web-ui/modules/app.methods.session-browser.mjs +35 -0
  43. package/web-ui/modules/app.methods.system-prompt.mjs +99 -19
  44. package/web-ui/modules/app.methods.theme.mjs +4 -3
  45. package/web-ui/modules/app.methods.web-ui-preferences.mjs +12 -0
  46. package/web-ui/modules/i18n/locales/en.mjs +239 -5
  47. package/web-ui/modules/i18n/locales/ja.mjs +239 -5
  48. package/web-ui/modules/i18n/locales/vi.mjs +239 -5
  49. package/web-ui/modules/i18n/locales/zh-tw.mjs +239 -5
  50. package/web-ui/modules/i18n/locales/zh.mjs +239 -5
  51. package/web-ui/modules/model-test.mjs +82 -0
  52. package/web-ui/modules/plugins.methods.mjs +3 -1
  53. package/web-ui/modules/prompt-ecosystem.methods.mjs +4 -3
  54. package/web-ui/modules/routing.mjs +206 -0
  55. package/web-ui/modules/session-collections.mjs +65 -0
  56. package/web-ui/modules/session-evidence.mjs +81 -0
  57. package/web-ui/modules/session-features.mjs +15 -1
  58. package/web-ui/modules/session-git.mjs +39 -0
  59. package/web-ui/modules/session-stories.mjs +64 -0
  60. package/web-ui/modules/usage-pricing.mjs +30 -0
  61. package/web-ui/partials/index/layout-footer.html +1 -1
  62. package/web-ui/partials/index/layout-header.html +33 -12
  63. package/web-ui/partials/index/modals-basic.html +15 -0
  64. package/web-ui/partials/index/panel-plugins.html +3 -9
  65. package/web-ui/partials/index/panel-prompts.html +13 -7
  66. package/web-ui/partials/index/panel-routing.html +3 -0
  67. package/web-ui/partials/index/panel-sessions.html +20 -20
  68. package/web-ui/partials/index/panel-settings.html +11 -1
  69. package/web-ui/partials/index/panel-usage.html +2 -0
  70. package/web-ui/partials/index/plugin-file-sharing.html +47 -0
  71. package/web-ui/partials/index/routing-model-test.html +53 -0
  72. package/web-ui/partials/index/session-diagnostics.html +7 -4
  73. package/web-ui/partials/index/session-features.html +82 -2
  74. package/web-ui/partials/index/thread-handoff.html +73 -62
  75. package/web-ui/partials/index/usage-records.html +41 -0
  76. package/web-ui/res/web-ui-render.precompiled.js +1378 -230
  77. package/web-ui/styles/base-theme.css +1 -1
  78. package/web-ui/styles/modals-core.css +6 -5
  79. package/web-ui/styles/navigation-panels.css +4 -0
  80. package/web-ui/styles/plugins-panel.css +40 -1
  81. package/web-ui/styles/responsive.css +10 -5
  82. package/web-ui/styles/routing.css +78 -0
  83. package/web-ui/styles/session-features.css +180 -7
  84. package/web-ui/styles/sessions-list.css +74 -0
  85. package/web-ui/styles/sessions-preview.css +106 -68
  86. package/web-ui/styles/sessions-usage.css +8 -0
  87. package/web-ui/styles/settings-panel.css +30 -0
  88. package/web-ui/styles/system-prompt.css +8 -7
  89. package/web-ui/styles/theme-violet-tokens.css +52 -0
  90. package/web-ui/styles/theme-violet.css +1742 -0
  91. package/web-ui/styles.css +2 -0
@@ -0,0 +1,101 @@
1
+ import { authorizationHeaders, withAccessToken } from '../../web-ui/modules/access-token.mjs';
2
+
3
+ const FILE_SHARING_ROUTE = '/api/file-sharing';
4
+ const MAX_SHARE_MANIFEST_BYTES = 512 * 1024;
5
+ const FILE_SHARING_ERRORS = new Set(['emptyFolder', 'invalid', 'busy', 'notFound', 'lanUnavailable', 'failed']);
6
+
7
+ async function requestFileSharing(suffix = '', options = {}) {
8
+ const response = await fetch(FILE_SHARING_ROUTE + suffix, {
9
+ ...options,
10
+ headers: authorizationHeaders(options.headers),
11
+ cache: 'no-store'
12
+ });
13
+ const payload = await response.json();
14
+ if (!response.ok) throw new Error(FILE_SHARING_ERRORS.has(payload.error) ? payload.error : 'failed');
15
+ return payload;
16
+ }
17
+
18
+ function fileSharingMessage(t, error) {
19
+ return t(`plugins.fileSharing.${FILE_SHARING_ERRORS.has(error.message) ? error.message : 'failed'}`);
20
+ }
21
+
22
+ export function createFileSharingMethods() {
23
+ return {
24
+ async refreshFileSharing() {
25
+ return this.runFileSharingAction(async () => {
26
+ this.fileSharingBatches = (await requestFileSharing()).batches;
27
+ });
28
+ },
29
+ selectFileSharingItems(event, isFolder) {
30
+ const input = event.target;
31
+ const files = Array.from(input.files || []);
32
+ input.value = '';
33
+ if (this.fileSharingBusy) return;
34
+ this.fileSharingError = '';
35
+ if (!files.length) {
36
+ if (isFolder) this.fileSharingError = this.t('plugins.fileSharing.emptyFolder');
37
+ return;
38
+ }
39
+ const entries = files.map(file => ({ name: isFolder ? file.webkitRelativePath : file.name, size: file.size }));
40
+ const folder = isFolder ? entries[0].name.split('/')[0] : '';
41
+ const bytes = new TextEncoder().encode(JSON.stringify({ folder, files: entries }));
42
+ if (bytes.length > MAX_SHARE_MANIFEST_BYTES) {
43
+ this.fileSharingError = this.t('plugins.fileSharing.invalid');
44
+ return;
45
+ }
46
+ const prefix = new ArrayBuffer(4);
47
+ new DataView(prefix).setUint32(0, bytes.length);
48
+ this.fileSharingPending = { entries, body: new Blob([prefix, bytes, ...files]) };
49
+ },
50
+ async runFileSharingAction(action) {
51
+ if (this.fileSharingBusy) return false;
52
+ this.fileSharingBusy = true;
53
+ this.fileSharingError = '';
54
+ try {
55
+ await action();
56
+ return true;
57
+ } catch (error) {
58
+ this.fileSharingError = fileSharingMessage(this.t, error);
59
+ return false;
60
+ } finally {
61
+ this.fileSharingBusy = false;
62
+ }
63
+ },
64
+ async uploadFileSharingItems() {
65
+ if (!this.fileSharingPending) return;
66
+ await this.runFileSharingAction(async () => {
67
+ const { batch } = await requestFileSharing('', {
68
+ method: 'POST', headers: { 'Content-Type': 'application/octet-stream' }, body: this.fileSharingPending.body
69
+ });
70
+ this.fileSharingPending = null;
71
+ this.fileSharingBatches.push(batch);
72
+ });
73
+ },
74
+ async removeFileSharingBatch(id) {
75
+ await this.runFileSharingAction(async () => {
76
+ await requestFileSharing(`/${id}`, { method: 'DELETE' });
77
+ this.fileSharingBatches = this.fileSharingBatches.filter(batch => batch.id !== id);
78
+ });
79
+ },
80
+ async copyFileSharingLink(id, index) {
81
+ await this.runFileSharingAction(async () => {
82
+ const { url } = await requestFileSharing(`/${id}/${index}/link`, { method: 'POST' });
83
+ let copied = false;
84
+ try {
85
+ if (navigator.clipboard?.writeText) {
86
+ await navigator.clipboard.writeText(url);
87
+ copied = true;
88
+ }
89
+ } catch (_) { /* HTTP and restricted contexts use the fallback. */ }
90
+ if (copied || this.fallbackCopyText(url)) {
91
+ this.showMessage(this.t('toast.copy.ok'), 'success');
92
+ } else {
93
+ window.prompt(this.t('plugins.fileSharing.copyManually'), url);
94
+ }
95
+ });
96
+ },
97
+ fileSharingDownloadUrl(id, index) {
98
+ return withAccessToken(`${FILE_SHARING_ROUTE}/${id}/${index}`);
99
+ }
100
+ };
101
+ }
@@ -0,0 +1,3 @@
1
+ export async function loadFileSharingOverview(app) {
2
+ return app.refreshFileSharing();
3
+ }
@@ -0,0 +1,5 @@
1
+ export const pluginOwnership = {
2
+ pluginId: 'file-sharing',
3
+ createdBy: 'ymkiux',
4
+ maintainers: ['ymkiux']
5
+ };
@@ -158,12 +158,21 @@ function localizeBuiltinPromptTemplate(item, t) {
158
158
 
159
159
  import { pluginsRegistry } from '../registry.mjs';
160
160
 
161
+ const PLUGIN_TAB_ORDER = new Map([
162
+ ['prompt-templates', 0],
163
+ ['text-tools', 1],
164
+ ['file-sharing', 2]
165
+ ]);
166
+
161
167
  export function createPromptTemplatesComputed() {
162
168
  return {
163
169
  pluginsCatalog() {
164
170
  return pluginsRegistry
165
171
  .map((entry) => entry && entry.meta)
166
172
  .filter(Boolean)
173
+ .sort((left, right) =>
174
+ (PLUGIN_TAB_ORDER.get(left.id) ?? PLUGIN_TAB_ORDER.size)
175
+ - (PLUGIN_TAB_ORDER.get(right.id) ?? PLUGIN_TAB_ORDER.size))
167
176
  .map((meta) => localizePluginMeta(meta, this.t));
168
177
  },
169
178
 
@@ -1,9 +1,12 @@
1
+ import { fileSharingPluginMeta } from './file-sharing/manifest.mjs';
2
+ import { loadFileSharingOverview } from './file-sharing/overview.mjs';
1
3
  import { promptTemplatesPluginMeta } from './prompt-templates/manifest.mjs';
2
4
  import { loadPromptTemplatesOverview } from './prompt-templates/overview.mjs';
3
5
  import { textToolsPluginMeta } from './text-tools/manifest.mjs';
4
6
  import { loadTextToolsOverview } from './text-tools/overview.mjs';
5
7
 
6
8
  export const pluginsRegistry = [
9
+ { id: fileSharingPluginMeta.id, meta: fileSharingPluginMeta, loadOverview: loadFileSharingOverview },
7
10
  { id: promptTemplatesPluginMeta.id, meta: promptTemplatesPluginMeta, loadOverview: loadPromptTemplatesOverview },
8
11
  { id: textToolsPluginMeta.id, meta: textToolsPluginMeta, loadOverview: loadTextToolsOverview }
9
12
  ];
package/web-ui/app.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { modelTestMixin } from './modules/model-test.mjs';
1
2
  import { configChangeMixin } from './modules/app.methods.config-changes.mjs';
2
3
  import { threadHandoffMixin } from './modules/thread-handoff.mjs';
3
4
  import { sessionFeaturesMixin } from './modules/session-features.mjs';
@@ -181,6 +182,10 @@ document.addEventListener('DOMContentLoaded', () => {
181
182
  pluginsError: '',
182
183
  textToolsActiveToolId: '',
183
184
  textToolsInput: '',
185
+ fileSharingBatches: [],
186
+ fileSharingPending: null,
187
+ fileSharingBusy: false,
188
+ fileSharingError: '',
184
189
  promptTemplatesListRaw: [],
185
190
  promptTemplatesLoadedOnce: false,
186
191
  promptTemplatesKeyword: '',
@@ -262,6 +267,12 @@ document.addEventListener('DOMContentLoaded', () => {
262
267
  agentsModalHint: '保存后会写入目标 AGENTS.md(与 config.toml 同级)。',
263
268
  sysPromptScope: 'global',
264
269
  sysPromptMode: 'system',
270
+ sysPromptFileName: '',
271
+ sysPromptFiles: [],
272
+ sysPromptFilesLoading: false,
273
+ sysPromptFilesError: '',
274
+ sysPromptFileMissing: false,
275
+ _sysPromptFilesRequestToken: null,
265
276
  sysPromptContent: '',
266
277
  sysPromptOriginalContent: '',
267
278
  sysPromptPath: '',
@@ -315,6 +326,11 @@ document.addEventListener('DOMContentLoaded', () => {
315
326
  sessionsViewMode: 'browser',
316
327
  sessionsUsageTimeRange: '7d',
317
328
  sessionsUsageList: [],
329
+ usageRecords: null,
330
+ usageRecordsLoading: false,
331
+ usageRecordsError: '',
332
+ usageRecordsRange: '',
333
+ usageRecordsOpen: false,
318
334
  sessionsUsageCompareEnabled: false,
319
335
  sessionsUsageSelectedDayKey: '',
320
336
  sessionsUsageLoadedOnce: false,
@@ -442,6 +458,7 @@ document.addEventListener('DOMContentLoaded', () => {
442
458
  installRegistryCustom: '',
443
459
  installStatusTargets: null,
444
460
  appLatestVersion: '',
461
+ showAppUpdateModal: false,
445
462
  appVersionStatusLoading: false,
446
463
  appVersionStatusError: '',
447
464
  appVersionStatusChecked: false,
@@ -612,7 +629,7 @@ document.addEventListener('DOMContentLoaded', () => {
612
629
  kilocodeShowKey: false,
613
630
  kilocodeAutoSaveSignature: '',
614
631
  forceCompactLayout: false,
615
- sidebarCollapsed: false,
632
+ sidebarCollapsed: true,
616
633
  theme: 'light',
617
634
  sessionLoadNativeDialog: false,
618
635
  starPrompted: false,
@@ -680,7 +697,7 @@ document.addEventListener('DOMContentLoaded', () => {
680
697
  this.agentsModalHint = this.t('modal.agents.hint');
681
698
  }
682
699
  {
683
- const mainTabSet = new Set(['dashboard', 'config', 'sessions', 'usage', 'market', 'plugins', 'docs', 'settings', 'trash', 'prompts']);
700
+ const mainTabSet = new Set(['dashboard', 'config', 'routing', 'sessions', 'usage', 'market', 'plugins', 'docs', 'settings', 'trash', 'prompts']);
684
701
  let urlMainTab = '';
685
702
  try {
686
703
  const url = new URL(window.location.href);
@@ -934,6 +951,11 @@ document.addEventListener('DOMContentLoaded', () => {
934
951
  this.persistWebUiPreferences({ sysPromptScope: newVal });
935
952
  }
936
953
  },
954
+ sysPromptFileName(newVal) {
955
+ if (typeof this.persistWebUiPreferences === 'function') {
956
+ this.persistWebUiPreferences({ sysPromptFileName: newVal });
957
+ }
958
+ },
937
959
  sysPromptMode(newVal) {
938
960
  if (typeof this.persistWebUiPreferences === 'function') {
939
961
  this.persistWebUiPreferences({ sysPromptMode: newVal });
@@ -958,6 +980,7 @@ document.addEventListener('DOMContentLoaded', () => {
958
980
  appOptions.render = window.__CODEXMATE_WEB_UI_RENDER__;
959
981
  }
960
982
 
983
+ appOptions.mixins.push(modelTestMixin);
961
984
  appOptions.mixins.push(sessionFeaturesMixin);
962
985
  const app = createApp(appOptions);
963
986
  app.config.errorHandler = (err, vm, info) => {
package/web-ui/index.html CHANGED
@@ -12,12 +12,12 @@
12
12
  <script src="/res/purify.min.js"></script>
13
13
  <link rel="stylesheet" href="/web-ui/styles.css">
14
14
  <script>
15
- // Render hint: skip the light flash for dark-theme users before the
15
+ // Render hint: restore the selected theme before the
16
16
  // server preference store loads. Kept in sync by applyDocumentTheme().
17
17
  (function () {
18
18
  try {
19
19
  var cachedTheme = localStorage.getItem('codexmateThemeCache');
20
- if (cachedTheme === 'dark' || cachedTheme === 'ocean') {
20
+ if (cachedTheme === 'dark' || cachedTheme === 'ocean' || cachedTheme === 'violet') {
21
21
  document.documentElement.setAttribute('data-theme', cachedTheme);
22
22
  }
23
23
  } catch (_) {}
@@ -35,6 +35,7 @@
35
35
  <!-- @include ./partials/index/panel-config-kilocode.html -->
36
36
  <!-- @include ./partials/index/panel-config-pi.html -->
37
37
  <!-- @include ./partials/index/modals-pi-provider.html -->
38
+ <!-- @include ./partials/index/panel-routing.html -->
38
39
  <!-- @include ./partials/index/panel-sessions.html -->
39
40
  <!-- @include ./partials/index/panel-usage.html -->
40
41
  <!-- @include ./partials/index/panel-docs.html -->
@@ -0,0 +1,39 @@
1
+ const ARTIFACT_FORMATS = Object.freeze({
2
+ evidence: 'codexmate-evidence.md',
3
+ receipt: 'codexmate-development-receipt.md',
4
+ relay: 'codexmate-agent-relay.md'
5
+ });
6
+ const quote = text => String(text).split('\n').map(line => '> ' + line).join('\n');
7
+ const sourceKey = item => JSON.stringify([item.session.source, item.session.sessionId, item.session.filePath, item.nodeId]);
8
+
9
+ export function sessionArtifactFilename(format) {
10
+ return ARTIFACT_FORMATS[format];
11
+ }
12
+
13
+ export function renderSessionArtifact({ format, goal, note, selections, evidence, translate }) {
14
+ const t = translate;
15
+ const entries = selections.map(item => ({ item, source: evidence.get(sourceKey(item)) }));
16
+ const lines = [`# ${t('artifacts.' + format)}`, '', t('artifacts.scope'), '',
17
+ `## ${t('artifacts.goal')}`, '', quote(goal.trim() || t('artifacts.unspecified'))];
18
+ if (note.trim()) lines.push('', `## ${t('artifacts.note')}`, '', quote(note.trim()));
19
+ if (format === 'receipt') {
20
+ lines.push('', `## ${t('artifacts.checks')}`, '');
21
+ for (const status of ['passed', 'failed', 'unverified']) {
22
+ const count = entries.filter(entry => entry.source.status === status).length;
23
+ lines.push(`- ${t('evidence.' + status)}: ${count}`);
24
+ }
25
+ lines.push('', t('artifacts.noVerdict'));
26
+ } else {
27
+ lines.push('', `## ${t('artifacts.executor')}`, '', t('artifacts.executorTask'), '',
28
+ `## ${t('artifacts.reviewer')}`, '', t('artifacts.reviewerTask'));
29
+ }
30
+ lines.push('', `## ${t('artifacts.sources')}`);
31
+ for (const [index, { item, source }] of entries.entries()) {
32
+ lines.push('', `### ${index + 1}. ${item.session.title || item.session.sessionId}`, '',
33
+ `${item.session.source} · ${item.session.sessionId} · ${source.nodeId}`,
34
+ `${t('evidence.path')}: ${JSON.stringify(item.session.filePath || item.session.cwd || '')}`,
35
+ `SHA-256: ${source.textHash}`, `${t('evidence.status')}: ${t('evidence.' + source.status)}`, '', quote(source.excerpt));
36
+ }
37
+ lines.push('', `## ${t('artifacts.uat')}`, '', t('artifacts.uatTask'));
38
+ return lines.join('\n').trim() + '\n';
39
+ }
@@ -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');
@@ -293,6 +293,16 @@ export function createAgentsMethods(options = {}) {
293
293
  if (!event) {
294
294
  return;
295
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
+ }
296
306
  const isCmdLike = !!(event.metaKey || event.ctrlKey);
297
307
  const key = typeof event.key === 'string' ? event.key : '';
298
308
  const isSearchHotkey = isCmdLike && !event.altKey && (key === 'k' || key === 'K');
@@ -1077,9 +1087,12 @@ export function createAgentsMethods(options = {}) {
1077
1087
  });
1078
1088
  },
1079
1089
 
1080
- loadPromptsTabContent() {
1090
+ async loadPromptsTabContent() {
1081
1091
  if (typeof this.loadPromptsPathReferences === "function") this.loadPromptsPathReferences();
1082
1092
  if (this.promptsSubTab === 'system') {
1093
+ const didLoadFallback = typeof this.loadSystemPromptFiles === 'function' && await this.loadSystemPromptFiles();
1094
+ if (this.promptsSubTab !== 'system' || didLoadFallback) return;
1095
+ if (this.sysPromptLoading || this.sysPromptSaving || this.sysPromptDiffVisible || this.hasSysPromptContentChanged()) return;
1083
1096
  if (typeof this.loadSystemPrompt === 'function') this.loadSystemPrompt();
1084
1097
  } else {
1085
1098
  if (this.promptsSubTab === 'claude-project' && !this.projectPathOptions.length && !this.projectPathOptionsLoading && typeof this.loadProjectPathOptions === 'function') {
@@ -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;
@@ -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'
@@ -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
 
@@ -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');
@@ -828,6 +828,40 @@ export function createSessionBrowserMethods(options = {}) {
828
828
  }
829
829
  },
830
830
 
831
+ toggleUsageRecords(event) {
832
+ this.usageRecordsOpen = event.target.open;
833
+ if (this.usageRecordsOpen) return this.loadUsageRecords();
834
+ },
835
+ formatUsageRecordCount(value) {
836
+ return value === null ? this.t('usage.records.unknown') : Number(value || 0).toLocaleString('en-US');
837
+ },
838
+ async loadUsageRecords(options = {}) {
839
+ if (this.usageRecordsLoading) return;
840
+ const range = this.sessionsUsageTimeRange;
841
+ if (!options.forceRefresh && this.usageRecords && this.usageRecordsRange === range) return;
842
+ this.usageRecordsLoading = true;
843
+ this.usageRecordsError = '';
844
+ if (this.usageRecordsRange !== range) this.usageRecords = null;
845
+ const today = new Date();
846
+ const from = new Date(Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate() - (range === '30d' ? 29 : 6)));
847
+ try {
848
+ const report = await api('read-sessions-usage-report', { source: 'all',
849
+ limit: range === 'all' ? 2000 : (range === '30d' ? 1200 : 600),
850
+ ...(range === 'all' ? {} : { from: from.toISOString().slice(0, 10), to: today.toISOString().slice(0, 10) }),
851
+ forceRefresh: !!options.forceRefresh });
852
+ if (report.error) throw new Error(report.error);
853
+ if (range === this.sessionsUsageTimeRange) {
854
+ this.usageRecords = report;
855
+ this.usageRecordsRange = range;
856
+ }
857
+ } catch (error) {
858
+ if (range === this.sessionsUsageTimeRange) this.usageRecordsError = error.message;
859
+ } finally {
860
+ this.usageRecordsLoading = false;
861
+ if (this.usageRecordsOpen && range !== this.sessionsUsageTimeRange) return this.loadUsageRecords();
862
+ }
863
+ },
864
+
831
865
  async loadSessionsUsage(options = {}) {
832
866
  if (this.sessionsUsageLoading) return;
833
867
  const normalizedRange = typeof options.range === 'string'
@@ -865,6 +899,7 @@ export function createSessionBrowserMethods(options = {}) {
865
899
  return;
866
900
  }
867
901
  this.sessionsUsageList = Array.isArray(res.sessions) ? res.sessions : [];
902
+ if (this.usageRecordsOpen) void this.loadUsageRecords({ forceRefresh: !!options.forceRefresh });
868
903
  loadSucceeded = true;
869
904
  } catch (e) {
870
905
  this.sessionsUsageError = '加载 usage 统计失败';