codexmate 0.0.20 → 0.0.21

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