codexmate 0.0.25 → 0.0.26
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.
- package/README.md +416 -413
- package/README.zh.md +349 -346
- package/cli/agents-files.js +224 -224
- package/cli/archive-helpers.js +446 -446
- package/cli/auth-profiles.js +375 -375
- package/cli/builtin-proxy.js +1079 -1079
- package/cli/claude-proxy.js +1022 -1022
- package/cli/config-bootstrap.js +384 -384
- package/cli/config-health.js +338 -338
- package/cli/doctor-core.js +903 -903
- package/cli/import-skills-url.js +356 -356
- package/cli/openai-bridge.js +997 -997
- package/cli/openclaw-config.js +629 -629
- package/cli/session-convert-args.js +65 -0
- package/cli/session-convert-io.js +82 -0
- package/cli/session-convert.js +43 -0
- package/cli/session-usage.concurrent.js +28 -28
- package/cli/session-usage.js +118 -118
- package/cli/session-usage.models.js +176 -176
- package/cli/skills.js +1141 -1141
- package/cli/zip-commands.js +510 -510
- package/cli.js +15218 -14736
- package/lib/automation.js +404 -404
- package/lib/cli-file-utils.js +151 -151
- package/lib/cli-models-utils.js +379 -379
- package/lib/cli-network-utils.js +190 -190
- package/lib/cli-path-utils.js +85 -85
- package/lib/cli-session-utils.js +121 -121
- package/lib/cli-sessions.js +417 -417
- package/lib/cli-utils.js +155 -155
- package/lib/download-artifacts.js +92 -92
- package/lib/mcp-stdio.js +453 -453
- package/lib/task-orchestrator.js +869 -869
- package/lib/text-diff.js +303 -303
- package/lib/workflow-engine.js +340 -340
- package/package.json +74 -74
- package/plugins/README.md +20 -20
- package/plugins/README.zh-CN.md +20 -20
- package/plugins/prompt-templates/comment-polish/index.mjs +25 -25
- package/plugins/prompt-templates/computed.mjs +253 -253
- package/plugins/prompt-templates/index.mjs +8 -8
- package/plugins/prompt-templates/manifest.mjs +15 -15
- package/plugins/prompt-templates/methods.mjs +619 -619
- package/plugins/prompt-templates/overview.mjs +90 -90
- package/plugins/prompt-templates/ownership.mjs +19 -19
- package/plugins/prompt-templates/rule-ack/index.mjs +21 -21
- package/plugins/prompt-templates/storage.mjs +64 -64
- package/plugins/registry.mjs +16 -16
- package/web-ui/app.js +625 -612
- package/web-ui/index.html +35 -35
- package/web-ui/logic.agents-diff.mjs +386 -386
- package/web-ui/logic.claude.mjs +168 -168
- package/web-ui/logic.mjs +5 -5
- package/web-ui/logic.runtime.mjs +128 -128
- package/web-ui/logic.session-convert.mjs +70 -0
- package/web-ui/logic.sessions.mjs +709 -614
- package/web-ui/modules/api.mjs +90 -90
- package/web-ui/modules/app.computed.dashboard.mjs +171 -128
- package/web-ui/modules/app.computed.index.mjs +17 -17
- package/web-ui/modules/app.computed.main-tabs.mjs +205 -205
- package/web-ui/modules/app.computed.session.mjs +946 -670
- package/web-ui/modules/app.constants.mjs +15 -15
- package/web-ui/modules/app.methods.agents.mjs +632 -632
- package/web-ui/modules/app.methods.claude-config.mjs +179 -174
- package/web-ui/modules/app.methods.codex-config.mjs +860 -784
- package/web-ui/modules/app.methods.index.mjs +92 -92
- package/web-ui/modules/app.methods.install.mjs +205 -205
- package/web-ui/modules/app.methods.navigation.mjs +743 -695
- package/web-ui/modules/app.methods.openclaw-core.mjs +814 -814
- package/web-ui/modules/app.methods.openclaw-editing.mjs +372 -372
- package/web-ui/modules/app.methods.openclaw-persist.mjs +369 -369
- package/web-ui/modules/app.methods.providers.mjs +404 -404
- package/web-ui/modules/app.methods.runtime.mjs +345 -345
- package/web-ui/modules/app.methods.session-actions.mjs +596 -544
- package/web-ui/modules/app.methods.session-browser.mjs +985 -722
- package/web-ui/modules/app.methods.session-timeline.mjs +479 -448
- package/web-ui/modules/app.methods.session-trash.mjs +424 -424
- package/web-ui/modules/app.methods.startup-claude.mjs +522 -417
- package/web-ui/modules/app.methods.task-orchestration.mjs +556 -556
- package/web-ui/modules/config-mode.computed.mjs +124 -124
- package/web-ui/modules/config-template-confirm-pref.mjs +33 -33
- package/web-ui/modules/i18n.dict.mjs +2113 -2055
- package/web-ui/modules/i18n.mjs +56 -56
- package/web-ui/modules/plugins.computed.mjs +3 -3
- package/web-ui/modules/plugins.methods.mjs +3 -3
- package/web-ui/modules/plugins.storage.mjs +11 -11
- package/web-ui/modules/sessions-filters-url.mjs +85 -85
- package/web-ui/modules/skills.computed.mjs +107 -107
- package/web-ui/modules/skills.methods.mjs +481 -481
- package/web-ui/partials/index/layout-footer.html +13 -13
- package/web-ui/partials/index/layout-header.html +475 -475
- package/web-ui/partials/index/modal-config-template-agents.html +174 -174
- package/web-ui/partials/index/modal-confirm-toast.html +32 -32
- package/web-ui/partials/index/modal-health-check.html +45 -45
- package/web-ui/partials/index/modal-openclaw-config.html +280 -280
- package/web-ui/partials/index/modal-skills.html +200 -200
- package/web-ui/partials/index/modals-basic.html +165 -165
- package/web-ui/partials/index/panel-config-claude.html +184 -179
- package/web-ui/partials/index/panel-config-codex.html +283 -283
- package/web-ui/partials/index/panel-config-openclaw.html +83 -83
- package/web-ui/partials/index/panel-dashboard.html +186 -186
- package/web-ui/partials/index/panel-docs.html +147 -147
- package/web-ui/partials/index/panel-market.html +177 -177
- package/web-ui/partials/index/panel-orchestration.html +391 -391
- package/web-ui/partials/index/panel-plugins.html +279 -279
- package/web-ui/partials/index/panel-sessions.html +326 -303
- package/web-ui/partials/index/panel-settings.html +258 -258
- package/web-ui/partials/index/panel-usage.html +342 -361
- package/web-ui/res/json5.min.js +1 -1
- package/web-ui/res/vue.global.prod.js +13 -13
- package/web-ui/session-helpers.mjs +576 -573
- package/web-ui/source-bundle.cjs +233 -233
- package/web-ui/styles/base-theme.css +268 -264
- package/web-ui/styles/controls-forms.css +423 -423
- package/web-ui/styles/dashboard.css +274 -274
- package/web-ui/styles/docs-panel.css +247 -247
- package/web-ui/styles/feedback.css +108 -108
- package/web-ui/styles/health-check-dialog.css +144 -144
- package/web-ui/styles/layout-shell.css +603 -603
- package/web-ui/styles/modals-core.css +464 -464
- package/web-ui/styles/navigation-panels.css +390 -390
- package/web-ui/styles/openclaw-structured.css +266 -266
- package/web-ui/styles/plugins-panel.css +523 -523
- package/web-ui/styles/responsive.css +454 -454
- package/web-ui/styles/sessions-list.css +415 -398
- package/web-ui/styles/sessions-preview.css +411 -411
- package/web-ui/styles/sessions-toolbar-trash.css +330 -268
- package/web-ui/styles/sessions-usage.css +945 -912
- package/web-ui/styles/settings-panel.css +166 -166
- package/web-ui/styles/skills-list.css +303 -303
- package/web-ui/styles/skills-market.css +406 -406
- package/web-ui/styles/task-orchestration.css +822 -822
- package/web-ui/styles/titles-cards.css +408 -408
- package/web-ui/styles.css +21 -21
- package/web-ui.html +17 -17
|
@@ -1,695 +1,743 @@
|
|
|
1
|
-
export function createNavigationMethods(options = {}) {
|
|
2
|
-
const {
|
|
3
|
-
configModeSet,
|
|
4
|
-
switchMainTabHelper,
|
|
5
|
-
loadMoreSessionMessagesHelper
|
|
6
|
-
} = options;
|
|
7
|
-
const NAV_STATE_STORAGE_KEY = 'codexmateNavState.v1';
|
|
8
|
-
const MAIN_TAB_SET = new Set([
|
|
9
|
-
'dashboard',
|
|
10
|
-
'config',
|
|
11
|
-
'sessions',
|
|
12
|
-
'usage',
|
|
13
|
-
'orchestration',
|
|
14
|
-
'market',
|
|
15
|
-
'plugins',
|
|
16
|
-
'docs',
|
|
17
|
-
'settings'
|
|
18
|
-
]);
|
|
19
|
-
const loadDoctorOverview = async (vm, options = {}) => {
|
|
20
|
-
if (!vm || typeof vm !== 'object') return false;
|
|
21
|
-
if (vm.__doctorLoading) return false;
|
|
22
|
-
const forceRefresh = !!(options && options.forceRefresh);
|
|
23
|
-
vm.__doctorLoading = true;
|
|
24
|
-
let ok = true;
|
|
25
|
-
try {
|
|
26
|
-
if (typeof vm.runHealthCheck === 'function') {
|
|
27
|
-
await vm.runHealthCheck({ doctor: true, silent: true, forceRefresh });
|
|
28
|
-
}
|
|
29
|
-
vm.__doctorLoadedOnce = true;
|
|
30
|
-
return true;
|
|
31
|
-
} catch (_) {
|
|
32
|
-
ok = false;
|
|
33
|
-
vm.__doctorLoadedOnce = true;
|
|
34
|
-
return false;
|
|
35
|
-
} finally {
|
|
36
|
-
vm.__doctorLoading = false;
|
|
37
|
-
if (!ok) {
|
|
38
|
-
vm.__doctorLoadedOnce = true;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const readNavState = () => {
|
|
43
|
-
if (typeof localStorage === 'undefined') return null;
|
|
44
|
-
let raw = '';
|
|
45
|
-
try {
|
|
46
|
-
raw = localStorage.getItem(NAV_STATE_STORAGE_KEY) || '';
|
|
47
|
-
} catch (_) {
|
|
48
|
-
raw = '';
|
|
49
|
-
}
|
|
50
|
-
if (!raw) return null;
|
|
51
|
-
try {
|
|
52
|
-
const parsed = JSON.parse(raw);
|
|
53
|
-
return parsed && typeof parsed === 'object' ? parsed : null;
|
|
54
|
-
} catch (_) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const persistNavState = (vm) => {
|
|
59
|
-
if (!vm || vm.__navStateRestoring) return;
|
|
60
|
-
if (typeof localStorage === 'undefined') return;
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
pendingConfigMode
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const normalizedTab = typeof tab === 'string'
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
const
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
},
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
this.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
if (
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
if (!
|
|
345
|
-
if (
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
this.
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
const
|
|
385
|
-
if (
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
const
|
|
406
|
-
switchState
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
return
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
this.
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
if (
|
|
567
|
-
this.
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
if (
|
|
575
|
-
return;
|
|
576
|
-
}
|
|
577
|
-
this.
|
|
578
|
-
|
|
579
|
-
},
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
if (
|
|
583
|
-
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
this.
|
|
616
|
-
},
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
this.
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
this.
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
this.
|
|
631
|
-
this.
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
this.
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
1
|
+
export function createNavigationMethods(options = {}) {
|
|
2
|
+
const {
|
|
3
|
+
configModeSet,
|
|
4
|
+
switchMainTabHelper,
|
|
5
|
+
loadMoreSessionMessagesHelper
|
|
6
|
+
} = options;
|
|
7
|
+
const NAV_STATE_STORAGE_KEY = 'codexmateNavState.v1';
|
|
8
|
+
const MAIN_TAB_SET = new Set([
|
|
9
|
+
'dashboard',
|
|
10
|
+
'config',
|
|
11
|
+
'sessions',
|
|
12
|
+
'usage',
|
|
13
|
+
'orchestration',
|
|
14
|
+
'market',
|
|
15
|
+
'plugins',
|
|
16
|
+
'docs',
|
|
17
|
+
'settings'
|
|
18
|
+
]);
|
|
19
|
+
const loadDoctorOverview = async (vm, options = {}) => {
|
|
20
|
+
if (!vm || typeof vm !== 'object') return false;
|
|
21
|
+
if (vm.__doctorLoading) return false;
|
|
22
|
+
const forceRefresh = !!(options && options.forceRefresh);
|
|
23
|
+
vm.__doctorLoading = true;
|
|
24
|
+
let ok = true;
|
|
25
|
+
try {
|
|
26
|
+
if (typeof vm.runHealthCheck === 'function') {
|
|
27
|
+
await vm.runHealthCheck({ doctor: true, silent: true, forceRefresh });
|
|
28
|
+
}
|
|
29
|
+
vm.__doctorLoadedOnce = true;
|
|
30
|
+
return true;
|
|
31
|
+
} catch (_) {
|
|
32
|
+
ok = false;
|
|
33
|
+
vm.__doctorLoadedOnce = true;
|
|
34
|
+
return false;
|
|
35
|
+
} finally {
|
|
36
|
+
vm.__doctorLoading = false;
|
|
37
|
+
if (!ok) {
|
|
38
|
+
vm.__doctorLoadedOnce = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const readNavState = () => {
|
|
43
|
+
if (typeof localStorage === 'undefined') return null;
|
|
44
|
+
let raw = '';
|
|
45
|
+
try {
|
|
46
|
+
raw = localStorage.getItem(NAV_STATE_STORAGE_KEY) || '';
|
|
47
|
+
} catch (_) {
|
|
48
|
+
raw = '';
|
|
49
|
+
}
|
|
50
|
+
if (!raw) return null;
|
|
51
|
+
try {
|
|
52
|
+
const parsed = JSON.parse(raw);
|
|
53
|
+
return parsed && typeof parsed === 'object' ? parsed : null;
|
|
54
|
+
} catch (_) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const persistNavState = (vm, overrides = null) => {
|
|
59
|
+
if (!vm || vm.__navStateRestoring) return;
|
|
60
|
+
if (typeof localStorage === 'undefined') return;
|
|
61
|
+
const resolvedOverrides = overrides && typeof overrides === 'object' ? overrides : null;
|
|
62
|
+
const mainTabSource = resolvedOverrides && typeof resolvedOverrides.mainTab === 'string'
|
|
63
|
+
? resolvedOverrides.mainTab
|
|
64
|
+
: vm.mainTab;
|
|
65
|
+
const configModeSource = resolvedOverrides && typeof resolvedOverrides.configMode === 'string'
|
|
66
|
+
? resolvedOverrides.configMode
|
|
67
|
+
: vm.configMode;
|
|
68
|
+
const mainTab = typeof mainTabSource === 'string' ? mainTabSource.trim().toLowerCase() : '';
|
|
69
|
+
const configMode = typeof configModeSource === 'string' ? configModeSource.trim().toLowerCase() : '';
|
|
70
|
+
const snapshot = {
|
|
71
|
+
mainTab: MAIN_TAB_SET.has(mainTab) ? mainTab : 'dashboard',
|
|
72
|
+
configMode: configModeSet && configModeSet.has(configMode) ? configMode : 'codex'
|
|
73
|
+
};
|
|
74
|
+
try {
|
|
75
|
+
localStorage.setItem(NAV_STATE_STORAGE_KEY, JSON.stringify(snapshot));
|
|
76
|
+
} catch (_) {}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
restoreNavStateFromStorage() {
|
|
81
|
+
if (this.__navStateRestoring) return false;
|
|
82
|
+
const restored = readNavState();
|
|
83
|
+
if (!restored) return false;
|
|
84
|
+
const nextMainTab = restored && typeof restored.mainTab === 'string'
|
|
85
|
+
? restored.mainTab.trim().toLowerCase()
|
|
86
|
+
: '';
|
|
87
|
+
const nextConfigMode = restored && typeof restored.configMode === 'string'
|
|
88
|
+
? restored.configMode.trim().toLowerCase()
|
|
89
|
+
: '';
|
|
90
|
+
const shouldUpdateConfigMode = !!(nextConfigMode && configModeSet && configModeSet.has(nextConfigMode));
|
|
91
|
+
const shouldUpdateMainTab = !!(nextMainTab && MAIN_TAB_SET.has(nextMainTab) && nextMainTab !== this.mainTab);
|
|
92
|
+
if (!shouldUpdateConfigMode && !shouldUpdateMainTab) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
this.__navStateRestoring = true;
|
|
96
|
+
try {
|
|
97
|
+
if (shouldUpdateConfigMode) {
|
|
98
|
+
this.configMode = nextConfigMode;
|
|
99
|
+
}
|
|
100
|
+
if (shouldUpdateMainTab) {
|
|
101
|
+
this.switchMainTab(nextMainTab);
|
|
102
|
+
}
|
|
103
|
+
} finally {
|
|
104
|
+
this.__navStateRestoring = false;
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
},
|
|
108
|
+
switchConfigMode(mode) {
|
|
109
|
+
const normalizedMode = typeof mode === 'string'
|
|
110
|
+
? mode.trim().toLowerCase()
|
|
111
|
+
: '';
|
|
112
|
+
this.cancelTouchNavIntentReset();
|
|
113
|
+
if (typeof this.ensureMainTabSwitchState === 'function') {
|
|
114
|
+
this.ensureMainTabSwitchState().pendingConfigMode = '';
|
|
115
|
+
}
|
|
116
|
+
this.configMode = configModeSet.has(normalizedMode) ? normalizedMode : 'codex';
|
|
117
|
+
if (this.mainTab === 'config') {
|
|
118
|
+
if (this.configMode === 'claude') {
|
|
119
|
+
const expectedMainTab = 'config';
|
|
120
|
+
const expectedConfigMode = 'claude';
|
|
121
|
+
const refresh = () => {
|
|
122
|
+
if (this.mainTab !== expectedMainTab || this.configMode !== expectedConfigMode) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
this.refreshClaudeModelContext();
|
|
126
|
+
};
|
|
127
|
+
if (typeof this.scheduleAfterFrame === 'function') {
|
|
128
|
+
this.scheduleAfterFrame(refresh);
|
|
129
|
+
} else {
|
|
130
|
+
refresh();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
this.scheduleAfterFrame(() => {
|
|
134
|
+
this.clearMainTabSwitchIntent('config');
|
|
135
|
+
});
|
|
136
|
+
persistNavState(this);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
persistNavState(this, {
|
|
140
|
+
mainTab: 'config',
|
|
141
|
+
configMode: normalizedMode
|
|
142
|
+
});
|
|
143
|
+
this.switchMainTab('config');
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
ensureMainTabSwitchState() {
|
|
147
|
+
if (this.__mainTabSwitchState) {
|
|
148
|
+
return this.__mainTabSwitchState;
|
|
149
|
+
}
|
|
150
|
+
this.__mainTabSwitchState = {
|
|
151
|
+
intent: '',
|
|
152
|
+
pendingTarget: '',
|
|
153
|
+
pendingConfigMode: '',
|
|
154
|
+
ticket: 0
|
|
155
|
+
};
|
|
156
|
+
return this.__mainTabSwitchState;
|
|
157
|
+
},
|
|
158
|
+
ensureImmediateNavDomState() {
|
|
159
|
+
if (typeof document === 'undefined') {
|
|
160
|
+
return {
|
|
161
|
+
navNodes: [],
|
|
162
|
+
sessionPanelEl: null
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
if (!this.__immediateNavDomState) {
|
|
166
|
+
this.__immediateNavDomState = {
|
|
167
|
+
navNodes: [],
|
|
168
|
+
sessionPanelEl: null
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
const state = this.__immediateNavDomState;
|
|
172
|
+
const needsNavRefresh = !Array.isArray(state.navNodes)
|
|
173
|
+
|| !state.navNodes.length
|
|
174
|
+
|| state.navNodes.some((node) => !node || !node.isConnected);
|
|
175
|
+
if (needsNavRefresh) {
|
|
176
|
+
state.navNodes = Array.from(document.querySelectorAll('[data-main-tab]'));
|
|
177
|
+
}
|
|
178
|
+
if (!state.sessionPanelEl || !state.sessionPanelEl.isConnected) {
|
|
179
|
+
state.sessionPanelEl = document.getElementById('panel-sessions');
|
|
180
|
+
}
|
|
181
|
+
return state;
|
|
182
|
+
},
|
|
183
|
+
setMainTabSwitchIntent(tab) {
|
|
184
|
+
const normalizedTab = typeof tab === 'string'
|
|
185
|
+
? tab.trim().toLowerCase()
|
|
186
|
+
: '';
|
|
187
|
+
if (!normalizedTab) return;
|
|
188
|
+
const state = this.ensureMainTabSwitchState();
|
|
189
|
+
state.intent = normalizedTab;
|
|
190
|
+
},
|
|
191
|
+
cancelTouchNavIntentReset() {
|
|
192
|
+
if (this.__touchNavIntentResetTimer) {
|
|
193
|
+
clearTimeout(this.__touchNavIntentResetTimer);
|
|
194
|
+
this.__touchNavIntentResetTimer = null;
|
|
195
|
+
}
|
|
196
|
+
this.__touchNavIntentResetToken = 0;
|
|
197
|
+
},
|
|
198
|
+
scheduleTouchNavIntentReset(kind, value) {
|
|
199
|
+
const normalizedKind = typeof kind === 'string' ? kind.trim().toLowerCase() : '';
|
|
200
|
+
const normalizedValue = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
201
|
+
if (!normalizedKind || !normalizedValue) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const expectedIntent = normalizedKind === 'config' ? 'config' : normalizedValue;
|
|
205
|
+
this.cancelTouchNavIntentReset();
|
|
206
|
+
const token = (Number(this.__touchNavIntentResetToken) || 0) + 1;
|
|
207
|
+
this.__touchNavIntentResetToken = token;
|
|
208
|
+
this.__touchNavIntentResetTimer = setTimeout(() => {
|
|
209
|
+
if (this.__touchNavIntentResetToken !== token) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
this.__touchNavIntentResetTimer = null;
|
|
213
|
+
this.__touchNavIntentResetToken = 0;
|
|
214
|
+
const liveIntent = String(this.ensureMainTabSwitchState().intent || '').trim().toLowerCase();
|
|
215
|
+
if (liveIntent !== expectedIntent) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
this.clearMainTabSwitchIntent(expectedIntent);
|
|
219
|
+
}, 1000);
|
|
220
|
+
},
|
|
221
|
+
applyImmediateNavIntent(tab, configMode = '') {
|
|
222
|
+
if (typeof document === 'undefined') return;
|
|
223
|
+
const normalizedTab = typeof tab === 'string' ? tab.trim().toLowerCase() : '';
|
|
224
|
+
if (!normalizedTab) return;
|
|
225
|
+
const normalizedMode = typeof configMode === 'string' ? configMode.trim().toLowerCase() : '';
|
|
226
|
+
const domState = this.ensureImmediateNavDomState();
|
|
227
|
+
const nodes = Array.isArray(domState.navNodes) ? domState.navNodes : [];
|
|
228
|
+
for (const node of nodes) {
|
|
229
|
+
if (!node || !node.classList) continue;
|
|
230
|
+
const nodeTab = String(node.getAttribute('data-main-tab') || '').trim().toLowerCase();
|
|
231
|
+
const nodeMode = String(node.getAttribute('data-config-mode') || '').trim().toLowerCase();
|
|
232
|
+
let shouldActivate = nodeTab === normalizedTab;
|
|
233
|
+
if (shouldActivate && normalizedTab === 'config') {
|
|
234
|
+
shouldActivate = nodeMode ? nodeMode === normalizedMode : false;
|
|
235
|
+
}
|
|
236
|
+
node.classList.toggle('nav-intent-active', !!shouldActivate);
|
|
237
|
+
node.classList.toggle('nav-intent-inactive', !shouldActivate);
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
clearImmediateNavIntent() {
|
|
241
|
+
if (typeof document === 'undefined') return;
|
|
242
|
+
const domState = this.ensureImmediateNavDomState();
|
|
243
|
+
const nodes = Array.isArray(domState.navNodes) ? domState.navNodes : [];
|
|
244
|
+
for (const node of nodes) {
|
|
245
|
+
if (!node || !node.classList) continue;
|
|
246
|
+
node.classList.remove('nav-intent-active');
|
|
247
|
+
node.classList.remove('nav-intent-inactive');
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
setSessionPanelFastHidden(hidden) {
|
|
251
|
+
if (typeof document === 'undefined') return;
|
|
252
|
+
const domState = this.ensureImmediateNavDomState();
|
|
253
|
+
const panel = domState.sessionPanelEl;
|
|
254
|
+
if (!panel || !panel.classList) return;
|
|
255
|
+
panel.classList.toggle('session-panel-fast-hidden', !!hidden);
|
|
256
|
+
},
|
|
257
|
+
isSessionPanelFastHidden() {
|
|
258
|
+
if (typeof document === 'undefined') return false;
|
|
259
|
+
const domState = this.ensureImmediateNavDomState();
|
|
260
|
+
const panel = domState.sessionPanelEl;
|
|
261
|
+
return !!(panel && panel.classList && panel.classList.contains('session-panel-fast-hidden'));
|
|
262
|
+
},
|
|
263
|
+
recordPointerNavCommit(kind, value) {
|
|
264
|
+
const normalizedKind = typeof kind === 'string' ? kind.trim().toLowerCase() : '';
|
|
265
|
+
const normalizedValue = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
266
|
+
if (!normalizedKind || !normalizedValue) {
|
|
267
|
+
this.__pointerNavCommitState = null;
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
this.__pointerNavCommitState = {
|
|
271
|
+
kind: normalizedKind,
|
|
272
|
+
value: normalizedValue,
|
|
273
|
+
at: Date.now()
|
|
274
|
+
};
|
|
275
|
+
},
|
|
276
|
+
consumePointerNavCommit(kind, value) {
|
|
277
|
+
const normalizedKind = typeof kind === 'string' ? kind.trim().toLowerCase() : '';
|
|
278
|
+
const normalizedValue = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
279
|
+
const state = this.__pointerNavCommitState;
|
|
280
|
+
this.__pointerNavCommitState = null;
|
|
281
|
+
if (!state || !normalizedKind || !normalizedValue) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
if (state.kind !== normalizedKind || state.value !== normalizedValue) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
return (Date.now() - Number(state.at || 0)) <= 1000;
|
|
288
|
+
},
|
|
289
|
+
onMainTabPointerDown(tab) {
|
|
290
|
+
const event = arguments.length > 1 ? arguments[1] : null;
|
|
291
|
+
if (event && typeof event.button === 'number' && event.button !== 0) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const normalizedTab = typeof tab === 'string' ? tab.trim().toLowerCase() : '';
|
|
295
|
+
if (!normalizedTab) return;
|
|
296
|
+
persistNavState(this, { mainTab: normalizedTab });
|
|
297
|
+
this.setMainTabSwitchIntent(normalizedTab);
|
|
298
|
+
this.applyImmediateNavIntent(normalizedTab);
|
|
299
|
+
const shouldHideSessionPanel = this.mainTab === 'sessions' && normalizedTab !== 'sessions';
|
|
300
|
+
this.setSessionPanelFastHidden(shouldHideSessionPanel);
|
|
301
|
+
const pointerType = event && typeof event.pointerType === 'string'
|
|
302
|
+
? event.pointerType.trim().toLowerCase()
|
|
303
|
+
: '';
|
|
304
|
+
if (pointerType === 'touch') {
|
|
305
|
+
this.scheduleTouchNavIntentReset('main', normalizedTab);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
this.recordPointerNavCommit('main', normalizedTab);
|
|
309
|
+
this.switchMainTab(normalizedTab);
|
|
310
|
+
},
|
|
311
|
+
onConfigTabPointerDown(mode) {
|
|
312
|
+
const event = arguments.length > 1 ? arguments[1] : null;
|
|
313
|
+
if (event && typeof event.button === 'number' && event.button !== 0) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
const normalizedMode = typeof mode === 'string' ? mode.trim().toLowerCase() : '';
|
|
317
|
+
if (!normalizedMode) return;
|
|
318
|
+
persistNavState(this, { mainTab: 'config', configMode: normalizedMode });
|
|
319
|
+
this.setMainTabSwitchIntent('config');
|
|
320
|
+
if (typeof this.ensureMainTabSwitchState === 'function') {
|
|
321
|
+
this.ensureMainTabSwitchState().pendingConfigMode = normalizedMode;
|
|
322
|
+
}
|
|
323
|
+
this.applyImmediateNavIntent('config', normalizedMode);
|
|
324
|
+
const shouldHideSessionPanel = this.mainTab === 'sessions';
|
|
325
|
+
this.setSessionPanelFastHidden(shouldHideSessionPanel);
|
|
326
|
+
const pointerType = event && typeof event.pointerType === 'string'
|
|
327
|
+
? event.pointerType.trim().toLowerCase()
|
|
328
|
+
: '';
|
|
329
|
+
if (pointerType === 'touch') {
|
|
330
|
+
this.scheduleTouchNavIntentReset('config', normalizedMode);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
this.recordPointerNavCommit('config', normalizedMode);
|
|
334
|
+
this.switchConfigMode(normalizedMode);
|
|
335
|
+
},
|
|
336
|
+
onMainTabClick(tab) {
|
|
337
|
+
const normalizedTab = typeof tab === 'string' ? tab.trim().toLowerCase() : '';
|
|
338
|
+
if (!normalizedTab) return;
|
|
339
|
+
if (this.consumePointerNavCommit('main', normalizedTab)) return;
|
|
340
|
+
this.switchMainTab(normalizedTab);
|
|
341
|
+
},
|
|
342
|
+
onConfigTabClick(mode) {
|
|
343
|
+
const normalizedMode = typeof mode === 'string' ? mode.trim().toLowerCase() : '';
|
|
344
|
+
if (!normalizedMode) return;
|
|
345
|
+
if (this.consumePointerNavCommit('config', normalizedMode)) return;
|
|
346
|
+
this.switchConfigMode(normalizedMode);
|
|
347
|
+
},
|
|
348
|
+
clearMainTabSwitchIntent(expectedTab = '') {
|
|
349
|
+
const state = this.ensureMainTabSwitchState();
|
|
350
|
+
if (expectedTab && state.intent && state.intent !== expectedTab) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
this.cancelTouchNavIntentReset();
|
|
354
|
+
state.intent = '';
|
|
355
|
+
state.pendingTarget = '';
|
|
356
|
+
state.pendingConfigMode = '';
|
|
357
|
+
this.clearImmediateNavIntent();
|
|
358
|
+
this.setSessionPanelFastHidden(false);
|
|
359
|
+
},
|
|
360
|
+
getMainTabForNav() {
|
|
361
|
+
const state = this.ensureMainTabSwitchState();
|
|
362
|
+
return state.intent || this.mainTab;
|
|
363
|
+
},
|
|
364
|
+
isMainTabNavActive(tab) {
|
|
365
|
+
return this.getMainTabForNav() === tab;
|
|
366
|
+
},
|
|
367
|
+
isConfigModeNavActive(mode) {
|
|
368
|
+
if (!this.isMainTabNavActive('config')) {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
const state = this.ensureMainTabSwitchState();
|
|
372
|
+
const pendingMode = typeof state.pendingConfigMode === 'string'
|
|
373
|
+
? state.pendingConfigMode.trim().toLowerCase()
|
|
374
|
+
: '';
|
|
375
|
+
if (state.intent === 'config' && pendingMode) {
|
|
376
|
+
return pendingMode === mode;
|
|
377
|
+
}
|
|
378
|
+
return this.configMode === mode;
|
|
379
|
+
},
|
|
380
|
+
switchMainTab(tab) {
|
|
381
|
+
const normalizedTab = typeof tab === 'string'
|
|
382
|
+
? tab.trim().toLowerCase()
|
|
383
|
+
: '';
|
|
384
|
+
const targetTab = normalizedTab || tab;
|
|
385
|
+
if (!targetTab) return;
|
|
386
|
+
if (targetTab === 'orchestration' && this.taskOrchestrationTabEnabled !== true) {
|
|
387
|
+
return this.switchMainTab('config');
|
|
388
|
+
}
|
|
389
|
+
persistNavState(this, {
|
|
390
|
+
mainTab: targetTab,
|
|
391
|
+
configMode: targetTab === 'config' ? this.configMode : this.configMode
|
|
392
|
+
});
|
|
393
|
+
this.cancelTouchNavIntentReset();
|
|
394
|
+
if (targetTab === 'sessions') {
|
|
395
|
+
this.cancelScheduledSessionTabDeferredTeardown();
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
this.setMainTabSwitchIntent(targetTab);
|
|
399
|
+
if (targetTab === 'config') {
|
|
400
|
+
this.applyImmediateNavIntent('config', this.configMode);
|
|
401
|
+
} else {
|
|
402
|
+
this.applyImmediateNavIntent(targetTab);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const previousTab = this.mainTab;
|
|
406
|
+
const switchState = this.ensureMainTabSwitchState();
|
|
407
|
+
if (targetTab !== 'config') {
|
|
408
|
+
switchState.pendingConfigMode = '';
|
|
409
|
+
}
|
|
410
|
+
if (targetTab === previousTab) {
|
|
411
|
+
switchState.ticket += 1;
|
|
412
|
+
switchState.pendingTarget = '';
|
|
413
|
+
if (targetTab === 'dashboard' && !this.__doctorLoadedOnce) {
|
|
414
|
+
void loadDoctorOverview(this);
|
|
415
|
+
}
|
|
416
|
+
if (
|
|
417
|
+
targetTab === 'sessions'
|
|
418
|
+
&& typeof this.prepareSessionTabRender === 'function'
|
|
419
|
+
&& (!this.sessionListRenderEnabled || !this.sessionPreviewRenderEnabled)
|
|
420
|
+
) {
|
|
421
|
+
this.prepareSessionTabRender();
|
|
422
|
+
}
|
|
423
|
+
this.scheduleAfterFrame(() => {
|
|
424
|
+
this.clearMainTabSwitchIntent(normalizedTab);
|
|
425
|
+
});
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
const isLeavingSessions = previousTab === 'sessions' && targetTab !== 'sessions';
|
|
429
|
+
const shouldDeferApply = isLeavingSessions;
|
|
430
|
+
if (isLeavingSessions && !this.isSessionPanelFastHidden()) {
|
|
431
|
+
this.setSessionPanelFastHidden(true);
|
|
432
|
+
}
|
|
433
|
+
if (shouldDeferApply && typeof this.suspendSessionTabRender === 'function') {
|
|
434
|
+
this.suspendSessionTabRender();
|
|
435
|
+
}
|
|
436
|
+
if (!shouldDeferApply) {
|
|
437
|
+
switchState.ticket += 1;
|
|
438
|
+
switchState.pendingTarget = '';
|
|
439
|
+
const result = switchMainTabHelper.call(this, targetTab);
|
|
440
|
+
persistNavState(this);
|
|
441
|
+
if (targetTab === 'dashboard') {
|
|
442
|
+
void loadDoctorOverview(this);
|
|
443
|
+
}
|
|
444
|
+
this.scheduleAfterFrame(() => {
|
|
445
|
+
this.clearMainTabSwitchIntent(normalizedTab);
|
|
446
|
+
});
|
|
447
|
+
return result;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const ticket = ++switchState.ticket;
|
|
451
|
+
switchState.pendingTarget = targetTab;
|
|
452
|
+
this.scheduleAfterFrame(() => {
|
|
453
|
+
const liveState = this.ensureMainTabSwitchState();
|
|
454
|
+
if (ticket !== liveState.ticket) return;
|
|
455
|
+
const pendingTarget = liveState.pendingTarget || targetTab;
|
|
456
|
+
liveState.pendingTarget = '';
|
|
457
|
+
switchMainTabHelper.call(this, pendingTarget);
|
|
458
|
+
persistNavState(this);
|
|
459
|
+
if (pendingTarget === 'dashboard') {
|
|
460
|
+
void loadDoctorOverview(this);
|
|
461
|
+
}
|
|
462
|
+
this.clearMainTabSwitchIntent(normalizedTab);
|
|
463
|
+
});
|
|
464
|
+
},
|
|
465
|
+
|
|
466
|
+
scheduleAfterFrame(task) {
|
|
467
|
+
const callback = typeof task === 'function' ? task : () => {};
|
|
468
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
469
|
+
requestAnimationFrame(callback);
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
setTimeout(callback, 16);
|
|
473
|
+
},
|
|
474
|
+
scheduleIdleTask(task, timeoutMs = 160) {
|
|
475
|
+
const callback = typeof task === 'function' ? task : () => {};
|
|
476
|
+
const timeout = Number.isFinite(timeoutMs)
|
|
477
|
+
? Math.max(16, Math.floor(timeoutMs))
|
|
478
|
+
: 160;
|
|
479
|
+
if (typeof requestIdleCallback === 'function') {
|
|
480
|
+
const id = requestIdleCallback(callback, { timeout });
|
|
481
|
+
return {
|
|
482
|
+
type: 'idle',
|
|
483
|
+
id
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
const id = setTimeout(callback, timeout);
|
|
487
|
+
return {
|
|
488
|
+
type: 'timeout',
|
|
489
|
+
id
|
|
490
|
+
};
|
|
491
|
+
},
|
|
492
|
+
cancelIdleTask(handle) {
|
|
493
|
+
if (!handle || typeof handle !== 'object') return;
|
|
494
|
+
const type = handle.type;
|
|
495
|
+
const id = handle.id;
|
|
496
|
+
if (type === 'idle') {
|
|
497
|
+
if (typeof cancelIdleCallback === 'function') {
|
|
498
|
+
cancelIdleCallback(id);
|
|
499
|
+
} else {
|
|
500
|
+
clearTimeout(id);
|
|
501
|
+
}
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
if (type === 'timeout') {
|
|
505
|
+
clearTimeout(id);
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
scheduleSessionTabDeferredTeardown(task) {
|
|
509
|
+
const callback = typeof task === 'function' ? task : () => {};
|
|
510
|
+
this.cancelScheduledSessionTabDeferredTeardown();
|
|
511
|
+
this.__sessionTabDeferredTeardownHandle = this.scheduleIdleTask(() => {
|
|
512
|
+
this.__sessionTabDeferredTeardownHandle = null;
|
|
513
|
+
callback();
|
|
514
|
+
}, 180);
|
|
515
|
+
},
|
|
516
|
+
cancelScheduledSessionTabDeferredTeardown() {
|
|
517
|
+
const handle = this.__sessionTabDeferredTeardownHandle || null;
|
|
518
|
+
if (!handle) return;
|
|
519
|
+
this.cancelIdleTask(handle);
|
|
520
|
+
this.__sessionTabDeferredTeardownHandle = null;
|
|
521
|
+
},
|
|
522
|
+
|
|
523
|
+
setSessionListRef(element) {
|
|
524
|
+
this.__sessionListRef = element || null;
|
|
525
|
+
if (this.__sessionListRef && this.mainTab === 'sessions' && this.sessionListRenderEnabled) {
|
|
526
|
+
this.scheduleSessionListViewportFill();
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
getSessionListRenderSource() {
|
|
530
|
+
return Array.isArray(this.sortedSessionsList) ? this.sortedSessionsList : [];
|
|
531
|
+
},
|
|
532
|
+
cancelScheduledSessionListViewportFill() {
|
|
533
|
+
const handle = this.__sessionListViewportFillHandle || null;
|
|
534
|
+
if (!handle) return;
|
|
535
|
+
this.cancelIdleTask(handle);
|
|
536
|
+
this.__sessionListViewportFillHandle = null;
|
|
537
|
+
},
|
|
538
|
+
resetSessionListRender() {
|
|
539
|
+
this.cancelScheduledSessionListViewportFill();
|
|
540
|
+
this.sessionListVisibleCount = 0;
|
|
541
|
+
},
|
|
542
|
+
expandVisibleSessionList(stepSize, options = {}) {
|
|
543
|
+
const list = this.getSessionListRenderSource();
|
|
544
|
+
const total = list.length;
|
|
545
|
+
if (total <= 0) {
|
|
546
|
+
this.sessionListVisibleCount = 0;
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
const rawVisibleCount = Number(this.sessionListVisibleCount);
|
|
550
|
+
const currentCount = Number.isFinite(rawVisibleCount)
|
|
551
|
+
? Math.max(0, Math.floor(rawVisibleCount))
|
|
552
|
+
: 0;
|
|
553
|
+
const initialBatchSize = Number.isFinite(this.sessionListInitialBatchSize)
|
|
554
|
+
? Math.max(1, Math.floor(this.sessionListInitialBatchSize))
|
|
555
|
+
: 80;
|
|
556
|
+
const loadStep = Number.isFinite(stepSize)
|
|
557
|
+
? Math.max(0, Math.floor(stepSize))
|
|
558
|
+
: (Number.isFinite(this.sessionListLoadStep)
|
|
559
|
+
? Math.max(1, Math.floor(this.sessionListLoadStep))
|
|
560
|
+
: 120);
|
|
561
|
+
let nextCount = currentCount > 0
|
|
562
|
+
? Math.min(total, currentCount + loadStep)
|
|
563
|
+
: Math.min(total, initialBatchSize);
|
|
564
|
+
if (options && options.ensureActive !== false) {
|
|
565
|
+
const activeKey = this.activeSession ? this.getSessionExportKey(this.activeSession) : '';
|
|
566
|
+
if (activeKey) {
|
|
567
|
+
const activeIndex = list.findIndex((session) => this.getSessionExportKey(session) === activeKey);
|
|
568
|
+
if (activeIndex >= 0) {
|
|
569
|
+
nextCount = Math.max(nextCount, activeIndex + 1);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
nextCount = Math.min(total, nextCount);
|
|
574
|
+
if (nextCount <= currentCount) {
|
|
575
|
+
return false;
|
|
576
|
+
}
|
|
577
|
+
this.sessionListVisibleCount = nextCount;
|
|
578
|
+
return true;
|
|
579
|
+
},
|
|
580
|
+
scheduleSessionListViewportFill() {
|
|
581
|
+
this.cancelScheduledSessionListViewportFill();
|
|
582
|
+
if (this.mainTab !== 'sessions' || !this.sessionListRenderEnabled) {
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
const run = () => {
|
|
586
|
+
this.__sessionListViewportFillHandle = null;
|
|
587
|
+
if (this.mainTab !== 'sessions' || !this.sessionListRenderEnabled) {
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
const list = this.getSessionListRenderSource();
|
|
591
|
+
const total = list.length;
|
|
592
|
+
const visibleCount = Number(this.sessionListVisibleCount);
|
|
593
|
+
const normalizedVisibleCount = Number.isFinite(visibleCount)
|
|
594
|
+
? Math.max(0, Math.floor(visibleCount))
|
|
595
|
+
: 0;
|
|
596
|
+
if (total <= 0 || normalizedVisibleCount >= total) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
const listEl = this.__sessionListRef || null;
|
|
600
|
+
if (!listEl) {
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
const clientHeight = Number(listEl.clientHeight) || 0;
|
|
604
|
+
const scrollHeight = Number(listEl.scrollHeight) || 0;
|
|
605
|
+
const scrollTop = Number(listEl.scrollTop) || 0;
|
|
606
|
+
const remaining = Math.max(0, scrollHeight - scrollTop - clientHeight);
|
|
607
|
+
const shouldGrow = scrollHeight <= (clientHeight + 160) || remaining <= Math.max(160, clientHeight);
|
|
608
|
+
if (!shouldGrow) {
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
if (this.expandVisibleSessionList(undefined, { ensureActive: true })) {
|
|
612
|
+
this.scheduleSessionListViewportFill();
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
this.__sessionListViewportFillHandle = this.scheduleIdleTask(run, 120);
|
|
616
|
+
},
|
|
617
|
+
primeSessionListRender() {
|
|
618
|
+
this.resetSessionListRender();
|
|
619
|
+
if (this.mainTab !== 'sessions' || !this.sessionListRenderEnabled) {
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
this.expandVisibleSessionList(undefined, { ensureActive: true });
|
|
623
|
+
this.scheduleSessionListViewportFill();
|
|
624
|
+
},
|
|
625
|
+
onSessionListScroll(event) {
|
|
626
|
+
const nextRef = event && event.currentTarget ? event.currentTarget : this.__sessionListRef;
|
|
627
|
+
if (nextRef) {
|
|
628
|
+
this.__sessionListRef = nextRef;
|
|
629
|
+
}
|
|
630
|
+
this.scheduleSessionListViewportFill();
|
|
631
|
+
if (typeof this.scheduleSessionListMessageCountHydrate === 'function') {
|
|
632
|
+
this.scheduleSessionListMessageCountHydrate();
|
|
633
|
+
}
|
|
634
|
+
},
|
|
635
|
+
|
|
636
|
+
resetSessionPreviewMessageRender() {
|
|
637
|
+
this.sessionPreviewVisibleCount = 0;
|
|
638
|
+
this.invalidateSessionTimelineMeasurementCache();
|
|
639
|
+
},
|
|
640
|
+
|
|
641
|
+
resetSessionDetailPagination() {
|
|
642
|
+
const initialLimit = Number.isFinite(this.sessionDetailInitialMessageLimit)
|
|
643
|
+
? Math.max(1, Math.floor(this.sessionDetailInitialMessageLimit))
|
|
644
|
+
: 80;
|
|
645
|
+
this.sessionDetailMessageLimit = initialLimit;
|
|
646
|
+
this.sessionPreviewPendingVisibleCount = 0;
|
|
647
|
+
},
|
|
648
|
+
|
|
649
|
+
primeSessionPreviewMessageRender() {
|
|
650
|
+
this.sessionPreviewVisibleCount = 0;
|
|
651
|
+
this.invalidateSessionTimelineMeasurementCache();
|
|
652
|
+
if (this.mainTab !== 'sessions' || !this.sessionPreviewRenderEnabled) {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
const total = Array.isArray(this.activeSessionMessages)
|
|
656
|
+
? this.activeSessionMessages.length
|
|
657
|
+
: 0;
|
|
658
|
+
if (total <= 0) return;
|
|
659
|
+
const baseSize = Number.isFinite(this.sessionPreviewInitialBatchSize)
|
|
660
|
+
? Math.max(1, Math.floor(this.sessionPreviewInitialBatchSize))
|
|
661
|
+
: 40;
|
|
662
|
+
this.sessionPreviewVisibleCount = Math.min(baseSize, total);
|
|
663
|
+
this.invalidateSessionTimelineMeasurementCache();
|
|
664
|
+
},
|
|
665
|
+
|
|
666
|
+
async loadMoreSessionMessages(stepSize) {
|
|
667
|
+
return loadMoreSessionMessagesHelper.call(this, stepSize);
|
|
668
|
+
},
|
|
669
|
+
|
|
670
|
+
suspendSessionTabRender() {
|
|
671
|
+
this.sessionTabRenderTicket += 1;
|
|
672
|
+
this.sessionListRenderEnabled = false;
|
|
673
|
+
this.sessionPreviewRenderEnabled = false;
|
|
674
|
+
this.cancelScheduledSessionListViewportFill();
|
|
675
|
+
this.cancelSessionTimelineSync();
|
|
676
|
+
this.sessionTimelineActiveKey = '';
|
|
677
|
+
this.sessionTimelineLastSyncAt = 0;
|
|
678
|
+
this.sessionTimelineLastScrollTop = 0;
|
|
679
|
+
this.sessionTimelineLastAnchorY = 0;
|
|
680
|
+
this.sessionTimelineLastDirection = 0;
|
|
681
|
+
this.__sessionListRef = null;
|
|
682
|
+
this.sessionPreviewScrollEl = null;
|
|
683
|
+
this.sessionPreviewContainerEl = null;
|
|
684
|
+
this.sessionPreviewHeaderEl = null;
|
|
685
|
+
},
|
|
686
|
+
|
|
687
|
+
finalizeSessionTabTeardown() {
|
|
688
|
+
this.resetSessionListRender();
|
|
689
|
+
this.resetSessionPreviewMessageRender();
|
|
690
|
+
this.sessionPreviewPendingVisibleCount = 0;
|
|
691
|
+
this.clearSessionTimelineRefs();
|
|
692
|
+
},
|
|
693
|
+
|
|
694
|
+
teardownSessionTabRender() {
|
|
695
|
+
this.suspendSessionTabRender();
|
|
696
|
+
this.finalizeSessionTabTeardown();
|
|
697
|
+
},
|
|
698
|
+
|
|
699
|
+
prepareSessionTabRender() {
|
|
700
|
+
const ticket = ++this.sessionTabRenderTicket;
|
|
701
|
+
this.sessionListRenderEnabled = false;
|
|
702
|
+
this.sessionPreviewRenderEnabled = false;
|
|
703
|
+
this.resetSessionListRender();
|
|
704
|
+
this.resetSessionPreviewMessageRender();
|
|
705
|
+
|
|
706
|
+
this.scheduleAfterFrame(() => {
|
|
707
|
+
if (ticket !== this.sessionTabRenderTicket || this.mainTab !== 'sessions') {
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
this.sessionListRenderEnabled = true;
|
|
711
|
+
this.primeSessionListRender();
|
|
712
|
+
|
|
713
|
+
this.scheduleAfterFrame(() => {
|
|
714
|
+
if (ticket !== this.sessionTabRenderTicket || this.mainTab !== 'sessions') {
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
this.sessionPreviewRenderEnabled = true;
|
|
718
|
+
this.$nextTick(() => {
|
|
719
|
+
if (ticket !== this.sessionTabRenderTicket || this.mainTab !== 'sessions') {
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
this.primeSessionPreviewMessageRender();
|
|
723
|
+
this.updateSessionTimelineOffset();
|
|
724
|
+
if (!this.sessionTimelineEnabled) {
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
const syncTask = () => {
|
|
728
|
+
if (ticket !== this.sessionTabRenderTicket || this.mainTab !== 'sessions') {
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
this.scheduleSessionTimelineSync();
|
|
732
|
+
};
|
|
733
|
+
if (typeof this.scheduleAfterFrame === 'function') {
|
|
734
|
+
this.scheduleAfterFrame(syncTask);
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
syncTask();
|
|
738
|
+
});
|
|
739
|
+
});
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
}
|