codexmate 0.0.26 → 0.0.27
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 +421 -416
- package/README.zh.md +354 -349
- 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 +1299 -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 +1091 -997
- package/cli/openclaw-config.js +629 -629
- package/cli/session-convert-args.js +65 -65
- package/cli/session-convert-io.js +82 -82
- package/cli/session-convert.js +43 -43
- 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 +15251 -15218
- 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 +1 -1
- 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 +634 -625
- 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 -70
- package/web-ui/logic.sessions.mjs +765 -709
- package/web-ui/modules/api.mjs +90 -90
- package/web-ui/modules/app.computed.dashboard.mjs +171 -171
- 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 +994 -946
- 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 +184 -179
- package/web-ui/modules/app.methods.codex-config.mjs +860 -860
- 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 -743
- 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 -596
- package/web-ui/modules/app.methods.session-browser.mjs +989 -985
- package/web-ui/modules/app.methods.session-timeline.mjs +479 -479
- package/web-ui/modules/app.methods.session-trash.mjs +439 -424
- package/web-ui/modules/app.methods.startup-claude.mjs +526 -522
- 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 +2131 -2113
- 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 +187 -184
- 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 -326
- package/web-ui/partials/index/panel-settings.html +274 -258
- package/web-ui/partials/index/panel-usage.html +371 -342
- 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 -576
- package/web-ui/source-bundle.cjs +233 -233
- package/web-ui/styles/base-theme.css +268 -268
- 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 -415
- package/web-ui/styles/sessions-preview.css +411 -411
- package/web-ui/styles/sessions-toolbar-trash.css +330 -330
- package/web-ui/styles/sessions-usage.css +1040 -945
- package/web-ui/styles/settings-panel.css +185 -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,479 +1,479 @@
|
|
|
1
|
-
import { shouldForceCompactLayoutMode } from '../logic.mjs';
|
|
2
|
-
|
|
3
|
-
export function createSessionTimelineMethods() {
|
|
4
|
-
const getSessionPreviewHeaderElement = (context, scrollEl = context.sessionPreviewScrollEl || context.$refs.sessionPreviewScroll) => {
|
|
5
|
-
const container = context.sessionPreviewContainerEl || context.$refs.sessionPreviewContainer;
|
|
6
|
-
return context.sessionPreviewHeaderEl
|
|
7
|
-
|| (scrollEl && typeof scrollEl.querySelector === 'function'
|
|
8
|
-
? scrollEl.querySelector('.session-preview-header')
|
|
9
|
-
: null)
|
|
10
|
-
|| (container && typeof container.querySelector === 'function'
|
|
11
|
-
? container.querySelector('.session-preview-header')
|
|
12
|
-
: null)
|
|
13
|
-
|| null;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const getSessionPreviewHeaderOffset = (context, scrollEl = context.sessionPreviewScrollEl || context.$refs.sessionPreviewScroll) => {
|
|
17
|
-
const header = getSessionPreviewHeaderElement(context, scrollEl);
|
|
18
|
-
const headerHeight = header && typeof header.getBoundingClientRect === 'function'
|
|
19
|
-
? Math.ceil(header.getBoundingClientRect().height)
|
|
20
|
-
: 0;
|
|
21
|
-
return headerHeight > 0 ? (headerHeight + 12) : 72;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
hasRenderableSessionTimeline() {
|
|
26
|
-
return !!(
|
|
27
|
-
this.sessionTimelineEnabled
|
|
28
|
-
&& this.mainTab === 'sessions'
|
|
29
|
-
&& this.getMainTabForNav() === 'sessions'
|
|
30
|
-
&& this.sessionPreviewRenderEnabled
|
|
31
|
-
&& Array.isArray(this.sessionTimelineNodes)
|
|
32
|
-
&& this.sessionTimelineNodes.length
|
|
33
|
-
);
|
|
34
|
-
},
|
|
35
|
-
setSessionPreviewContainerRef(el) {
|
|
36
|
-
this.sessionPreviewContainerEl = el || null;
|
|
37
|
-
this.updateSessionTimelineOffset();
|
|
38
|
-
},
|
|
39
|
-
disconnectSessionPreviewHeaderResizeObserver() {
|
|
40
|
-
if (!this.sessionPreviewHeaderResizeObserver) return;
|
|
41
|
-
this.sessionPreviewHeaderResizeObserver.disconnect();
|
|
42
|
-
this.sessionPreviewHeaderResizeObserver = null;
|
|
43
|
-
},
|
|
44
|
-
observeSessionPreviewHeaderResize() {
|
|
45
|
-
this.disconnectSessionPreviewHeaderResizeObserver();
|
|
46
|
-
},
|
|
47
|
-
setSessionPreviewHeaderRef(el) {
|
|
48
|
-
this.disconnectSessionPreviewHeaderResizeObserver();
|
|
49
|
-
this.sessionPreviewHeaderEl = el || null;
|
|
50
|
-
this.observeSessionPreviewHeaderResize();
|
|
51
|
-
this.updateSessionTimelineOffset();
|
|
52
|
-
},
|
|
53
|
-
setSessionPreviewScrollRef(el) {
|
|
54
|
-
this.sessionPreviewScrollEl = el || null;
|
|
55
|
-
this.invalidateSessionTimelineMeasurementCache();
|
|
56
|
-
const shouldSync = !!(
|
|
57
|
-
this.sessionPreviewScrollEl
|
|
58
|
-
&& this.mainTab === 'sessions'
|
|
59
|
-
&& this.getMainTabForNav() === 'sessions'
|
|
60
|
-
&& this.sessionPreviewRenderEnabled
|
|
61
|
-
&& this.sessionTimelineNodes.length
|
|
62
|
-
);
|
|
63
|
-
if (!shouldSync) {
|
|
64
|
-
this.cancelSessionTimelineSync();
|
|
65
|
-
this.updateSessionTimelineOffset();
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const boundScrollEl = this.sessionPreviewScrollEl;
|
|
69
|
-
this.$nextTick(() => {
|
|
70
|
-
if (this.sessionPreviewScrollEl !== boundScrollEl) return;
|
|
71
|
-
if (this.mainTab !== 'sessions' || !this.sessionPreviewRenderEnabled) return;
|
|
72
|
-
if (!this.sessionTimelineNodes.length) return;
|
|
73
|
-
this.scheduleSessionTimelineSync();
|
|
74
|
-
});
|
|
75
|
-
this.updateSessionTimelineOffset();
|
|
76
|
-
},
|
|
77
|
-
clearSessionTimelineRefs() {
|
|
78
|
-
this.sessionMessageRefMap = Object.create(null);
|
|
79
|
-
this.sessionMessageRefBinderMap = Object.create(null);
|
|
80
|
-
this.sessionTimelineLastAnchorY = 0;
|
|
81
|
-
this.sessionTimelineLastDirection = 0;
|
|
82
|
-
this.invalidateSessionTimelineMeasurementCache(true);
|
|
83
|
-
},
|
|
84
|
-
ensureSessionTimelineMeasurementCache() {
|
|
85
|
-
if (this.__sessionTimelineMeasurementCache) {
|
|
86
|
-
return this.__sessionTimelineMeasurementCache;
|
|
87
|
-
}
|
|
88
|
-
this.__sessionTimelineMeasurementCache = {
|
|
89
|
-
offsetByKey: Object.create(null),
|
|
90
|
-
dirty: true
|
|
91
|
-
};
|
|
92
|
-
return this.__sessionTimelineMeasurementCache;
|
|
93
|
-
},
|
|
94
|
-
invalidateSessionTimelineMeasurementCache(resetOffset = false) {
|
|
95
|
-
const cache = this.ensureSessionTimelineMeasurementCache();
|
|
96
|
-
if (resetOffset) {
|
|
97
|
-
cache.offsetByKey = Object.create(null);
|
|
98
|
-
}
|
|
99
|
-
cache.dirty = true;
|
|
100
|
-
},
|
|
101
|
-
refreshSessionTimelineMeasurementCache(nodes = null) {
|
|
102
|
-
const cache = this.ensureSessionTimelineMeasurementCache();
|
|
103
|
-
const nodeList = Array.isArray(nodes) ? nodes : (Array.isArray(this.sessionTimelineNodes) ? this.sessionTimelineNodes : []);
|
|
104
|
-
if (!nodeList.length) {
|
|
105
|
-
cache.offsetByKey = Object.create(null);
|
|
106
|
-
cache.dirty = false;
|
|
107
|
-
return cache.offsetByKey;
|
|
108
|
-
}
|
|
109
|
-
const scrollEl = this.sessionPreviewScrollEl || this.$refs.sessionPreviewScroll;
|
|
110
|
-
const scrollRect = scrollEl && typeof scrollEl.getBoundingClientRect === 'function'
|
|
111
|
-
? scrollEl.getBoundingClientRect()
|
|
112
|
-
: null;
|
|
113
|
-
const scrollTop = scrollEl ? Number(scrollEl.scrollTop || 0) : 0;
|
|
114
|
-
const nextOffsetByKey = Object.create(null);
|
|
115
|
-
for (const node of nodeList) {
|
|
116
|
-
if (!node || !node.key) continue;
|
|
117
|
-
const messageEl = this.sessionMessageRefMap[node.key];
|
|
118
|
-
if (!messageEl) continue;
|
|
119
|
-
let top = Number.NaN;
|
|
120
|
-
if (
|
|
121
|
-
scrollRect
|
|
122
|
-
&& typeof messageEl.getBoundingClientRect === 'function'
|
|
123
|
-
) {
|
|
124
|
-
const messageRect = messageEl.getBoundingClientRect();
|
|
125
|
-
top = scrollTop + (messageRect.top - scrollRect.top);
|
|
126
|
-
} else {
|
|
127
|
-
top = Number(messageEl.offsetTop || 0);
|
|
128
|
-
}
|
|
129
|
-
if (!Number.isFinite(top)) continue;
|
|
130
|
-
nextOffsetByKey[node.key] = top;
|
|
131
|
-
}
|
|
132
|
-
cache.offsetByKey = nextOffsetByKey;
|
|
133
|
-
cache.dirty = false;
|
|
134
|
-
return cache.offsetByKey;
|
|
135
|
-
},
|
|
136
|
-
getCachedSessionTimelineMeasuredNodes(nodes) {
|
|
137
|
-
const nodeList = Array.isArray(nodes) ? nodes : [];
|
|
138
|
-
if (!nodeList.length) {
|
|
139
|
-
return [];
|
|
140
|
-
}
|
|
141
|
-
const cache = this.ensureSessionTimelineMeasurementCache();
|
|
142
|
-
if (cache.dirty) {
|
|
143
|
-
this.refreshSessionTimelineMeasurementCache(nodeList);
|
|
144
|
-
}
|
|
145
|
-
const offsetByKey = cache.offsetByKey || Object.create(null);
|
|
146
|
-
const measuredNodes = [];
|
|
147
|
-
for (const node of nodeList) {
|
|
148
|
-
if (!node || !node.key) continue;
|
|
149
|
-
const top = Number(offsetByKey[node.key]);
|
|
150
|
-
if (!Number.isFinite(top)) continue;
|
|
151
|
-
measuredNodes.push({
|
|
152
|
-
key: node.key,
|
|
153
|
-
top
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
if (measuredNodes.length >= nodeList.length) {
|
|
157
|
-
return measuredNodes;
|
|
158
|
-
}
|
|
159
|
-
const refreshedOffsetByKey = this.refreshSessionTimelineMeasurementCache(nodeList);
|
|
160
|
-
const refreshedNodes = [];
|
|
161
|
-
for (const node of nodeList) {
|
|
162
|
-
if (!node || !node.key) continue;
|
|
163
|
-
const top = Number(refreshedOffsetByKey[node.key]);
|
|
164
|
-
if (!Number.isFinite(top)) continue;
|
|
165
|
-
refreshedNodes.push({
|
|
166
|
-
key: node.key,
|
|
167
|
-
top
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
return refreshedNodes;
|
|
171
|
-
},
|
|
172
|
-
getSessionMessageRefBinder(messageKey) {
|
|
173
|
-
if (!this.isSessionTimelineNodeKey(messageKey)) return null;
|
|
174
|
-
const current = this.sessionMessageRefBinderMap[messageKey];
|
|
175
|
-
if (!current || current.ticket !== this.sessionTabRenderTicket) {
|
|
176
|
-
const ticket = this.sessionTabRenderTicket;
|
|
177
|
-
this.sessionMessageRefBinderMap[messageKey] = {
|
|
178
|
-
ticket,
|
|
179
|
-
bind: (el) => {
|
|
180
|
-
this.bindSessionMessageRef(messageKey, el, ticket);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
return this.sessionMessageRefBinderMap[messageKey].bind;
|
|
185
|
-
},
|
|
186
|
-
updateSessionTimelineOffset() {
|
|
187
|
-
const container = this.sessionPreviewContainerEl || this.$refs.sessionPreviewContainer;
|
|
188
|
-
if (!container || !container.style) return;
|
|
189
|
-
if (!this.hasRenderableSessionTimeline()) {
|
|
190
|
-
if (this.__sessionPreviewHeaderOffsetPx != null) {
|
|
191
|
-
container.style.removeProperty('--session-preview-header-offset');
|
|
192
|
-
this.__sessionPreviewHeaderOffsetPx = null;
|
|
193
|
-
}
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
const offset = getSessionPreviewHeaderOffset(this);
|
|
197
|
-
if (this.__sessionPreviewHeaderOffsetPx === offset) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
this.__sessionPreviewHeaderOffsetPx = offset;
|
|
201
|
-
container.style.setProperty('--session-preview-header-offset', `${offset}px`);
|
|
202
|
-
},
|
|
203
|
-
bindSessionMessageRef(messageKey, el, ticket = this.sessionTabRenderTicket) {
|
|
204
|
-
if (!this.sessionTimelineEnabled) return;
|
|
205
|
-
if (!messageKey) return;
|
|
206
|
-
if (ticket !== this.sessionTabRenderTicket) return;
|
|
207
|
-
if (el) {
|
|
208
|
-
if (!this.isSessionTimelineNodeKey(messageKey)) return;
|
|
209
|
-
if (this.sessionMessageRefMap[messageKey] === el) return;
|
|
210
|
-
this.sessionMessageRefMap[messageKey] = el;
|
|
211
|
-
this.invalidateSessionTimelineMeasurementCache();
|
|
212
|
-
} else {
|
|
213
|
-
if (!this.sessionMessageRefMap[messageKey]) return;
|
|
214
|
-
delete this.sessionMessageRefMap[messageKey];
|
|
215
|
-
this.invalidateSessionTimelineMeasurementCache();
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
isSessionTimelineNodeKey(messageKey) {
|
|
219
|
-
if (!messageKey) return false;
|
|
220
|
-
return !!(this.sessionTimelineNodeKeyMap && this.sessionTimelineNodeKeyMap[messageKey]);
|
|
221
|
-
},
|
|
222
|
-
pruneSessionMessageRefs() {
|
|
223
|
-
const nodeKeyMap = this.sessionTimelineNodeKeyMap || Object.create(null);
|
|
224
|
-
let removed = false;
|
|
225
|
-
for (const key of Object.keys(this.sessionMessageRefMap)) {
|
|
226
|
-
if (nodeKeyMap[key]) continue;
|
|
227
|
-
delete this.sessionMessageRefMap[key];
|
|
228
|
-
removed = true;
|
|
229
|
-
}
|
|
230
|
-
for (const key of Object.keys(this.sessionMessageRefBinderMap)) {
|
|
231
|
-
if (nodeKeyMap[key]) continue;
|
|
232
|
-
delete this.sessionMessageRefBinderMap[key];
|
|
233
|
-
}
|
|
234
|
-
if (removed) {
|
|
235
|
-
this.invalidateSessionTimelineMeasurementCache();
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
cancelSessionTimelineSync() {
|
|
239
|
-
if (!this.sessionTimelineRafId) return;
|
|
240
|
-
if (typeof cancelAnimationFrame === 'function') {
|
|
241
|
-
cancelAnimationFrame(this.sessionTimelineRafId);
|
|
242
|
-
}
|
|
243
|
-
this.sessionTimelineRafId = 0;
|
|
244
|
-
},
|
|
245
|
-
scheduleSessionTimelineSync() {
|
|
246
|
-
this.updateSessionTimelineOffset();
|
|
247
|
-
if (this.sessionTimelineRafId) return;
|
|
248
|
-
if (typeof requestAnimationFrame === 'function') {
|
|
249
|
-
this.sessionTimelineRafId = requestAnimationFrame(() => {
|
|
250
|
-
this.sessionTimelineRafId = 0;
|
|
251
|
-
this.syncSessionTimelineActiveFromScroll();
|
|
252
|
-
});
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
this.syncSessionTimelineActiveFromScroll();
|
|
256
|
-
},
|
|
257
|
-
onSessionPreviewScroll() {
|
|
258
|
-
if (
|
|
259
|
-
this.mainTab !== 'sessions'
|
|
260
|
-
|| this.getMainTabForNav() !== 'sessions'
|
|
261
|
-
|| !this.sessionPreviewRenderEnabled
|
|
262
|
-
) return;
|
|
263
|
-
const scrollEl = this.sessionPreviewScrollEl || this.$refs.sessionPreviewScroll;
|
|
264
|
-
if (!scrollEl) return;
|
|
265
|
-
|
|
266
|
-
if (
|
|
267
|
-
this.canLoadMoreSessionMessages
|
|
268
|
-
&& !this.sessionPreviewLoadingMore
|
|
269
|
-
&& !this.sessionDetailLoading
|
|
270
|
-
&& typeof this.loadMoreSessionMessages === 'function'
|
|
271
|
-
) {
|
|
272
|
-
const now = Date.now();
|
|
273
|
-
const lastAt = Number(this.sessionPreviewAutoLoadLastAt || 0);
|
|
274
|
-
if (!this.sessionPreviewAutoLoadPending && (now - lastAt) >= 200) {
|
|
275
|
-
const scrollTop = Number(scrollEl.scrollTop || 0);
|
|
276
|
-
const clientHeight = Number(scrollEl.clientHeight || 0);
|
|
277
|
-
const scrollHeight = Number(scrollEl.scrollHeight || 0);
|
|
278
|
-
const threshold = 240;
|
|
279
|
-
if (
|
|
280
|
-
Number.isFinite(scrollTop)
|
|
281
|
-
&& Number.isFinite(clientHeight)
|
|
282
|
-
&& Number.isFinite(scrollHeight)
|
|
283
|
-
&& (scrollTop + clientHeight) >= (scrollHeight - threshold)
|
|
284
|
-
) {
|
|
285
|
-
this.sessionPreviewAutoLoadLastAt = now;
|
|
286
|
-
this.sessionPreviewAutoLoadPending = true;
|
|
287
|
-
Promise.resolve(this.loadMoreSessionMessages()).finally(() => {
|
|
288
|
-
this.sessionPreviewAutoLoadPending = false;
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if (!this.sessionTimelineEnabled) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
if (!this.sessionTimelineNodes.length) return;
|
|
298
|
-
const now = Date.now();
|
|
299
|
-
const currentTop = Number(scrollEl.scrollTop || 0);
|
|
300
|
-
const delta = Math.abs(currentTop - Number(this.sessionTimelineLastScrollTop || 0));
|
|
301
|
-
const elapsed = now - Number(this.sessionTimelineLastSyncAt || 0);
|
|
302
|
-
if (delta < 48 && elapsed < 120) {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
this.sessionTimelineLastScrollTop = currentTop;
|
|
306
|
-
this.sessionTimelineLastSyncAt = now;
|
|
307
|
-
this.scheduleSessionTimelineSync();
|
|
308
|
-
},
|
|
309
|
-
onWindowResize() {
|
|
310
|
-
this.updateCompactLayoutMode();
|
|
311
|
-
if (
|
|
312
|
-
!this.sessionTimelineEnabled
|
|
313
|
-
|| this.mainTab !== 'sessions'
|
|
314
|
-
|| this.getMainTabForNav() !== 'sessions'
|
|
315
|
-
|| !this.sessionPreviewRenderEnabled
|
|
316
|
-
) {
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
if (!this.sessionTimelineNodes.length) return;
|
|
320
|
-
this.updateSessionTimelineOffset();
|
|
321
|
-
this.invalidateSessionTimelineMeasurementCache();
|
|
322
|
-
this.scheduleSessionTimelineSync();
|
|
323
|
-
},
|
|
324
|
-
shouldForceCompactLayout() {
|
|
325
|
-
if (typeof window === 'undefined' || typeof navigator === 'undefined') {
|
|
326
|
-
return false;
|
|
327
|
-
}
|
|
328
|
-
const doc = typeof document !== 'undefined' ? document : null;
|
|
329
|
-
const viewportWidth = Math.max(
|
|
330
|
-
0,
|
|
331
|
-
Number(window.innerWidth || 0),
|
|
332
|
-
Number(doc && doc.documentElement ? doc.documentElement.clientWidth : 0)
|
|
333
|
-
);
|
|
334
|
-
const screenWidth = Number(window.screen && window.screen.width ? window.screen.width : 0);
|
|
335
|
-
const screenHeight = Number(window.screen && window.screen.height ? window.screen.height : 0);
|
|
336
|
-
const shortEdge = screenWidth > 0 && screenHeight > 0
|
|
337
|
-
? Math.min(screenWidth, screenHeight)
|
|
338
|
-
: 0;
|
|
339
|
-
const touchPoints = Number(navigator.maxTouchPoints || 0);
|
|
340
|
-
const userAgent = String(navigator.userAgent || '');
|
|
341
|
-
const isMobileUa = /(Android|iPhone|iPad|iPod|Mobile)/i.test(userAgent);
|
|
342
|
-
let coarsePointer = false;
|
|
343
|
-
let noHover = false;
|
|
344
|
-
try {
|
|
345
|
-
coarsePointer = !!(window.matchMedia && window.matchMedia('(pointer: coarse)').matches);
|
|
346
|
-
} catch (_) {}
|
|
347
|
-
try {
|
|
348
|
-
noHover = !!(window.matchMedia && window.matchMedia('(hover: none)').matches);
|
|
349
|
-
} catch (_) {}
|
|
350
|
-
return shouldForceCompactLayoutMode({
|
|
351
|
-
viewportWidth,
|
|
352
|
-
screenWidth,
|
|
353
|
-
screenHeight,
|
|
354
|
-
shortEdge,
|
|
355
|
-
maxTouchPoints: touchPoints,
|
|
356
|
-
userAgent,
|
|
357
|
-
isMobileUa,
|
|
358
|
-
coarsePointer,
|
|
359
|
-
noHover
|
|
360
|
-
});
|
|
361
|
-
},
|
|
362
|
-
applyCompactLayoutClass(enabled) {
|
|
363
|
-
if (typeof document === 'undefined' || !document.body) {
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
document.body.classList.toggle('force-compact', !!enabled);
|
|
367
|
-
},
|
|
368
|
-
updateCompactLayoutMode() {
|
|
369
|
-
const enabled = this.shouldForceCompactLayout();
|
|
370
|
-
this.forceCompactLayout = enabled;
|
|
371
|
-
this.applyCompactLayoutClass(enabled);
|
|
372
|
-
},
|
|
373
|
-
syncSessionTimelineActiveFromScroll() {
|
|
374
|
-
if (
|
|
375
|
-
!this.sessionTimelineEnabled
|
|
376
|
-
|| this.mainTab !== 'sessions'
|
|
377
|
-
|| this.getMainTabForNav() !== 'sessions'
|
|
378
|
-
|| !this.sessionPreviewRenderEnabled
|
|
379
|
-
) {
|
|
380
|
-
if (this.sessionTimelineActiveKey) {
|
|
381
|
-
this.sessionTimelineActiveKey = '';
|
|
382
|
-
}
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
const nodes = Array.isArray(this.sessionTimelineNodes) ? this.sessionTimelineNodes : [];
|
|
386
|
-
if (!nodes.length) {
|
|
387
|
-
if (this.sessionTimelineActiveKey) {
|
|
388
|
-
this.sessionTimelineActiveKey = '';
|
|
389
|
-
}
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
this.pruneSessionMessageRefs();
|
|
393
|
-
const scrollEl = this.sessionPreviewScrollEl || this.$refs.sessionPreviewScroll;
|
|
394
|
-
if (!scrollEl) {
|
|
395
|
-
if (!this.isSessionTimelineNodeKey(this.sessionTimelineActiveKey)) {
|
|
396
|
-
const fallbackKey = nodes[0].key;
|
|
397
|
-
if (this.sessionTimelineActiveKey !== fallbackKey) {
|
|
398
|
-
this.sessionTimelineActiveKey = fallbackKey;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
const stickyOffset = getSessionPreviewHeaderOffset(this, scrollEl);
|
|
404
|
-
const rawAnchorY = Number(scrollEl.scrollTop || 0) + stickyOffset;
|
|
405
|
-
const previousAnchorY = Number(this.sessionTimelineLastAnchorY || 0);
|
|
406
|
-
let direction = rawAnchorY - previousAnchorY;
|
|
407
|
-
if (Math.abs(direction) < 1) {
|
|
408
|
-
direction = Number(this.sessionTimelineLastDirection || 0);
|
|
409
|
-
} else {
|
|
410
|
-
this.sessionTimelineLastDirection = direction > 0 ? 1 : -1;
|
|
411
|
-
}
|
|
412
|
-
this.sessionTimelineLastAnchorY = rawAnchorY;
|
|
413
|
-
const hysteresisPx = 18;
|
|
414
|
-
const hysteresis = direction > 0 ? -hysteresisPx : (direction < 0 ? hysteresisPx : 0);
|
|
415
|
-
const anchorY = rawAnchorY + hysteresis;
|
|
416
|
-
const measuredNodes = this.getCachedSessionTimelineMeasuredNodes(nodes);
|
|
417
|
-
if (!measuredNodes.length) {
|
|
418
|
-
if (!this.isSessionTimelineNodeKey(this.sessionTimelineActiveKey)) {
|
|
419
|
-
this.sessionTimelineActiveKey = nodes[0].key;
|
|
420
|
-
}
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
let low = 0;
|
|
424
|
-
let high = measuredNodes.length - 1;
|
|
425
|
-
let candidateIndex = 0;
|
|
426
|
-
while (low <= high) {
|
|
427
|
-
const mid = Math.floor((low + high) / 2);
|
|
428
|
-
if (measuredNodes[mid].top <= anchorY) {
|
|
429
|
-
candidateIndex = mid;
|
|
430
|
-
low = mid + 1;
|
|
431
|
-
} else {
|
|
432
|
-
high = mid - 1;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
let currentIndex = -1;
|
|
436
|
-
if (this.sessionTimelineActiveKey) {
|
|
437
|
-
for (let i = 0; i < measuredNodes.length; i += 1) {
|
|
438
|
-
if (measuredNodes[i].key === this.sessionTimelineActiveKey) {
|
|
439
|
-
currentIndex = i;
|
|
440
|
-
break;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
if (currentIndex >= 0) {
|
|
445
|
-
if (direction > 0 && candidateIndex < currentIndex) {
|
|
446
|
-
candidateIndex = currentIndex;
|
|
447
|
-
} else if (direction < 0 && candidateIndex > currentIndex) {
|
|
448
|
-
candidateIndex = currentIndex;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
const activeKey = measuredNodes[candidateIndex].key;
|
|
452
|
-
if (this.sessionTimelineActiveKey !== activeKey) {
|
|
453
|
-
this.sessionTimelineActiveKey = activeKey;
|
|
454
|
-
}
|
|
455
|
-
},
|
|
456
|
-
jumpToSessionTimelineNode(messageKey) {
|
|
457
|
-
if (!this.sessionTimelineEnabled || this.mainTab !== 'sessions' || !this.sessionPreviewRenderEnabled) return;
|
|
458
|
-
if (!messageKey) return;
|
|
459
|
-
if (!this.isSessionTimelineNodeKey(messageKey)) return;
|
|
460
|
-
const scrollEl = this.sessionPreviewScrollEl || this.$refs.sessionPreviewScroll;
|
|
461
|
-
if (!scrollEl) return;
|
|
462
|
-
const messageEl = this.sessionMessageRefMap[messageKey];
|
|
463
|
-
if (!messageEl) return;
|
|
464
|
-
const stickyOffset = getSessionPreviewHeaderOffset(this, scrollEl);
|
|
465
|
-
const scrollRect = scrollEl.getBoundingClientRect();
|
|
466
|
-
const messageRect = messageEl.getBoundingClientRect();
|
|
467
|
-
const targetScrollTop = scrollEl.scrollTop + (messageRect.top - scrollRect.top) - stickyOffset;
|
|
468
|
-
this.sessionTimelineActiveKey = messageKey;
|
|
469
|
-
if (typeof scrollEl.scrollTo === 'function') {
|
|
470
|
-
scrollEl.scrollTo({
|
|
471
|
-
top: Math.max(0, targetScrollTop),
|
|
472
|
-
behavior: 'smooth'
|
|
473
|
-
});
|
|
474
|
-
} else {
|
|
475
|
-
messageEl.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
}
|
|
1
|
+
import { shouldForceCompactLayoutMode } from '../logic.mjs';
|
|
2
|
+
|
|
3
|
+
export function createSessionTimelineMethods() {
|
|
4
|
+
const getSessionPreviewHeaderElement = (context, scrollEl = context.sessionPreviewScrollEl || context.$refs.sessionPreviewScroll) => {
|
|
5
|
+
const container = context.sessionPreviewContainerEl || context.$refs.sessionPreviewContainer;
|
|
6
|
+
return context.sessionPreviewHeaderEl
|
|
7
|
+
|| (scrollEl && typeof scrollEl.querySelector === 'function'
|
|
8
|
+
? scrollEl.querySelector('.session-preview-header')
|
|
9
|
+
: null)
|
|
10
|
+
|| (container && typeof container.querySelector === 'function'
|
|
11
|
+
? container.querySelector('.session-preview-header')
|
|
12
|
+
: null)
|
|
13
|
+
|| null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const getSessionPreviewHeaderOffset = (context, scrollEl = context.sessionPreviewScrollEl || context.$refs.sessionPreviewScroll) => {
|
|
17
|
+
const header = getSessionPreviewHeaderElement(context, scrollEl);
|
|
18
|
+
const headerHeight = header && typeof header.getBoundingClientRect === 'function'
|
|
19
|
+
? Math.ceil(header.getBoundingClientRect().height)
|
|
20
|
+
: 0;
|
|
21
|
+
return headerHeight > 0 ? (headerHeight + 12) : 72;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
hasRenderableSessionTimeline() {
|
|
26
|
+
return !!(
|
|
27
|
+
this.sessionTimelineEnabled
|
|
28
|
+
&& this.mainTab === 'sessions'
|
|
29
|
+
&& this.getMainTabForNav() === 'sessions'
|
|
30
|
+
&& this.sessionPreviewRenderEnabled
|
|
31
|
+
&& Array.isArray(this.sessionTimelineNodes)
|
|
32
|
+
&& this.sessionTimelineNodes.length
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
setSessionPreviewContainerRef(el) {
|
|
36
|
+
this.sessionPreviewContainerEl = el || null;
|
|
37
|
+
this.updateSessionTimelineOffset();
|
|
38
|
+
},
|
|
39
|
+
disconnectSessionPreviewHeaderResizeObserver() {
|
|
40
|
+
if (!this.sessionPreviewHeaderResizeObserver) return;
|
|
41
|
+
this.sessionPreviewHeaderResizeObserver.disconnect();
|
|
42
|
+
this.sessionPreviewHeaderResizeObserver = null;
|
|
43
|
+
},
|
|
44
|
+
observeSessionPreviewHeaderResize() {
|
|
45
|
+
this.disconnectSessionPreviewHeaderResizeObserver();
|
|
46
|
+
},
|
|
47
|
+
setSessionPreviewHeaderRef(el) {
|
|
48
|
+
this.disconnectSessionPreviewHeaderResizeObserver();
|
|
49
|
+
this.sessionPreviewHeaderEl = el || null;
|
|
50
|
+
this.observeSessionPreviewHeaderResize();
|
|
51
|
+
this.updateSessionTimelineOffset();
|
|
52
|
+
},
|
|
53
|
+
setSessionPreviewScrollRef(el) {
|
|
54
|
+
this.sessionPreviewScrollEl = el || null;
|
|
55
|
+
this.invalidateSessionTimelineMeasurementCache();
|
|
56
|
+
const shouldSync = !!(
|
|
57
|
+
this.sessionPreviewScrollEl
|
|
58
|
+
&& this.mainTab === 'sessions'
|
|
59
|
+
&& this.getMainTabForNav() === 'sessions'
|
|
60
|
+
&& this.sessionPreviewRenderEnabled
|
|
61
|
+
&& this.sessionTimelineNodes.length
|
|
62
|
+
);
|
|
63
|
+
if (!shouldSync) {
|
|
64
|
+
this.cancelSessionTimelineSync();
|
|
65
|
+
this.updateSessionTimelineOffset();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const boundScrollEl = this.sessionPreviewScrollEl;
|
|
69
|
+
this.$nextTick(() => {
|
|
70
|
+
if (this.sessionPreviewScrollEl !== boundScrollEl) return;
|
|
71
|
+
if (this.mainTab !== 'sessions' || !this.sessionPreviewRenderEnabled) return;
|
|
72
|
+
if (!this.sessionTimelineNodes.length) return;
|
|
73
|
+
this.scheduleSessionTimelineSync();
|
|
74
|
+
});
|
|
75
|
+
this.updateSessionTimelineOffset();
|
|
76
|
+
},
|
|
77
|
+
clearSessionTimelineRefs() {
|
|
78
|
+
this.sessionMessageRefMap = Object.create(null);
|
|
79
|
+
this.sessionMessageRefBinderMap = Object.create(null);
|
|
80
|
+
this.sessionTimelineLastAnchorY = 0;
|
|
81
|
+
this.sessionTimelineLastDirection = 0;
|
|
82
|
+
this.invalidateSessionTimelineMeasurementCache(true);
|
|
83
|
+
},
|
|
84
|
+
ensureSessionTimelineMeasurementCache() {
|
|
85
|
+
if (this.__sessionTimelineMeasurementCache) {
|
|
86
|
+
return this.__sessionTimelineMeasurementCache;
|
|
87
|
+
}
|
|
88
|
+
this.__sessionTimelineMeasurementCache = {
|
|
89
|
+
offsetByKey: Object.create(null),
|
|
90
|
+
dirty: true
|
|
91
|
+
};
|
|
92
|
+
return this.__sessionTimelineMeasurementCache;
|
|
93
|
+
},
|
|
94
|
+
invalidateSessionTimelineMeasurementCache(resetOffset = false) {
|
|
95
|
+
const cache = this.ensureSessionTimelineMeasurementCache();
|
|
96
|
+
if (resetOffset) {
|
|
97
|
+
cache.offsetByKey = Object.create(null);
|
|
98
|
+
}
|
|
99
|
+
cache.dirty = true;
|
|
100
|
+
},
|
|
101
|
+
refreshSessionTimelineMeasurementCache(nodes = null) {
|
|
102
|
+
const cache = this.ensureSessionTimelineMeasurementCache();
|
|
103
|
+
const nodeList = Array.isArray(nodes) ? nodes : (Array.isArray(this.sessionTimelineNodes) ? this.sessionTimelineNodes : []);
|
|
104
|
+
if (!nodeList.length) {
|
|
105
|
+
cache.offsetByKey = Object.create(null);
|
|
106
|
+
cache.dirty = false;
|
|
107
|
+
return cache.offsetByKey;
|
|
108
|
+
}
|
|
109
|
+
const scrollEl = this.sessionPreviewScrollEl || this.$refs.sessionPreviewScroll;
|
|
110
|
+
const scrollRect = scrollEl && typeof scrollEl.getBoundingClientRect === 'function'
|
|
111
|
+
? scrollEl.getBoundingClientRect()
|
|
112
|
+
: null;
|
|
113
|
+
const scrollTop = scrollEl ? Number(scrollEl.scrollTop || 0) : 0;
|
|
114
|
+
const nextOffsetByKey = Object.create(null);
|
|
115
|
+
for (const node of nodeList) {
|
|
116
|
+
if (!node || !node.key) continue;
|
|
117
|
+
const messageEl = this.sessionMessageRefMap[node.key];
|
|
118
|
+
if (!messageEl) continue;
|
|
119
|
+
let top = Number.NaN;
|
|
120
|
+
if (
|
|
121
|
+
scrollRect
|
|
122
|
+
&& typeof messageEl.getBoundingClientRect === 'function'
|
|
123
|
+
) {
|
|
124
|
+
const messageRect = messageEl.getBoundingClientRect();
|
|
125
|
+
top = scrollTop + (messageRect.top - scrollRect.top);
|
|
126
|
+
} else {
|
|
127
|
+
top = Number(messageEl.offsetTop || 0);
|
|
128
|
+
}
|
|
129
|
+
if (!Number.isFinite(top)) continue;
|
|
130
|
+
nextOffsetByKey[node.key] = top;
|
|
131
|
+
}
|
|
132
|
+
cache.offsetByKey = nextOffsetByKey;
|
|
133
|
+
cache.dirty = false;
|
|
134
|
+
return cache.offsetByKey;
|
|
135
|
+
},
|
|
136
|
+
getCachedSessionTimelineMeasuredNodes(nodes) {
|
|
137
|
+
const nodeList = Array.isArray(nodes) ? nodes : [];
|
|
138
|
+
if (!nodeList.length) {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
const cache = this.ensureSessionTimelineMeasurementCache();
|
|
142
|
+
if (cache.dirty) {
|
|
143
|
+
this.refreshSessionTimelineMeasurementCache(nodeList);
|
|
144
|
+
}
|
|
145
|
+
const offsetByKey = cache.offsetByKey || Object.create(null);
|
|
146
|
+
const measuredNodes = [];
|
|
147
|
+
for (const node of nodeList) {
|
|
148
|
+
if (!node || !node.key) continue;
|
|
149
|
+
const top = Number(offsetByKey[node.key]);
|
|
150
|
+
if (!Number.isFinite(top)) continue;
|
|
151
|
+
measuredNodes.push({
|
|
152
|
+
key: node.key,
|
|
153
|
+
top
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (measuredNodes.length >= nodeList.length) {
|
|
157
|
+
return measuredNodes;
|
|
158
|
+
}
|
|
159
|
+
const refreshedOffsetByKey = this.refreshSessionTimelineMeasurementCache(nodeList);
|
|
160
|
+
const refreshedNodes = [];
|
|
161
|
+
for (const node of nodeList) {
|
|
162
|
+
if (!node || !node.key) continue;
|
|
163
|
+
const top = Number(refreshedOffsetByKey[node.key]);
|
|
164
|
+
if (!Number.isFinite(top)) continue;
|
|
165
|
+
refreshedNodes.push({
|
|
166
|
+
key: node.key,
|
|
167
|
+
top
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return refreshedNodes;
|
|
171
|
+
},
|
|
172
|
+
getSessionMessageRefBinder(messageKey) {
|
|
173
|
+
if (!this.isSessionTimelineNodeKey(messageKey)) return null;
|
|
174
|
+
const current = this.sessionMessageRefBinderMap[messageKey];
|
|
175
|
+
if (!current || current.ticket !== this.sessionTabRenderTicket) {
|
|
176
|
+
const ticket = this.sessionTabRenderTicket;
|
|
177
|
+
this.sessionMessageRefBinderMap[messageKey] = {
|
|
178
|
+
ticket,
|
|
179
|
+
bind: (el) => {
|
|
180
|
+
this.bindSessionMessageRef(messageKey, el, ticket);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
return this.sessionMessageRefBinderMap[messageKey].bind;
|
|
185
|
+
},
|
|
186
|
+
updateSessionTimelineOffset() {
|
|
187
|
+
const container = this.sessionPreviewContainerEl || this.$refs.sessionPreviewContainer;
|
|
188
|
+
if (!container || !container.style) return;
|
|
189
|
+
if (!this.hasRenderableSessionTimeline()) {
|
|
190
|
+
if (this.__sessionPreviewHeaderOffsetPx != null) {
|
|
191
|
+
container.style.removeProperty('--session-preview-header-offset');
|
|
192
|
+
this.__sessionPreviewHeaderOffsetPx = null;
|
|
193
|
+
}
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const offset = getSessionPreviewHeaderOffset(this);
|
|
197
|
+
if (this.__sessionPreviewHeaderOffsetPx === offset) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
this.__sessionPreviewHeaderOffsetPx = offset;
|
|
201
|
+
container.style.setProperty('--session-preview-header-offset', `${offset}px`);
|
|
202
|
+
},
|
|
203
|
+
bindSessionMessageRef(messageKey, el, ticket = this.sessionTabRenderTicket) {
|
|
204
|
+
if (!this.sessionTimelineEnabled) return;
|
|
205
|
+
if (!messageKey) return;
|
|
206
|
+
if (ticket !== this.sessionTabRenderTicket) return;
|
|
207
|
+
if (el) {
|
|
208
|
+
if (!this.isSessionTimelineNodeKey(messageKey)) return;
|
|
209
|
+
if (this.sessionMessageRefMap[messageKey] === el) return;
|
|
210
|
+
this.sessionMessageRefMap[messageKey] = el;
|
|
211
|
+
this.invalidateSessionTimelineMeasurementCache();
|
|
212
|
+
} else {
|
|
213
|
+
if (!this.sessionMessageRefMap[messageKey]) return;
|
|
214
|
+
delete this.sessionMessageRefMap[messageKey];
|
|
215
|
+
this.invalidateSessionTimelineMeasurementCache();
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
isSessionTimelineNodeKey(messageKey) {
|
|
219
|
+
if (!messageKey) return false;
|
|
220
|
+
return !!(this.sessionTimelineNodeKeyMap && this.sessionTimelineNodeKeyMap[messageKey]);
|
|
221
|
+
},
|
|
222
|
+
pruneSessionMessageRefs() {
|
|
223
|
+
const nodeKeyMap = this.sessionTimelineNodeKeyMap || Object.create(null);
|
|
224
|
+
let removed = false;
|
|
225
|
+
for (const key of Object.keys(this.sessionMessageRefMap)) {
|
|
226
|
+
if (nodeKeyMap[key]) continue;
|
|
227
|
+
delete this.sessionMessageRefMap[key];
|
|
228
|
+
removed = true;
|
|
229
|
+
}
|
|
230
|
+
for (const key of Object.keys(this.sessionMessageRefBinderMap)) {
|
|
231
|
+
if (nodeKeyMap[key]) continue;
|
|
232
|
+
delete this.sessionMessageRefBinderMap[key];
|
|
233
|
+
}
|
|
234
|
+
if (removed) {
|
|
235
|
+
this.invalidateSessionTimelineMeasurementCache();
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
cancelSessionTimelineSync() {
|
|
239
|
+
if (!this.sessionTimelineRafId) return;
|
|
240
|
+
if (typeof cancelAnimationFrame === 'function') {
|
|
241
|
+
cancelAnimationFrame(this.sessionTimelineRafId);
|
|
242
|
+
}
|
|
243
|
+
this.sessionTimelineRafId = 0;
|
|
244
|
+
},
|
|
245
|
+
scheduleSessionTimelineSync() {
|
|
246
|
+
this.updateSessionTimelineOffset();
|
|
247
|
+
if (this.sessionTimelineRafId) return;
|
|
248
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
249
|
+
this.sessionTimelineRafId = requestAnimationFrame(() => {
|
|
250
|
+
this.sessionTimelineRafId = 0;
|
|
251
|
+
this.syncSessionTimelineActiveFromScroll();
|
|
252
|
+
});
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
this.syncSessionTimelineActiveFromScroll();
|
|
256
|
+
},
|
|
257
|
+
onSessionPreviewScroll() {
|
|
258
|
+
if (
|
|
259
|
+
this.mainTab !== 'sessions'
|
|
260
|
+
|| this.getMainTabForNav() !== 'sessions'
|
|
261
|
+
|| !this.sessionPreviewRenderEnabled
|
|
262
|
+
) return;
|
|
263
|
+
const scrollEl = this.sessionPreviewScrollEl || this.$refs.sessionPreviewScroll;
|
|
264
|
+
if (!scrollEl) return;
|
|
265
|
+
|
|
266
|
+
if (
|
|
267
|
+
this.canLoadMoreSessionMessages
|
|
268
|
+
&& !this.sessionPreviewLoadingMore
|
|
269
|
+
&& !this.sessionDetailLoading
|
|
270
|
+
&& typeof this.loadMoreSessionMessages === 'function'
|
|
271
|
+
) {
|
|
272
|
+
const now = Date.now();
|
|
273
|
+
const lastAt = Number(this.sessionPreviewAutoLoadLastAt || 0);
|
|
274
|
+
if (!this.sessionPreviewAutoLoadPending && (now - lastAt) >= 200) {
|
|
275
|
+
const scrollTop = Number(scrollEl.scrollTop || 0);
|
|
276
|
+
const clientHeight = Number(scrollEl.clientHeight || 0);
|
|
277
|
+
const scrollHeight = Number(scrollEl.scrollHeight || 0);
|
|
278
|
+
const threshold = 240;
|
|
279
|
+
if (
|
|
280
|
+
Number.isFinite(scrollTop)
|
|
281
|
+
&& Number.isFinite(clientHeight)
|
|
282
|
+
&& Number.isFinite(scrollHeight)
|
|
283
|
+
&& (scrollTop + clientHeight) >= (scrollHeight - threshold)
|
|
284
|
+
) {
|
|
285
|
+
this.sessionPreviewAutoLoadLastAt = now;
|
|
286
|
+
this.sessionPreviewAutoLoadPending = true;
|
|
287
|
+
Promise.resolve(this.loadMoreSessionMessages()).finally(() => {
|
|
288
|
+
this.sessionPreviewAutoLoadPending = false;
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (!this.sessionTimelineEnabled) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (!this.sessionTimelineNodes.length) return;
|
|
298
|
+
const now = Date.now();
|
|
299
|
+
const currentTop = Number(scrollEl.scrollTop || 0);
|
|
300
|
+
const delta = Math.abs(currentTop - Number(this.sessionTimelineLastScrollTop || 0));
|
|
301
|
+
const elapsed = now - Number(this.sessionTimelineLastSyncAt || 0);
|
|
302
|
+
if (delta < 48 && elapsed < 120) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
this.sessionTimelineLastScrollTop = currentTop;
|
|
306
|
+
this.sessionTimelineLastSyncAt = now;
|
|
307
|
+
this.scheduleSessionTimelineSync();
|
|
308
|
+
},
|
|
309
|
+
onWindowResize() {
|
|
310
|
+
this.updateCompactLayoutMode();
|
|
311
|
+
if (
|
|
312
|
+
!this.sessionTimelineEnabled
|
|
313
|
+
|| this.mainTab !== 'sessions'
|
|
314
|
+
|| this.getMainTabForNav() !== 'sessions'
|
|
315
|
+
|| !this.sessionPreviewRenderEnabled
|
|
316
|
+
) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (!this.sessionTimelineNodes.length) return;
|
|
320
|
+
this.updateSessionTimelineOffset();
|
|
321
|
+
this.invalidateSessionTimelineMeasurementCache();
|
|
322
|
+
this.scheduleSessionTimelineSync();
|
|
323
|
+
},
|
|
324
|
+
shouldForceCompactLayout() {
|
|
325
|
+
if (typeof window === 'undefined' || typeof navigator === 'undefined') {
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
const doc = typeof document !== 'undefined' ? document : null;
|
|
329
|
+
const viewportWidth = Math.max(
|
|
330
|
+
0,
|
|
331
|
+
Number(window.innerWidth || 0),
|
|
332
|
+
Number(doc && doc.documentElement ? doc.documentElement.clientWidth : 0)
|
|
333
|
+
);
|
|
334
|
+
const screenWidth = Number(window.screen && window.screen.width ? window.screen.width : 0);
|
|
335
|
+
const screenHeight = Number(window.screen && window.screen.height ? window.screen.height : 0);
|
|
336
|
+
const shortEdge = screenWidth > 0 && screenHeight > 0
|
|
337
|
+
? Math.min(screenWidth, screenHeight)
|
|
338
|
+
: 0;
|
|
339
|
+
const touchPoints = Number(navigator.maxTouchPoints || 0);
|
|
340
|
+
const userAgent = String(navigator.userAgent || '');
|
|
341
|
+
const isMobileUa = /(Android|iPhone|iPad|iPod|Mobile)/i.test(userAgent);
|
|
342
|
+
let coarsePointer = false;
|
|
343
|
+
let noHover = false;
|
|
344
|
+
try {
|
|
345
|
+
coarsePointer = !!(window.matchMedia && window.matchMedia('(pointer: coarse)').matches);
|
|
346
|
+
} catch (_) {}
|
|
347
|
+
try {
|
|
348
|
+
noHover = !!(window.matchMedia && window.matchMedia('(hover: none)').matches);
|
|
349
|
+
} catch (_) {}
|
|
350
|
+
return shouldForceCompactLayoutMode({
|
|
351
|
+
viewportWidth,
|
|
352
|
+
screenWidth,
|
|
353
|
+
screenHeight,
|
|
354
|
+
shortEdge,
|
|
355
|
+
maxTouchPoints: touchPoints,
|
|
356
|
+
userAgent,
|
|
357
|
+
isMobileUa,
|
|
358
|
+
coarsePointer,
|
|
359
|
+
noHover
|
|
360
|
+
});
|
|
361
|
+
},
|
|
362
|
+
applyCompactLayoutClass(enabled) {
|
|
363
|
+
if (typeof document === 'undefined' || !document.body) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
document.body.classList.toggle('force-compact', !!enabled);
|
|
367
|
+
},
|
|
368
|
+
updateCompactLayoutMode() {
|
|
369
|
+
const enabled = this.shouldForceCompactLayout();
|
|
370
|
+
this.forceCompactLayout = enabled;
|
|
371
|
+
this.applyCompactLayoutClass(enabled);
|
|
372
|
+
},
|
|
373
|
+
syncSessionTimelineActiveFromScroll() {
|
|
374
|
+
if (
|
|
375
|
+
!this.sessionTimelineEnabled
|
|
376
|
+
|| this.mainTab !== 'sessions'
|
|
377
|
+
|| this.getMainTabForNav() !== 'sessions'
|
|
378
|
+
|| !this.sessionPreviewRenderEnabled
|
|
379
|
+
) {
|
|
380
|
+
if (this.sessionTimelineActiveKey) {
|
|
381
|
+
this.sessionTimelineActiveKey = '';
|
|
382
|
+
}
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
const nodes = Array.isArray(this.sessionTimelineNodes) ? this.sessionTimelineNodes : [];
|
|
386
|
+
if (!nodes.length) {
|
|
387
|
+
if (this.sessionTimelineActiveKey) {
|
|
388
|
+
this.sessionTimelineActiveKey = '';
|
|
389
|
+
}
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
this.pruneSessionMessageRefs();
|
|
393
|
+
const scrollEl = this.sessionPreviewScrollEl || this.$refs.sessionPreviewScroll;
|
|
394
|
+
if (!scrollEl) {
|
|
395
|
+
if (!this.isSessionTimelineNodeKey(this.sessionTimelineActiveKey)) {
|
|
396
|
+
const fallbackKey = nodes[0].key;
|
|
397
|
+
if (this.sessionTimelineActiveKey !== fallbackKey) {
|
|
398
|
+
this.sessionTimelineActiveKey = fallbackKey;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
const stickyOffset = getSessionPreviewHeaderOffset(this, scrollEl);
|
|
404
|
+
const rawAnchorY = Number(scrollEl.scrollTop || 0) + stickyOffset;
|
|
405
|
+
const previousAnchorY = Number(this.sessionTimelineLastAnchorY || 0);
|
|
406
|
+
let direction = rawAnchorY - previousAnchorY;
|
|
407
|
+
if (Math.abs(direction) < 1) {
|
|
408
|
+
direction = Number(this.sessionTimelineLastDirection || 0);
|
|
409
|
+
} else {
|
|
410
|
+
this.sessionTimelineLastDirection = direction > 0 ? 1 : -1;
|
|
411
|
+
}
|
|
412
|
+
this.sessionTimelineLastAnchorY = rawAnchorY;
|
|
413
|
+
const hysteresisPx = 18;
|
|
414
|
+
const hysteresis = direction > 0 ? -hysteresisPx : (direction < 0 ? hysteresisPx : 0);
|
|
415
|
+
const anchorY = rawAnchorY + hysteresis;
|
|
416
|
+
const measuredNodes = this.getCachedSessionTimelineMeasuredNodes(nodes);
|
|
417
|
+
if (!measuredNodes.length) {
|
|
418
|
+
if (!this.isSessionTimelineNodeKey(this.sessionTimelineActiveKey)) {
|
|
419
|
+
this.sessionTimelineActiveKey = nodes[0].key;
|
|
420
|
+
}
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
let low = 0;
|
|
424
|
+
let high = measuredNodes.length - 1;
|
|
425
|
+
let candidateIndex = 0;
|
|
426
|
+
while (low <= high) {
|
|
427
|
+
const mid = Math.floor((low + high) / 2);
|
|
428
|
+
if (measuredNodes[mid].top <= anchorY) {
|
|
429
|
+
candidateIndex = mid;
|
|
430
|
+
low = mid + 1;
|
|
431
|
+
} else {
|
|
432
|
+
high = mid - 1;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
let currentIndex = -1;
|
|
436
|
+
if (this.sessionTimelineActiveKey) {
|
|
437
|
+
for (let i = 0; i < measuredNodes.length; i += 1) {
|
|
438
|
+
if (measuredNodes[i].key === this.sessionTimelineActiveKey) {
|
|
439
|
+
currentIndex = i;
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
if (currentIndex >= 0) {
|
|
445
|
+
if (direction > 0 && candidateIndex < currentIndex) {
|
|
446
|
+
candidateIndex = currentIndex;
|
|
447
|
+
} else if (direction < 0 && candidateIndex > currentIndex) {
|
|
448
|
+
candidateIndex = currentIndex;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
const activeKey = measuredNodes[candidateIndex].key;
|
|
452
|
+
if (this.sessionTimelineActiveKey !== activeKey) {
|
|
453
|
+
this.sessionTimelineActiveKey = activeKey;
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
jumpToSessionTimelineNode(messageKey) {
|
|
457
|
+
if (!this.sessionTimelineEnabled || this.mainTab !== 'sessions' || !this.sessionPreviewRenderEnabled) return;
|
|
458
|
+
if (!messageKey) return;
|
|
459
|
+
if (!this.isSessionTimelineNodeKey(messageKey)) return;
|
|
460
|
+
const scrollEl = this.sessionPreviewScrollEl || this.$refs.sessionPreviewScroll;
|
|
461
|
+
if (!scrollEl) return;
|
|
462
|
+
const messageEl = this.sessionMessageRefMap[messageKey];
|
|
463
|
+
if (!messageEl) return;
|
|
464
|
+
const stickyOffset = getSessionPreviewHeaderOffset(this, scrollEl);
|
|
465
|
+
const scrollRect = scrollEl.getBoundingClientRect();
|
|
466
|
+
const messageRect = messageEl.getBoundingClientRect();
|
|
467
|
+
const targetScrollTop = scrollEl.scrollTop + (messageRect.top - scrollRect.top) - stickyOffset;
|
|
468
|
+
this.sessionTimelineActiveKey = messageKey;
|
|
469
|
+
if (typeof scrollEl.scrollTo === 'function') {
|
|
470
|
+
scrollEl.scrollTo({
|
|
471
|
+
top: Math.max(0, targetScrollTop),
|
|
472
|
+
behavior: 'smooth'
|
|
473
|
+
});
|
|
474
|
+
} else {
|
|
475
|
+
messageEl.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
}
|