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
@@ -0,0 +1,206 @@
1
+ import { api } from './api.mjs';
2
+ import { createModelTestMethods, modelTestData } from './model-test.mjs';
3
+
4
+ const MAX_MEMBERS = 16;
5
+ export function createRoutingMethods({ request = api, origin = () => globalThis.location.origin } = {}) {
6
+ return {
7
+ ...createModelTestMethods({ request }),
8
+ applyRoutingState(state) {
9
+ this.routingGroups = state.groups;
10
+ this.routingBindings = { 'openai-chat': '', ...state.bindings };
11
+ this.routingCatalogs = { 'openai-chat': [], ...state.catalogs };
12
+ this.routingBridges = { 'openai-chat': { active: false, enabled: false }, ...state.bridges };
13
+ this.routingRevision = state.revision;
14
+ if (state.openaiChat) this.routingOpenaiAccess = state.openaiChat;
15
+ this.routingLoaded = true;
16
+ },
17
+ async loadRouting() {
18
+ if (this.routingLoading || this.routingSaving) return;
19
+ this.routingLoading = true;
20
+ this.routingError = '';
21
+ try {
22
+ const state = await request('routing-get');
23
+ if (state.error) throw new Error(typeof state.error === 'string' ? state.error : state.error.message);
24
+ this.applyRoutingState(state);
25
+ } catch (error) {
26
+ this.routingError = error.message || this.t('routing.failed');
27
+ } finally { this.routingLoading = false; }
28
+ },
29
+ routingTargetName(target = this.routingTarget) {
30
+ return { codex: 'Codex', claude: 'Claude', 'openai-chat': 'OpenAI Chat' }[target];
31
+ },
32
+ routingPermissionTarget(target = this.routingTarget) {
33
+ return target === 'openai-chat' ? 'codex' : target;
34
+ },
35
+ routingOpenaiBaseUrl() {
36
+ return origin() + this.routingOpenaiAccess.basePath;
37
+ },
38
+ routingGroupsForTarget() {
39
+ return this.routingGroups.filter(group => group.target === this.routingTarget);
40
+ },
41
+ routingCatalog() {
42
+ return this.routingCatalogs[this.routingTarget] || [];
43
+ },
44
+ routingStateLabel() {
45
+ const bridge = this.routingBridges[this.routingTarget];
46
+ if (bridge.active) {
47
+ const id = this.routingBindings[this.routingTarget];
48
+ if (!id) return this.t('routing.state.legacy');
49
+ const group = this.routingGroups.find(item => item.id === id);
50
+ return this.t(this.routingTarget === 'openai-chat' ? 'routing.openai.active' : 'routing.state.group', { name: group.name });
51
+ }
52
+ return this.t(this.routingTarget === 'openai-chat' ? 'routing.openai.off' : bridge.enabled ? 'routing.state.pending' : 'routing.state.off');
53
+ },
54
+ routingMemberRole(index, strategy) {
55
+ if (strategy === 'rotate') return this.t('routing.role.member', { index: index + 1 });
56
+ return this.t(index === 0 ? 'routing.role.primary' : 'routing.role.backup', { index });
57
+ },
58
+ setRoutingTarget(target) {
59
+ if (this.routingDraft || this.routingSaving) return;
60
+ this.routingTarget = target;
61
+ },
62
+ routingMemberModel(providerName) {
63
+ if (this.routingPermissionTarget() === 'codex') {
64
+ const model = this.currentModels?.[providerName] || (this.currentProvider === providerName ? this.currentModel : '');
65
+ if (typeof model === 'string' && model.trim()) return model.trim();
66
+ }
67
+ return this.routingCatalog().find(entry => entry.name === providerName)?.model || '';
68
+ },
69
+ routingDefaultMember() {
70
+ const used = new Set((this.routingDraft?.members || []).map(member => member.provider));
71
+ const provider = this.routingCatalog().find(entry => !used.has(entry.name));
72
+ return provider ? { provider: provider.name, model: this.routingMemberModel(provider.name) } : { provider: '', model: '' };
73
+ },
74
+ editRoutingGroup(group = null) {
75
+ this.routingError = '';
76
+ if (group) this.routingDraft = { ...group, members: group.members.map(member => ({ ...member })), revision: this.routingRevision };
77
+ else {
78
+ const names = new Set(this.routingGroupsForTarget().map(item => item.name));
79
+ let index = 1;
80
+ const target = this.routingTargetName();
81
+ let name = this.t('routing.defaultName', { target, index });
82
+ while (names.has(name)) name = this.t('routing.defaultName', { target, index: ++index });
83
+ this.routingDraft = { name, target: this.routingTarget, strategy: 'order', members: [this.routingDefaultMember()], revision: this.routingRevision };
84
+ }
85
+ if (typeof this.$nextTick === 'function') this.$nextTick(() => {
86
+ const input = this.$refs.routingNameInput;
87
+ if (input) { input.focus(); input.select(); }
88
+ });
89
+ },
90
+ cancelRoutingEdit() {
91
+ if (!this.routingSaving) this.routingDraft = null;
92
+ },
93
+ addRoutingMember() {
94
+ if (this.routingDraft.members.length < MAX_MEMBERS) this.routingDraft.members.push(this.routingDefaultMember());
95
+ },
96
+ setRoutingMemberProvider(index) {
97
+ const member = this.routingDraft.members[index];
98
+ member.model = this.routingMemberModel(member.provider);
99
+ },
100
+ moveRoutingMember(index, offset) {
101
+ const members = this.routingDraft.members;
102
+ const destination = index + offset;
103
+ if (destination < 0 || destination >= members.length) return;
104
+ const [member] = members.splice(index, 1);
105
+ members.splice(destination, 0, member);
106
+ },
107
+ routingDraftError() {
108
+ const draft = this.routingDraft;
109
+ if (!draft || !draft.name.trim()) return this.t('routing.nameRequired');
110
+ const pairs = new Set();
111
+ for (const [index, member] of draft.members.entries()) {
112
+ if (!member.provider.trim() || !member.model.trim()) return this.t('routing.memberRequired', { index: index + 1 });
113
+ if (!this.routingCatalog().some(entry => entry.name === member.provider)) return this.t('routing.memberMissing', { index: index + 1 });
114
+ const pair = JSON.stringify([member.provider.trim(), member.model.trim()]);
115
+ if (pairs.has(pair)) return this.t('routing.memberDuplicate', { index: index + 1 });
116
+ pairs.add(pair);
117
+ }
118
+ return '';
119
+ },
120
+ async writeRouting(action, params, options = {}) {
121
+ if (this.routingSaving || this.routingLoading || !this.isToolConfigWriteAllowed(this.routingPermissionTarget())) return false;
122
+ const target = this.routingTarget;
123
+ let bindingConfirmed = false;
124
+ this.routingSaving = true;
125
+ this.routingError = '';
126
+ try {
127
+ const result = await request(action, params);
128
+ if (result.error) throw new Error(typeof result.error === 'string' ? result.error : result.error.message);
129
+ let state = result.groups ? result : await request('routing-get');
130
+ if (state.error) throw new Error(typeof state.error === 'string' ? state.error : state.error.message);
131
+ if (options.activate) {
132
+ if (state.bindings[target] !== params.id) throw new Error(this.t('routing.notActive'));
133
+ bindingConfirmed = true;
134
+ if (!state.bridges[target].active) {
135
+ this.applyRoutingState(state);
136
+ const toggle = target === 'claude' ? 'claude-local-bridge-toggle' : 'local-bridge-toggle';
137
+ const bridge = await request(toggle, { enable: true });
138
+ if (bridge.error) throw new Error(typeof bridge.error === 'string' ? bridge.error : bridge.error.message);
139
+ state = await request('routing-get');
140
+ if (state.error) throw new Error(typeof state.error === 'string' ? state.error : state.error.message);
141
+ }
142
+ if (!state.bridges[target].active || state.bindings[target] !== params.id) throw new Error(this.t('routing.notActive'));
143
+ }
144
+ this.applyRoutingState(state);
145
+ this.showMessage(this.t(options.activate ? 'routing.groupActivated' : 'routing.updated', { name: options.name }), 'success');
146
+ return true;
147
+ } catch (error) {
148
+ const message = error.message || this.t('routing.failed');
149
+ this.routingError = bindingConfirmed ? this.t('routing.activationUnconfirmed', { message }) : message;
150
+ return false;
151
+ } finally { this.routingSaving = false; }
152
+ },
153
+ async saveRoutingGroup() {
154
+ if (this.routingSaving || this.routingLoading || !this.isToolConfigWriteAllowed(this.routingPermissionTarget())) return;
155
+ const error = this.routingDraftError();
156
+ if (error) { this.routingError = error; return; }
157
+ if (await this.writeRouting('routing-save', this.routingDraft)) this.routingDraft = null;
158
+ },
159
+ async bindRoutingGroup(id) {
160
+ await this.writeRouting('routing-bind', { target: this.routingTarget, id, revision: this.routingRevision });
161
+ },
162
+ async useRoutingGroup(group) {
163
+ if (this.routingSaving || this.routingLoading || !this.isToolConfigWriteAllowed(this.routingPermissionTarget())) return;
164
+ this.routingPendingGroupId = group.id;
165
+ try {
166
+ if (this.routingBindings[this.routingTarget] === group.id && this.routingBridges[this.routingTarget].active) {
167
+ await this.bindRoutingGroup('');
168
+ return;
169
+ }
170
+ await this.writeRouting('routing-bind', { target: this.routingTarget, id: group.id, revision: this.routingRevision }, { activate: true, name: group.name });
171
+ } finally { this.routingPendingGroupId = ''; }
172
+ },
173
+ async deleteRoutingGroup(group) {
174
+ if (this.routingBindings[group.target] === group.id || !this.isToolConfigWriteAllowed(this.routingPermissionTarget(group.target))) return;
175
+ const revision = this.routingRevision;
176
+ const confirmed = await this.requestConfirmDialog({
177
+ title: this.t('routing.delete'), message: this.t('routing.deleteConfirm', { name: group.name }),
178
+ confirmText: this.t('routing.delete'), cancelText: this.t('common.cancel'), danger: true
179
+ });
180
+ if (confirmed) await this.writeRouting('routing-delete', { id: group.id, revision });
181
+ },
182
+ async toggleRoutingBridge() {
183
+ if (this.routingTarget === 'openai-chat') { await this.bindRoutingGroup(''); return; }
184
+ const action = this.routingTarget === 'claude' ? 'claude-local-bridge-toggle' : 'local-bridge-toggle';
185
+ await this.writeRouting(action, { enable: !this.routingBridges[this.routingTarget].active });
186
+ }
187
+ };
188
+ }
189
+ export const routingMixin = {
190
+ data() {
191
+ return {
192
+ ...modelTestData(),
193
+ routingTarget: 'codex', routingGroups: [], routingBindings: { codex: '', claude: '', 'openai-chat': '' },
194
+ routingCatalogs: { codex: [], claude: [], 'openai-chat': [] },
195
+ routingBridges: { codex: { enabled: false, active: false }, claude: { enabled: false, active: false }, 'openai-chat': { enabled: false, active: false } },
196
+ routingOpenaiAccess: { basePath: '/bridge/openai-chat/v1', model: 'routing', requiresToken: false },
197
+ routingRevision: '', routingDraft: null, routingLoading: false, routingSaving: false, routingPendingGroupId: '',
198
+ routingLoaded: false, routingError: ''
199
+ };
200
+ },
201
+ computed: { modelTestRenderedResponse() { return this.modelTestPreview(); } },
202
+ watch: {
203
+ mainTab(tab) { if (tab === 'routing') { this.loadRouting(); this.loadModelTestCatalog(); } }
204
+ },
205
+ methods: createRoutingMethods()
206
+ };
@@ -0,0 +1,279 @@
1
+ import { api } from './api.mjs';
2
+ import { contextWindowReference } from '../logic.context-window.mjs';
3
+ const SessionMessageActions = {
4
+ props: { message: { type: Object, required: true } },
5
+ render() {
6
+ // A child render tracks shared action state independently of the message v-memo.
7
+ const vm = this.$parent;
8
+ return Vue.h('div', { class: 'session-feature-controls' }, [
9
+ Vue.h('button', { type: 'button', class: 'btn-mini feature-icon-button', disabled: vm.featureBusy,
10
+ title: vm.t('features.bookmark'), 'aria-label': vm.t('features.bookmark'),
11
+ onClick: () => vm.bookmarkMessage(this.message) }, [
12
+ Vue.h('svg', { viewBox: '0 0 24 24', width: 18, height: 18, fill: 'none',
13
+ stroke: 'currentColor', 'stroke-width': 1.8, 'stroke-linejoin': 'round' }, [
14
+ Vue.h('path', { d: 'M6 3h12v18l-6-4-6 4V3Z' })
15
+ ])
16
+ ]),
17
+ Vue.h('label', { class: 'feature-message-select' }, [Vue.h('input', { type: 'checkbox', checked: vm.selectedContextIds.includes(vm.contextSelectionKey(this.message)),
18
+ 'aria-label': vm.t('features.selectMessage'), onChange: () => vm.toggleHandoffMessage(this.message) })])
19
+ ]);
20
+ }
21
+ };
22
+ export const sessionFeaturesMixin = {
23
+ components: { SessionMessageActions },
24
+ data() {
25
+ return { featureView: '', featureBusy: false, featureError: '', bookmarks: [], bookmarkRevision: '',
26
+ bookmarkQuery: '', bookmarkTag: '', bookmarkProject: '', bookmarkEditor: null,
27
+ selectedContextIds: [], featureFocus: null, featureRequestSeq: 0,
28
+ indexReport: null, indexResults: null, indexQuery: '', indexTimer: null, handoffDraftEvidence: [], handoffUnverified: [], projectReport: null, projectSelected: '', projectAlias: '', projectPrompt: null, contextWindowInput: '', contextSelectedModel: '', contextFeatureSettings: null, contextSettingsRevision: '', diagnosticsReport: null, diagnosticsMarkdown: '', diagnosticsRemote: false,
29
+ diagnosticsTargets: [], diagnosticsSelected: [], diagnosticsTimer: null };
30
+ },
31
+ computed: {
32
+ contextPreferenceKey() {
33
+ return `${this.handoffSessionKey}::${this.contextSelectedModel || this.sessionContextHealth?.models?.[0] || 'manual'}`;
34
+ },
35
+ contextReference() {
36
+ try { return contextWindowReference(this.sessionContextHealth, { model: this.contextSelectedModel, window: this.contextWindowInput }); }
37
+ catch (_) { return { status: 'invalid', source: 'manual' }; }
38
+ },
39
+ contextReminderDismissed() { return !!this.contextFeatureSettings?.dismissed?.[this.contextPreferenceKey]; }
40
+ },
41
+ beforeUnmount() { clearTimeout(this.indexTimer); clearTimeout(this.diagnosticsTimer); },
42
+ watch: {
43
+ sessionContextHealth(report) {
44
+ if (!report) return;
45
+ this.contextSelectedModel = report.models?.length === 1 ? report.models[0] : '';
46
+ void this.loadContextPreferences();
47
+ },
48
+ contextSelectedModel() { if (this.sessionContextHealth) void this.loadContextPreferences(); },
49
+ handoffSessionKey() { this.contextWindowInput = ''; this.contextSelectedModel = ''; this.selectedContextIds = []; this.handoffDraftEvidence = []; this.handoffUnverified = []; this.featureFocus = null; this.featureRequestSeq++; this.featureBusy = false; }
50
+ },
51
+ methods: {
52
+ featureErrorText(error) {
53
+ const key = `features.error.${error.message || error}`;
54
+ const text = this.t(key);
55
+ return text === key ? this.t('features.error.feature-read-failed') : text;
56
+ },
57
+ sessionNodeParams(msg) {
58
+ const session = this.activeSession;
59
+ const index = msg.recordLineIndex;
60
+ if (!session) throw new Error('bookmark-source-unavailable');
61
+ return { source: session.source, sessionId: session.sessionId, filePath: session.filePath,
62
+ cwd: session.cwd || '', ...(msg.id && /^record-/.test(msg.id) ? { nodeId: msg.id } : (Number.isInteger(index) && index >= 0
63
+ ? { nodeId: `record-${index}` } : { messageText: msg.text })) };
64
+ },
65
+ async featureCall(action, params = {}) {
66
+ const result = await api(action, params);
67
+ if (result.error) throw new Error(result.error);
68
+ return result;
69
+ },
70
+ async openFeatureView(view) {
71
+ this.featureView = this.featureView === view ? '' : view;
72
+ this.featureError = '';
73
+ if (this.featureView === 'bookmarks') await this.loadBookmarks();
74
+ if (this.featureView === 'search') await this.pollSessionIndex();
75
+ if (this.featureView === 'projects') await this.loadProjectWorkspace();
76
+ },
77
+ async loadBookmarks() {
78
+ const seq = ++this.featureRequestSeq;
79
+ this.featureBusy = true; this.featureError = '';
80
+ try {
81
+ const result = await this.featureCall('session-bookmarks-list', { query: this.bookmarkQuery,
82
+ tag: this.bookmarkTag, project: this.bookmarkProject });
83
+ if (seq !== this.featureRequestSeq) return;
84
+ this.bookmarks = result.items; this.bookmarkRevision = result.revision;
85
+ } catch (error) { if (seq === this.featureRequestSeq) this.featureError = this.featureErrorText(error); }
86
+ finally { if (seq === this.featureRequestSeq) this.featureBusy = false; }
87
+ },
88
+ async bookmarkMessage(msg) {
89
+ if (this.featureBusy) return;
90
+ this.featureBusy = true; this.featureError = '';
91
+ try {
92
+ const params = this.sessionNodeParams(msg);
93
+ const list = await this.featureCall('session-bookmarks-list');
94
+ const result = await this.featureCall('session-bookmark-save', { ...params, note: '', tags: [], revision: list.revision });
95
+ this.bookmarkEditor = { ...result.item, tagsText: result.item.tags.join(', ') };
96
+ this.bookmarks = result.items; this.bookmarkRevision = result.revision; this.featureView = 'bookmarks';
97
+ } catch (error) { this.featureError = this.featureErrorText(error); }
98
+ finally { this.featureBusy = false; }
99
+ },
100
+ async saveBookmark() {
101
+ if (!this.bookmarkEditor || this.featureBusy) return;
102
+ this.featureBusy = true; this.featureError = '';
103
+ try {
104
+ const item = this.bookmarkEditor;
105
+ const result = await this.featureCall('session-bookmark-save', { id: item.id, note: item.note,
106
+ tags: item.tagsText.split(/[,,]/).map((tag) => tag.trim()).filter(Boolean), revision: this.bookmarkRevision });
107
+ this.bookmarks = result.items; this.bookmarkRevision = result.revision; this.bookmarkEditor = null;
108
+ } catch (error) { this.featureError = this.featureErrorText(error); }
109
+ finally { this.featureBusy = false; }
110
+ },
111
+ async removeBookmark(item) {
112
+ if (this.featureBusy) return;
113
+ this.featureBusy = true; this.featureError = '';
114
+ try {
115
+ const result = await this.featureCall('session-bookmark-remove', { id: item.id, revision: this.bookmarkRevision });
116
+ this.bookmarks = result.items; this.bookmarkRevision = result.revision;
117
+ if (this.bookmarkEditor?.id === item.id) this.bookmarkEditor = null;
118
+ } catch (error) { this.featureError = this.featureErrorText(error); }
119
+ finally { this.featureBusy = false; }
120
+ },
121
+ async locateBookmark(item) {
122
+ this.featureError = '';
123
+ try {
124
+ const result = await this.featureCall('session-bookmark-locate', { id: item.id });
125
+ if (!result.available) throw new Error('bookmark-source-unavailable');
126
+ await this.selectSession({ ...item, title: item.excerpt.slice(0, 80) });
127
+ this.featureFocus = result.node;
128
+ await this.$nextTick(); this.$refs.featureFocus?.focus();
129
+ } catch (error) { this.featureError = this.featureErrorText(error); }
130
+ },
131
+ async pollSessionIndex() {
132
+ clearTimeout(this.indexTimer);
133
+ try {
134
+ this.indexReport = await this.featureCall('session-index-status');
135
+ if (this.indexReport.job.status === 'running') {
136
+ this.indexTimer = setTimeout(() => this.pollSessionIndex(), 1000);
137
+ }
138
+ } catch (error) { this.featureError = this.featureErrorText(error); }
139
+ },
140
+ async refreshSessionIndex(rebuild = false) {
141
+ this.featureError = '';
142
+ try {
143
+ await this.featureCall('session-index-refresh', { source: this.sessionFilterSource || 'all', rebuild: rebuild === true });
144
+ await this.pollSessionIndex();
145
+ } catch (error) { this.featureError = this.featureErrorText(error); }
146
+ },
147
+ async cancelSessionIndex() {
148
+ try { await this.featureCall('session-index-cancel'); await this.pollSessionIndex(); }
149
+ catch (error) { this.featureError = this.featureErrorText(error); }
150
+ },
151
+ async searchSessionIndex() {
152
+ if (this.featureBusy) return;
153
+ const seq = ++this.featureRequestSeq;
154
+ this.featureBusy = true; this.featureError = ''; this.indexResults = null;
155
+ try {
156
+ const result = await this.featureCall('session-index-search', { query: this.indexQuery,
157
+ source: this.sessionFilterSource || 'all', project: this.sessionPathFilter, role: this.sessionRoleFilter, scope: 'all' });
158
+ if (seq === this.featureRequestSeq) this.indexResults = result;
159
+ } catch (error) { if (seq === this.featureRequestSeq) this.featureError = this.featureErrorText(error); }
160
+ finally { if (seq === this.featureRequestSeq) this.featureBusy = false; }
161
+ },
162
+ async openIndexedMessage(result) {
163
+ this.featureError = '';
164
+ try {
165
+ const found = await this.featureCall('session-index-node', { ...result.session, nodeId: result.nodeId, textHash: result.textHash });
166
+ await this.selectSession(result.session);
167
+ this.featureFocus = found.node;
168
+ await this.$nextTick(); this.$refs.featureFocus?.focus();
169
+ } catch (error) { this.featureError = this.featureErrorText(error); }
170
+ },
171
+ async generateSelectedHandoff() {
172
+ if (this.featureBusy || !this.activeSession) return;
173
+ const seq = this.handoffRequestSeq;
174
+ this.featureBusy = true; this.featureError = '';
175
+ try {
176
+ const result = await this.featureCall('session-handoff-draft', { ...this.activeSession,
177
+ selections: this.selectedContextIds, goal: this.handoffDraft.goal });
178
+ if (seq !== this.handoffRequestSeq) return;
179
+ this.handoffDraft = { ...this.handoffDraft, goal: result.card.goal,
180
+ ...Object.fromEntries(['completed', 'blockers', 'nextSteps', 'files'].map((key) => [key, result.card[key].join('\n')])) };
181
+ this.handoffDraftEvidence = result.evidence; this.handoffUnverified = result.unverified;
182
+ this.handoffExpanded = true;
183
+ } catch (error) { if (seq === this.handoffRequestSeq) this.featureError = this.featureErrorText(error); }
184
+ finally { this.featureBusy = false; }
185
+ },
186
+ async locateDraftEvidence(item) {
187
+ await this.openIndexedMessage({ session: { source: item.source, sessionId: item.sessionId, filePath: item.filePath, cwd: item.cwd }, nodeId: item.nodeId, textHash: item.textHash });
188
+ },
189
+ async loadProjectWorkspace(project) {
190
+ const seq = ++this.featureRequestSeq;
191
+ this.featureBusy = true; this.featureError = '';
192
+ try {
193
+ const result = await this.featureCall('session-projects', project === undefined ? {} : { project });
194
+ if (seq !== this.featureRequestSeq) return;
195
+ this.projectReport = result; this.projectPrompt = null; this.projectSelected = project === undefined ? '' : project;
196
+ } catch (error) { if (seq === this.featureRequestSeq) this.featureError = this.featureErrorText(error); }
197
+ finally { if (seq === this.featureRequestSeq) this.featureBusy = false; }
198
+ },
199
+ async openProjectPrompt(file) {
200
+ try {
201
+ const project = this.projectReport.detail.cwd;
202
+ const name = file.slice(project.length + 1).replace(/\\/g, '/');
203
+ this.projectPrompt = await this.featureCall('session-project-prompt', { project, name });
204
+ } catch (error) { this.featureError = this.featureErrorText(error); }
205
+ },
206
+ async mapProjectWorkspace() {
207
+ this.featureError = '';
208
+ try {
209
+ await this.featureCall('session-project-map', { from: this.projectSelected, to: this.projectAlias,
210
+ revision: this.projectReport.revision });
211
+ await this.loadProjectWorkspace(this.projectAlias || this.projectSelected);
212
+ this.projectAlias = '';
213
+ } catch (error) { this.featureError = this.featureErrorText(error); }
214
+ },
215
+ async loadContextPreferences() {
216
+ const key = this.contextPreferenceKey;
217
+ try {
218
+ const result = await this.featureCall('session-feature-settings-get');
219
+ if (key !== this.contextPreferenceKey) return;
220
+ this.contextFeatureSettings = result.settings; this.contextSettingsRevision = result.revision;
221
+ this.contextWindowInput = result.settings.windows[key] === undefined ? '' : String(result.settings.windows[key]);
222
+ } catch (error) { this.featureError = this.featureErrorText(error); }
223
+ },
224
+ async saveContextPreferences(dismissed = false) {
225
+ try {
226
+ if (this.contextReference?.status === 'invalid') throw new Error('context-window-invalid');
227
+ const key = this.contextPreferenceKey;
228
+ const result = await this.featureCall('session-feature-settings-save', { key,
229
+ window: this.contextWindowInput === '' ? '' : Number(this.contextWindowInput), dismissed,
230
+ revision: this.contextSettingsRevision });
231
+ if (key !== this.contextPreferenceKey) return;
232
+ this.contextFeatureSettings = result.settings; this.contextSettingsRevision = result.revision;
233
+ } catch (error) { this.featureError = this.featureErrorText(error); }
234
+ },
235
+ async loadDiagnosticTargets() {
236
+ try {
237
+ const result = await this.featureCall('session-diagnostics-targets', { cwd: this.activeSession?.cwd });
238
+ this.diagnosticsTargets = result.names;
239
+ } catch (error) { this.featureError = this.featureErrorText(error); }
240
+ },
241
+ async startDiagnostics() {
242
+ this.featureError = '';
243
+ try {
244
+ await this.featureCall('session-diagnostics-start', { remote: this.diagnosticsRemote,
245
+ mcpNames: this.diagnosticsSelected, cwd: this.activeSession?.cwd });
246
+ await this.pollDiagnostics();
247
+ } catch (error) { this.featureError = this.featureErrorText(error); }
248
+ },
249
+ async pollDiagnostics() {
250
+ clearTimeout(this.diagnosticsTimer);
251
+ try {
252
+ const result = await this.featureCall('session-diagnostics-status');
253
+ this.diagnosticsReport = result.report; this.diagnosticsMarkdown = result.markdown;
254
+ if (result.report.status === 'running') this.diagnosticsTimer = setTimeout(() => this.pollDiagnostics(), 1000);
255
+ } catch (error) { this.featureError = this.featureErrorText(error); }
256
+ },
257
+ async cancelDiagnostics() {
258
+ try { await this.featureCall('session-diagnostics-cancel'); await this.pollDiagnostics(); }
259
+ catch (error) { this.featureError = this.featureErrorText(error); }
260
+ },
261
+ exportDiagnostics(format) {
262
+ this.downloadTextFile(`codexmate-diagnostics.${format === 'json' ? 'json' : 'md'}`,
263
+ format === 'json' ? JSON.stringify(this.diagnosticsReport, null, 2) : this.diagnosticsMarkdown,
264
+ format === 'json' ? 'application/json;charset=utf-8' : 'text/markdown;charset=utf-8');
265
+ },
266
+ contextSelectionKey(msg) {
267
+ if (msg.id && /^record-/.test(msg.id)) return msg.id;
268
+ return Number.isInteger(msg.recordLineIndex) && msg.recordLineIndex >= 0
269
+ ? `record-${msg.recordLineIndex}` : `text:${msg.text}`;
270
+ },
271
+ toggleHandoffMessage(msg) {
272
+ try {
273
+ const nodeId = this.contextSelectionKey(msg);
274
+ this.selectedContextIds = this.selectedContextIds.includes(nodeId)
275
+ ? this.selectedContextIds.filter((id) => id !== nodeId) : [...this.selectedContextIds, nodeId];
276
+ } catch (error) { this.featureError = this.featureErrorText(error); }
277
+ }
278
+ }
279
+ };
@@ -101,7 +101,7 @@ export const threadHandoffMixin = {
101
101
  this.handoffError = '';
102
102
  this.handoffNotice = '';
103
103
  try {
104
- const result = await api('thread-handoff-create', { threadId, target: draft.target.trim(), card, cwd: this.activeSession.cwd || undefined });
104
+ const result = await api('thread-handoff-create', { threadId, target: draft.target.trim(), card, ...(this.handoffDraftEvidence?.length ? { evidence: this.handoffDraftEvidence } : {}), cwd: this.activeSession.cwd || undefined });
105
105
  if (result.error) throw new Error(result.error);
106
106
  if (requestSeq !== this.handoffRequestSeq) return;
107
107
  this.handoffNotice = result.message || '已生成交接记录;读取状态以交接历史为准。';
@@ -0,0 +1,25 @@
1
+ <section v-if="mainTab === 'config' && lastConfigChange && lastConfigChange.target === configMode" class="config-change-last" aria-live="polite">
2
+ <span>{{ t('changes.last') }} · {{ lastConfigChange.createdAt }}</span>
3
+ <button type="button" class="btn-tool" @click="undoLastConfigChange" :disabled="configChangeBusy || configChangeApplying || !isToolConfigWriteAllowed(configMode)">{{ t('changes.undo') }}</button>
4
+ </section>
5
+ <teleport to="body">
6
+ <div v-if="configChangePreview" class="modal-overlay config-change-overlay" @click.self="closeConfigChangePreview()" @keydown="handleConfigChangeKeydown">
7
+ <section class="modal modal-wide config-change-modal" role="dialog" aria-modal="true" aria-labelledby="config-change-title" aria-describedby="config-change-hint" :aria-busy="configChangeApplying">
8
+ <h2 id="config-change-title" class="modal-title">{{ t('changes.preview') }}</h2>
9
+ <p id="config-change-hint" class="form-hint">{{ t('changes.hint') }}</p>
10
+ <div class="config-change-files" tabindex="0" :aria-label="t('changes.files')">
11
+ <article v-for="file in configChangePreview.files" :key="file.path" class="config-change-file">
12
+ <h3><span>{{ t('changes.operation.' + file.operation) }}</span> <code>{{ file.path }}</code></h3>
13
+ <p v-if="file.hidden" class="form-hint">{{ t('changes.hidden') }}</p>
14
+ <p v-else-if="file.maskedOnly" class="form-hint">{{ t('changes.maskedOnly') }}</p>
15
+ <pre v-else class="config-change-diff"><template v-for="(line, index) in file.diff.lines" :key="index"><span :class="['config-change-line', 'config-change-line-' + line.type]">{{ line.type === 'add' ? '+' : line.type === 'del' ? '−' : ' ' }} {{ line.text || line.value }}</span></template></pre>
16
+ </article>
17
+ </div>
18
+ <p v-if="configChangeError" class="form-hint form-error" role="alert">{{ configChangeError }}</p>
19
+ <div class="btn-group config-change-actions">
20
+ <button ref="configChangeCancel" type="button" class="btn btn-cancel" @click="closeConfigChangePreview()" :disabled="configChangeApplying">{{ t('common.cancel') }}</button>
21
+ <button type="button" class="btn btn-confirm" @click="confirmConfigChange" :disabled="configChangeApplying || !!configChangeError">{{ configChangeApplying ? t('changes.saving') : t('changes.apply') }}</button>
22
+ </div>
23
+ </section>
24
+ </div>
25
+ </teleport>
@@ -0,0 +1,17 @@
1
+ <section v-if="sessionContextHealth" class="context-window-reference" :aria-label="t('features.windowReference')">
2
+ <div class="feature-section-heading"><h4>{{ t('features.windowReference') }}</h4><small v-if="contextReference?.percentage !== undefined" class="feature-meta">{{ t('features.windowSource.' + contextReference.source) }}</small></div>
3
+ <p v-if="contextReference?.percentage !== undefined" class="feature-hint">{{ t('features.contextEstimate', { percent: contextReference.percentage.toFixed(2), window: contextReference.window }) }}</p>
4
+ <p v-else class="feature-hint">{{ t('features.windowStatus.' + (contextReference?.status || 'unknown')) }}</p>
5
+ <details class="feature-disclosure">
6
+ <summary>{{ t('features.windowSettings') }}</summary>
7
+ <div class="feature-window-fields">
8
+ <label v-if="sessionContextHealth.models?.length">{{ t('features.model') }}<select v-model="contextSelectedModel" :aria-label="t('features.model')"><option value="">{{ t('features.chooseModel') }}</option><option v-for="model in sessionContextHealth.models" :key="model" :value="model">{{ model }}</option></select></label>
9
+ <label>{{ t('features.contextWindow') }}<input v-model="contextWindowInput" type="number" min="1" step="1" :aria-label="t('features.contextWindow')"></label>
10
+ <button type="button" class="btn-mini" @click="saveContextPreferences(false)" :disabled="contextReference?.status === 'invalid'">{{ t('features.save') }}</button>
11
+ </div>
12
+ </details>
13
+ <div v-if="contextReference && ['warning', 'high'].includes(contextReference.status) && !contextReminderDismissed" role="status" class="feature-window-warning">
14
+ <span>{{ t('features.windowStatus.' + contextReference.status) }}</span>
15
+ <div class="feature-record-actions"><button type="button" class="btn-mini" @click="handoffExpanded = true">{{ t('features.handoffs') }}</button><button type="button" class="btn-mini feature-quiet" @click="saveContextPreferences(true)">{{ t('features.dismiss') }}</button></div>
16
+ </div>
17
+ </section>