@meridianlabs/log-viewer 0.3.231 → 0.3.233
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/lib/e2e/chat-virtualization.spec.d.ts +2 -0
- package/lib/e2e/chat-virtualization.spec.d.ts.map +1 -0
- package/lib/index.js +1710 -101
- package/lib/index.js.map +1 -1
- package/lib/styles/index.css +191 -13
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React$1 from "react";
|
|
2
2
|
import React, { Children, Component, Fragment, Suspense, createContext, createElement, forwardRef, isValidElement, lazy, memo, startTransition, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import * as ReactDOM from "react-dom";
|
|
4
|
-
import So, { createPortal } from "react-dom";
|
|
4
|
+
import So, { createPortal, flushSync } from "react-dom";
|
|
5
5
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import markdownitMathjax3 from "markdown-it-mathjax3";
|
|
7
7
|
//#region \0rolldown/runtime.js
|
|
@@ -7094,7 +7094,7 @@ function useLocation() {
|
|
|
7094
7094
|
return React$1.useContext(LocationContext).location;
|
|
7095
7095
|
}
|
|
7096
7096
|
var navigateEffectWarning = `You should call navigate() in a React.useEffect(), not when your component is first rendered.`;
|
|
7097
|
-
function useIsomorphicLayoutEffect$
|
|
7097
|
+
function useIsomorphicLayoutEffect$2(cb) {
|
|
7098
7098
|
if (!React$1.useContext(NavigationContext).static) React$1.useLayoutEffect(cb);
|
|
7099
7099
|
}
|
|
7100
7100
|
function useNavigate() {
|
|
@@ -7109,7 +7109,7 @@ function useNavigateUnstable() {
|
|
|
7109
7109
|
let { pathname: locationPathname } = useLocation();
|
|
7110
7110
|
let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
|
|
7111
7111
|
let activeRef = React$1.useRef(false);
|
|
7112
|
-
useIsomorphicLayoutEffect$
|
|
7112
|
+
useIsomorphicLayoutEffect$2(() => {
|
|
7113
7113
|
activeRef.current = true;
|
|
7114
7114
|
});
|
|
7115
7115
|
return React$1.useCallback((to, options = {}) => {
|
|
@@ -7434,7 +7434,7 @@ function useNavigateStable() {
|
|
|
7434
7434
|
let { router } = useDataRouterContext("useNavigate");
|
|
7435
7435
|
let id = useCurrentRouteId("useNavigate");
|
|
7436
7436
|
let activeRef = React$1.useRef(false);
|
|
7437
|
-
useIsomorphicLayoutEffect$
|
|
7437
|
+
useIsomorphicLayoutEffect$2(() => {
|
|
7438
7438
|
activeRef.current = true;
|
|
7439
7439
|
});
|
|
7440
7440
|
return React$1.useCallback(async (to, options = {}) => {
|
|
@@ -29857,6 +29857,17 @@ var clearDocumentSelection = () => {
|
|
|
29857
29857
|
else if (sel.empty) sel.empty();
|
|
29858
29858
|
}
|
|
29859
29859
|
};
|
|
29860
|
+
/**
|
|
29861
|
+
* True if the element accepts text input (input/textarea/select/contentEditable).
|
|
29862
|
+
* Use to skip global keyboard handlers when focus is in a form field.
|
|
29863
|
+
*/
|
|
29864
|
+
function isEditableTarget(el) {
|
|
29865
|
+
if (!el) return false;
|
|
29866
|
+
const tag = el.tagName;
|
|
29867
|
+
if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return true;
|
|
29868
|
+
if (el.isContentEditable) return true;
|
|
29869
|
+
return false;
|
|
29870
|
+
}
|
|
29860
29871
|
//#endregion
|
|
29861
29872
|
//#region ../../packages/util/src/format.ts
|
|
29862
29873
|
/**
|
|
@@ -30455,7 +30466,7 @@ function throttle(func, wait, options = {}) {
|
|
|
30455
30466
|
* Creates a debounced version of a function that delays invoking the function
|
|
30456
30467
|
* until after `wait` milliseconds have passed since the last time it was invoked.
|
|
30457
30468
|
*/
|
|
30458
|
-
function debounce$
|
|
30469
|
+
function debounce$2(func, wait, options = {}) {
|
|
30459
30470
|
let timeout = null;
|
|
30460
30471
|
let args;
|
|
30461
30472
|
let result;
|
|
@@ -36291,7 +36302,7 @@ var fromEntries = function fromEntries(entries) {
|
|
|
36291
36302
|
/**
|
|
36292
36303
|
* Small wrapper around `useLayoutEffect` to get rid of the warning on SSR envs
|
|
36293
36304
|
*/
|
|
36294
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" && window.document && window.document.createElement ? React$1.useLayoutEffect : React$1.useEffect;
|
|
36305
|
+
var useIsomorphicLayoutEffect$1 = typeof window !== "undefined" && window.document && window.document.createElement ? React$1.useLayoutEffect : React$1.useEffect;
|
|
36295
36306
|
var bottom = "bottom";
|
|
36296
36307
|
var right$4 = "right";
|
|
36297
36308
|
var left$4 = "left";
|
|
@@ -37431,7 +37442,7 @@ function orderModifiers(modifiers) {
|
|
|
37431
37442
|
}
|
|
37432
37443
|
//#endregion
|
|
37433
37444
|
//#region ../../node_modules/.pnpm/@popperjs+core@2.11.8/node_modules/@popperjs/core/lib/utils/debounce.js
|
|
37434
|
-
function debounce(fn) {
|
|
37445
|
+
function debounce$1(fn) {
|
|
37435
37446
|
var pending;
|
|
37436
37447
|
return function() {
|
|
37437
37448
|
if (!pending) pending = new Promise(function(resolve) {
|
|
@@ -37535,7 +37546,7 @@ function popperGenerator(generatorOptions) {
|
|
|
37535
37546
|
}) || state;
|
|
37536
37547
|
}
|
|
37537
37548
|
},
|
|
37538
|
-
update: debounce(function() {
|
|
37549
|
+
update: debounce$1(function() {
|
|
37539
37550
|
return new Promise(function(resolve) {
|
|
37540
37551
|
instance.forceUpdate();
|
|
37541
37552
|
resolve(state);
|
|
@@ -37717,10 +37728,10 @@ var usePopper = function usePopper(referenceElement, popperElement, options) {
|
|
|
37717
37728
|
updateStateModifier
|
|
37718
37729
|
]);
|
|
37719
37730
|
var popperInstanceRef = React$1.useRef();
|
|
37720
|
-
useIsomorphicLayoutEffect(function() {
|
|
37731
|
+
useIsomorphicLayoutEffect$1(function() {
|
|
37721
37732
|
if (popperInstanceRef.current) popperInstanceRef.current.setOptions(popperOptions);
|
|
37722
37733
|
}, [popperOptions]);
|
|
37723
|
-
useIsomorphicLayoutEffect(function() {
|
|
37734
|
+
useIsomorphicLayoutEffect$1(function() {
|
|
37724
37735
|
if (referenceElement == null || popperElement == null) return;
|
|
37725
37736
|
var popperInstance = (options.createPopper || createPopper)(referenceElement, popperElement, popperOptions);
|
|
37726
37737
|
popperInstanceRef.current = popperInstance;
|
|
@@ -38550,7 +38561,7 @@ function useStatefulScrollPosition(elementRef, elementKey, delay = 1e3, scrollab
|
|
|
38550
38561
|
log$13.debug(`Storing scroll position`, elementKey, position);
|
|
38551
38562
|
setScrollPosition(position);
|
|
38552
38563
|
}, [elementKey, setScrollPosition]);
|
|
38553
|
-
const handleScroll = useMemo(() => debounce$
|
|
38564
|
+
const handleScroll = useMemo(() => debounce$2(handleScrollInner, delay), [handleScrollInner, delay]);
|
|
38554
38565
|
const restoreScrollPosition = useCallback(() => {
|
|
38555
38566
|
const element = elementRef.current;
|
|
38556
38567
|
const savedPosition = scrollPositionRef.current;
|
|
@@ -38622,7 +38633,7 @@ var useVirtuosoState = (virtuosoRef, elementKey, delay = 1e3) => {
|
|
|
38622
38633
|
setListPosition(state);
|
|
38623
38634
|
}, [elementKey, setListPosition]);
|
|
38624
38635
|
useEffect(() => {
|
|
38625
|
-
debouncedFnRef.current = debounce$
|
|
38636
|
+
debouncedFnRef.current = debounce$2((isScrolling) => {
|
|
38626
38637
|
log$12.debug("List scroll", isScrolling);
|
|
38627
38638
|
const element = virtuosoRef.current;
|
|
38628
38639
|
if (!element) return;
|
|
@@ -38833,52 +38844,46 @@ function useRevokableUrls() {
|
|
|
38833
38844
|
}
|
|
38834
38845
|
//#endregion
|
|
38835
38846
|
//#region ../../packages/react/src/hooks/useListKeyboardNavigation.ts
|
|
38836
|
-
|
|
38837
|
-
|
|
38838
|
-
|
|
38839
|
-
*
|
|
38840
|
-
* When the Virtuoso handle is available it delegates to `scrollToIndex`;
|
|
38841
|
-
* otherwise it falls back to `scrollTo` on the scroll container.
|
|
38842
|
-
*/
|
|
38847
|
+
function isVirtualListHandle(handle) {
|
|
38848
|
+
return "jumpToStart" in handle;
|
|
38849
|
+
}
|
|
38843
38850
|
function useListKeyboardNavigation({ listHandle, scrollRef, itemCount }) {
|
|
38844
38851
|
useEffect(() => {
|
|
38845
38852
|
const handleKeyDown = (event) => {
|
|
38846
|
-
|
|
38847
|
-
|
|
38848
|
-
|
|
38849
|
-
|
|
38850
|
-
|
|
38853
|
+
const hasModifier = event.metaKey || event.ctrlKey;
|
|
38854
|
+
const isUp = event.key === "ArrowUp" && hasModifier || event.key === "Home" && hasModifier;
|
|
38855
|
+
const isDown = event.key === "ArrowDown" && hasModifier || event.key === "End" && hasModifier;
|
|
38856
|
+
if (!isUp && !isDown) return;
|
|
38857
|
+
if (isEditableTarget(document.activeElement)) return;
|
|
38858
|
+
event.preventDefault();
|
|
38859
|
+
event.stopImmediatePropagation();
|
|
38860
|
+
const handle = listHandle.current;
|
|
38861
|
+
if (isUp) if (handle && isVirtualListHandle(handle)) handle.jumpToStart();
|
|
38862
|
+
else if (handle) handle.scrollToIndex({
|
|
38863
|
+
index: 0,
|
|
38864
|
+
align: "center"
|
|
38865
|
+
});
|
|
38866
|
+
else scrollRef?.current?.scrollTo({ top: 0 });
|
|
38867
|
+
else if (handle && isVirtualListHandle(handle)) handle.jumpToEnd();
|
|
38868
|
+
else if (handle) {
|
|
38869
|
+
handle.scrollToIndex({
|
|
38870
|
+
index: Math.max(itemCount - 5, 0),
|
|
38851
38871
|
align: "center"
|
|
38852
38872
|
});
|
|
38853
|
-
|
|
38854
|
-
|
|
38855
|
-
|
|
38856
|
-
|
|
38857
|
-
} else if (event.key === "ArrowDown") {
|
|
38858
|
-
event.preventDefault();
|
|
38859
|
-
if (listHandle.current) {
|
|
38860
|
-
listHandle.current.scrollToIndex({
|
|
38861
|
-
index: Math.max(itemCount - 5, 0),
|
|
38862
|
-
align: "center"
|
|
38863
|
-
});
|
|
38864
|
-
setTimeout(() => {
|
|
38865
|
-
listHandle.current?.scrollToIndex({
|
|
38866
|
-
index: Math.max(itemCount - 1, 0),
|
|
38867
|
-
align: "end"
|
|
38868
|
-
});
|
|
38869
|
-
}, 250);
|
|
38870
|
-
} else {
|
|
38871
|
-
const el = scrollRef?.current;
|
|
38872
|
-
if (el) el.scrollTo({
|
|
38873
|
-
top: el.scrollHeight,
|
|
38874
|
-
behavior: "instant"
|
|
38873
|
+
setTimeout(() => {
|
|
38874
|
+
listHandle.current?.scrollToIndex({
|
|
38875
|
+
index: Math.max(itemCount - 1, 0),
|
|
38876
|
+
align: "end"
|
|
38875
38877
|
});
|
|
38876
|
-
}
|
|
38878
|
+
}, 250);
|
|
38879
|
+
} else {
|
|
38880
|
+
const el = scrollRef?.current;
|
|
38881
|
+
if (el) el.scrollTop = el.scrollHeight;
|
|
38877
38882
|
}
|
|
38878
38883
|
};
|
|
38879
|
-
|
|
38884
|
+
window.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
38880
38885
|
return () => {
|
|
38881
|
-
|
|
38886
|
+
window.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
38882
38887
|
};
|
|
38883
38888
|
}, [
|
|
38884
38889
|
listHandle,
|
|
@@ -42373,7 +42378,7 @@ var LiveVirtualList = ({ id, listHandle, className, data, renderRow, scrollRef,
|
|
|
42373
42378
|
}, []);
|
|
42374
42379
|
const searchInText = useCallback((text, searchTerm) => {
|
|
42375
42380
|
const lowerText = text.toLowerCase();
|
|
42376
|
-
const prepared = prepareSearchTerm(searchTerm);
|
|
42381
|
+
const prepared = prepareSearchTerm$1(searchTerm);
|
|
42377
42382
|
if (lowerText.includes(prepared.simple)) return true;
|
|
42378
42383
|
if (prepared.unquoted && lowerText.includes(prepared.unquoted)) return true;
|
|
42379
42384
|
if (prepared.jsonEscaped && lowerText.includes(prepared.jsonEscaped)) return true;
|
|
@@ -42541,7 +42546,7 @@ var LiveVirtualList = ({ id, listHandle, className, data, renderRow, scrollRef,
|
|
|
42541
42546
|
width: "100%"
|
|
42542
42547
|
},
|
|
42543
42548
|
data,
|
|
42544
|
-
defaultItemHeight:
|
|
42549
|
+
defaultItemHeight: 450,
|
|
42545
42550
|
itemContent: renderRow,
|
|
42546
42551
|
increaseViewportBy: {
|
|
42547
42552
|
top: 1e3,
|
|
@@ -42566,7 +42571,7 @@ var LiveVirtualList = ({ id, listHandle, className, data, renderRow, scrollRef,
|
|
|
42566
42571
|
components: mergedComponents
|
|
42567
42572
|
});
|
|
42568
42573
|
};
|
|
42569
|
-
var prepareSearchTerm = (term) => {
|
|
42574
|
+
var prepareSearchTerm$1 = (term) => {
|
|
42570
42575
|
const lower = term.toLowerCase();
|
|
42571
42576
|
if (!term.includes("\"") && !term.includes(":")) return { simple: lower };
|
|
42572
42577
|
return {
|
|
@@ -50400,7 +50405,7 @@ var initializeStore = (api, capabilities, storage) => {
|
|
|
50400
50405
|
getItem: (name) => {
|
|
50401
50406
|
return storage ? storage.getItem(name) : null;
|
|
50402
50407
|
},
|
|
50403
|
-
setItem: debounce$
|
|
50408
|
+
setItem: debounce$2((name, value) => {
|
|
50404
50409
|
if (storage) {
|
|
50405
50410
|
const wrapper = value;
|
|
50406
50411
|
const filtered = {
|
|
@@ -55746,7 +55751,7 @@ var getFieldKey = (col) => {
|
|
|
55746
55751
|
* @returns A debounced function that resizes grid columns to fit
|
|
55747
55752
|
*/
|
|
55748
55753
|
var createGridColumnResizer = (gridRef, delayMs = 10) => {
|
|
55749
|
-
return debounce$
|
|
55754
|
+
return debounce$2(() => {
|
|
55750
55755
|
gridRef.current?.api?.sizeColumnsToFit();
|
|
55751
55756
|
}, delayMs);
|
|
55752
55757
|
};
|
|
@@ -104944,7 +104949,7 @@ var FindBand = () => {
|
|
|
104944
104949
|
input.setSelectionRange(len, len);
|
|
104945
104950
|
}
|
|
104946
104951
|
}, []);
|
|
104947
|
-
const debouncedSearch = useMemo(() => debounce$
|
|
104952
|
+
const debouncedSearch = useMemo(() => debounce$2(async () => {
|
|
104948
104953
|
if (!searchBoxRef.current) return;
|
|
104949
104954
|
await handleSearch(false);
|
|
104950
104955
|
needsCursorRestoreRef.current = true;
|
|
@@ -105346,6 +105351,17 @@ var resolveToolInput = (fn, toolArgs) => {
|
|
|
105346
105351
|
contentType: "markdown"
|
|
105347
105352
|
};
|
|
105348
105353
|
}
|
|
105354
|
+
if (fn === "spawn_agent" && typeof toolArgs.agent_type === "string") {
|
|
105355
|
+
const agentType = toolArgs.agent_type;
|
|
105356
|
+
return {
|
|
105357
|
+
name: fn,
|
|
105358
|
+
functionCall: `${fn}: ${agentType}`,
|
|
105359
|
+
title: `${fn}: ${agentType}`,
|
|
105360
|
+
input,
|
|
105361
|
+
description,
|
|
105362
|
+
contentType: "markdown"
|
|
105363
|
+
};
|
|
105364
|
+
}
|
|
105349
105365
|
if (fn === "agent_status" || fn === "agent_wait" || fn === "agent_cancel" || fn === "agent_list") return {
|
|
105350
105366
|
name: fn,
|
|
105351
105367
|
functionCall,
|
|
@@ -105353,6 +105369,13 @@ var resolveToolInput = (fn, toolArgs) => {
|
|
|
105353
105369
|
description,
|
|
105354
105370
|
contentType: "markdown"
|
|
105355
105371
|
};
|
|
105372
|
+
if (fn === "wait_agent" || fn === "close_agent" || fn === "resume_agent") return {
|
|
105373
|
+
name: fn,
|
|
105374
|
+
functionCall,
|
|
105375
|
+
input,
|
|
105376
|
+
description,
|
|
105377
|
+
contentType: "markdown"
|
|
105378
|
+
};
|
|
105356
105379
|
return {
|
|
105357
105380
|
name: fn,
|
|
105358
105381
|
functionCall,
|
|
@@ -105413,8 +105436,185 @@ var extractInputMetadata = (toolName) => {
|
|
|
105413
105436
|
descriptionArg: "task_description",
|
|
105414
105437
|
contentType: "markdown"
|
|
105415
105438
|
};
|
|
105439
|
+
else if (toolName === "exec_command") return {
|
|
105440
|
+
inputArg: "cmd",
|
|
105441
|
+
contentType: "bash"
|
|
105442
|
+
};
|
|
105443
|
+
else if (toolName === "spawn_agent") return {
|
|
105444
|
+
inputArg: "message",
|
|
105445
|
+
contentType: "markdown"
|
|
105446
|
+
};
|
|
105447
|
+
else if (toolName === "send_input") return {
|
|
105448
|
+
inputArg: "message",
|
|
105449
|
+
contentType: "markdown"
|
|
105450
|
+
};
|
|
105451
|
+
else if (toolName === "tool_search") return { contentType: "markdown" };
|
|
105416
105452
|
else return;
|
|
105417
105453
|
};
|
|
105454
|
+
var kCodexAgentResultTools = new Set([
|
|
105455
|
+
"wait_agent",
|
|
105456
|
+
"close_agent",
|
|
105457
|
+
"resume_agent"
|
|
105458
|
+
]);
|
|
105459
|
+
/**
|
|
105460
|
+
* Reshapes a Codex sub-agent tool *result* into markdown, or returns undefined
|
|
105461
|
+
* when no reshape applies (caller renders the raw output).
|
|
105462
|
+
*
|
|
105463
|
+
* `spawn_agent` returns `{"agent_id": …, "nickname": …}` — we surface a compact
|
|
105464
|
+
* line naming the spawned sub-agent. `wait_agent` / `close_agent` /
|
|
105465
|
+
* `resume_agent` return JSON-wrapped status whose `completed` fields hold the
|
|
105466
|
+
* sub-agent's markdown final answer — we surface those answers. Accepts a raw
|
|
105467
|
+
* string output or structured content (the viewer wraps tool results as
|
|
105468
|
+
* `Content[]`), extracting the underlying text either way. The raw output
|
|
105469
|
+
* remains in the JSON tab.
|
|
105470
|
+
*
|
|
105471
|
+
* (`tool_search` is handled separately by `parseToolSearchCatalog` +
|
|
105472
|
+
* `ToolSearchView`, which needs real collapsible `<details>` elements that the
|
|
105473
|
+
* HTML-escaping markdown pipeline can't produce from a string.)
|
|
105474
|
+
*/
|
|
105475
|
+
var codexToolMarkdown = (fn, output) => {
|
|
105476
|
+
const text = toolOutputText(output);
|
|
105477
|
+
if (text === void 0) return;
|
|
105478
|
+
if (fn === "spawn_agent") return formatSpawnAgentResult(text);
|
|
105479
|
+
if (kCodexAgentResultTools.has(fn)) return extractCodexAgentAnswers(text);
|
|
105480
|
+
};
|
|
105481
|
+
var formatSpawnAgentResult = (text) => {
|
|
105482
|
+
let data;
|
|
105483
|
+
try {
|
|
105484
|
+
data = JSON.parse(text);
|
|
105485
|
+
} catch {
|
|
105486
|
+
return;
|
|
105487
|
+
}
|
|
105488
|
+
if (!data || typeof data !== "object") return;
|
|
105489
|
+
const record = data;
|
|
105490
|
+
const nickname = typeof record.nickname === "string" ? record.nickname : void 0;
|
|
105491
|
+
const agentId = typeof record.agent_id === "string" ? record.agent_id : void 0;
|
|
105492
|
+
const parts = [];
|
|
105493
|
+
if (nickname) parts.push(nickname);
|
|
105494
|
+
if (agentId) parts.push(`\`${agentId}\``);
|
|
105495
|
+
return parts.length > 0 ? parts.join(" — ") : void 0;
|
|
105496
|
+
};
|
|
105497
|
+
var toolOutputText = (output) => {
|
|
105498
|
+
if (typeof output === "string") return output;
|
|
105499
|
+
if (Array.isArray(output)) {
|
|
105500
|
+
const parts = [];
|
|
105501
|
+
for (const item of output) collectContentText(item, parts);
|
|
105502
|
+
return parts.length > 0 ? parts.join("") : void 0;
|
|
105503
|
+
}
|
|
105504
|
+
};
|
|
105505
|
+
var collectContentText = (item, parts) => {
|
|
105506
|
+
if (!item || typeof item !== "object") return;
|
|
105507
|
+
const record = item;
|
|
105508
|
+
if (record.type === "text" && typeof record.text === "string") parts.push(record.text);
|
|
105509
|
+
else if (record.type === "tool" && Array.isArray(record.content)) for (const child of record.content) collectContentText(child, parts);
|
|
105510
|
+
};
|
|
105511
|
+
var formatSubagentNotifications = (content) => {
|
|
105512
|
+
const text = toolOutputText(content);
|
|
105513
|
+
if (text === void 0 || !text.includes("<subagent_notification>")) return;
|
|
105514
|
+
const lines = [];
|
|
105515
|
+
const regex = /<subagent_notification>([\s\S]*?)<\/subagent_notification>/g;
|
|
105516
|
+
let match;
|
|
105517
|
+
while ((match = regex.exec(text)) !== null) {
|
|
105518
|
+
const line = formatSubagentNotification(match[1]);
|
|
105519
|
+
if (line) lines.push(line);
|
|
105520
|
+
}
|
|
105521
|
+
return lines.length > 0 ? lines.join("\n\n") : void 0;
|
|
105522
|
+
};
|
|
105523
|
+
var formatSubagentNotification = (payload) => {
|
|
105524
|
+
let data;
|
|
105525
|
+
try {
|
|
105526
|
+
data = JSON.parse(payload.trim());
|
|
105527
|
+
} catch {
|
|
105528
|
+
return;
|
|
105529
|
+
}
|
|
105530
|
+
if (!data || typeof data !== "object") return;
|
|
105531
|
+
const record = data;
|
|
105532
|
+
const agentPath = typeof record.agent_path === "string" ? record.agent_path : void 0;
|
|
105533
|
+
const status = record.status && typeof record.status === "object" ? Object.keys(record.status)[0] : void 0;
|
|
105534
|
+
if (agentPath === void 0 && status === void 0) return;
|
|
105535
|
+
const statusWord = status ?? "notified";
|
|
105536
|
+
return agentPath ? `agent ${statusWord}: \`${agentPath}\`` : `agent ${statusWord}`;
|
|
105537
|
+
};
|
|
105538
|
+
var parseToolSearchCatalog = (output) => {
|
|
105539
|
+
const text = toolOutputText(output);
|
|
105540
|
+
if (text === void 0) return;
|
|
105541
|
+
let data;
|
|
105542
|
+
try {
|
|
105543
|
+
data = JSON.parse(text);
|
|
105544
|
+
} catch {
|
|
105545
|
+
return;
|
|
105546
|
+
}
|
|
105547
|
+
if (!Array.isArray(data)) return;
|
|
105548
|
+
const namespaces = [];
|
|
105549
|
+
const looseTools = [];
|
|
105550
|
+
for (const entry of data) {
|
|
105551
|
+
if (!entry || typeof entry !== "object") continue;
|
|
105552
|
+
const record = entry;
|
|
105553
|
+
const rawTools = Array.isArray(record.tools) ? record.tools : void 0;
|
|
105554
|
+
if (record.type === "function" || rawTools === void 0 && "parameters" in record) {
|
|
105555
|
+
const tool = parseToolEntry(record);
|
|
105556
|
+
if (tool) looseTools.push(tool);
|
|
105557
|
+
continue;
|
|
105558
|
+
}
|
|
105559
|
+
const name = typeof record.name === "string" ? record.name : void 0;
|
|
105560
|
+
const description = typeof record.description === "string" ? record.description : "";
|
|
105561
|
+
const toolList = rawTools ?? [];
|
|
105562
|
+
if (name === void 0 && toolList.length === 0) continue;
|
|
105563
|
+
const tools = [];
|
|
105564
|
+
for (const tool of toolList) {
|
|
105565
|
+
if (!tool || typeof tool !== "object") continue;
|
|
105566
|
+
const parsed = parseToolEntry(tool);
|
|
105567
|
+
if (parsed) tools.push(parsed);
|
|
105568
|
+
}
|
|
105569
|
+
namespaces.push({
|
|
105570
|
+
name,
|
|
105571
|
+
description,
|
|
105572
|
+
tools
|
|
105573
|
+
});
|
|
105574
|
+
}
|
|
105575
|
+
if (looseTools.length > 0) namespaces.push({
|
|
105576
|
+
name: void 0,
|
|
105577
|
+
description: "",
|
|
105578
|
+
tools: looseTools
|
|
105579
|
+
});
|
|
105580
|
+
return namespaces.length > 0 ? namespaces : void 0;
|
|
105581
|
+
};
|
|
105582
|
+
var parseToolEntry = (tool) => {
|
|
105583
|
+
const name = typeof tool.name === "string" ? tool.name : void 0;
|
|
105584
|
+
if (name === void 0) return;
|
|
105585
|
+
return {
|
|
105586
|
+
signature: `${name}(${toolParamNames(tool).join(", ")})`,
|
|
105587
|
+
description: typeof tool.description === "string" ? dedentDescription(tool.description) : ""
|
|
105588
|
+
};
|
|
105589
|
+
};
|
|
105590
|
+
var toolParamNames = (tool) => {
|
|
105591
|
+
const parameters = tool.parameters;
|
|
105592
|
+
if (parameters && typeof parameters === "object") {
|
|
105593
|
+
const properties = parameters.properties;
|
|
105594
|
+
if (properties && typeof properties === "object") return Object.keys(properties);
|
|
105595
|
+
}
|
|
105596
|
+
return [];
|
|
105597
|
+
};
|
|
105598
|
+
var dedentDescription = (description) => description.split("\n").map((line) => line.trim()).join("\n").trim();
|
|
105599
|
+
var extractCodexAgentAnswers = (output) => {
|
|
105600
|
+
if (typeof output !== "string") return;
|
|
105601
|
+
let data;
|
|
105602
|
+
try {
|
|
105603
|
+
data = JSON.parse(output);
|
|
105604
|
+
} catch {
|
|
105605
|
+
return;
|
|
105606
|
+
}
|
|
105607
|
+
const answers = [];
|
|
105608
|
+
const visit = (node) => {
|
|
105609
|
+
if (Array.isArray(node)) node.forEach(visit);
|
|
105610
|
+
else if (node && typeof node === "object") for (const [key, value] of Object.entries(node)) if ((key === "completed" || key === "failed" || key === "cancelled") && typeof value === "string") answers.push(cleanCodexAnswer(value));
|
|
105611
|
+
else visit(value);
|
|
105612
|
+
};
|
|
105613
|
+
visit(data);
|
|
105614
|
+
const nonEmpty = answers.filter((answer) => answer.length > 0);
|
|
105615
|
+
return nonEmpty.length > 0 ? nonEmpty.join("\n\n---\n\n") : void 0;
|
|
105616
|
+
};
|
|
105617
|
+
var cleanCodexAnswer = (text) => text.replace(/<content-internal>[\s\S]*?<\/content-internal>/g, "").trimEnd();
|
|
105418
105618
|
/**
|
|
105419
105619
|
* Substitutes `{{param_name}}` placeholders in tool call content
|
|
105420
105620
|
* with actual values from the tool call arguments.
|
|
@@ -106140,6 +106340,53 @@ var MessageContents = ({ message, references }) => {
|
|
|
106140
106340
|
references
|
|
106141
106341
|
}) });
|
|
106142
106342
|
};
|
|
106343
|
+
var ToolSearchView_module_default = {
|
|
106344
|
+
catalog: "_catalog_gx8eg_1",
|
|
106345
|
+
namespace: "_namespace_gx8eg_7",
|
|
106346
|
+
namespaceName: "_namespaceName_gx8eg_13",
|
|
106347
|
+
namespaceDescription: "_namespaceDescription_gx8eg_17",
|
|
106348
|
+
tool: "_tool_gx8eg_21",
|
|
106349
|
+
summary: "_summary_gx8eg_25",
|
|
106350
|
+
toolNoDetails: "_toolNoDetails_gx8eg_38",
|
|
106351
|
+
description: "_description_gx8eg_42"
|
|
106352
|
+
};
|
|
106353
|
+
//#endregion
|
|
106354
|
+
//#region ../../packages/inspect-components/src/chat/tools/ToolSearchView.tsx
|
|
106355
|
+
/**
|
|
106356
|
+
* Renders a Codex `tool_search` catalog: each namespace lists its tools, with
|
|
106357
|
+
* each tool a collapsible `<details>` — the signature in the summary, the
|
|
106358
|
+
* description (markdown) in the body. Compact by default; expand for detail.
|
|
106359
|
+
*/
|
|
106360
|
+
var ToolSearchView = ({ namespaces }) => {
|
|
106361
|
+
return /* @__PURE__ */ jsx("div", {
|
|
106362
|
+
className: ToolSearchView_module_default.catalog,
|
|
106363
|
+
children: namespaces.map((namespace, nsIdx) => /* @__PURE__ */ jsxs("div", {
|
|
106364
|
+
className: ToolSearchView_module_default.namespace,
|
|
106365
|
+
children: [namespace.name ? /* @__PURE__ */ jsxs("div", {
|
|
106366
|
+
className: ToolSearchView_module_default.namespaceHeader,
|
|
106367
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
106368
|
+
className: ToolSearchView_module_default.namespaceName,
|
|
106369
|
+
children: namespace.name
|
|
106370
|
+
}), namespace.description ? /* @__PURE__ */ jsxs("span", {
|
|
106371
|
+
className: ToolSearchView_module_default.namespaceDescription,
|
|
106372
|
+
children: [" — ", namespace.description]
|
|
106373
|
+
}) : null]
|
|
106374
|
+
}) : null, namespace.tools.map((tool, toolIdx) => tool.description ? /* @__PURE__ */ jsxs("details", {
|
|
106375
|
+
className: ToolSearchView_module_default.tool,
|
|
106376
|
+
children: [/* @__PURE__ */ jsx("summary", {
|
|
106377
|
+
className: ToolSearchView_module_default.summary,
|
|
106378
|
+
children: /* @__PURE__ */ jsx("code", { children: tool.signature })
|
|
106379
|
+
}), /* @__PURE__ */ jsx(MarkdownDiv, {
|
|
106380
|
+
className: ToolSearchView_module_default.description,
|
|
106381
|
+
markdown: tool.description
|
|
106382
|
+
})]
|
|
106383
|
+
}, `tool-${toolIdx}`) : /* @__PURE__ */ jsx("div", {
|
|
106384
|
+
className: ToolSearchView_module_default.toolNoDetails,
|
|
106385
|
+
children: /* @__PURE__ */ jsx("code", { children: tool.signature })
|
|
106386
|
+
}, `tool-${toolIdx}`))]
|
|
106387
|
+
}, `ns-${nsIdx}`))
|
|
106388
|
+
});
|
|
106389
|
+
};
|
|
106143
106390
|
//#endregion
|
|
106144
106391
|
//#region ../../packages/inspect-components/src/chat/tools/customToolRendering.tsx
|
|
106145
106392
|
/**
|
|
@@ -106148,6 +106395,10 @@ var MessageContents = ({ message, references }) => {
|
|
|
106148
106395
|
*/
|
|
106149
106396
|
var getDefaultCustomToolView = (props) => {
|
|
106150
106397
|
if (props.tool === "answer") return /* @__PURE__ */ jsx(AnswerToolCallView, { ...props });
|
|
106398
|
+
if (props.tool === "tool_search") {
|
|
106399
|
+
const namespaces = parseToolSearchCatalog(props.output);
|
|
106400
|
+
if (namespaces) return /* @__PURE__ */ jsx(ToolSearchView, { namespaces });
|
|
106401
|
+
}
|
|
106151
106402
|
};
|
|
106152
106403
|
var AnswerToolCallView = (props) => {
|
|
106153
106404
|
return /* @__PURE__ */ jsx(SourceCodePanel, {
|
|
@@ -106270,7 +106521,10 @@ var ToolCallView = ({ id, tool, functionCall, input, description, contentType, v
|
|
|
106270
106521
|
return false;
|
|
106271
106522
|
}
|
|
106272
106523
|
const collapse = Array.isArray(output) ? output.every((item) => !isContentImage(item)) : !isContentImage(output);
|
|
106273
|
-
const normalizedContent = useMemo(() =>
|
|
106524
|
+
const normalizedContent = useMemo(() => {
|
|
106525
|
+
const markdown = codexToolMarkdown(tool, output);
|
|
106526
|
+
return normalizeContent(markdown !== void 0 ? markdown : output);
|
|
106527
|
+
}, [tool, output]);
|
|
106274
106528
|
const hasContent = normalizedContent.find((c) => {
|
|
106275
106529
|
if (c.type === "tool") {
|
|
106276
106530
|
for (const t of c.content) if (t.type === "text") {
|
|
@@ -106402,6 +106656,11 @@ var ChatMessage = memo(function ChatMessage({ id, message, display, linking, ref
|
|
|
106402
106656
|
const isNonSubagentTool = message.role === "tool" && message.function !== "Task" && message.function !== "task" && message.function !== "Agent" && message.function !== "agent";
|
|
106403
106657
|
const collapse = message.role === "system" || message.role === "user" || message.role === "assistant" || message.role === "tool";
|
|
106404
106658
|
const hideRole = unlabeledRoles?.includes(message.role) ?? false;
|
|
106659
|
+
let toolSearchNamespaces;
|
|
106660
|
+
let toolMarkdown;
|
|
106661
|
+
if (isNonSubagentTool && message.role === "tool" && message.function) if (message.function === "tool_search") toolSearchNamespaces = parseToolSearchCatalog(message.content);
|
|
106662
|
+
else toolMarkdown = codexToolMarkdown(message.function, message.content);
|
|
106663
|
+
const subagentNotifications = message.role === "user" ? formatSubagentNotifications(message.content) : void 0;
|
|
106405
106664
|
if (hideRole) {
|
|
106406
106665
|
const content = message.content;
|
|
106407
106666
|
const hasVisibleContent = typeof content === "string" ? content.trim().length > 0 : Array.isArray(content) && content.some((c) => c.type !== "tool_use");
|
|
@@ -106434,7 +106693,7 @@ var ChatMessage = memo(function ChatMessage({ id, message, display, linking, ref
|
|
|
106434
106693
|
id: `${id}-message`,
|
|
106435
106694
|
collapse,
|
|
106436
106695
|
lines: message.role === "tool" ? 30 : message.role === "assistant" ? 25 : collapse ? 15 : 25,
|
|
106437
|
-
children: isNonSubagentTool ? /* @__PURE__ */ jsx(ToolOutput, { output: typeof message.content === "string" ? message.content : message.content.filter((c) => c.type === "text" || c.type === "image") }) : /* @__PURE__ */ jsx(MessageContents, {
|
|
106696
|
+
children: isNonSubagentTool ? toolSearchNamespaces ? /* @__PURE__ */ jsx(ToolSearchView, { namespaces: toolSearchNamespaces }) : toolMarkdown !== void 0 ? /* @__PURE__ */ jsx(MarkdownDiv, { markdown: toolMarkdown }) : /* @__PURE__ */ jsx(ToolOutput, { output: typeof message.content === "string" ? message.content : message.content.filter((c) => c.type === "text" || c.type === "image") }) : subagentNotifications !== void 0 ? /* @__PURE__ */ jsx(MarkdownDiv, { markdown: subagentNotifications }) : /* @__PURE__ */ jsx(MessageContents, {
|
|
106438
106697
|
message,
|
|
106439
106698
|
references
|
|
106440
106699
|
}, `${id}-contents`)
|
|
@@ -106642,21 +106901,1344 @@ var ChatView = ({ id, messages, className, display, labels, linking, tools, refe
|
|
|
106642
106901
|
})
|
|
106643
106902
|
});
|
|
106644
106903
|
};
|
|
106645
|
-
|
|
106904
|
+
//#endregion
|
|
106905
|
+
//#region ../../node_modules/.pnpm/@tanstack+virtual-core@3.14.0/node_modules/@tanstack/virtual-core/dist/esm/utils.js
|
|
106906
|
+
function memo$1(getDeps, fn, opts) {
|
|
106907
|
+
let deps = opts.initialDeps ?? [];
|
|
106908
|
+
let result;
|
|
106909
|
+
let isInitial = true;
|
|
106910
|
+
function memoizedFunction() {
|
|
106911
|
+
var _a, _b, _c;
|
|
106912
|
+
let depTime;
|
|
106913
|
+
if (opts.key && ((_a = opts.debug) == null ? void 0 : _a.call(opts))) depTime = Date.now();
|
|
106914
|
+
const newDeps = getDeps();
|
|
106915
|
+
if (!(newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep))) return result;
|
|
106916
|
+
deps = newDeps;
|
|
106917
|
+
let resultTime;
|
|
106918
|
+
if (opts.key && ((_b = opts.debug) == null ? void 0 : _b.call(opts))) resultTime = Date.now();
|
|
106919
|
+
result = fn(...newDeps);
|
|
106920
|
+
if (opts.key && ((_c = opts.debug) == null ? void 0 : _c.call(opts))) {
|
|
106921
|
+
const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
|
|
106922
|
+
const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
|
|
106923
|
+
const resultFpsPercentage = resultEndTime / 16;
|
|
106924
|
+
const pad = (str, num) => {
|
|
106925
|
+
str = String(str);
|
|
106926
|
+
while (str.length < num) str = " " + str;
|
|
106927
|
+
return str;
|
|
106928
|
+
};
|
|
106929
|
+
console.info(`%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`, `
|
|
106930
|
+
font-size: .6rem;
|
|
106931
|
+
font-weight: bold;
|
|
106932
|
+
color: hsl(${Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120))}deg 100% 31%);`, opts == null ? void 0 : opts.key);
|
|
106933
|
+
}
|
|
106934
|
+
if ((opts == null ? void 0 : opts.onChange) && !(isInitial && opts.skipInitialOnChange)) opts.onChange(result);
|
|
106935
|
+
isInitial = false;
|
|
106936
|
+
return result;
|
|
106937
|
+
}
|
|
106938
|
+
memoizedFunction.updateDeps = (newDeps) => {
|
|
106939
|
+
deps = newDeps;
|
|
106940
|
+
};
|
|
106941
|
+
return memoizedFunction;
|
|
106942
|
+
}
|
|
106943
|
+
function notUndefined(value, msg) {
|
|
106944
|
+
if (value === void 0) throw new Error(`Unexpected undefined${msg ? `: ${msg}` : ""}`);
|
|
106945
|
+
else return value;
|
|
106946
|
+
}
|
|
106947
|
+
var approxEqual = (a, b) => Math.abs(a - b) < 1.01;
|
|
106948
|
+
var debounce = (targetWindow, fn, ms) => {
|
|
106949
|
+
let timeoutId;
|
|
106950
|
+
return function(...args) {
|
|
106951
|
+
targetWindow.clearTimeout(timeoutId);
|
|
106952
|
+
timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms);
|
|
106953
|
+
};
|
|
106954
|
+
};
|
|
106955
|
+
//#endregion
|
|
106956
|
+
//#region ../../node_modules/.pnpm/@tanstack+virtual-core@3.14.0/node_modules/@tanstack/virtual-core/dist/esm/index.js
|
|
106957
|
+
var getRect = (element) => {
|
|
106958
|
+
const { offsetWidth, offsetHeight } = element;
|
|
106959
|
+
return {
|
|
106960
|
+
width: offsetWidth,
|
|
106961
|
+
height: offsetHeight
|
|
106962
|
+
};
|
|
106963
|
+
};
|
|
106964
|
+
var defaultKeyExtractor = (index) => index;
|
|
106965
|
+
var defaultRangeExtractor = (range) => {
|
|
106966
|
+
const start = Math.max(range.startIndex - range.overscan, 0);
|
|
106967
|
+
const end = Math.min(range.endIndex + range.overscan, range.count - 1);
|
|
106968
|
+
const arr = [];
|
|
106969
|
+
for (let i = start; i <= end; i++) arr.push(i);
|
|
106970
|
+
return arr;
|
|
106971
|
+
};
|
|
106972
|
+
var observeElementRect = (instance, cb) => {
|
|
106973
|
+
const element = instance.scrollElement;
|
|
106974
|
+
if (!element) return;
|
|
106975
|
+
const targetWindow = instance.targetWindow;
|
|
106976
|
+
if (!targetWindow) return;
|
|
106977
|
+
const handler = (rect) => {
|
|
106978
|
+
const { width, height } = rect;
|
|
106979
|
+
cb({
|
|
106980
|
+
width: Math.round(width),
|
|
106981
|
+
height: Math.round(height)
|
|
106982
|
+
});
|
|
106983
|
+
};
|
|
106984
|
+
handler(getRect(element));
|
|
106985
|
+
if (!targetWindow.ResizeObserver) return () => {};
|
|
106986
|
+
const observer = new targetWindow.ResizeObserver((entries) => {
|
|
106987
|
+
const run = () => {
|
|
106988
|
+
const entry = entries[0];
|
|
106989
|
+
if (entry == null ? void 0 : entry.borderBoxSize) {
|
|
106990
|
+
const box = entry.borderBoxSize[0];
|
|
106991
|
+
if (box) {
|
|
106992
|
+
handler({
|
|
106993
|
+
width: box.inlineSize,
|
|
106994
|
+
height: box.blockSize
|
|
106995
|
+
});
|
|
106996
|
+
return;
|
|
106997
|
+
}
|
|
106998
|
+
}
|
|
106999
|
+
handler(getRect(element));
|
|
107000
|
+
};
|
|
107001
|
+
instance.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
|
|
107002
|
+
});
|
|
107003
|
+
observer.observe(element, { box: "border-box" });
|
|
107004
|
+
return () => {
|
|
107005
|
+
observer.unobserve(element);
|
|
107006
|
+
};
|
|
107007
|
+
};
|
|
107008
|
+
var addEventListenerOptions = { passive: true };
|
|
107009
|
+
var supportsScrollend = typeof window == "undefined" ? true : "onscrollend" in window;
|
|
107010
|
+
var observeElementOffset = (instance, cb) => {
|
|
107011
|
+
const element = instance.scrollElement;
|
|
107012
|
+
if (!element) return;
|
|
107013
|
+
const targetWindow = instance.targetWindow;
|
|
107014
|
+
if (!targetWindow) return;
|
|
107015
|
+
let offset = 0;
|
|
107016
|
+
const fallback = instance.options.useScrollendEvent && supportsScrollend ? () => void 0 : debounce(targetWindow, () => {
|
|
107017
|
+
cb(offset, false);
|
|
107018
|
+
}, instance.options.isScrollingResetDelay);
|
|
107019
|
+
const createHandler = (isScrolling) => () => {
|
|
107020
|
+
const { horizontal, isRtl } = instance.options;
|
|
107021
|
+
offset = horizontal ? element["scrollLeft"] * (isRtl && -1 || 1) : element["scrollTop"];
|
|
107022
|
+
fallback();
|
|
107023
|
+
cb(offset, isScrolling);
|
|
107024
|
+
};
|
|
107025
|
+
const handler = createHandler(true);
|
|
107026
|
+
const endHandler = createHandler(false);
|
|
107027
|
+
element.addEventListener("scroll", handler, addEventListenerOptions);
|
|
107028
|
+
const registerScrollendEvent = instance.options.useScrollendEvent && supportsScrollend;
|
|
107029
|
+
if (registerScrollendEvent) element.addEventListener("scrollend", endHandler, addEventListenerOptions);
|
|
107030
|
+
return () => {
|
|
107031
|
+
element.removeEventListener("scroll", handler);
|
|
107032
|
+
if (registerScrollendEvent) element.removeEventListener("scrollend", endHandler);
|
|
107033
|
+
};
|
|
107034
|
+
};
|
|
107035
|
+
var measureElement = (element, entry, instance) => {
|
|
107036
|
+
if (entry == null ? void 0 : entry.borderBoxSize) {
|
|
107037
|
+
const box = entry.borderBoxSize[0];
|
|
107038
|
+
if (box) return Math.round(box[instance.options.horizontal ? "inlineSize" : "blockSize"]);
|
|
107039
|
+
}
|
|
107040
|
+
return element[instance.options.horizontal ? "offsetWidth" : "offsetHeight"];
|
|
107041
|
+
};
|
|
107042
|
+
var elementScroll = (offset, { adjustments = 0, behavior }, instance) => {
|
|
107043
|
+
var _a, _b;
|
|
107044
|
+
const toOffset = offset + adjustments;
|
|
107045
|
+
(_b = (_a = instance.scrollElement) == null ? void 0 : _a.scrollTo) == null || _b.call(_a, {
|
|
107046
|
+
[instance.options.horizontal ? "left" : "top"]: toOffset,
|
|
107047
|
+
behavior
|
|
107048
|
+
});
|
|
107049
|
+
};
|
|
107050
|
+
var Virtualizer = class {
|
|
107051
|
+
constructor(opts) {
|
|
107052
|
+
this.unsubs = [];
|
|
107053
|
+
this.scrollElement = null;
|
|
107054
|
+
this.targetWindow = null;
|
|
107055
|
+
this.isScrolling = false;
|
|
107056
|
+
this.scrollState = null;
|
|
107057
|
+
this.measurementsCache = [];
|
|
107058
|
+
this.itemSizeCache = /* @__PURE__ */ new Map();
|
|
107059
|
+
this.laneAssignments = /* @__PURE__ */ new Map();
|
|
107060
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
107061
|
+
this.prevLanes = void 0;
|
|
107062
|
+
this.lanesChangedFlag = false;
|
|
107063
|
+
this.lanesSettling = false;
|
|
107064
|
+
this.scrollRect = null;
|
|
107065
|
+
this.scrollOffset = null;
|
|
107066
|
+
this.scrollDirection = null;
|
|
107067
|
+
this.scrollAdjustments = 0;
|
|
107068
|
+
this.elementsCache = /* @__PURE__ */ new Map();
|
|
107069
|
+
this.now = () => {
|
|
107070
|
+
var _a, _b, _c;
|
|
107071
|
+
return ((_c = (_b = (_a = this.targetWindow) == null ? void 0 : _a.performance) == null ? void 0 : _b.now) == null ? void 0 : _c.call(_b)) ?? Date.now();
|
|
107072
|
+
};
|
|
107073
|
+
this.observer = /* @__PURE__ */ (() => {
|
|
107074
|
+
let _ro = null;
|
|
107075
|
+
const get = () => {
|
|
107076
|
+
if (_ro) return _ro;
|
|
107077
|
+
if (!this.targetWindow || !this.targetWindow.ResizeObserver) return null;
|
|
107078
|
+
return _ro = new this.targetWindow.ResizeObserver((entries) => {
|
|
107079
|
+
entries.forEach((entry) => {
|
|
107080
|
+
const run = () => {
|
|
107081
|
+
const node = entry.target;
|
|
107082
|
+
const index = this.indexFromElement(node);
|
|
107083
|
+
if (!node.isConnected) {
|
|
107084
|
+
this.observer.unobserve(node);
|
|
107085
|
+
return;
|
|
107086
|
+
}
|
|
107087
|
+
if (this.shouldMeasureDuringScroll(index)) this.resizeItem(index, this.options.measureElement(node, entry, this));
|
|
107088
|
+
};
|
|
107089
|
+
this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
|
|
107090
|
+
});
|
|
107091
|
+
});
|
|
107092
|
+
};
|
|
107093
|
+
return {
|
|
107094
|
+
disconnect: () => {
|
|
107095
|
+
var _a;
|
|
107096
|
+
(_a = get()) == null || _a.disconnect();
|
|
107097
|
+
_ro = null;
|
|
107098
|
+
},
|
|
107099
|
+
observe: (target) => {
|
|
107100
|
+
var _a;
|
|
107101
|
+
return (_a = get()) == null ? void 0 : _a.observe(target, { box: "border-box" });
|
|
107102
|
+
},
|
|
107103
|
+
unobserve: (target) => {
|
|
107104
|
+
var _a;
|
|
107105
|
+
return (_a = get()) == null ? void 0 : _a.unobserve(target);
|
|
107106
|
+
}
|
|
107107
|
+
};
|
|
107108
|
+
})();
|
|
107109
|
+
this.range = null;
|
|
107110
|
+
this.setOptions = (opts2) => {
|
|
107111
|
+
Object.entries(opts2).forEach(([key, value]) => {
|
|
107112
|
+
if (typeof value === "undefined") delete opts2[key];
|
|
107113
|
+
});
|
|
107114
|
+
this.options = {
|
|
107115
|
+
debug: false,
|
|
107116
|
+
initialOffset: 0,
|
|
107117
|
+
overscan: 1,
|
|
107118
|
+
paddingStart: 0,
|
|
107119
|
+
paddingEnd: 0,
|
|
107120
|
+
scrollPaddingStart: 0,
|
|
107121
|
+
scrollPaddingEnd: 0,
|
|
107122
|
+
horizontal: false,
|
|
107123
|
+
getItemKey: defaultKeyExtractor,
|
|
107124
|
+
rangeExtractor: defaultRangeExtractor,
|
|
107125
|
+
onChange: () => {},
|
|
107126
|
+
measureElement,
|
|
107127
|
+
initialRect: {
|
|
107128
|
+
width: 0,
|
|
107129
|
+
height: 0
|
|
107130
|
+
},
|
|
107131
|
+
scrollMargin: 0,
|
|
107132
|
+
gap: 0,
|
|
107133
|
+
indexAttribute: "data-index",
|
|
107134
|
+
initialMeasurementsCache: [],
|
|
107135
|
+
lanes: 1,
|
|
107136
|
+
isScrollingResetDelay: 150,
|
|
107137
|
+
enabled: true,
|
|
107138
|
+
isRtl: false,
|
|
107139
|
+
useScrollendEvent: false,
|
|
107140
|
+
useAnimationFrameWithResizeObserver: false,
|
|
107141
|
+
laneAssignmentMode: "estimate",
|
|
107142
|
+
...opts2
|
|
107143
|
+
};
|
|
107144
|
+
};
|
|
107145
|
+
this.notify = (sync) => {
|
|
107146
|
+
var _a, _b;
|
|
107147
|
+
(_b = (_a = this.options).onChange) == null || _b.call(_a, this, sync);
|
|
107148
|
+
};
|
|
107149
|
+
this.maybeNotify = memo$1(() => {
|
|
107150
|
+
this.calculateRange();
|
|
107151
|
+
return [
|
|
107152
|
+
this.isScrolling,
|
|
107153
|
+
this.range ? this.range.startIndex : null,
|
|
107154
|
+
this.range ? this.range.endIndex : null
|
|
107155
|
+
];
|
|
107156
|
+
}, (isScrolling) => {
|
|
107157
|
+
this.notify(isScrolling);
|
|
107158
|
+
}, {
|
|
107159
|
+
key: process.env.NODE_ENV !== "production" && "maybeNotify",
|
|
107160
|
+
debug: () => this.options.debug,
|
|
107161
|
+
initialDeps: [
|
|
107162
|
+
this.isScrolling,
|
|
107163
|
+
this.range ? this.range.startIndex : null,
|
|
107164
|
+
this.range ? this.range.endIndex : null
|
|
107165
|
+
]
|
|
107166
|
+
});
|
|
107167
|
+
this.cleanup = () => {
|
|
107168
|
+
this.unsubs.filter(Boolean).forEach((d) => d());
|
|
107169
|
+
this.unsubs = [];
|
|
107170
|
+
this.observer.disconnect();
|
|
107171
|
+
if (this.rafId != null && this.targetWindow) {
|
|
107172
|
+
this.targetWindow.cancelAnimationFrame(this.rafId);
|
|
107173
|
+
this.rafId = null;
|
|
107174
|
+
}
|
|
107175
|
+
this.scrollState = null;
|
|
107176
|
+
this.scrollElement = null;
|
|
107177
|
+
this.targetWindow = null;
|
|
107178
|
+
};
|
|
107179
|
+
this._didMount = () => {
|
|
107180
|
+
return () => {
|
|
107181
|
+
this.cleanup();
|
|
107182
|
+
};
|
|
107183
|
+
};
|
|
107184
|
+
this._willUpdate = () => {
|
|
107185
|
+
var _a;
|
|
107186
|
+
const scrollElement = this.options.enabled ? this.options.getScrollElement() : null;
|
|
107187
|
+
if (this.scrollElement !== scrollElement) {
|
|
107188
|
+
this.cleanup();
|
|
107189
|
+
if (!scrollElement) {
|
|
107190
|
+
this.maybeNotify();
|
|
107191
|
+
return;
|
|
107192
|
+
}
|
|
107193
|
+
this.scrollElement = scrollElement;
|
|
107194
|
+
if (this.scrollElement && "ownerDocument" in this.scrollElement) this.targetWindow = this.scrollElement.ownerDocument.defaultView;
|
|
107195
|
+
else this.targetWindow = ((_a = this.scrollElement) == null ? void 0 : _a.window) ?? null;
|
|
107196
|
+
this.elementsCache.forEach((cached) => {
|
|
107197
|
+
this.observer.observe(cached);
|
|
107198
|
+
});
|
|
107199
|
+
this.unsubs.push(this.options.observeElementRect(this, (rect) => {
|
|
107200
|
+
this.scrollRect = rect;
|
|
107201
|
+
this.maybeNotify();
|
|
107202
|
+
}));
|
|
107203
|
+
this.unsubs.push(this.options.observeElementOffset(this, (offset, isScrolling) => {
|
|
107204
|
+
this.scrollAdjustments = 0;
|
|
107205
|
+
this.scrollDirection = isScrolling ? this.getScrollOffset() < offset ? "forward" : "backward" : null;
|
|
107206
|
+
this.scrollOffset = offset;
|
|
107207
|
+
this.isScrolling = isScrolling;
|
|
107208
|
+
if (this.scrollState) this.scheduleScrollReconcile();
|
|
107209
|
+
this.maybeNotify();
|
|
107210
|
+
}));
|
|
107211
|
+
this._scrollToOffset(this.getScrollOffset(), {
|
|
107212
|
+
adjustments: void 0,
|
|
107213
|
+
behavior: void 0
|
|
107214
|
+
});
|
|
107215
|
+
}
|
|
107216
|
+
};
|
|
107217
|
+
this.rafId = null;
|
|
107218
|
+
this.getSize = () => {
|
|
107219
|
+
if (!this.options.enabled) {
|
|
107220
|
+
this.scrollRect = null;
|
|
107221
|
+
return 0;
|
|
107222
|
+
}
|
|
107223
|
+
this.scrollRect = this.scrollRect ?? this.options.initialRect;
|
|
107224
|
+
return this.scrollRect[this.options.horizontal ? "width" : "height"];
|
|
107225
|
+
};
|
|
107226
|
+
this.getScrollOffset = () => {
|
|
107227
|
+
if (!this.options.enabled) {
|
|
107228
|
+
this.scrollOffset = null;
|
|
107229
|
+
return 0;
|
|
107230
|
+
}
|
|
107231
|
+
this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset);
|
|
107232
|
+
return this.scrollOffset;
|
|
107233
|
+
};
|
|
107234
|
+
this.getFurthestMeasurement = (measurements, index) => {
|
|
107235
|
+
const furthestMeasurementsFound = /* @__PURE__ */ new Map();
|
|
107236
|
+
const furthestMeasurements = /* @__PURE__ */ new Map();
|
|
107237
|
+
for (let m = index - 1; m >= 0; m--) {
|
|
107238
|
+
const measurement = measurements[m];
|
|
107239
|
+
if (furthestMeasurementsFound.has(measurement.lane)) continue;
|
|
107240
|
+
const previousFurthestMeasurement = furthestMeasurements.get(measurement.lane);
|
|
107241
|
+
if (previousFurthestMeasurement == null || measurement.end > previousFurthestMeasurement.end) furthestMeasurements.set(measurement.lane, measurement);
|
|
107242
|
+
else if (measurement.end < previousFurthestMeasurement.end) furthestMeasurementsFound.set(measurement.lane, true);
|
|
107243
|
+
if (furthestMeasurementsFound.size === this.options.lanes) break;
|
|
107244
|
+
}
|
|
107245
|
+
return furthestMeasurements.size === this.options.lanes ? Array.from(furthestMeasurements.values()).sort((a, b) => {
|
|
107246
|
+
if (a.end === b.end) return a.index - b.index;
|
|
107247
|
+
return a.end - b.end;
|
|
107248
|
+
})[0] : void 0;
|
|
107249
|
+
};
|
|
107250
|
+
this.getMeasurementOptions = memo$1(() => [
|
|
107251
|
+
this.options.count,
|
|
107252
|
+
this.options.paddingStart,
|
|
107253
|
+
this.options.scrollMargin,
|
|
107254
|
+
this.options.getItemKey,
|
|
107255
|
+
this.options.enabled,
|
|
107256
|
+
this.options.lanes,
|
|
107257
|
+
this.options.laneAssignmentMode
|
|
107258
|
+
], (count, paddingStart, scrollMargin, getItemKey, enabled, lanes, laneAssignmentMode) => {
|
|
107259
|
+
if (this.prevLanes !== void 0 && this.prevLanes !== lanes) this.lanesChangedFlag = true;
|
|
107260
|
+
this.prevLanes = lanes;
|
|
107261
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
107262
|
+
return {
|
|
107263
|
+
count,
|
|
107264
|
+
paddingStart,
|
|
107265
|
+
scrollMargin,
|
|
107266
|
+
getItemKey,
|
|
107267
|
+
enabled,
|
|
107268
|
+
lanes,
|
|
107269
|
+
laneAssignmentMode
|
|
107270
|
+
};
|
|
107271
|
+
}, { key: false });
|
|
107272
|
+
this.getMeasurements = memo$1(() => [this.getMeasurementOptions(), this.itemSizeCache], ({ count, paddingStart, scrollMargin, getItemKey, enabled, lanes, laneAssignmentMode }, itemSizeCache) => {
|
|
107273
|
+
if (!enabled) {
|
|
107274
|
+
this.measurementsCache = [];
|
|
107275
|
+
this.itemSizeCache.clear();
|
|
107276
|
+
this.laneAssignments.clear();
|
|
107277
|
+
return [];
|
|
107278
|
+
}
|
|
107279
|
+
if (this.laneAssignments.size > count) {
|
|
107280
|
+
for (const index of this.laneAssignments.keys()) if (index >= count) this.laneAssignments.delete(index);
|
|
107281
|
+
}
|
|
107282
|
+
if (this.lanesChangedFlag) {
|
|
107283
|
+
this.lanesChangedFlag = false;
|
|
107284
|
+
this.lanesSettling = true;
|
|
107285
|
+
this.measurementsCache = [];
|
|
107286
|
+
this.itemSizeCache.clear();
|
|
107287
|
+
this.laneAssignments.clear();
|
|
107288
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
107289
|
+
}
|
|
107290
|
+
if (this.measurementsCache.length === 0 && !this.lanesSettling) {
|
|
107291
|
+
this.measurementsCache = this.options.initialMeasurementsCache;
|
|
107292
|
+
this.measurementsCache.forEach((item) => {
|
|
107293
|
+
this.itemSizeCache.set(item.key, item.size);
|
|
107294
|
+
});
|
|
107295
|
+
}
|
|
107296
|
+
const min = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
107297
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
107298
|
+
if (this.lanesSettling && this.measurementsCache.length === count) this.lanesSettling = false;
|
|
107299
|
+
const measurements = this.measurementsCache.slice(0, min);
|
|
107300
|
+
const laneLastIndex = new Array(lanes).fill(void 0);
|
|
107301
|
+
for (let m = 0; m < min; m++) {
|
|
107302
|
+
const item = measurements[m];
|
|
107303
|
+
if (item) laneLastIndex[item.lane] = m;
|
|
107304
|
+
}
|
|
107305
|
+
for (let i = min; i < count; i++) {
|
|
107306
|
+
const key = getItemKey(i);
|
|
107307
|
+
const cachedLane = this.laneAssignments.get(i);
|
|
107308
|
+
let lane;
|
|
107309
|
+
let start;
|
|
107310
|
+
const shouldCacheLane = laneAssignmentMode === "estimate" || itemSizeCache.has(key);
|
|
107311
|
+
if (cachedLane !== void 0 && this.options.lanes > 1) {
|
|
107312
|
+
lane = cachedLane;
|
|
107313
|
+
const prevIndex = laneLastIndex[lane];
|
|
107314
|
+
const prevInLane = prevIndex !== void 0 ? measurements[prevIndex] : void 0;
|
|
107315
|
+
start = prevInLane ? prevInLane.end + this.options.gap : paddingStart + scrollMargin;
|
|
107316
|
+
} else {
|
|
107317
|
+
const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i);
|
|
107318
|
+
start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
|
|
107319
|
+
lane = furthestMeasurement ? furthestMeasurement.lane : i % this.options.lanes;
|
|
107320
|
+
if (this.options.lanes > 1 && shouldCacheLane) this.laneAssignments.set(i, lane);
|
|
107321
|
+
}
|
|
107322
|
+
const measuredSize = itemSizeCache.get(key);
|
|
107323
|
+
const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
|
|
107324
|
+
const end = start + size;
|
|
107325
|
+
measurements[i] = {
|
|
107326
|
+
index: i,
|
|
107327
|
+
start,
|
|
107328
|
+
size,
|
|
107329
|
+
end,
|
|
107330
|
+
key,
|
|
107331
|
+
lane
|
|
107332
|
+
};
|
|
107333
|
+
laneLastIndex[lane] = i;
|
|
107334
|
+
}
|
|
107335
|
+
this.measurementsCache = measurements;
|
|
107336
|
+
return measurements;
|
|
107337
|
+
}, {
|
|
107338
|
+
key: process.env.NODE_ENV !== "production" && "getMeasurements",
|
|
107339
|
+
debug: () => this.options.debug
|
|
107340
|
+
});
|
|
107341
|
+
this.calculateRange = memo$1(() => [
|
|
107342
|
+
this.getMeasurements(),
|
|
107343
|
+
this.getSize(),
|
|
107344
|
+
this.getScrollOffset(),
|
|
107345
|
+
this.options.lanes
|
|
107346
|
+
], (measurements, outerSize, scrollOffset, lanes) => {
|
|
107347
|
+
return this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
|
|
107348
|
+
measurements,
|
|
107349
|
+
outerSize,
|
|
107350
|
+
scrollOffset,
|
|
107351
|
+
lanes
|
|
107352
|
+
}) : null;
|
|
107353
|
+
}, {
|
|
107354
|
+
key: process.env.NODE_ENV !== "production" && "calculateRange",
|
|
107355
|
+
debug: () => this.options.debug
|
|
107356
|
+
});
|
|
107357
|
+
this.getVirtualIndexes = memo$1(() => {
|
|
107358
|
+
let startIndex = null;
|
|
107359
|
+
let endIndex = null;
|
|
107360
|
+
const range = this.calculateRange();
|
|
107361
|
+
if (range) {
|
|
107362
|
+
startIndex = range.startIndex;
|
|
107363
|
+
endIndex = range.endIndex;
|
|
107364
|
+
}
|
|
107365
|
+
this.maybeNotify.updateDeps([
|
|
107366
|
+
this.isScrolling,
|
|
107367
|
+
startIndex,
|
|
107368
|
+
endIndex
|
|
107369
|
+
]);
|
|
107370
|
+
return [
|
|
107371
|
+
this.options.rangeExtractor,
|
|
107372
|
+
this.options.overscan,
|
|
107373
|
+
this.options.count,
|
|
107374
|
+
startIndex,
|
|
107375
|
+
endIndex
|
|
107376
|
+
];
|
|
107377
|
+
}, (rangeExtractor, overscan, count, startIndex, endIndex) => {
|
|
107378
|
+
return startIndex === null || endIndex === null ? [] : rangeExtractor({
|
|
107379
|
+
startIndex,
|
|
107380
|
+
endIndex,
|
|
107381
|
+
overscan,
|
|
107382
|
+
count
|
|
107383
|
+
});
|
|
107384
|
+
}, {
|
|
107385
|
+
key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
|
|
107386
|
+
debug: () => this.options.debug
|
|
107387
|
+
});
|
|
107388
|
+
this.indexFromElement = (node) => {
|
|
107389
|
+
const attributeName = this.options.indexAttribute;
|
|
107390
|
+
const indexStr = node.getAttribute(attributeName);
|
|
107391
|
+
if (!indexStr) {
|
|
107392
|
+
console.warn(`Missing attribute name '${attributeName}={index}' on measured element.`);
|
|
107393
|
+
return -1;
|
|
107394
|
+
}
|
|
107395
|
+
return parseInt(indexStr, 10);
|
|
107396
|
+
};
|
|
107397
|
+
this.shouldMeasureDuringScroll = (index) => {
|
|
107398
|
+
var _a;
|
|
107399
|
+
if (!this.scrollState || this.scrollState.behavior !== "smooth") return true;
|
|
107400
|
+
const scrollIndex = this.scrollState.index ?? ((_a = this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)) == null ? void 0 : _a.index);
|
|
107401
|
+
if (scrollIndex !== void 0 && this.range) {
|
|
107402
|
+
const bufferSize = Math.max(this.options.overscan, Math.ceil((this.range.endIndex - this.range.startIndex) / 2));
|
|
107403
|
+
const minIndex = Math.max(0, scrollIndex - bufferSize);
|
|
107404
|
+
const maxIndex = Math.min(this.options.count - 1, scrollIndex + bufferSize);
|
|
107405
|
+
return index >= minIndex && index <= maxIndex;
|
|
107406
|
+
}
|
|
107407
|
+
return true;
|
|
107408
|
+
};
|
|
107409
|
+
this.measureElement = (node) => {
|
|
107410
|
+
if (!node) {
|
|
107411
|
+
this.elementsCache.forEach((cached, key2) => {
|
|
107412
|
+
if (!cached.isConnected) {
|
|
107413
|
+
this.observer.unobserve(cached);
|
|
107414
|
+
this.elementsCache.delete(key2);
|
|
107415
|
+
}
|
|
107416
|
+
});
|
|
107417
|
+
return;
|
|
107418
|
+
}
|
|
107419
|
+
const index = this.indexFromElement(node);
|
|
107420
|
+
const key = this.options.getItemKey(index);
|
|
107421
|
+
const prevNode = this.elementsCache.get(key);
|
|
107422
|
+
if (prevNode !== node) {
|
|
107423
|
+
if (prevNode) this.observer.unobserve(prevNode);
|
|
107424
|
+
this.observer.observe(node);
|
|
107425
|
+
this.elementsCache.set(key, node);
|
|
107426
|
+
}
|
|
107427
|
+
if ((!this.isScrolling || this.scrollState) && this.shouldMeasureDuringScroll(index)) this.resizeItem(index, this.options.measureElement(node, void 0, this));
|
|
107428
|
+
};
|
|
107429
|
+
this.resizeItem = (index, size) => {
|
|
107430
|
+
var _a;
|
|
107431
|
+
const item = this.measurementsCache[index];
|
|
107432
|
+
if (!item) return;
|
|
107433
|
+
const delta = size - (this.itemSizeCache.get(item.key) ?? item.size);
|
|
107434
|
+
if (delta !== 0) {
|
|
107435
|
+
if (((_a = this.scrollState) == null ? void 0 : _a.behavior) !== "smooth" && (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(item, delta, this) : item.start < this.getScrollOffset() + this.scrollAdjustments)) {
|
|
107436
|
+
if (process.env.NODE_ENV !== "production" && this.options.debug) console.info("correction", delta);
|
|
107437
|
+
this._scrollToOffset(this.getScrollOffset(), {
|
|
107438
|
+
adjustments: this.scrollAdjustments += delta,
|
|
107439
|
+
behavior: void 0
|
|
107440
|
+
});
|
|
107441
|
+
}
|
|
107442
|
+
this.pendingMeasuredCacheIndexes.push(item.index);
|
|
107443
|
+
this.itemSizeCache = new Map(this.itemSizeCache.set(item.key, size));
|
|
107444
|
+
this.notify(false);
|
|
107445
|
+
}
|
|
107446
|
+
};
|
|
107447
|
+
this.getVirtualItems = memo$1(() => [this.getVirtualIndexes(), this.getMeasurements()], (indexes, measurements) => {
|
|
107448
|
+
const virtualItems = [];
|
|
107449
|
+
for (let k = 0, len = indexes.length; k < len; k++) {
|
|
107450
|
+
const measurement = measurements[indexes[k]];
|
|
107451
|
+
virtualItems.push(measurement);
|
|
107452
|
+
}
|
|
107453
|
+
return virtualItems;
|
|
107454
|
+
}, {
|
|
107455
|
+
key: process.env.NODE_ENV !== "production" && "getVirtualItems",
|
|
107456
|
+
debug: () => this.options.debug
|
|
107457
|
+
});
|
|
107458
|
+
this.getVirtualItemForOffset = (offset) => {
|
|
107459
|
+
const measurements = this.getMeasurements();
|
|
107460
|
+
if (measurements.length === 0) return;
|
|
107461
|
+
return notUndefined(measurements[findNearestBinarySearch(0, measurements.length - 1, (index) => notUndefined(measurements[index]).start, offset)]);
|
|
107462
|
+
};
|
|
107463
|
+
this.getMaxScrollOffset = () => {
|
|
107464
|
+
if (!this.scrollElement) return 0;
|
|
107465
|
+
if ("scrollHeight" in this.scrollElement) return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
|
|
107466
|
+
else {
|
|
107467
|
+
const doc = this.scrollElement.document.documentElement;
|
|
107468
|
+
return this.options.horizontal ? doc.scrollWidth - this.scrollElement.innerWidth : doc.scrollHeight - this.scrollElement.innerHeight;
|
|
107469
|
+
}
|
|
107470
|
+
};
|
|
107471
|
+
this.getOffsetForAlignment = (toOffset, align, itemSize = 0) => {
|
|
107472
|
+
if (!this.scrollElement) return 0;
|
|
107473
|
+
const size = this.getSize();
|
|
107474
|
+
const scrollOffset = this.getScrollOffset();
|
|
107475
|
+
if (align === "auto") align = toOffset >= scrollOffset + size ? "end" : "start";
|
|
107476
|
+
if (align === "center") toOffset += (itemSize - size) / 2;
|
|
107477
|
+
else if (align === "end") toOffset -= size;
|
|
107478
|
+
const maxOffset = this.getMaxScrollOffset();
|
|
107479
|
+
return Math.max(Math.min(maxOffset, toOffset), 0);
|
|
107480
|
+
};
|
|
107481
|
+
this.getOffsetForIndex = (index, align = "auto") => {
|
|
107482
|
+
index = Math.max(0, Math.min(index, this.options.count - 1));
|
|
107483
|
+
const size = this.getSize();
|
|
107484
|
+
const scrollOffset = this.getScrollOffset();
|
|
107485
|
+
const item = this.measurementsCache[index];
|
|
107486
|
+
if (!item) return;
|
|
107487
|
+
if (align === "auto") if (item.end >= scrollOffset + size - this.options.scrollPaddingEnd) align = "end";
|
|
107488
|
+
else if (item.start <= scrollOffset + this.options.scrollPaddingStart) align = "start";
|
|
107489
|
+
else return [scrollOffset, align];
|
|
107490
|
+
if (align === "end" && index === this.options.count - 1) return [this.getMaxScrollOffset(), align];
|
|
107491
|
+
const toOffset = align === "end" ? item.end + this.options.scrollPaddingEnd : item.start - this.options.scrollPaddingStart;
|
|
107492
|
+
return [this.getOffsetForAlignment(toOffset, align, item.size), align];
|
|
107493
|
+
};
|
|
107494
|
+
this.scrollToOffset = (toOffset, { align = "start", behavior = "auto" } = {}) => {
|
|
107495
|
+
const offset = this.getOffsetForAlignment(toOffset, align);
|
|
107496
|
+
const now = this.now();
|
|
107497
|
+
this.scrollState = {
|
|
107498
|
+
index: null,
|
|
107499
|
+
align,
|
|
107500
|
+
behavior,
|
|
107501
|
+
startedAt: now,
|
|
107502
|
+
lastTargetOffset: offset,
|
|
107503
|
+
stableFrames: 0
|
|
107504
|
+
};
|
|
107505
|
+
this._scrollToOffset(offset, {
|
|
107506
|
+
adjustments: void 0,
|
|
107507
|
+
behavior
|
|
107508
|
+
});
|
|
107509
|
+
this.scheduleScrollReconcile();
|
|
107510
|
+
};
|
|
107511
|
+
this.scrollToIndex = (index, { align: initialAlign = "auto", behavior = "auto" } = {}) => {
|
|
107512
|
+
index = Math.max(0, Math.min(index, this.options.count - 1));
|
|
107513
|
+
const offsetInfo = this.getOffsetForIndex(index, initialAlign);
|
|
107514
|
+
if (!offsetInfo) return;
|
|
107515
|
+
const [offset, align] = offsetInfo;
|
|
107516
|
+
const now = this.now();
|
|
107517
|
+
this.scrollState = {
|
|
107518
|
+
index,
|
|
107519
|
+
align,
|
|
107520
|
+
behavior,
|
|
107521
|
+
startedAt: now,
|
|
107522
|
+
lastTargetOffset: offset,
|
|
107523
|
+
stableFrames: 0
|
|
107524
|
+
};
|
|
107525
|
+
this._scrollToOffset(offset, {
|
|
107526
|
+
adjustments: void 0,
|
|
107527
|
+
behavior
|
|
107528
|
+
});
|
|
107529
|
+
this.scheduleScrollReconcile();
|
|
107530
|
+
};
|
|
107531
|
+
this.scrollBy = (delta, { behavior = "auto" } = {}) => {
|
|
107532
|
+
const offset = this.getScrollOffset() + delta;
|
|
107533
|
+
const now = this.now();
|
|
107534
|
+
this.scrollState = {
|
|
107535
|
+
index: null,
|
|
107536
|
+
align: "start",
|
|
107537
|
+
behavior,
|
|
107538
|
+
startedAt: now,
|
|
107539
|
+
lastTargetOffset: offset,
|
|
107540
|
+
stableFrames: 0
|
|
107541
|
+
};
|
|
107542
|
+
this._scrollToOffset(offset, {
|
|
107543
|
+
adjustments: void 0,
|
|
107544
|
+
behavior
|
|
107545
|
+
});
|
|
107546
|
+
this.scheduleScrollReconcile();
|
|
107547
|
+
};
|
|
107548
|
+
this.getTotalSize = () => {
|
|
107549
|
+
var _a;
|
|
107550
|
+
const measurements = this.getMeasurements();
|
|
107551
|
+
let end;
|
|
107552
|
+
if (measurements.length === 0) end = this.options.paddingStart;
|
|
107553
|
+
else if (this.options.lanes === 1) end = ((_a = measurements[measurements.length - 1]) == null ? void 0 : _a.end) ?? 0;
|
|
107554
|
+
else {
|
|
107555
|
+
const endByLane = Array(this.options.lanes).fill(null);
|
|
107556
|
+
let endIndex = measurements.length - 1;
|
|
107557
|
+
while (endIndex >= 0 && endByLane.some((val) => val === null)) {
|
|
107558
|
+
const item = measurements[endIndex];
|
|
107559
|
+
if (endByLane[item.lane] === null) endByLane[item.lane] = item.end;
|
|
107560
|
+
endIndex--;
|
|
107561
|
+
}
|
|
107562
|
+
end = Math.max(...endByLane.filter((val) => val !== null));
|
|
107563
|
+
}
|
|
107564
|
+
return Math.max(end - this.options.scrollMargin + this.options.paddingEnd, 0);
|
|
107565
|
+
};
|
|
107566
|
+
this._scrollToOffset = (offset, { adjustments, behavior }) => {
|
|
107567
|
+
this.options.scrollToFn(offset, {
|
|
107568
|
+
behavior,
|
|
107569
|
+
adjustments
|
|
107570
|
+
}, this);
|
|
107571
|
+
};
|
|
107572
|
+
this.measure = () => {
|
|
107573
|
+
this.itemSizeCache = /* @__PURE__ */ new Map();
|
|
107574
|
+
this.laneAssignments = /* @__PURE__ */ new Map();
|
|
107575
|
+
this.notify(false);
|
|
107576
|
+
};
|
|
107577
|
+
this.setOptions(opts);
|
|
107578
|
+
}
|
|
107579
|
+
scheduleScrollReconcile() {
|
|
107580
|
+
if (!this.targetWindow) {
|
|
107581
|
+
this.scrollState = null;
|
|
107582
|
+
return;
|
|
107583
|
+
}
|
|
107584
|
+
if (this.rafId != null) return;
|
|
107585
|
+
this.rafId = this.targetWindow.requestAnimationFrame(() => {
|
|
107586
|
+
this.rafId = null;
|
|
107587
|
+
this.reconcileScroll();
|
|
107588
|
+
});
|
|
107589
|
+
}
|
|
107590
|
+
reconcileScroll() {
|
|
107591
|
+
if (!this.scrollState) return;
|
|
107592
|
+
if (!this.scrollElement) return;
|
|
107593
|
+
if (this.now() - this.scrollState.startedAt > 5e3) {
|
|
107594
|
+
this.scrollState = null;
|
|
107595
|
+
return;
|
|
107596
|
+
}
|
|
107597
|
+
const offsetInfo = this.scrollState.index != null ? this.getOffsetForIndex(this.scrollState.index, this.scrollState.align) : void 0;
|
|
107598
|
+
const targetOffset = offsetInfo ? offsetInfo[0] : this.scrollState.lastTargetOffset;
|
|
107599
|
+
const STABLE_FRAMES = 1;
|
|
107600
|
+
const targetChanged = targetOffset !== this.scrollState.lastTargetOffset;
|
|
107601
|
+
if (!targetChanged && approxEqual(targetOffset, this.getScrollOffset())) {
|
|
107602
|
+
this.scrollState.stableFrames++;
|
|
107603
|
+
if (this.scrollState.stableFrames >= STABLE_FRAMES) {
|
|
107604
|
+
this.scrollState = null;
|
|
107605
|
+
return;
|
|
107606
|
+
}
|
|
107607
|
+
} else {
|
|
107608
|
+
this.scrollState.stableFrames = 0;
|
|
107609
|
+
if (targetChanged) {
|
|
107610
|
+
this.scrollState.lastTargetOffset = targetOffset;
|
|
107611
|
+
this.scrollState.behavior = "auto";
|
|
107612
|
+
this._scrollToOffset(targetOffset, {
|
|
107613
|
+
adjustments: void 0,
|
|
107614
|
+
behavior: "auto"
|
|
107615
|
+
});
|
|
107616
|
+
}
|
|
107617
|
+
}
|
|
107618
|
+
this.scheduleScrollReconcile();
|
|
107619
|
+
}
|
|
107620
|
+
};
|
|
107621
|
+
var findNearestBinarySearch = (low, high, getCurrentValue, value) => {
|
|
107622
|
+
while (low <= high) {
|
|
107623
|
+
const middle = (low + high) / 2 | 0;
|
|
107624
|
+
const currentValue = getCurrentValue(middle);
|
|
107625
|
+
if (currentValue < value) low = middle + 1;
|
|
107626
|
+
else if (currentValue > value) high = middle - 1;
|
|
107627
|
+
else return middle;
|
|
107628
|
+
}
|
|
107629
|
+
if (low > 0) return low - 1;
|
|
107630
|
+
else return 0;
|
|
107631
|
+
};
|
|
107632
|
+
function calculateRange({ measurements, outerSize, scrollOffset, lanes }) {
|
|
107633
|
+
const lastIndex = measurements.length - 1;
|
|
107634
|
+
const getOffset = (index) => measurements[index].start;
|
|
107635
|
+
if (measurements.length <= lanes) return {
|
|
107636
|
+
startIndex: 0,
|
|
107637
|
+
endIndex: lastIndex
|
|
107638
|
+
};
|
|
107639
|
+
let startIndex = findNearestBinarySearch(0, lastIndex, getOffset, scrollOffset);
|
|
107640
|
+
let endIndex = startIndex;
|
|
107641
|
+
if (lanes === 1) while (endIndex < lastIndex && measurements[endIndex].end < scrollOffset + outerSize) endIndex++;
|
|
107642
|
+
else if (lanes > 1) {
|
|
107643
|
+
const endPerLane = Array(lanes).fill(0);
|
|
107644
|
+
while (endIndex < lastIndex && endPerLane.some((pos) => pos < scrollOffset + outerSize)) {
|
|
107645
|
+
const item = measurements[endIndex];
|
|
107646
|
+
endPerLane[item.lane] = item.end;
|
|
107647
|
+
endIndex++;
|
|
107648
|
+
}
|
|
107649
|
+
const startPerLane = Array(lanes).fill(scrollOffset + outerSize);
|
|
107650
|
+
while (startIndex >= 0 && startPerLane.some((pos) => pos >= scrollOffset)) {
|
|
107651
|
+
const item = measurements[startIndex];
|
|
107652
|
+
startPerLane[item.lane] = item.start;
|
|
107653
|
+
startIndex--;
|
|
107654
|
+
}
|
|
107655
|
+
startIndex = Math.max(0, startIndex - startIndex % lanes);
|
|
107656
|
+
endIndex = Math.min(lastIndex, endIndex + (lanes - 1 - endIndex % lanes));
|
|
107657
|
+
}
|
|
107658
|
+
return {
|
|
107659
|
+
startIndex,
|
|
107660
|
+
endIndex
|
|
107661
|
+
};
|
|
107662
|
+
}
|
|
107663
|
+
//#endregion
|
|
107664
|
+
//#region ../../node_modules/.pnpm/@tanstack+react-virtual@3.13.24_react-dom@19.2.6_react@19.2.6__react@19.2.6/node_modules/@tanstack/react-virtual/dist/esm/index.js
|
|
107665
|
+
var useIsomorphicLayoutEffect = typeof document !== "undefined" ? React$1.useLayoutEffect : React$1.useEffect;
|
|
107666
|
+
function useVirtualizerBase({ useFlushSync = true, ...options }) {
|
|
107667
|
+
const rerender = React$1.useReducer(() => ({}), {})[1];
|
|
107668
|
+
const resolvedOptions = {
|
|
107669
|
+
...options,
|
|
107670
|
+
onChange: (instance2, sync) => {
|
|
107671
|
+
var _a;
|
|
107672
|
+
if (useFlushSync && sync) flushSync(rerender);
|
|
107673
|
+
else rerender();
|
|
107674
|
+
(_a = options.onChange) == null || _a.call(options, instance2, sync);
|
|
107675
|
+
}
|
|
107676
|
+
};
|
|
107677
|
+
const [instance] = React$1.useState(() => new Virtualizer(resolvedOptions));
|
|
107678
|
+
instance.setOptions(resolvedOptions);
|
|
107679
|
+
useIsomorphicLayoutEffect(() => {
|
|
107680
|
+
return instance._didMount();
|
|
107681
|
+
}, []);
|
|
107682
|
+
useIsomorphicLayoutEffect(() => {
|
|
107683
|
+
return instance._willUpdate();
|
|
107684
|
+
});
|
|
107685
|
+
return instance;
|
|
107686
|
+
}
|
|
107687
|
+
function useVirtualizer(options) {
|
|
107688
|
+
return useVirtualizerBase({
|
|
107689
|
+
observeElementRect,
|
|
107690
|
+
observeElementOffset,
|
|
107691
|
+
scrollToFn: elementScroll,
|
|
107692
|
+
...options
|
|
107693
|
+
});
|
|
107694
|
+
}
|
|
107695
|
+
//#endregion
|
|
107696
|
+
//#region ../../packages/react/src/virtual/scale-coordinate-space.ts
|
|
107697
|
+
var SAFE_MAX_SPACER = 16e6;
|
|
107698
|
+
function computeScale(contentTotal, safeMax) {
|
|
107699
|
+
if (contentTotal <= safeMax) return 1;
|
|
107700
|
+
return contentTotal / safeMax;
|
|
107701
|
+
}
|
|
107702
|
+
//#endregion
|
|
107703
|
+
//#region ../../packages/react/src/virtual/use-scaled-virtualizer.ts
|
|
107704
|
+
function useScaledVirtualizer(opts) {
|
|
107705
|
+
const scaleRef = useRef(1);
|
|
107706
|
+
const scaledObserveElementOffset = useMemo(() => (instance, cb) => {
|
|
107707
|
+
const el = instance.scrollElement;
|
|
107708
|
+
if (!el) return;
|
|
107709
|
+
const onScroll = () => {
|
|
107710
|
+
cb(el.scrollTop * scaleRef.current, true);
|
|
107711
|
+
};
|
|
107712
|
+
const onScrollEnd = () => {
|
|
107713
|
+
cb(el.scrollTop * scaleRef.current, false);
|
|
107714
|
+
};
|
|
107715
|
+
cb(el.scrollTop * scaleRef.current, false);
|
|
107716
|
+
el.addEventListener("scroll", onScroll, { passive: true });
|
|
107717
|
+
el.addEventListener("scrollend", onScrollEnd, { passive: true });
|
|
107718
|
+
return () => {
|
|
107719
|
+
el.removeEventListener("scroll", onScroll);
|
|
107720
|
+
el.removeEventListener("scrollend", onScrollEnd);
|
|
107721
|
+
};
|
|
107722
|
+
}, []);
|
|
107723
|
+
const scaledScrollToFn = useCallback((offset, { adjustments, behavior }, instance) => {
|
|
107724
|
+
const el = instance.scrollElement;
|
|
107725
|
+
if (!el) return;
|
|
107726
|
+
const adjusted = offset + (adjustments ?? 0);
|
|
107727
|
+
el.scrollTo({
|
|
107728
|
+
top: adjusted / scaleRef.current,
|
|
107729
|
+
behavior
|
|
107730
|
+
});
|
|
107731
|
+
}, []);
|
|
107732
|
+
const virtualizer = useVirtualizer({
|
|
107733
|
+
count: opts.count,
|
|
107734
|
+
estimateSize: opts.estimateSize,
|
|
107735
|
+
getScrollElement: opts.getScrollElement,
|
|
107736
|
+
overscan: opts.overscan ?? 5,
|
|
107737
|
+
observeElementOffset: scaledObserveElementOffset,
|
|
107738
|
+
scrollToFn: scaledScrollToFn
|
|
107739
|
+
});
|
|
107740
|
+
const contentTotal = virtualizer.getTotalSize();
|
|
107741
|
+
const scale = computeScale(contentTotal, SAFE_MAX_SPACER);
|
|
107742
|
+
scaleRef.current = scale;
|
|
107743
|
+
return {
|
|
107744
|
+
virtualizer,
|
|
107745
|
+
scale,
|
|
107746
|
+
spacerHeight: scale === 1 ? contentTotal : SAFE_MAX_SPACER,
|
|
107747
|
+
toContentScroll: useCallback((spacerScroll) => spacerScroll * scale, [scale]),
|
|
107748
|
+
toSpacerScroll: useCallback((contentScroll) => contentScroll / scale, [scale])
|
|
107749
|
+
};
|
|
107750
|
+
}
|
|
107751
|
+
//#endregion
|
|
107752
|
+
//#region ../../packages/react/src/virtual/use-virtual-list-state.ts
|
|
107753
|
+
var CURRENT_VERSION = 1;
|
|
107754
|
+
function useVirtualListState(persistenceKey) {
|
|
107755
|
+
const [stored, setStored] = useProperty(persistenceKey, "snapshot", { defaultValue: null });
|
|
107756
|
+
return {
|
|
107757
|
+
getRestoreSnapshot: useCallback(() => {
|
|
107758
|
+
if (!stored) return void 0;
|
|
107759
|
+
if (stored.version !== CURRENT_VERSION) return void 0;
|
|
107760
|
+
return stored;
|
|
107761
|
+
}, [stored]),
|
|
107762
|
+
recordSnapshot: useCallback((snapshot) => {
|
|
107763
|
+
setStored(snapshot);
|
|
107764
|
+
}, [setStored])
|
|
107765
|
+
};
|
|
107766
|
+
}
|
|
107767
|
+
var VirtualList_module_default = {
|
|
107768
|
+
scroller: "_scroller_qi4v2_1",
|
|
107769
|
+
spacer: "_spacer_qi4v2_5"
|
|
107770
|
+
};
|
|
107771
|
+
//#endregion
|
|
107772
|
+
//#region ../../packages/react/src/virtual/VirtualList.tsx
|
|
107773
|
+
var BOTTOM_THRESHOLD_PX = 30;
|
|
107774
|
+
var SMOOTH_SCROLL_MAX_S = 10;
|
|
107775
|
+
var PERSIST_DEBOUNCE_MS = 250;
|
|
107776
|
+
var DEFAULT_ITEM_HEIGHT_PX = 400;
|
|
107777
|
+
var MAX_CHUNK_HEIGHT = 5e6;
|
|
107778
|
+
function PaddingChunks({ height, prefix }) {
|
|
107779
|
+
if (height <= 0) return null;
|
|
107780
|
+
const chunks = [];
|
|
107781
|
+
let remaining = height;
|
|
107782
|
+
let i = 0;
|
|
107783
|
+
while (remaining > 0) {
|
|
107784
|
+
const h = Math.min(remaining, MAX_CHUNK_HEIGHT);
|
|
107785
|
+
chunks.push(/* @__PURE__ */ jsx("div", { style: { height: h } }, `${prefix}-${i}`));
|
|
107786
|
+
remaining -= h;
|
|
107787
|
+
i++;
|
|
107788
|
+
}
|
|
107789
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: chunks });
|
|
107790
|
+
}
|
|
107791
|
+
function prepareSearchTerm(term) {
|
|
107792
|
+
const lower = term.toLowerCase();
|
|
107793
|
+
if (!term.includes("\"") && !term.includes(":")) return { simple: lower };
|
|
107794
|
+
return {
|
|
107795
|
+
simple: lower,
|
|
107796
|
+
unquoted: lower.replace(/"/g, ""),
|
|
107797
|
+
jsonEscaped: lower.replace(/"/g, "\\\"")
|
|
107798
|
+
};
|
|
107799
|
+
}
|
|
107800
|
+
function VirtualList({ persistenceKey, ref, className, scrollRef: externalScrollRef, data, renderRow, live, showProgress, initialIndex, stickyHeaderOffset, components, smoothScroll = true, itemSearchText, findScope = "local", scrollToTopOnFinish = false, onVisibleRangeChange }) {
|
|
107801
|
+
const internalScrollRef = useRef(null);
|
|
107802
|
+
const [scrollParent, setScrollParent] = useState(null);
|
|
107803
|
+
useEffect(() => {
|
|
107804
|
+
if (!externalScrollRef) return;
|
|
107805
|
+
const sync = () => {
|
|
107806
|
+
setScrollParent((prev) => prev === externalScrollRef.current ? prev : externalScrollRef.current ?? null);
|
|
107807
|
+
};
|
|
107808
|
+
sync();
|
|
107809
|
+
const observer = new MutationObserver(sync);
|
|
107810
|
+
observer.observe(document.body, {
|
|
107811
|
+
childList: true,
|
|
107812
|
+
subtree: true
|
|
107813
|
+
});
|
|
107814
|
+
return () => observer.disconnect();
|
|
107815
|
+
}, [externalScrollRef]);
|
|
107816
|
+
const getScrollElement = useCallback(() => scrollParent ?? internalScrollRef.current, [scrollParent]);
|
|
107817
|
+
const { virtualizer, scale, spacerHeight, toContentScroll, toSpacerScroll } = useScaledVirtualizer({
|
|
107818
|
+
count: data.length,
|
|
107819
|
+
estimateSize: () => DEFAULT_ITEM_HEIGHT_PX,
|
|
107820
|
+
getScrollElement
|
|
107821
|
+
});
|
|
107822
|
+
const { getRestoreSnapshot, recordSnapshot } = useVirtualListState(persistenceKey);
|
|
107823
|
+
const [followOutput, setFollowOutput] = useProperty(persistenceKey, "follow", { defaultValue: null });
|
|
107824
|
+
const isAutoScrollingRef = useRef(false);
|
|
107825
|
+
useEffect(() => {
|
|
107826
|
+
if (followOutput === null) setFollowOutput(!!live);
|
|
107827
|
+
}, [
|
|
107828
|
+
followOutput,
|
|
107829
|
+
live,
|
|
107830
|
+
setFollowOutput
|
|
107831
|
+
]);
|
|
107832
|
+
const prevLive = usePreviousValue(live);
|
|
107833
|
+
useEffect(() => {
|
|
107834
|
+
if (scrollToTopOnFinish && !live && prevLive && followOutput) {
|
|
107835
|
+
const el = getScrollElement();
|
|
107836
|
+
if (el) {
|
|
107837
|
+
setFollowOutput(false);
|
|
107838
|
+
setTimeout(() => el.scrollTo({
|
|
107839
|
+
top: 0,
|
|
107840
|
+
behavior: "auto"
|
|
107841
|
+
}), 100);
|
|
107842
|
+
}
|
|
107843
|
+
}
|
|
107844
|
+
}, [
|
|
107845
|
+
live,
|
|
107846
|
+
prevLive,
|
|
107847
|
+
followOutput,
|
|
107848
|
+
scrollToTopOnFinish,
|
|
107849
|
+
getScrollElement,
|
|
107850
|
+
setFollowOutput
|
|
107851
|
+
]);
|
|
107852
|
+
const handleScroll = useRafThrottle(() => {
|
|
107853
|
+
if (isAutoScrollingRef.current) return;
|
|
107854
|
+
if (!live) return;
|
|
107855
|
+
const el = getScrollElement();
|
|
107856
|
+
if (!el) return;
|
|
107857
|
+
const atBottom = el.scrollHeight - el.scrollTop <= el.clientHeight + BOTTOM_THRESHOLD_PX;
|
|
107858
|
+
if (atBottom && !followOutput) setFollowOutput(true);
|
|
107859
|
+
else if (!atBottom && followOutput) setFollowOutput(false);
|
|
107860
|
+
});
|
|
107861
|
+
useEffect(() => {
|
|
107862
|
+
const el = getScrollElement();
|
|
107863
|
+
if (!el) return;
|
|
107864
|
+
el.addEventListener("scroll", handleScroll);
|
|
107865
|
+
return () => el.removeEventListener("scroll", handleScroll);
|
|
107866
|
+
}, [getScrollElement, handleScroll]);
|
|
107867
|
+
const contentTotal = virtualizer.getTotalSize();
|
|
107868
|
+
useEffect(() => {
|
|
107869
|
+
if (!followOutput || !live) return;
|
|
107870
|
+
const el = getScrollElement();
|
|
107871
|
+
if (!el) return;
|
|
107872
|
+
requestAnimationFrame(() => {
|
|
107873
|
+
isAutoScrollingRef.current = true;
|
|
107874
|
+
el.scrollTo({ top: el.scrollHeight });
|
|
107875
|
+
requestAnimationFrame(() => {
|
|
107876
|
+
isAutoScrollingRef.current = false;
|
|
107877
|
+
});
|
|
107878
|
+
});
|
|
107879
|
+
}, [
|
|
107880
|
+
contentTotal,
|
|
107881
|
+
followOutput,
|
|
107882
|
+
live,
|
|
107883
|
+
getScrollElement
|
|
107884
|
+
]);
|
|
107885
|
+
const hasInitialScrolledRef = useRef(false);
|
|
107886
|
+
const lastInitialKeyRef = useRef(null);
|
|
107887
|
+
const lastInitialIndexRef = useRef(void 0);
|
|
107888
|
+
useEffect(() => {
|
|
107889
|
+
if (lastInitialKeyRef.current !== persistenceKey || lastInitialIndexRef.current !== initialIndex) {
|
|
107890
|
+
hasInitialScrolledRef.current = false;
|
|
107891
|
+
lastInitialKeyRef.current = persistenceKey;
|
|
107892
|
+
lastInitialIndexRef.current = initialIndex ?? void 0;
|
|
107893
|
+
}
|
|
107894
|
+
if (hasInitialScrolledRef.current) return;
|
|
107895
|
+
const el = getScrollElement();
|
|
107896
|
+
if (!el) return;
|
|
107897
|
+
const snapshot = getRestoreSnapshot();
|
|
107898
|
+
requestAnimationFrame(() => {
|
|
107899
|
+
if (initialIndex != null) {
|
|
107900
|
+
virtualizer.scrollToIndex(initialIndex, {
|
|
107901
|
+
align: "start",
|
|
107902
|
+
behavior: "auto"
|
|
107903
|
+
});
|
|
107904
|
+
if (stickyHeaderOffset) el.scrollTop -= stickyHeaderOffset;
|
|
107905
|
+
hasInitialScrolledRef.current = true;
|
|
107906
|
+
} else if (snapshot) {
|
|
107907
|
+
if (el.scrollTop === 0) if (snapshot.totalCount === data.length) el.scrollTop = toSpacerScroll(snapshot.scrollOffset);
|
|
107908
|
+
else {
|
|
107909
|
+
const maxScroll = Math.max(0, contentTotal - el.clientHeight);
|
|
107910
|
+
el.scrollTop = toSpacerScroll(Math.min(snapshot.scrollOffset, maxScroll));
|
|
107911
|
+
}
|
|
107912
|
+
hasInitialScrolledRef.current = true;
|
|
107913
|
+
}
|
|
107914
|
+
});
|
|
107915
|
+
}, [
|
|
107916
|
+
persistenceKey,
|
|
107917
|
+
initialIndex,
|
|
107918
|
+
stickyHeaderOffset,
|
|
107919
|
+
contentTotal,
|
|
107920
|
+
data.length,
|
|
107921
|
+
getRestoreSnapshot,
|
|
107922
|
+
getScrollElement,
|
|
107923
|
+
toSpacerScroll,
|
|
107924
|
+
virtualizer
|
|
107925
|
+
]);
|
|
107926
|
+
const persistTimerRef = useRef(null);
|
|
107927
|
+
const persistOnScroll = useRafThrottle(() => {
|
|
107928
|
+
if (isAutoScrollingRef.current) return;
|
|
107929
|
+
if (persistTimerRef.current) clearTimeout(persistTimerRef.current);
|
|
107930
|
+
persistTimerRef.current = setTimeout(() => {
|
|
107931
|
+
const el = getScrollElement();
|
|
107932
|
+
if (!el) return;
|
|
107933
|
+
recordSnapshot({
|
|
107934
|
+
version: 1,
|
|
107935
|
+
scrollOffset: toContentScroll(el.scrollTop),
|
|
107936
|
+
totalCount: data.length
|
|
107937
|
+
});
|
|
107938
|
+
}, PERSIST_DEBOUNCE_MS);
|
|
107939
|
+
});
|
|
107940
|
+
useEffect(() => {
|
|
107941
|
+
const el = getScrollElement();
|
|
107942
|
+
if (!el) return;
|
|
107943
|
+
el.addEventListener("scroll", persistOnScroll);
|
|
107944
|
+
return () => el.removeEventListener("scroll", persistOnScroll);
|
|
107945
|
+
}, [getScrollElement, persistOnScroll]);
|
|
107946
|
+
const items = virtualizer.getVirtualItems();
|
|
107947
|
+
const startIndex = items[0]?.index ?? 0;
|
|
107948
|
+
const endIndex = items[items.length - 1]?.index ?? 0;
|
|
107949
|
+
const visibleRangeRef = useRef({
|
|
107950
|
+
startIndex: 0,
|
|
107951
|
+
endIndex: 0
|
|
107952
|
+
});
|
|
107953
|
+
useEffect(() => {
|
|
107954
|
+
visibleRangeRef.current = {
|
|
107955
|
+
startIndex,
|
|
107956
|
+
endIndex
|
|
107957
|
+
};
|
|
107958
|
+
onVisibleRangeChange?.({
|
|
107959
|
+
startIndex,
|
|
107960
|
+
endIndex
|
|
107961
|
+
});
|
|
107962
|
+
}, [
|
|
107963
|
+
startIndex,
|
|
107964
|
+
endIndex,
|
|
107965
|
+
onVisibleRangeChange
|
|
107966
|
+
]);
|
|
107967
|
+
useImperativeHandle(ref, () => ({
|
|
107968
|
+
scrollToIndex(opts) {
|
|
107969
|
+
const behavior = scale > SMOOTH_SCROLL_MAX_S ? "auto" : opts.behavior ?? (smoothScroll ? "smooth" : "auto");
|
|
107970
|
+
virtualizer.scrollToIndex(opts.index, {
|
|
107971
|
+
align: opts.align,
|
|
107972
|
+
behavior
|
|
107973
|
+
});
|
|
107974
|
+
if (opts.offset) {
|
|
107975
|
+
const el = getScrollElement();
|
|
107976
|
+
if (el) el.scrollTop += opts.offset;
|
|
107977
|
+
}
|
|
107978
|
+
},
|
|
107979
|
+
scrollTo(opts) {
|
|
107980
|
+
const el = getScrollElement();
|
|
107981
|
+
if (!el) return;
|
|
107982
|
+
const behavior = scale > SMOOTH_SCROLL_MAX_S ? "auto" : opts.behavior ?? (smoothScroll ? "smooth" : "auto");
|
|
107983
|
+
el.scrollTo({
|
|
107984
|
+
top: opts.top,
|
|
107985
|
+
behavior
|
|
107986
|
+
});
|
|
107987
|
+
},
|
|
107988
|
+
getState(callback) {
|
|
107989
|
+
const el = getScrollElement();
|
|
107990
|
+
callback({
|
|
107991
|
+
version: 1,
|
|
107992
|
+
scrollOffset: el ? toContentScroll(el.scrollTop) : 0,
|
|
107993
|
+
totalCount: data.length
|
|
107994
|
+
});
|
|
107995
|
+
},
|
|
107996
|
+
jumpToStart() {
|
|
107997
|
+
const el = getScrollElement();
|
|
107998
|
+
if (el) el.scrollTop = 0;
|
|
107999
|
+
},
|
|
108000
|
+
jumpToEnd() {
|
|
108001
|
+
const el = getScrollElement();
|
|
108002
|
+
if (el) el.scrollTop = spacerHeight;
|
|
108003
|
+
}
|
|
108004
|
+
}), [
|
|
108005
|
+
virtualizer,
|
|
108006
|
+
scale,
|
|
108007
|
+
spacerHeight,
|
|
108008
|
+
smoothScroll,
|
|
108009
|
+
getScrollElement,
|
|
108010
|
+
toContentScroll,
|
|
108011
|
+
data.length
|
|
108012
|
+
]);
|
|
108013
|
+
const { registerVirtualList, registerMatchCounter } = useExtendedFind();
|
|
108014
|
+
const searchInData = useCallback((term, direction, onContentReady) => {
|
|
108015
|
+
if (!term || data.length === 0) return Promise.resolve(false);
|
|
108016
|
+
const isForward = direction === "forward";
|
|
108017
|
+
const len = data.length;
|
|
108018
|
+
const range = visibleRangeRef.current;
|
|
108019
|
+
const current = isForward ? range.endIndex : range.startIndex;
|
|
108020
|
+
const getText = itemSearchText ?? ((item) => JSON.stringify(item));
|
|
108021
|
+
const prepared = prepareSearchTerm(term);
|
|
108022
|
+
for (let offset = 1; offset < len; offset++) {
|
|
108023
|
+
const i = isForward ? (current + offset) % len : (current - offset + len) % len;
|
|
108024
|
+
const item = data[i];
|
|
108025
|
+
if (item === void 0) continue;
|
|
108026
|
+
const texts = getText(item);
|
|
108027
|
+
if ((Array.isArray(texts) ? texts : [texts]).some((text) => {
|
|
108028
|
+
const lower = text.toLowerCase();
|
|
108029
|
+
if (lower.includes(prepared.simple)) return true;
|
|
108030
|
+
if (prepared.unquoted && lower.includes(prepared.unquoted)) return true;
|
|
108031
|
+
if (prepared.jsonEscaped && lower.includes(prepared.jsonEscaped)) return true;
|
|
108032
|
+
return false;
|
|
108033
|
+
})) {
|
|
108034
|
+
virtualizer.scrollToIndex(i, { align: "center" });
|
|
108035
|
+
setTimeout(onContentReady, 200);
|
|
108036
|
+
return Promise.resolve(true);
|
|
108037
|
+
}
|
|
108038
|
+
}
|
|
108039
|
+
return Promise.resolve(false);
|
|
108040
|
+
}, [
|
|
108041
|
+
data,
|
|
108042
|
+
itemSearchText,
|
|
108043
|
+
virtualizer
|
|
108044
|
+
]);
|
|
108045
|
+
const countMatchesInData = useCallback((term) => {
|
|
108046
|
+
if (!term || data.length === 0) return 0;
|
|
108047
|
+
const getText = itemSearchText ?? ((item) => JSON.stringify(item));
|
|
108048
|
+
const lower = term.toLowerCase();
|
|
108049
|
+
let total = 0;
|
|
108050
|
+
for (const item of data) {
|
|
108051
|
+
const texts = getText(item);
|
|
108052
|
+
const textArray = Array.isArray(texts) ? texts : [texts];
|
|
108053
|
+
for (const text of textArray) {
|
|
108054
|
+
const lowerText = text.toLowerCase();
|
|
108055
|
+
let pos = 0;
|
|
108056
|
+
while ((pos = lowerText.indexOf(lower, pos)) !== -1) {
|
|
108057
|
+
total++;
|
|
108058
|
+
pos += lower.length;
|
|
108059
|
+
}
|
|
108060
|
+
}
|
|
108061
|
+
}
|
|
108062
|
+
return total;
|
|
108063
|
+
}, [data, itemSearchText]);
|
|
108064
|
+
useEffect(() => {
|
|
108065
|
+
if (findScope === "none") return;
|
|
108066
|
+
const u1 = registerVirtualList(persistenceKey, searchInData);
|
|
108067
|
+
const u2 = registerMatchCounter(persistenceKey, countMatchesInData);
|
|
108068
|
+
return () => {
|
|
108069
|
+
u1();
|
|
108070
|
+
u2();
|
|
108071
|
+
};
|
|
108072
|
+
}, [
|
|
108073
|
+
findScope,
|
|
108074
|
+
persistenceKey,
|
|
108075
|
+
registerVirtualList,
|
|
108076
|
+
registerMatchCounter,
|
|
108077
|
+
searchInData,
|
|
108078
|
+
countMatchesInData
|
|
108079
|
+
]);
|
|
108080
|
+
const ItemSlot = components?.Item;
|
|
108081
|
+
const FooterSlot = components?.Footer;
|
|
108082
|
+
const ownsScroll = !externalScrollRef;
|
|
108083
|
+
const firstItem = items.length > 0 ? items[0] : void 0;
|
|
108084
|
+
const lastItem = items.length > 0 ? items[items.length - 1] : void 0;
|
|
108085
|
+
const topPaddingContent = firstItem?.start ?? 0;
|
|
108086
|
+
const topPaddingSpacer = topPaddingContent / scale;
|
|
108087
|
+
const renderedBandHeight = firstItem && lastItem ? lastItem.start + lastItem.size - firstItem.start : 0;
|
|
108088
|
+
const bottomPaddingSpacer = (lastItem ? Math.max(0, virtualizer.getTotalSize() - (lastItem.start + lastItem.size)) : virtualizer.getTotalSize()) / scale;
|
|
108089
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
108090
|
+
ref: (el) => {
|
|
108091
|
+
if (ownsScroll) internalScrollRef.current = el;
|
|
108092
|
+
},
|
|
108093
|
+
className: clsx(VirtualList_module_default.scroller, className),
|
|
108094
|
+
style: ownsScroll ? {
|
|
108095
|
+
height: "100%",
|
|
108096
|
+
width: "100%",
|
|
108097
|
+
overflow: "auto"
|
|
108098
|
+
} : { width: "100%" },
|
|
108099
|
+
children: [
|
|
108100
|
+
/* @__PURE__ */ jsx(PaddingChunks, {
|
|
108101
|
+
height: topPaddingSpacer,
|
|
108102
|
+
prefix: "top"
|
|
108103
|
+
}),
|
|
108104
|
+
/* @__PURE__ */ jsx("div", {
|
|
108105
|
+
style: {
|
|
108106
|
+
position: "relative",
|
|
108107
|
+
height: renderedBandHeight
|
|
108108
|
+
},
|
|
108109
|
+
children: items.map((vItem) => {
|
|
108110
|
+
const item = data[vItem.index];
|
|
108111
|
+
if (item === void 0) return null;
|
|
108112
|
+
const top = vItem.start - topPaddingContent;
|
|
108113
|
+
const child = renderRow(vItem.index, item);
|
|
108114
|
+
if (ItemSlot) return /* @__PURE__ */ jsx("div", {
|
|
108115
|
+
ref: virtualizer.measureElement,
|
|
108116
|
+
"data-index": vItem.index,
|
|
108117
|
+
style: {
|
|
108118
|
+
position: "absolute",
|
|
108119
|
+
top,
|
|
108120
|
+
left: 0,
|
|
108121
|
+
right: 0
|
|
108122
|
+
},
|
|
108123
|
+
children: /* @__PURE__ */ jsx(ItemSlot, {
|
|
108124
|
+
"data-index": vItem.index,
|
|
108125
|
+
"data-item-index": vItem.index,
|
|
108126
|
+
"data-known-size": vItem.size,
|
|
108127
|
+
style: {},
|
|
108128
|
+
children: child
|
|
108129
|
+
})
|
|
108130
|
+
}, vItem.key);
|
|
108131
|
+
return /* @__PURE__ */ jsx("div", {
|
|
108132
|
+
ref: virtualizer.measureElement,
|
|
108133
|
+
"data-index": vItem.index,
|
|
108134
|
+
"data-item-index": vItem.index,
|
|
108135
|
+
"data-known-size": vItem.size,
|
|
108136
|
+
style: {
|
|
108137
|
+
position: "absolute",
|
|
108138
|
+
top,
|
|
108139
|
+
left: 0,
|
|
108140
|
+
right: 0
|
|
108141
|
+
},
|
|
108142
|
+
children: child
|
|
108143
|
+
}, vItem.key);
|
|
108144
|
+
})
|
|
108145
|
+
}),
|
|
108146
|
+
/* @__PURE__ */ jsx(PaddingChunks, {
|
|
108147
|
+
height: bottomPaddingSpacer,
|
|
108148
|
+
prefix: "bot"
|
|
108149
|
+
}),
|
|
108150
|
+
showProgress && (FooterSlot ? /* @__PURE__ */ jsx(FooterSlot, {}) : /* @__PURE__ */ jsx("div", {
|
|
108151
|
+
style: {
|
|
108152
|
+
display: "flex",
|
|
108153
|
+
justifyContent: "center",
|
|
108154
|
+
padding: "1rem"
|
|
108155
|
+
},
|
|
108156
|
+
children: /* @__PURE__ */ jsx(PulsingDots, {
|
|
108157
|
+
subtle: false,
|
|
108158
|
+
size: "medium"
|
|
108159
|
+
})
|
|
108160
|
+
}))
|
|
108161
|
+
]
|
|
108162
|
+
});
|
|
108163
|
+
}
|
|
108164
|
+
var ChatViewVirtualList_module_default = {
|
|
108165
|
+
list: "_list_ejymp_1",
|
|
108166
|
+
generatingRow: "_generatingRow_ejymp_7",
|
|
108167
|
+
generatingLabel: "_generatingLabel_ejymp_15",
|
|
108168
|
+
generatingContent: "_generatingContent_ejymp_19"
|
|
108169
|
+
};
|
|
108170
|
+
var GeneratingIndicator_module_default = {
|
|
108171
|
+
bar: "_bar_pg4l8_1",
|
|
108172
|
+
"gen-sweep": "_gen-sweep_pg4l8_1",
|
|
108173
|
+
barLabelOnly: "_barLabelOnly_pg4l8_34",
|
|
108174
|
+
label: "_label_pg4l8_38",
|
|
108175
|
+
ell: "_ell_pg4l8_47",
|
|
108176
|
+
"gen-ell": "_gen-ell_pg4l8_1",
|
|
108177
|
+
attempt: "_attempt_pg4l8_64"
|
|
108178
|
+
};
|
|
108179
|
+
//#endregion
|
|
108180
|
+
//#region ../../packages/inspect-components/src/chat/GeneratingIndicator.tsx
|
|
108181
|
+
var GeneratingIndicator = ({ attempt, className }) => {
|
|
108182
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
108183
|
+
role: "status",
|
|
108184
|
+
"aria-live": "polite",
|
|
108185
|
+
className: clsx(GeneratingIndicator_module_default.bar, attempt === void 0 && GeneratingIndicator_module_default.barLabelOnly, className),
|
|
108186
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
108187
|
+
className: GeneratingIndicator_module_default.label,
|
|
108188
|
+
children: ["Generating", /* @__PURE__ */ jsxs("span", {
|
|
108189
|
+
className: GeneratingIndicator_module_default.ell,
|
|
108190
|
+
"aria-hidden": "true",
|
|
108191
|
+
children: [
|
|
108192
|
+
/* @__PURE__ */ jsx("i", { children: "." }),
|
|
108193
|
+
/* @__PURE__ */ jsx("i", { children: "." }),
|
|
108194
|
+
/* @__PURE__ */ jsx("i", { children: "." })
|
|
108195
|
+
]
|
|
108196
|
+
})]
|
|
108197
|
+
}), attempt !== void 0 && /* @__PURE__ */ jsxs("span", {
|
|
108198
|
+
className: GeneratingIndicator_module_default.attempt,
|
|
108199
|
+
children: ["attempt ", attempt]
|
|
108200
|
+
})]
|
|
108201
|
+
});
|
|
108202
|
+
};
|
|
108203
|
+
//#endregion
|
|
108204
|
+
//#region ../../packages/inspect-components/src/chat/livePlaceholder.ts
|
|
108205
|
+
function isLivePlaceholderMessage(message) {
|
|
108206
|
+
if (message.role !== "assistant") return false;
|
|
108207
|
+
if (message.tool_calls && message.tool_calls.length > 0) return false;
|
|
108208
|
+
return !messageHasVisibleContent(message);
|
|
108209
|
+
}
|
|
108210
|
+
function messageHasVisibleContent(message) {
|
|
108211
|
+
const content = message.content;
|
|
108212
|
+
if (typeof content === "string") return content.trim().length > 0;
|
|
108213
|
+
if (!Array.isArray(content)) return false;
|
|
108214
|
+
return content.some((c) => {
|
|
108215
|
+
if (c.type === "tool_use") return false;
|
|
108216
|
+
if (c.type === "text") {
|
|
108217
|
+
const hasText = c.text.trim().length > 0;
|
|
108218
|
+
const hasCitations = !!c.citations && c.citations.length > 0;
|
|
108219
|
+
return hasText || hasCitations;
|
|
108220
|
+
}
|
|
108221
|
+
if (c.type === "reasoning") {
|
|
108222
|
+
const hasReasoning = c.reasoning.trim().length > 0;
|
|
108223
|
+
const hasSummary = (c.summary?.trim().length ?? 0) > 0;
|
|
108224
|
+
return hasReasoning || hasSummary;
|
|
108225
|
+
}
|
|
108226
|
+
return true;
|
|
108227
|
+
});
|
|
108228
|
+
}
|
|
106646
108229
|
//#endregion
|
|
106647
108230
|
//#region ../../packages/inspect-components/src/chat/ChatViewVirtualList.tsx
|
|
106648
|
-
var
|
|
108231
|
+
var ChatItem = ({ children, ...props }) => {
|
|
106649
108232
|
return /* @__PURE__ */ jsx("div", {
|
|
106650
108233
|
className: clsx(ChatViewVirtualList_module_default.item),
|
|
106651
108234
|
"data-index": props["data-index"],
|
|
106652
|
-
"data-item-group-index": props["data-item-group-index"],
|
|
106653
108235
|
"data-item-index": props["data-item-index"],
|
|
106654
108236
|
"data-known-size": props["data-known-size"],
|
|
106655
108237
|
style: props.style,
|
|
106656
108238
|
children
|
|
106657
108239
|
});
|
|
106658
108240
|
};
|
|
106659
|
-
var
|
|
108241
|
+
var chatComponents = { Item: ChatItem };
|
|
106660
108242
|
var ChatViewVirtualList = memo(function ChatViewVirtualList({ id, messages, initialMessageId, offsetTop, className, scrollRef, running, onNativeFindChanged, display, labels, linking, tools }) {
|
|
106661
108243
|
const listHandle = useRef(null);
|
|
106662
108244
|
useEffect(() => {
|
|
@@ -106683,37 +108265,52 @@ var ChatViewVirtualList = memo(function ChatViewVirtualList({ id, messages, init
|
|
|
106683
108265
|
return index !== -1 ? index : void 0;
|
|
106684
108266
|
}, [initialMessageId, collapsedMessages]);
|
|
106685
108267
|
const maxLabelLength = useMemo(() => computeMaxLabelLength(labels?.messageLabels), [labels?.messageLabels]);
|
|
106686
|
-
|
|
106687
|
-
|
|
106688
|
-
|
|
106689
|
-
|
|
106690
|
-
|
|
106691
|
-
|
|
106692
|
-
|
|
106693
|
-
|
|
106694
|
-
|
|
106695
|
-
|
|
106696
|
-
|
|
106697
|
-
|
|
106698
|
-
|
|
106699
|
-
|
|
106700
|
-
|
|
106701
|
-
|
|
106702
|
-
|
|
106703
|
-
}, [
|
|
106704
|
-
id,
|
|
108268
|
+
const lastIndex = collapsedMessages.length - 1;
|
|
108269
|
+
const renderRow = useCallback((index, item) => {
|
|
108270
|
+
if (running && index === lastIndex && isLivePlaceholderMessage(item.message)) return /* @__PURE__ */ jsxs("div", {
|
|
108271
|
+
className: ChatViewVirtualList_module_default.generatingRow,
|
|
108272
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
108273
|
+
className: clsx("text-size-smaller", "text-style-secondary", ChatViewVirtualList_module_default.generatingLabel),
|
|
108274
|
+
style: { minWidth: `${maxLabelLength ?? 3}ch` },
|
|
108275
|
+
children: index + 1
|
|
108276
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
108277
|
+
className: ChatViewVirtualList_module_default.generatingContent,
|
|
108278
|
+
children: /* @__PURE__ */ jsx(GeneratingIndicator, {})
|
|
108279
|
+
})]
|
|
108280
|
+
});
|
|
108281
|
+
return /* @__PURE__ */ jsx(ChatMessageRow, {
|
|
108282
|
+
index,
|
|
108283
|
+
parentName: id || "chat-virtual-list",
|
|
108284
|
+
resolvedMessage: item,
|
|
106705
108285
|
display,
|
|
106706
108286
|
labels,
|
|
106707
108287
|
linking,
|
|
106708
108288
|
tools,
|
|
106709
108289
|
maxLabelLength
|
|
106710
|
-
|
|
106711
|
-
|
|
106712
|
-
|
|
108290
|
+
});
|
|
108291
|
+
}, [
|
|
108292
|
+
id,
|
|
108293
|
+
running,
|
|
108294
|
+
lastIndex,
|
|
108295
|
+
display,
|
|
108296
|
+
labels,
|
|
108297
|
+
linking,
|
|
108298
|
+
tools,
|
|
108299
|
+
maxLabelLength
|
|
108300
|
+
]);
|
|
108301
|
+
return /* @__PURE__ */ jsx(VirtualList, {
|
|
108302
|
+
persistenceKey: `chat-${id}`,
|
|
108303
|
+
ref: listHandle,
|
|
108304
|
+
className: clsx(ChatViewVirtualList_module_default.list, className),
|
|
108305
|
+
scrollRef,
|
|
108306
|
+
data: collapsedMessages,
|
|
108307
|
+
renderRow,
|
|
108308
|
+
initialIndex: initialMessageIndex,
|
|
108309
|
+
stickyHeaderOffset: offsetTop,
|
|
106713
108310
|
live: running,
|
|
106714
|
-
|
|
106715
|
-
components:
|
|
106716
|
-
|
|
108311
|
+
scrollToTopOnFinish: true,
|
|
108312
|
+
components: chatComponents,
|
|
108313
|
+
smoothScroll: false,
|
|
106717
108314
|
itemSearchText: messageSearchText
|
|
106718
108315
|
});
|
|
106719
108316
|
});
|
|
@@ -107897,7 +109494,7 @@ function eventToNode(event) {
|
|
|
107897
109494
|
const span = createTimelineSpan(`tool-agent-${event.id}`, agentName, "agent", nestedContent);
|
|
107898
109495
|
span.toolInvoked = true;
|
|
107899
109496
|
const agentResult = extractToolEventResult(event.result);
|
|
107900
|
-
if (agentResult) span.agentResult = agentResult;
|
|
109497
|
+
if (agentResult) span.agentResult = codexResultText(event.function, event.result, agentResult);
|
|
107901
109498
|
return span;
|
|
107902
109499
|
}
|
|
107903
109500
|
}
|
|
@@ -108323,6 +109920,18 @@ function getSpanToolResult(span) {
|
|
|
108323
109920
|
return span.agentResult;
|
|
108324
109921
|
}
|
|
108325
109922
|
/**
|
|
109923
|
+
* Reshape a Codex sub-agent tool result into nicer markdown when applicable
|
|
109924
|
+
* (e.g. `spawn_agent`'s `{agent_id, nickname}` → a compact name line); falls
|
|
109925
|
+
* back to the raw extracted text for non-Codex tools.
|
|
109926
|
+
*/
|
|
109927
|
+
function codexResultText(fn, content, fallback) {
|
|
109928
|
+
if (fn) {
|
|
109929
|
+
const markdown = codexToolMarkdown(fn, content);
|
|
109930
|
+
if (markdown !== void 0) return markdown;
|
|
109931
|
+
}
|
|
109932
|
+
return fallback;
|
|
109933
|
+
}
|
|
109934
|
+
/**
|
|
108326
109935
|
* Extract a string result from a ToolEvent result field.
|
|
108327
109936
|
*/
|
|
108328
109937
|
function extractToolEventResult(result) {
|
|
@@ -108356,7 +109965,7 @@ function extractAgentResults(parent) {
|
|
|
108356
109965
|
}
|
|
108357
109966
|
for (const sibling of content) if (sibling.type === "event" && sibling.event.event === "tool" && sibling.event.agent_span_id === item.id) {
|
|
108358
109967
|
const resultText = extractToolEventResult(sibling.event.result);
|
|
108359
|
-
if (resultText) item.agentResult = resultText;
|
|
109968
|
+
if (resultText) item.agentResult = codexResultText(sibling.event.function, sibling.event.result, resultText);
|
|
108360
109969
|
break;
|
|
108361
109970
|
}
|
|
108362
109971
|
const toolCallId = item.id.startsWith("agent-") ? item.id.slice(6) : null;
|
|
@@ -108368,7 +109977,7 @@ function extractAgentResults(parent) {
|
|
|
108368
109977
|
if (modelEvent.input) {
|
|
108369
109978
|
for (const msg of modelEvent.input) if (msg.role === "tool" && "tool_call_id" in msg && msg.tool_call_id === toolCallId) {
|
|
108370
109979
|
const text = extractToolEventResult(msg.content);
|
|
108371
|
-
if (text) item.agentResult = text;
|
|
109980
|
+
if (text) item.agentResult = codexResultText(msg.function, msg.content, text);
|
|
108372
109981
|
}
|
|
108373
109982
|
}
|
|
108374
109983
|
if (item.agentResult) break;
|
|
@@ -111556,7 +113165,7 @@ function recordRowEvents(agent, rowKey, out) {
|
|
|
111556
113165
|
*/
|
|
111557
113166
|
function findAllMatches(events, term, eventToRow) {
|
|
111558
113167
|
if (!term) return [];
|
|
111559
|
-
const prepared = prepareSearchTerm(term);
|
|
113168
|
+
const prepared = prepareSearchTerm$1(term);
|
|
111560
113169
|
const variants = [
|
|
111561
113170
|
prepared.simple,
|
|
111562
113171
|
...prepared.unquoted ? [prepared.unquoted] : [],
|
|
@@ -118383,16 +119992,16 @@ var messagesFromEvents = (events, stateRef) => {
|
|
|
118383
119992
|
return state.lastResult;
|
|
118384
119993
|
};
|
|
118385
119994
|
var SampleDisplay_module_default = {
|
|
118386
|
-
tabControls: "
|
|
118387
|
-
fullWidth: "
|
|
118388
|
-
metadataPanel: "
|
|
118389
|
-
padded: "
|
|
118390
|
-
error: "
|
|
118391
|
-
ansi: "
|
|
118392
|
-
noTop: "
|
|
118393
|
-
chat: "
|
|
118394
|
-
overflowVisible: "
|
|
118395
|
-
retriedErrors: "
|
|
119995
|
+
tabControls: "_tabControls_1jky3_7",
|
|
119996
|
+
fullWidth: "_fullWidth_1jky3_16",
|
|
119997
|
+
metadataPanel: "_metadataPanel_1jky3_20",
|
|
119998
|
+
padded: "_padded_1jky3_26",
|
|
119999
|
+
error: "_error_1jky3_31",
|
|
120000
|
+
ansi: "_ansi_1jky3_35",
|
|
120001
|
+
noTop: "_noTop_1jky3_39",
|
|
120002
|
+
chat: "_chat_1jky3_43",
|
|
120003
|
+
overflowVisible: "_overflowVisible_1jky3_51",
|
|
120004
|
+
retriedErrors: "_retriedErrors_1jky3_55"
|
|
118396
120005
|
};
|
|
118397
120006
|
//#endregion
|
|
118398
120007
|
//#region src/app/samples/SampleJSONView.tsx
|
|
@@ -150100,7 +151709,7 @@ var SampleFilter = () => {
|
|
|
150100
151709
|
activateOnCompletion: (c) => c.label.endsWith(" ")
|
|
150101
151710
|
}), [filterItems, samples]);
|
|
150102
151711
|
const makeLinter = useCallback(() => linter((view) => getLints(view, filterError)), [filterError]);
|
|
150103
|
-
const debounceSetFilter = useMemo(() => debounce$
|
|
151712
|
+
const debounceSetFilter = useMemo(() => debounce$2((value) => {
|
|
150104
151713
|
setFilter(value);
|
|
150105
151714
|
}, 200), [setFilter]);
|
|
150106
151715
|
const makeUpdateListener = useCallback(() => EditorView.updateListener.of((update) => {
|