@lvce-editor/chat-debug-view 10.13.0 → 10.16.0
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/dist/chatDebugViewWorkerMain.js +217 -160
- package/package.json +1 -1
|
@@ -2232,6 +2232,10 @@ const getEventsWithTime = events => {
|
|
|
2232
2232
|
});
|
|
2233
2233
|
};
|
|
2234
2234
|
|
|
2235
|
+
const clamp$1 = (value, minimum, maximum) => {
|
|
2236
|
+
return Math.max(minimum, Math.min(value, maximum));
|
|
2237
|
+
};
|
|
2238
|
+
|
|
2235
2239
|
const parseTimelineSeconds = value => {
|
|
2236
2240
|
const trimmed = value.trim();
|
|
2237
2241
|
if (!trimmed) {
|
|
@@ -2260,8 +2264,10 @@ const getNormalizedRange = (durationSeconds, startValue, endValue) => {
|
|
|
2260
2264
|
}
|
|
2261
2265
|
const rawStart = parsedStart ?? 0;
|
|
2262
2266
|
const rawEnd = parsedEnd ?? durationSeconds;
|
|
2263
|
-
const
|
|
2264
|
-
const
|
|
2267
|
+
const rangeStart = Math.min(rawStart, rawEnd);
|
|
2268
|
+
const rangeEnd = Math.max(rawStart, rawEnd);
|
|
2269
|
+
const normalizedStart = clamp$1(rangeStart, 0, durationSeconds);
|
|
2270
|
+
const normalizedEnd = clamp$1(rangeEnd, 0, durationSeconds);
|
|
2265
2271
|
return {
|
|
2266
2272
|
endSeconds: roundSeconds(normalizedEnd),
|
|
2267
2273
|
hasSelection: true,
|
|
@@ -2460,18 +2466,6 @@ const diff2 = uid => {
|
|
|
2460
2466
|
return diff(oldState, newState);
|
|
2461
2467
|
};
|
|
2462
2468
|
|
|
2463
|
-
const getSelectedDetailTab = detailTabs => {
|
|
2464
|
-
const selectedDetailTab = detailTabs.find(detailTab => detailTab.isSelected);
|
|
2465
|
-
if (selectedDetailTab) {
|
|
2466
|
-
return selectedDetailTab.name;
|
|
2467
|
-
}
|
|
2468
|
-
const responseTab = detailTabs.find(detailTab => detailTab.name === Response$1);
|
|
2469
|
-
if (responseTab) {
|
|
2470
|
-
return responseTab.name;
|
|
2471
|
-
}
|
|
2472
|
-
return detailTabs[0]?.name ?? Response$1;
|
|
2473
|
-
};
|
|
2474
|
-
|
|
2475
2469
|
const filterEventsByTimelineRange = (events, startValue, endValue) => {
|
|
2476
2470
|
const eventsWithTime = getEventsWithTime(events);
|
|
2477
2471
|
if (eventsWithTime.length === 0) {
|
|
@@ -2873,15 +2867,38 @@ const sortEventsByTableColumn = (events, sortColumn, sortDescending) => {
|
|
|
2873
2867
|
return sortableEvents.toSorted(compareEntries).map(item => item.event);
|
|
2874
2868
|
};
|
|
2875
2869
|
|
|
2876
|
-
const getCurrentEvents$
|
|
2870
|
+
const getCurrentEvents$1 = state => {
|
|
2877
2871
|
const eventCategoryFilters = getSelectedEventCategoryFilters(state.categoryFilters);
|
|
2878
2872
|
const filteredEvents = getFilteredEvents(state.events, state.filterValue, eventCategoryFilters, state.showInputEvents, state.showResponsePartEvents, state.showEventStreamFinishedEvents);
|
|
2879
2873
|
const timelineEvents = filterEventsByTimelineRange(filteredEvents, state.timelineStartSeconds, state.timelineEndSeconds);
|
|
2880
2874
|
return sortEventsByTableColumn(timelineEvents, state.sortColumn, state.sortDescending);
|
|
2881
2875
|
};
|
|
2882
2876
|
|
|
2883
|
-
const
|
|
2884
|
-
|
|
2877
|
+
const getCurrentEvents = state => getCurrentEvents$1(state);
|
|
2878
|
+
|
|
2879
|
+
const getSelectedDetailTab = detailTabs => {
|
|
2880
|
+
const selectedDetailTab = detailTabs.find(detailTab => detailTab.isSelected);
|
|
2881
|
+
if (selectedDetailTab) {
|
|
2882
|
+
return selectedDetailTab.name;
|
|
2883
|
+
}
|
|
2884
|
+
const responseTab = detailTabs.find(detailTab => detailTab.name === Response$1);
|
|
2885
|
+
if (responseTab) {
|
|
2886
|
+
return responseTab.name;
|
|
2887
|
+
}
|
|
2888
|
+
return detailTabs[0]?.name ?? Response$1;
|
|
2889
|
+
};
|
|
2890
|
+
|
|
2891
|
+
const loadSelectedEvent = async (_databaseName, _dataBaseVersion, _eventStoreName, sessionId, _sessionIdIndexName, eventId, type, endEventId) => {
|
|
2892
|
+
const raw = await loadSelectedEvent$1(sessionId, eventId, type);
|
|
2893
|
+
if (endEventId && endEventId !== -1) {
|
|
2894
|
+
const end = await loadSelectedEvent$1(sessionId, endEventId, type);
|
|
2895
|
+
// @ts-ignore
|
|
2896
|
+
return {
|
|
2897
|
+
...raw,
|
|
2898
|
+
endValue: end
|
|
2899
|
+
};
|
|
2900
|
+
}
|
|
2901
|
+
return raw;
|
|
2885
2902
|
};
|
|
2886
2903
|
|
|
2887
2904
|
const mergeSelectedEventDetails = (selectedEvent, selectedEventDetails) => {
|
|
@@ -2971,7 +2988,7 @@ const getScrollBarOffset = (deltaY, maxDeltaY, tableBodyHeight, scrollBarHeight)
|
|
|
2971
2988
|
return Math.round(deltaY / maxDeltaY * (tableBodyHeight - scrollBarHeight));
|
|
2972
2989
|
};
|
|
2973
2990
|
const applyVirtualTableState = state => {
|
|
2974
|
-
const currentEvents = getCurrentEvents$
|
|
2991
|
+
const currentEvents = getCurrentEvents$1(state);
|
|
2975
2992
|
const tableBodyHeight = getTableBodyHeight(state, currentEvents.length);
|
|
2976
2993
|
const deltaY = clampTableDeltaY(state.tableDeltaY, currentEvents.length, tableBodyHeight);
|
|
2977
2994
|
const minLineY = Math.floor(deltaY / devtoolsTableRowHeight);
|
|
@@ -2994,7 +3011,7 @@ const withSelectedEventVisible = state => {
|
|
|
2994
3011
|
if (state.selectedEventIndex === null || state.selectedEventIndex < 0) {
|
|
2995
3012
|
return applyVirtualTableState(state);
|
|
2996
3013
|
}
|
|
2997
|
-
const currentEvents = getCurrentEvents$
|
|
3014
|
+
const currentEvents = getCurrentEvents$1(state);
|
|
2998
3015
|
const tableBodyHeight = getTableBodyHeight(state, currentEvents.length);
|
|
2999
3016
|
const visibleRowCount = getVisibleRowCount(tableBodyHeight);
|
|
3000
3017
|
if (visibleRowCount === 0) {
|
|
@@ -3011,10 +3028,11 @@ const withSelectedEventVisible = state => {
|
|
|
3011
3028
|
return applyVirtualTableState(state);
|
|
3012
3029
|
};
|
|
3013
3030
|
|
|
3014
|
-
const
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3031
|
+
const getAttachmentImagePreviewAltText = event => {
|
|
3032
|
+
return typeof event.name === 'string' && event.name ? event.name : 'image preview';
|
|
3033
|
+
};
|
|
3034
|
+
|
|
3035
|
+
const getAttachmentImagePreviewBlob = event => {
|
|
3018
3036
|
const {
|
|
3019
3037
|
blob
|
|
3020
3038
|
} = event;
|
|
@@ -3023,24 +3041,37 @@ const getBlob = event => {
|
|
|
3023
3041
|
}
|
|
3024
3042
|
return undefined;
|
|
3025
3043
|
};
|
|
3026
|
-
|
|
3044
|
+
|
|
3045
|
+
const getAttachmentImagePreviewMimeType = event => {
|
|
3027
3046
|
return typeof event.mimeType === 'string' ? event.mimeType : undefined;
|
|
3028
3047
|
};
|
|
3029
|
-
|
|
3030
|
-
return typeof event.name === 'string' && event.name ? event.name : 'image preview';
|
|
3031
|
-
};
|
|
3032
|
-
const isImageMimeType = mimeType => {
|
|
3033
|
-
return typeof mimeType === 'string' && mimeType.startsWith('image/');
|
|
3034
|
-
};
|
|
3048
|
+
|
|
3035
3049
|
const formatImageSize = size => {
|
|
3036
3050
|
if (size < 1024) {
|
|
3037
3051
|
return `${size} B`;
|
|
3038
3052
|
}
|
|
3039
3053
|
return `${(size / 1024).toFixed(1)} kB`;
|
|
3040
3054
|
};
|
|
3055
|
+
|
|
3041
3056
|
const formatImageStats = (width, height, size) => {
|
|
3042
3057
|
return `${width} × ${height} px · ${formatImageSize(size)}`;
|
|
3043
3058
|
};
|
|
3059
|
+
|
|
3060
|
+
const getRasterImageStats = async blob => {
|
|
3061
|
+
if (typeof createImageBitmap !== 'function') {
|
|
3062
|
+
throw new TypeError('image bitmap decoder is not available');
|
|
3063
|
+
}
|
|
3064
|
+
const bitmap = await createImageBitmap(blob);
|
|
3065
|
+
try {
|
|
3066
|
+
return formatImageStats(bitmap.width, bitmap.height, blob.size);
|
|
3067
|
+
} finally {
|
|
3068
|
+
bitmap.close?.();
|
|
3069
|
+
}
|
|
3070
|
+
};
|
|
3071
|
+
|
|
3072
|
+
const svgWidthRegex = /\bwidth=["']([\d.]+)(?:px)?["']/i;
|
|
3073
|
+
const svgHeightRegex = /\bheight=["']([\d.]+)(?:px)?["']/i;
|
|
3074
|
+
const svgViewBoxRegex = /\bviewBox=["'][^"']*?([\d.]+)\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)["']/i;
|
|
3044
3075
|
const getSvgImageStats = async blob => {
|
|
3045
3076
|
const text = await blob.text();
|
|
3046
3077
|
const widthMatch = text.match(svgWidthRegex);
|
|
@@ -3054,27 +3085,7 @@ const getSvgImageStats = async blob => {
|
|
|
3054
3085
|
}
|
|
3055
3086
|
return undefined;
|
|
3056
3087
|
};
|
|
3057
|
-
|
|
3058
|
-
if (typeof FileReaderSync === 'function') {
|
|
3059
|
-
const reader = new FileReaderSync();
|
|
3060
|
-
return reader.readAsDataURL(blob);
|
|
3061
|
-
}
|
|
3062
|
-
if (typeof URL.createObjectURL === 'function') {
|
|
3063
|
-
return URL.createObjectURL(blob);
|
|
3064
|
-
}
|
|
3065
|
-
throw new Error('image preview reader is not available');
|
|
3066
|
-
};
|
|
3067
|
-
const getRasterImageStats = async blob => {
|
|
3068
|
-
if (typeof createImageBitmap !== 'function') {
|
|
3069
|
-
throw new TypeError('image bitmap decoder is not available');
|
|
3070
|
-
}
|
|
3071
|
-
const bitmap = await createImageBitmap(blob);
|
|
3072
|
-
try {
|
|
3073
|
-
return formatImageStats(bitmap.width, bitmap.height, blob.size);
|
|
3074
|
-
} finally {
|
|
3075
|
-
bitmap.close?.();
|
|
3076
|
-
}
|
|
3077
|
-
};
|
|
3088
|
+
|
|
3078
3089
|
const getImageStats = async (blob, mimeType) => {
|
|
3079
3090
|
if (mimeType === 'image/svg+xml') {
|
|
3080
3091
|
const svgStats = await getSvgImageStats(blob);
|
|
@@ -3085,19 +3096,35 @@ const getImageStats = async (blob, mimeType) => {
|
|
|
3085
3096
|
}
|
|
3086
3097
|
return getRasterImageStats(blob);
|
|
3087
3098
|
};
|
|
3099
|
+
|
|
3100
|
+
const isImageMimeType = mimeType => {
|
|
3101
|
+
return typeof mimeType === 'string' && mimeType.startsWith('image/');
|
|
3102
|
+
};
|
|
3103
|
+
|
|
3104
|
+
const readBlobAsPreviewUrl = blob => {
|
|
3105
|
+
if (typeof FileReaderSync === 'function') {
|
|
3106
|
+
const reader = new FileReaderSync();
|
|
3107
|
+
return reader.readAsDataURL(blob);
|
|
3108
|
+
}
|
|
3109
|
+
if (typeof URL.createObjectURL === 'function') {
|
|
3110
|
+
return URL.createObjectURL(blob);
|
|
3111
|
+
}
|
|
3112
|
+
throw new Error('image preview reader is not available');
|
|
3113
|
+
};
|
|
3114
|
+
|
|
3088
3115
|
const getAttachmentImagePreview = async event => {
|
|
3089
3116
|
if (event.type !== 'chat-attachment-added' && event.type !== 'chat-attachment-removed') {
|
|
3090
3117
|
return undefined;
|
|
3091
3118
|
}
|
|
3092
|
-
const blob =
|
|
3093
|
-
const mimeType =
|
|
3119
|
+
const blob = getAttachmentImagePreviewBlob(event);
|
|
3120
|
+
const mimeType = getAttachmentImagePreviewMimeType(event);
|
|
3094
3121
|
if (!blob || !isImageMimeType(mimeType)) {
|
|
3095
3122
|
return undefined;
|
|
3096
3123
|
}
|
|
3097
3124
|
try {
|
|
3098
3125
|
const stats = await getImageStats(blob, mimeType);
|
|
3099
3126
|
return {
|
|
3100
|
-
alt:
|
|
3127
|
+
alt: getAttachmentImagePreviewAltText(event),
|
|
3101
3128
|
previewType: 'image',
|
|
3102
3129
|
src: readBlobAsPreviewUrl(blob),
|
|
3103
3130
|
stats
|
|
@@ -3129,11 +3156,7 @@ const withPreparedSelectedEventPreview = async event => {
|
|
|
3129
3156
|
return setSelectedEventPreview(event, preview);
|
|
3130
3157
|
};
|
|
3131
3158
|
|
|
3132
|
-
const
|
|
3133
|
-
loadSelectedEvent: loadSelectedEvent
|
|
3134
|
-
};
|
|
3135
|
-
const getCurrentEvents$1 = state => getCurrentEvents$2(state);
|
|
3136
|
-
const selectEventAtIndex = async (state, selectedEventIndex, dependencies = selectEventAtIndexDependencies) => {
|
|
3159
|
+
const selectEventAtIndex = async (state, selectedEventIndex) => {
|
|
3137
3160
|
const {
|
|
3138
3161
|
databaseName,
|
|
3139
3162
|
dataBaseVersion,
|
|
@@ -3161,7 +3184,9 @@ const selectEventAtIndex = async (state, selectedEventIndex, dependencies = sele
|
|
|
3161
3184
|
selectedEventIndex
|
|
3162
3185
|
};
|
|
3163
3186
|
}
|
|
3164
|
-
const selectedEventDetails = await
|
|
3187
|
+
const selectedEventDetails = await loadSelectedEvent(databaseName, dataBaseVersion, eventStoreName, sessionId, sessionIdIndexName, selectedEvent.eventId, selectedEvent.type,
|
|
3188
|
+
// @ts-ignore
|
|
3189
|
+
selectedEvent['eventEndId'] || 0);
|
|
3165
3190
|
const resolvedSelectedEvent = await withPreparedSelectedEventPreview(mergeSelectedEventDetails(selectedEvent, selectedEventDetails));
|
|
3166
3191
|
return withSelectedEventVisible({
|
|
3167
3192
|
...state,
|
|
@@ -3178,7 +3203,7 @@ const selectEventAtIndex = async (state, selectedEventIndex, dependencies = sele
|
|
|
3178
3203
|
};
|
|
3179
3204
|
|
|
3180
3205
|
const focusIndex = async (state, index) => {
|
|
3181
|
-
const currentEvents = getCurrentEvents
|
|
3206
|
+
const currentEvents = getCurrentEvents(state);
|
|
3182
3207
|
if (currentEvents.length === 0 || state.selectedEventIndex === index) {
|
|
3183
3208
|
return state;
|
|
3184
3209
|
}
|
|
@@ -3268,7 +3293,10 @@ const getMenuEntriesTableHeader = state => {
|
|
|
3268
3293
|
|
|
3269
3294
|
const MenuChatDebugTableHeader = 2189;
|
|
3270
3295
|
const handleHeaderContextMenu = async (state, eventX, eventY) => {
|
|
3271
|
-
|
|
3296
|
+
const {
|
|
3297
|
+
uid
|
|
3298
|
+
} = state;
|
|
3299
|
+
await showContextMenu2(uid, MenuChatDebugTableHeader, eventX, eventY, {
|
|
3272
3300
|
menuId: MenuChatDebugTableHeader
|
|
3273
3301
|
});
|
|
3274
3302
|
return state;
|
|
@@ -3354,6 +3382,7 @@ const toPrettyEvents = rawEvents => {
|
|
|
3354
3382
|
const response = map[item.requestId];
|
|
3355
3383
|
if (response) {
|
|
3356
3384
|
pretty.push({
|
|
3385
|
+
eventEndId: response.eventId,
|
|
3357
3386
|
eventId: item.eventId,
|
|
3358
3387
|
type: 'ai-request-response'
|
|
3359
3388
|
});
|
|
@@ -3567,7 +3596,7 @@ const restoreSelectedEvent = async state => {
|
|
|
3567
3596
|
selectedEventIndex: null
|
|
3568
3597
|
};
|
|
3569
3598
|
}
|
|
3570
|
-
const currentEvents = getCurrentEvents$
|
|
3599
|
+
const currentEvents = getCurrentEvents$1(state);
|
|
3571
3600
|
const selectedEventIndex = currentEvents.findIndex(event => event.eventId === state.selectedEventId);
|
|
3572
3601
|
if (selectedEventIndex === -1) {
|
|
3573
3602
|
return {
|
|
@@ -3727,8 +3756,6 @@ const handleEscape = state => {
|
|
|
3727
3756
|
return state;
|
|
3728
3757
|
};
|
|
3729
3758
|
|
|
3730
|
-
const getCurrentEvents = state => getCurrentEvents$2(state);
|
|
3731
|
-
|
|
3732
3759
|
const getEventIndexByStableId$1 = (events, event) => {
|
|
3733
3760
|
return events.findIndex(candidate => candidate.eventId === event.eventId);
|
|
3734
3761
|
};
|
|
@@ -3798,9 +3825,6 @@ const handleEventCategoryFilter$1 = (state, value, ctrlKey = false, metaKey = fa
|
|
|
3798
3825
|
return withPreservedSelection$1(state, nextState);
|
|
3799
3826
|
};
|
|
3800
3827
|
|
|
3801
|
-
const handleEventRowClickDependencies = {
|
|
3802
|
-
loadSelectedEvent: loadSelectedEvent
|
|
3803
|
-
};
|
|
3804
3828
|
const isPrimaryButton = button => {
|
|
3805
3829
|
return button === 0;
|
|
3806
3830
|
};
|
|
@@ -3812,7 +3836,7 @@ const handleEventRowClick = async (state, index, button = 0) => {
|
|
|
3812
3836
|
if (actual === -1) {
|
|
3813
3837
|
return state;
|
|
3814
3838
|
}
|
|
3815
|
-
return selectEventAtIndex(state, actual
|
|
3839
|
+
return selectEventAtIndex(state, actual);
|
|
3816
3840
|
};
|
|
3817
3841
|
|
|
3818
3842
|
const handleEventRowClickAt = async (state, eventX, eventY, button = 0) => {
|
|
@@ -3847,7 +3871,7 @@ const getSelectedEventIndex = state => {
|
|
|
3847
3871
|
if (selectedEventIndex === null) {
|
|
3848
3872
|
return null;
|
|
3849
3873
|
}
|
|
3850
|
-
const filteredEvents = getCurrentEvents$
|
|
3874
|
+
const filteredEvents = getCurrentEvents$1(state);
|
|
3851
3875
|
const selectedEvent = filteredEvents[selectedEventIndex];
|
|
3852
3876
|
if (!selectedEvent) {
|
|
3853
3877
|
return null;
|
|
@@ -3865,12 +3889,12 @@ const getPreservedSelectedEventIndex = (oldState, newState) => {
|
|
|
3865
3889
|
if (selectedEventIndex === null) {
|
|
3866
3890
|
return null;
|
|
3867
3891
|
}
|
|
3868
|
-
const oldFilteredEvents = getCurrentEvents$
|
|
3892
|
+
const oldFilteredEvents = getCurrentEvents$1(oldState);
|
|
3869
3893
|
const selectedEvent = oldFilteredEvents[selectedEventIndex];
|
|
3870
3894
|
if (!selectedEvent) {
|
|
3871
3895
|
return null;
|
|
3872
3896
|
}
|
|
3873
|
-
const newFilteredEvents = getCurrentEvents$
|
|
3897
|
+
const newFilteredEvents = getCurrentEvents$1(newState);
|
|
3874
3898
|
const newIndex = getEventIndexByStableId(newFilteredEvents, selectedEvent);
|
|
3875
3899
|
if (newIndex === -1) {
|
|
3876
3900
|
return null;
|
|
@@ -4472,16 +4496,22 @@ const handlePreviewTextScrollBarPointerDown = (state, eventY) => {
|
|
|
4472
4496
|
};
|
|
4473
4497
|
|
|
4474
4498
|
const handlePreviewTextScrollBarPointerMove = (state, eventY) => {
|
|
4475
|
-
|
|
4499
|
+
const {
|
|
4500
|
+
previewTextDeltaY,
|
|
4501
|
+
previewTextScrollBarHandleOffset,
|
|
4502
|
+
previewTextScrollBarPointerActive,
|
|
4503
|
+
selectedEvent
|
|
4504
|
+
} = state;
|
|
4505
|
+
if (!previewTextScrollBarPointerActive) {
|
|
4476
4506
|
return state;
|
|
4477
4507
|
}
|
|
4478
4508
|
const viewportHeight = getPreviewTextViewportHeight(state);
|
|
4479
|
-
const virtualization = getPreviewVirtualizationState(
|
|
4509
|
+
const virtualization = getPreviewVirtualizationState(selectedEvent, viewportHeight, previewTextDeltaY);
|
|
4480
4510
|
if (viewportHeight === 0 || virtualization.scrollBarHeight === 0) {
|
|
4481
4511
|
return state;
|
|
4482
4512
|
}
|
|
4483
4513
|
const relativeY = eventY - getPreviewTextBodyY(state);
|
|
4484
|
-
const nextHandleTop = Math.max(0, Math.min(viewportHeight - virtualization.scrollBarHeight, relativeY -
|
|
4514
|
+
const nextHandleTop = Math.max(0, Math.min(viewportHeight - virtualization.scrollBarHeight, relativeY - previewTextScrollBarHandleOffset));
|
|
4485
4515
|
const percent = nextHandleTop / Math.max(1, viewportHeight - virtualization.scrollBarHeight);
|
|
4486
4516
|
const nextState = setPreviewTextDeltaY(state, percent * virtualization.maxDeltaY);
|
|
4487
4517
|
return {
|
|
@@ -4502,7 +4532,10 @@ const handlePreviewTextScrollBarPointerUp = state => {
|
|
|
4502
4532
|
};
|
|
4503
4533
|
|
|
4504
4534
|
const handlePreviewTextWheel = (state, deltaY) => {
|
|
4505
|
-
|
|
4535
|
+
const {
|
|
4536
|
+
previewTextDeltaY
|
|
4537
|
+
} = state;
|
|
4538
|
+
return setPreviewTextDeltaY(state, previewTextDeltaY + deltaY);
|
|
4506
4539
|
};
|
|
4507
4540
|
|
|
4508
4541
|
const handleRootContextMenu = state => {
|
|
@@ -4649,7 +4682,7 @@ const getHandleOffsetAndPercent = (tableBodyHeight, scrollBarHeight, relativeY)
|
|
|
4649
4682
|
};
|
|
4650
4683
|
};
|
|
4651
4684
|
const handleTableScrollBarPointerDown = (state, eventY) => {
|
|
4652
|
-
const currentEvents = getCurrentEvents$
|
|
4685
|
+
const currentEvents = getCurrentEvents$1(state);
|
|
4653
4686
|
const tableBodyHeight = getTableBodyHeight(state, currentEvents.length);
|
|
4654
4687
|
const scrollBarHeight = getScrollBarHeight(currentEvents.length, tableBodyHeight);
|
|
4655
4688
|
if (tableBodyHeight === 0 || scrollBarHeight === 0) {
|
|
@@ -4673,7 +4706,7 @@ const handleTableScrollBarPointerMove = (state, eventY) => {
|
|
|
4673
4706
|
if (!state.tableScrollBarPointerActive) {
|
|
4674
4707
|
return state;
|
|
4675
4708
|
}
|
|
4676
|
-
const currentEvents = getCurrentEvents$
|
|
4709
|
+
const currentEvents = getCurrentEvents$1(state);
|
|
4677
4710
|
const tableBodyHeight = getTableBodyHeight(state, currentEvents.length);
|
|
4678
4711
|
const scrollBarHeight = getScrollBarHeight(currentEvents.length, tableBodyHeight);
|
|
4679
4712
|
if (tableBodyHeight === 0 || scrollBarHeight === 0) {
|
|
@@ -5041,7 +5074,7 @@ const getDetailsLineNumberWidth = state => {
|
|
|
5041
5074
|
const getCss = state => {
|
|
5042
5075
|
const hasSelectedEvent = !!state.selectedEvent;
|
|
5043
5076
|
const tableWidth = hasSelectedEvent ? clampTableWidth(state, state.tableWidth) : getMainWidth(state);
|
|
5044
|
-
const currentEvents = getCurrentEvents$
|
|
5077
|
+
const currentEvents = getCurrentEvents$1(state);
|
|
5045
5078
|
const tableBodyHeight = getTableBodyHeight(state, currentEvents.length);
|
|
5046
5079
|
const scrollBarHeight = getScrollBarHeight(currentEvents.length, tableBodyHeight);
|
|
5047
5080
|
const maxDeltaY = getMaxDeltaY(currentEvents.length, tableBodyHeight);
|
|
@@ -5782,6 +5815,7 @@ const getFilterInputDom = (filterValue, useDevtoolsLayout) => {
|
|
|
5782
5815
|
};
|
|
5783
5816
|
};
|
|
5784
5817
|
|
|
5818
|
+
const selectedClassName = mergeClassNames(ChatDebugViewQuickFilterPill, ChatDebugViewQuickFilterPillSelected);
|
|
5785
5819
|
const getQuickFilterDom = categoryFilter => {
|
|
5786
5820
|
const {
|
|
5787
5821
|
isSelected,
|
|
@@ -5791,7 +5825,7 @@ const getQuickFilterDom = categoryFilter => {
|
|
|
5791
5825
|
return [{
|
|
5792
5826
|
ariaSelected: isSelected,
|
|
5793
5827
|
childCount: 1,
|
|
5794
|
-
className:
|
|
5828
|
+
className: isSelected ? selectedClassName : ChatDebugViewQuickFilterPill,
|
|
5795
5829
|
name,
|
|
5796
5830
|
onClick: HandleEventCategoryFilter,
|
|
5797
5831
|
role: Option,
|
|
@@ -5841,6 +5875,19 @@ const getDebugViewTopDom = (filterValue, useDevtoolsLayout, categoryFilters) =>
|
|
|
5841
5875
|
}, getFilterInputDom(filterValue, false), ...refreshButtonDom];
|
|
5842
5876
|
};
|
|
5843
5877
|
|
|
5878
|
+
const createDevtoolsRows = (events, selectedEventIndex, startIndex = 0) => {
|
|
5879
|
+
return events.map((event, index) => {
|
|
5880
|
+
const actualIndex = startIndex + index;
|
|
5881
|
+
return {
|
|
5882
|
+
event,
|
|
5883
|
+
index: actualIndex,
|
|
5884
|
+
isErrorStatus: hasErrorStatus(event),
|
|
5885
|
+
isEven: actualIndex % 2 === 1,
|
|
5886
|
+
isSelected: selectedEventIndex === actualIndex
|
|
5887
|
+
};
|
|
5888
|
+
});
|
|
5889
|
+
};
|
|
5890
|
+
|
|
5844
5891
|
const getNextSiblingIndex$2 = (nodes, index) => {
|
|
5845
5892
|
let nextSiblingIndex = index + 1;
|
|
5846
5893
|
const childCount = nodes[index]?.childCount || 0;
|
|
@@ -6910,12 +6957,15 @@ const getTextNode = (value, showLineNumbers = true, cursor = null, tokenSegments
|
|
|
6910
6957
|
return getEditorDom(lineData, showLineNumbers, cursor, showLineNumbers ? HandlePreviewTextPointerDown : undefined);
|
|
6911
6958
|
};
|
|
6912
6959
|
|
|
6960
|
+
const getTextEvent = (previewEvent, selectedEvent, previewTextCursor, virtualization) => {
|
|
6961
|
+
const isInvalidImageMessage = previewEvent === ImageCouldNotBeLoaded;
|
|
6962
|
+
const isChatMessageUpdatedPreview = !!selectedEvent && isChatMessageUpdatedEvent(selectedEvent);
|
|
6963
|
+
const showLineNumbers = !isInvalidImageMessage && !isChatMessageUpdatedPreview;
|
|
6964
|
+
return getTextNode(previewEvent, showLineNumbers, showLineNumbers ? previewTextCursor ?? null : null, undefined, virtualization);
|
|
6965
|
+
};
|
|
6913
6966
|
const getPreviewEventNodes = (previewEvent, selectedEvent, previewTextCursor, virtualization) => {
|
|
6914
6967
|
if (typeof previewEvent === 'string') {
|
|
6915
|
-
|
|
6916
|
-
const isChatMessageUpdatedPreview = !!selectedEvent && isChatMessageUpdatedEvent(selectedEvent);
|
|
6917
|
-
const showLineNumbers = !isInvalidImageMessage && !isChatMessageUpdatedPreview;
|
|
6918
|
-
return getTextNode(previewEvent, showLineNumbers, showLineNumbers ? previewTextCursor ?? null : null, undefined, virtualization);
|
|
6968
|
+
return getTextEvent(previewEvent, selectedEvent, previewTextCursor, virtualization);
|
|
6919
6969
|
}
|
|
6920
6970
|
if (isWriteFilePreview(previewEvent)) {
|
|
6921
6971
|
const language = getLanguageFromFileExtension(previewEvent.uri);
|
|
@@ -6991,13 +7041,6 @@ const getStartText = event => {
|
|
|
6991
7041
|
return getTimestampText(event.started ?? event.startTime ?? event.startTimestamp ?? event.timestamp);
|
|
6992
7042
|
};
|
|
6993
7043
|
|
|
6994
|
-
const getTimingPreviewSegments = event => {
|
|
6995
|
-
return [{
|
|
6996
|
-
endPercent: 100,
|
|
6997
|
-
label: getDurationText(event),
|
|
6998
|
-
startPercent: 0
|
|
6999
|
-
}];
|
|
7000
|
-
};
|
|
7001
7044
|
const getTimingPreviewSegmentNodes = segments => {
|
|
7002
7045
|
return [{
|
|
7003
7046
|
childCount: segments.length,
|
|
@@ -7013,6 +7056,15 @@ const getTimingPreviewSegmentNodes = segments => {
|
|
|
7013
7056
|
}, text(segment.label)];
|
|
7014
7057
|
})];
|
|
7015
7058
|
};
|
|
7059
|
+
|
|
7060
|
+
const getTimingPreviewSegments = event => {
|
|
7061
|
+
return [{
|
|
7062
|
+
endPercent: 100,
|
|
7063
|
+
label: getDurationText(event),
|
|
7064
|
+
startPercent: 0
|
|
7065
|
+
}];
|
|
7066
|
+
};
|
|
7067
|
+
|
|
7016
7068
|
const getTimingPreviewDom = event => {
|
|
7017
7069
|
const segments = getTimingPreviewSegments(event);
|
|
7018
7070
|
return [{
|
|
@@ -7074,27 +7126,30 @@ const getTimingContentNodes = (responseEventNodes, selectedEvent) => {
|
|
|
7074
7126
|
return getTimingDetailsDom(selectedEvent);
|
|
7075
7127
|
};
|
|
7076
7128
|
|
|
7077
|
-
const
|
|
7129
|
+
const getRowViewModels = event => {
|
|
7078
7130
|
const usageDetails = getTokenUsageDetails(event);
|
|
7079
7131
|
if (!usageDetails) {
|
|
7080
7132
|
return [];
|
|
7081
7133
|
}
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
}
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7134
|
+
return [{
|
|
7135
|
+
key: inputTokens(),
|
|
7136
|
+
value: usageDetails.inputTokens
|
|
7137
|
+
}, {
|
|
7138
|
+
key: outputTokens(),
|
|
7139
|
+
value: usageDetails.outputTokens
|
|
7140
|
+
}, {
|
|
7141
|
+
key: cachedTokens(),
|
|
7142
|
+
value: usageDetails.cachedTokens
|
|
7143
|
+
}].filter(row => row.value !== undefined);
|
|
7144
|
+
};
|
|
7145
|
+
const getTokenUsageDetailsDom = event => {
|
|
7146
|
+
const rowViewModels = getRowViewModels(event);
|
|
7147
|
+
if (rowViewModels.length === 0) {
|
|
7148
|
+
return [];
|
|
7095
7149
|
}
|
|
7150
|
+
const rows = rowViewModels.flatMap(row => getTimingRowDom(row.key, String(row.value)));
|
|
7096
7151
|
return [{
|
|
7097
|
-
childCount:
|
|
7152
|
+
childCount: rowViewModels.length,
|
|
7098
7153
|
className: ChatDebugViewTiming,
|
|
7099
7154
|
type: Div
|
|
7100
7155
|
}, ...rows];
|
|
@@ -7161,52 +7216,51 @@ const getEventTableMethodLabel = event => {
|
|
|
7161
7216
|
return '';
|
|
7162
7217
|
};
|
|
7163
7218
|
|
|
7219
|
+
const getTableCellDom = (column, event, isErrorStatus) => {
|
|
7220
|
+
switch (column) {
|
|
7221
|
+
case Duration:
|
|
7222
|
+
return [{
|
|
7223
|
+
childCount: 1,
|
|
7224
|
+
className: mergeClassNames(TableCell, ChatDebugViewCellDuration),
|
|
7225
|
+
type: Td
|
|
7226
|
+
}, text(getEventTableDurationText(event))];
|
|
7227
|
+
case Method:
|
|
7228
|
+
return [{
|
|
7229
|
+
childCount: 1,
|
|
7230
|
+
className: TableCell,
|
|
7231
|
+
type: Td
|
|
7232
|
+
}, text(getEventTableMethodLabel(event))];
|
|
7233
|
+
case Status$1:
|
|
7234
|
+
return [{
|
|
7235
|
+
childCount: 1,
|
|
7236
|
+
className: mergeClassNames(TableCell, isErrorStatus ? ChatDebugViewCellStatusError : ''),
|
|
7237
|
+
type: Td
|
|
7238
|
+
}, text(getStatusText(event))];
|
|
7239
|
+
case Type:
|
|
7240
|
+
return [{
|
|
7241
|
+
childCount: 1,
|
|
7242
|
+
className: TableCell,
|
|
7243
|
+
type: Td
|
|
7244
|
+
}, text(getEventTableTypeLabel(event))];
|
|
7245
|
+
default:
|
|
7246
|
+
return [];
|
|
7247
|
+
}
|
|
7248
|
+
};
|
|
7164
7249
|
const getRowCellNodes = (event, isErrorStatus, visibleTableColumns) => {
|
|
7165
7250
|
const orderedVisibleTableColumns = getOrderedVisibleTableColumns(visibleTableColumns);
|
|
7166
|
-
return orderedVisibleTableColumns.flatMap(
|
|
7167
|
-
|
|
7168
|
-
case Duration:
|
|
7169
|
-
return [{
|
|
7170
|
-
childCount: 1,
|
|
7171
|
-
className: mergeClassNames(TableCell, ChatDebugViewCellDuration),
|
|
7172
|
-
type: Td
|
|
7173
|
-
}, text(getEventTableDurationText(event))];
|
|
7174
|
-
case Method:
|
|
7175
|
-
return [{
|
|
7176
|
-
childCount: 1,
|
|
7177
|
-
className: TableCell,
|
|
7178
|
-
type: Td
|
|
7179
|
-
}, text(getEventTableMethodLabel(event))];
|
|
7180
|
-
case Status$1:
|
|
7181
|
-
return [{
|
|
7182
|
-
childCount: 1,
|
|
7183
|
-
className: mergeClassNames(TableCell, isErrorStatus ? ChatDebugViewCellStatusError : ''),
|
|
7184
|
-
type: Td
|
|
7185
|
-
}, text(getStatusText(event))];
|
|
7186
|
-
case Type:
|
|
7187
|
-
return [{
|
|
7188
|
-
childCount: 1,
|
|
7189
|
-
className: TableCell,
|
|
7190
|
-
type: Td
|
|
7191
|
-
}, text(getEventTableTypeLabel(event))];
|
|
7192
|
-
default:
|
|
7193
|
-
return [];
|
|
7194
|
-
}
|
|
7251
|
+
return orderedVisibleTableColumns.flatMap(column => {
|
|
7252
|
+
return getTableCellDom(column, event, isErrorStatus);
|
|
7195
7253
|
});
|
|
7196
7254
|
};
|
|
7197
7255
|
|
|
7198
|
-
const getDevtoolsRows = (
|
|
7199
|
-
return
|
|
7200
|
-
const
|
|
7201
|
-
const
|
|
7202
|
-
const rowClassName = isEvenRow ? TableRowEven : TableRowOdd;
|
|
7203
|
-
const isSelected = selectedEventIndex === actualIndex;
|
|
7204
|
-
const isErrorStatus = hasErrorStatus(event);
|
|
7205
|
-
const rowCellNodes = getRowCellNodes(event, isErrorStatus, visibleTableColumns);
|
|
7256
|
+
const getDevtoolsRows = (rows, visibleTableColumns = defaultVisibleTableColumns) => {
|
|
7257
|
+
return rows.flatMap(row => {
|
|
7258
|
+
const rowClassName = row.isEven ? TableRowEven : TableRowOdd;
|
|
7259
|
+
const rowCellNodes = getRowCellNodes(row.event, row.isErrorStatus, visibleTableColumns);
|
|
7206
7260
|
return [{
|
|
7207
7261
|
childCount: visibleTableColumns.length,
|
|
7208
|
-
className: mergeClassNames(TableRow, rowClassName, isSelected ? TableRowSelected : ''),
|
|
7209
|
-
'data-index': `${
|
|
7262
|
+
className: mergeClassNames(TableRow, rowClassName, row.isSelected ? TableRowSelected : ''),
|
|
7263
|
+
'data-index': `${row.index}`,
|
|
7210
7264
|
type: Tr
|
|
7211
7265
|
}, ...rowCellNodes];
|
|
7212
7266
|
});
|
|
@@ -7529,6 +7583,20 @@ const formatPercent = value => {
|
|
|
7529
7583
|
return `${Number(value.toFixed(3))}%`;
|
|
7530
7584
|
};
|
|
7531
7585
|
|
|
7586
|
+
const startHandle = {
|
|
7587
|
+
childCount: 0,
|
|
7588
|
+
className: mergeClassNames(ChatDebugViewTimelineSelectionHandle, ChatDebugViewTimelineSelectionHandleStart, ChatDebugViewTimelineSelectionMarker, ChatDebugViewTimelineSelectionMarkerStart),
|
|
7589
|
+
name: Start,
|
|
7590
|
+
role: None,
|
|
7591
|
+
type: Button$1
|
|
7592
|
+
};
|
|
7593
|
+
const endHandle = {
|
|
7594
|
+
childCount: 0,
|
|
7595
|
+
className: mergeClassNames(ChatDebugViewTimelineSelectionHandle, ChatDebugViewTimelineSelectionHandleEnd, ChatDebugViewTimelineSelectionMarker, ChatDebugViewTimelineSelectionMarkerEnd),
|
|
7596
|
+
name: End,
|
|
7597
|
+
role: None,
|
|
7598
|
+
type: Button$1
|
|
7599
|
+
};
|
|
7532
7600
|
const getSelectionNodesDom = (hasSelection, selectionStartPercent, selectionEndPercent) => {
|
|
7533
7601
|
if (!hasSelection || selectionStartPercent === null || selectionEndPercent === null) {
|
|
7534
7602
|
return [];
|
|
@@ -7538,19 +7606,7 @@ const getSelectionNodesDom = (hasSelection, selectionStartPercent, selectionEndP
|
|
|
7538
7606
|
className: ChatDebugViewTimelineSelectionRange,
|
|
7539
7607
|
style: `left:${formatPercent(selectionStartPercent)};width:${formatPercent(selectionEndPercent - selectionStartPercent)};`,
|
|
7540
7608
|
type: Div
|
|
7541
|
-
},
|
|
7542
|
-
childCount: 0,
|
|
7543
|
-
className: mergeClassNames(ChatDebugViewTimelineSelectionHandle, ChatDebugViewTimelineSelectionHandleStart, ChatDebugViewTimelineSelectionMarker, ChatDebugViewTimelineSelectionMarkerStart),
|
|
7544
|
-
name: Start,
|
|
7545
|
-
role: None,
|
|
7546
|
-
type: Button$1
|
|
7547
|
-
}, {
|
|
7548
|
-
childCount: 0,
|
|
7549
|
-
className: mergeClassNames(ChatDebugViewTimelineSelectionHandle, ChatDebugViewTimelineSelectionHandleEnd, ChatDebugViewTimelineSelectionMarker, ChatDebugViewTimelineSelectionMarkerEnd),
|
|
7550
|
-
name: End,
|
|
7551
|
-
role: None,
|
|
7552
|
-
type: Button$1
|
|
7553
|
-
}];
|
|
7609
|
+
}, startHandle, endHandle];
|
|
7554
7610
|
};
|
|
7555
7611
|
|
|
7556
7612
|
const getTimelineBadgeValues = durationSeconds => {
|
|
@@ -7639,7 +7695,8 @@ const getTimelineDom = (timelineInfo, hoverPercent = null) => {
|
|
|
7639
7695
|
|
|
7640
7696
|
const getDevtoolsDom = (events, selectedEvent, selectedEventIndex, timelineEvents, timelineStartSeconds, timelineEndSeconds, emptyMessage = noEventsFound(), timelineSelectionActive = false, timelineSelectionAnchorSeconds = '', timelineSelectionFocusSeconds = '', detailTabs = createDetailTabs(), visibleTableColumns = defaultVisibleTableColumns, tableColumns = createTableColumns(), timelineInfo, timelineHoverPercent = null, focus = 0, previewTextCursorRowIndex = null, previewTextCursorColumnIndex = null, previewTextDeltaY = 0, previewTextViewportHeight = 0, minLineY = 0, maxLineY = events.length) => {
|
|
7641
7697
|
const visibleEvents = events.slice(minLineY, maxLineY);
|
|
7642
|
-
const
|
|
7698
|
+
const rows = createDevtoolsRows(visibleEvents, selectedEventIndex, minLineY);
|
|
7699
|
+
const rowNodes = getDevtoolsRows(rows, visibleTableColumns);
|
|
7643
7700
|
const effectiveRange = getEffectiveTimelineRange(timelineStartSeconds, timelineEndSeconds, timelineSelectionActive, timelineSelectionAnchorSeconds, timelineSelectionFocusSeconds);
|
|
7644
7701
|
const resolvedTimelineInfo = timelineInfo || getTimelineInfo(timelineEvents, effectiveRange.startSeconds, effectiveRange.endSeconds);
|
|
7645
7702
|
const timelineNodes = getTimelineDom(resolvedTimelineInfo, timelineHoverPercent);
|
|
@@ -7773,7 +7830,7 @@ const renderItems = (oldState, newState) => {
|
|
|
7773
7830
|
if (newState.initial) {
|
|
7774
7831
|
return [SetDom2, newState.uid, []];
|
|
7775
7832
|
}
|
|
7776
|
-
const filteredEvents = getCurrentEvents$
|
|
7833
|
+
const filteredEvents = getCurrentEvents$1(newState);
|
|
7777
7834
|
const previewTextViewportHeight = getPreviewTextViewportHeight(newState);
|
|
7778
7835
|
const dom = getChatDebugViewDom(newState.errorMessage, newState.filterValue, getSelectedEventCategoryFilters(newState.categoryFilters), newState.categoryFilters, newState.showEventStreamFinishedEvents, newState.showInputEvents, newState.showResponsePartEvents, newState.useDevtoolsLayout, newState.selectedEvent, newState.selectedEventIndex, newState.timelineStartSeconds, newState.timelineEndSeconds, newState.timelineFilterDescription, withSessionEventIds(newState.timelineEvents), withSessionEventIds(filteredEvents), newState.timelineSelectionActive, newState.timelineSelectionAnchorSeconds, newState.timelineSelectionFocusSeconds, getVisibleTableColumns(newState.tableColumns), newState.detailTabs, newState.tableColumns, newState.timelineInfo, newState.timelineHoverPercent, newState.focus, newState.previewTextCursorRowIndex, newState.previewTextCursorColumnIndex, newState.tableMinLineY, newState.tableMaxLineY, newState.previewTextDeltaY, previewTextViewportHeight);
|
|
7779
7836
|
return [SetDom2, newState.uid, dom];
|