codexmate 0.0.18 → 0.0.20
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.en.md +34 -17
- package/README.md +34 -25
- package/cli/config-health.js +338 -0
- package/cli.js +1570 -839
- package/lib/cli-models-utils.js +186 -27
- package/lib/cli-network-utils.js +117 -101
- package/package.json +8 -1
- package/web-ui/app.js +379 -5754
- package/web-ui/index.html +15 -2079
- package/web-ui/logic.agents-diff.mjs +386 -0
- package/web-ui/logic.claude.mjs +108 -0
- package/web-ui/logic.mjs +5 -793
- package/web-ui/logic.runtime.mjs +124 -0
- package/web-ui/logic.sessions.mjs +263 -0
- package/web-ui/modules/api.mjs +69 -0
- package/web-ui/modules/app.computed.dashboard.mjs +113 -0
- package/web-ui/modules/app.computed.index.mjs +13 -0
- package/web-ui/modules/app.computed.session.mjs +141 -0
- package/web-ui/modules/app.constants.mjs +15 -0
- package/web-ui/modules/app.methods.agents.mjs +493 -0
- package/web-ui/modules/app.methods.claude-config.mjs +174 -0
- package/web-ui/modules/app.methods.codex-config.mjs +640 -0
- package/web-ui/modules/app.methods.index.mjs +86 -0
- package/web-ui/modules/app.methods.install.mjs +157 -0
- package/web-ui/modules/app.methods.navigation.mjs +478 -0
- package/web-ui/modules/app.methods.openclaw-core.mjs +514 -0
- package/web-ui/modules/app.methods.openclaw-editing.mjs +337 -0
- package/web-ui/modules/app.methods.openclaw-persist.mjs +251 -0
- package/web-ui/modules/app.methods.providers.mjs +265 -0
- package/web-ui/modules/app.methods.runtime.mjs +323 -0
- package/web-ui/modules/app.methods.session-actions.mjs +457 -0
- package/web-ui/modules/app.methods.session-browser.mjs +435 -0
- package/web-ui/modules/app.methods.session-timeline.mjs +441 -0
- package/web-ui/modules/app.methods.session-trash.mjs +419 -0
- package/web-ui/modules/app.methods.startup-claude.mjs +406 -0
- package/web-ui/modules/config-mode.computed.mjs +1 -0
- package/web-ui/modules/skills.computed.mjs +26 -1
- package/web-ui/modules/skills.methods.mjs +154 -23
- package/web-ui/partials/index/layout-footer.html +69 -0
- package/web-ui/partials/index/layout-header.html +337 -0
- package/web-ui/partials/index/modal-config-template-agents.html +125 -0
- package/web-ui/partials/index/modal-confirm-toast.html +32 -0
- package/web-ui/partials/index/modal-health-check.html +72 -0
- package/web-ui/partials/index/modal-openclaw-config.html +275 -0
- package/web-ui/partials/index/modal-skills.html +184 -0
- package/web-ui/partials/index/modals-basic.html +196 -0
- package/web-ui/partials/index/panel-config-claude.html +100 -0
- package/web-ui/partials/index/panel-config-codex.html +237 -0
- package/web-ui/partials/index/panel-config-openclaw.html +84 -0
- package/web-ui/partials/index/panel-market.html +174 -0
- package/web-ui/partials/index/panel-sessions.html +387 -0
- package/web-ui/partials/index/panel-settings.html +166 -0
- package/web-ui/session-helpers.mjs +12 -0
- package/web-ui/source-bundle.cjs +233 -0
- package/web-ui/styles/base-theme.css +373 -0
- package/web-ui/styles/controls-forms.css +354 -0
- package/web-ui/styles/feedback.css +108 -0
- package/web-ui/styles/health-check-dialog.css +144 -0
- package/web-ui/styles/layout-shell.css +330 -0
- package/web-ui/styles/modals-core.css +449 -0
- package/web-ui/styles/navigation-panels.css +381 -0
- package/web-ui/styles/openclaw-structured.css +266 -0
- package/web-ui/styles/responsive.css +416 -0
- package/web-ui/styles/sessions-list.css +414 -0
- package/web-ui/styles/sessions-preview.css +405 -0
- package/web-ui/styles/sessions-toolbar-trash.css +243 -0
- package/web-ui/styles/sessions-usage.css +276 -0
- package/web-ui/styles/skills-list.css +298 -0
- package/web-ui/styles/skills-market.css +335 -0
- package/web-ui/styles/titles-cards.css +407 -0
- package/web-ui/styles.css +16 -4499
- package/doc/CHANGELOG.md +0 -32
- package/doc/CHANGELOG.zh-CN.md +0 -34
|
@@ -0,0 +1,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
|
+
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
|
+
}
|