@opengeni/react 7.1.0 → 7.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/artifacts-document.js +2 -2
- package/dist/artifacts-presentation.js +2 -2
- package/dist/artifacts-spreadsheet.js +2 -2
- package/dist/artifacts.js +4 -4
- package/dist/{browser-viewer-MN7MOYQT.js → browser-viewer-TZ6T76E3.js} +2 -2
- package/dist/{chunk-KCGXPP5V.js → chunk-6P7T4RPE.js} +7 -3
- package/dist/chunk-6P7T4RPE.js.map +1 -0
- package/dist/{chunk-SHRCATV6.js → chunk-7J4DUR3E.js} +12 -5
- package/dist/chunk-7J4DUR3E.js.map +1 -0
- package/dist/{chunk-UQS7BGNQ.js → chunk-CP6IFD2Z.js} +79 -5
- package/dist/chunk-CP6IFD2Z.js.map +1 -0
- package/dist/{chunk-VR4Z73EU.js → chunk-G2SCXNXW.js} +9 -2
- package/dist/chunk-G2SCXNXW.js.map +1 -0
- package/dist/{chunk-5UONOQ3Y.js → chunk-K3MQZO7R.js} +150 -67
- package/dist/chunk-K3MQZO7R.js.map +1 -0
- package/dist/{chunk-OWHPKAOV.js → chunk-L6MYP3QU.js} +4 -2
- package/dist/{chunk-OWHPKAOV.js.map → chunk-L6MYP3QU.js.map} +1 -1
- package/dist/{chunk-ZC2DK5SC.js → chunk-VHEY4CB3.js} +84 -5
- package/dist/chunk-VHEY4CB3.js.map +1 -0
- package/dist/{chunk-XMXRI5JK.js → chunk-ZZ4744OZ.js} +128 -71
- package/dist/chunk-ZZ4744OZ.js.map +1 -0
- package/dist/components/artifacts/artifact-surface.d.ts +3 -1
- package/dist/components/artifacts/document-editor.d.ts +4 -2
- package/dist/components/artifacts/editable-document.d.ts +1 -1
- package/dist/components/artifacts/editable-presentation.d.ts +1 -1
- package/dist/components/artifacts/editable-spreadsheet.d.ts +2 -1
- package/dist/components/artifacts/presentation-editor.d.ts +4 -2
- package/dist/components/browser-viewer.d.ts +4 -1
- package/dist/components/markdown.d.ts +2 -0
- package/dist/components/session-capability-frame.d.ts +5 -1
- package/dist/connect.js +2 -2
- package/dist/hooks/use-browser-session.d.ts +3 -0
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/interaction.js +1 -1
- package/dist/session-ui.js +2 -2
- package/package.json +2 -2
- package/src/components/artifacts/artifact-surface.tsx +39 -19
- package/src/components/artifacts/document-editor.tsx +77 -9
- package/src/components/artifacts/editable-document.tsx +3 -0
- package/src/components/artifacts/editable-presentation.tsx +3 -0
- package/src/components/artifacts/editable-spreadsheet.tsx +3 -0
- package/src/components/artifacts/presentation-editor.tsx +6 -0
- package/src/components/browser-viewer.tsx +10 -0
- package/src/components/markdown.tsx +9 -2
- package/src/components/sandbox-workspace.tsx +1 -0
- package/src/components/session-capability-frame.tsx +11 -3
- package/src/components/session-mcp-capability-card.tsx +174 -70
- package/src/hooks/use-browser-session.ts +107 -3
- package/src/timeline/parsers.ts +2 -2
- package/src/timeline/tool-renderers.tsx +105 -16
- package/src/timeline/turn-summary.tsx +10 -2
- package/styles/compiled.css +6 -0
- package/styles/session-capability.css +2 -0
- package/dist/chunk-5UONOQ3Y.js.map +0 -1
- package/dist/chunk-KCGXPP5V.js.map +0 -1
- package/dist/chunk-SHRCATV6.js.map +0 -1
- package/dist/chunk-UQS7BGNQ.js.map +0 -1
- package/dist/chunk-VR4Z73EU.js.map +0 -1
- package/dist/chunk-XMXRI5JK.js.map +0 -1
- package/dist/chunk-ZC2DK5SC.js.map +0 -1
- /package/dist/{browser-viewer-MN7MOYQT.js.map → browser-viewer-TZ6T76E3.js.map} +0 -0
|
@@ -855,6 +855,13 @@ function useBrowserSession(options) {
|
|
|
855
855
|
const { client, workspaceId } = useEmbeddedBrowserInteraction(options);
|
|
856
856
|
const browserSessionId = options.browserSessionId;
|
|
857
857
|
const enabled = (options.enabled ?? true) && browserSessionId !== null;
|
|
858
|
+
const semanticObservationEnabled = options.semanticObservationEnabled ?? true;
|
|
859
|
+
const semanticObservationEnabledRef = useRef5(semanticObservationEnabled);
|
|
860
|
+
semanticObservationEnabledRef.current = semanticObservationEnabled;
|
|
861
|
+
const previousSemanticObservationRef = useRef5({
|
|
862
|
+
browserSessionId,
|
|
863
|
+
enabled: semanticObservationEnabled
|
|
864
|
+
});
|
|
858
865
|
const pageLive = usePageLiveActivity();
|
|
859
866
|
const pollIntervalMs = Math.max(750, options.pollIntervalMs ?? 2e3);
|
|
860
867
|
const [state, setState] = useState5(() => emptyState4(browserSessionId, enabled));
|
|
@@ -862,7 +869,12 @@ function useBrowserSession(options) {
|
|
|
862
869
|
const refreshBlocked = isNonRetryableInteractionError(visible.error);
|
|
863
870
|
const selectedTargetIdRef = useRef5(visible.selectedTargetId);
|
|
864
871
|
selectedTargetIdRef.current = visible.selectedTargetId;
|
|
872
|
+
const selectedTargetRef = useRef5(
|
|
873
|
+
visible.targets.find((target) => target.id === visible.selectedTargetId) ?? null
|
|
874
|
+
);
|
|
875
|
+
selectedTargetRef.current = visible.targets.find((target) => target.id === visible.selectedTargetId) ?? null;
|
|
865
876
|
const observationRef = useRef5({ browserSessionId, observation: visible.observation });
|
|
877
|
+
const lastObservationAtRef = useRef5(0);
|
|
866
878
|
if (observationRef.current.browserSessionId !== browserSessionId) {
|
|
867
879
|
observationRef.current = {
|
|
868
880
|
browserSessionId,
|
|
@@ -903,19 +915,21 @@ function useBrowserSession(options) {
|
|
|
903
915
|
if (!mountedRef.current || requestRef.current.id !== id) return;
|
|
904
916
|
const selected = chooseTarget(targetResponse.targets, selectedTargetIdRef.current);
|
|
905
917
|
selectedTargetIdRef.current = selected?.id ?? null;
|
|
906
|
-
observationRef.current
|
|
918
|
+
const previousObservation = observationRef.current.browserSessionId === browserSessionId ? observationRef.current.observation : null;
|
|
919
|
+
const retainedObservation = selected && previousObservation && sameObservationTarget(previousObservation, selected) ? previousObservation : null;
|
|
920
|
+
observationRef.current = { browserSessionId, observation: retainedObservation };
|
|
907
921
|
setState(
|
|
908
922
|
(current) => current.browserSessionId === browserSessionId ? {
|
|
909
923
|
...current,
|
|
910
924
|
session,
|
|
911
925
|
targets: targetResponse.targets,
|
|
912
926
|
selectedTargetId: selected?.id ?? null,
|
|
913
|
-
observation:
|
|
927
|
+
observation: retainedObservation,
|
|
914
928
|
loading: false,
|
|
915
929
|
error: null
|
|
916
930
|
} : current
|
|
917
931
|
);
|
|
918
|
-
if (!selected) return;
|
|
932
|
+
if (!selected || !semanticObservationEnabledRef.current) return;
|
|
919
933
|
try {
|
|
920
934
|
const observation = await client.observeBrowserTarget(
|
|
921
935
|
workspaceId,
|
|
@@ -925,6 +939,7 @@ function useBrowserSession(options) {
|
|
|
925
939
|
);
|
|
926
940
|
if (!mountedRef.current || requestRef.current.id !== id) return;
|
|
927
941
|
observationRef.current = { browserSessionId, observation };
|
|
942
|
+
lastObservationAtRef.current = Date.now();
|
|
928
943
|
setState(
|
|
929
944
|
(current) => current.browserSessionId === browserSessionId && current.selectedTargetId === observation.target.id ? { ...current, observation } : current
|
|
930
945
|
);
|
|
@@ -948,6 +963,33 @@ function useBrowserSession(options) {
|
|
|
948
963
|
}
|
|
949
964
|
}
|
|
950
965
|
}, [browserSessionId, client, enabled, workspaceId]);
|
|
966
|
+
const refreshSemantic = useCallback5(async () => {
|
|
967
|
+
if (!enabled || !browserSessionId) return;
|
|
968
|
+
const target = selectedTargetRef.current;
|
|
969
|
+
if (!target) return;
|
|
970
|
+
const id = requestRef.current.id + 1;
|
|
971
|
+
requestRef.current.controller?.abort();
|
|
972
|
+
const controller = new AbortController();
|
|
973
|
+
requestRef.current = { id, controller };
|
|
974
|
+
try {
|
|
975
|
+
const observation = await client.observeBrowserTarget(
|
|
976
|
+
workspaceId,
|
|
977
|
+
browserSessionId,
|
|
978
|
+
target.id,
|
|
979
|
+
{ signal: controller.signal }
|
|
980
|
+
);
|
|
981
|
+
if (!mountedRef.current || requestRef.current.id !== id) return;
|
|
982
|
+
if (!sameObservationTarget(observation, selectedTargetRef.current)) return;
|
|
983
|
+
observationRef.current = { browserSessionId, observation };
|
|
984
|
+
lastObservationAtRef.current = Date.now();
|
|
985
|
+
setState(
|
|
986
|
+
(current) => current.browserSessionId === browserSessionId && current.selectedTargetId === target.id ? { ...current, observation } : current
|
|
987
|
+
);
|
|
988
|
+
} catch {
|
|
989
|
+
} finally {
|
|
990
|
+
if (requestRef.current.id === id) requestRef.current = { id, controller: null };
|
|
991
|
+
}
|
|
992
|
+
}, [browserSessionId, client, enabled, workspaceId]);
|
|
951
993
|
useEffect5(() => {
|
|
952
994
|
mountedRef.current = true;
|
|
953
995
|
if (!enabled) {
|
|
@@ -964,6 +1006,24 @@ function useBrowserSession(options) {
|
|
|
964
1006
|
invalidateRefresh();
|
|
965
1007
|
};
|
|
966
1008
|
}, [browserSessionId, enabled, invalidateRefresh, refresh]);
|
|
1009
|
+
useEffect5(() => {
|
|
1010
|
+
const previous = previousSemanticObservationRef.current;
|
|
1011
|
+
previousSemanticObservationRef.current = {
|
|
1012
|
+
browserSessionId,
|
|
1013
|
+
enabled: semanticObservationEnabled
|
|
1014
|
+
};
|
|
1015
|
+
if (enabled && semanticObservationEnabled && previous.browserSessionId === browserSessionId && !previous.enabled) {
|
|
1016
|
+
const currentObservation = observationRef.current.observation;
|
|
1017
|
+
if (currentObservation && sameObservationTarget(currentObservation, selectedTargetRef.current) && Date.now() - lastObservationAtRef.current < pollIntervalMs) {
|
|
1018
|
+
return;
|
|
1019
|
+
}
|
|
1020
|
+
observationRef.current = { browserSessionId, observation: null };
|
|
1021
|
+
setState(
|
|
1022
|
+
(current) => current.browserSessionId === browserSessionId ? { ...current, observation: null } : current
|
|
1023
|
+
);
|
|
1024
|
+
void refreshSemantic();
|
|
1025
|
+
}
|
|
1026
|
+
}, [browserSessionId, enabled, pollIntervalMs, refreshSemantic, semanticObservationEnabled]);
|
|
967
1027
|
useEffect5(() => {
|
|
968
1028
|
if (!enabled || !pageLive || visible.mutating || refreshBlocked) return;
|
|
969
1029
|
const timer = setInterval(() => {
|
|
@@ -1055,6 +1115,7 @@ function useBrowserSession(options) {
|
|
|
1055
1115
|
}
|
|
1056
1116
|
selectedTargetIdRef.current = target.id;
|
|
1057
1117
|
observationRef.current = { browserSessionId, observation };
|
|
1118
|
+
lastObservationAtRef.current = Date.now();
|
|
1058
1119
|
setState(
|
|
1059
1120
|
(current) => current.browserSessionId === browserSessionId ? {
|
|
1060
1121
|
...current,
|
|
@@ -1083,6 +1144,7 @@ function useBrowserSession(options) {
|
|
|
1083
1144
|
const target = observation.target;
|
|
1084
1145
|
selectedTargetIdRef.current = target.id;
|
|
1085
1146
|
observationRef.current = { browserSessionId, observation };
|
|
1147
|
+
lastObservationAtRef.current = Date.now();
|
|
1086
1148
|
setState(
|
|
1087
1149
|
(current) => current.browserSessionId === browserSessionId ? {
|
|
1088
1150
|
...current,
|
|
@@ -1111,6 +1173,7 @@ function useBrowserSession(options) {
|
|
|
1111
1173
|
const observation = selected ? await client.observeBrowserTarget(workspaceId, browserSessionId, selected.id) : null;
|
|
1112
1174
|
selectedTargetIdRef.current = selected?.id ?? null;
|
|
1113
1175
|
observationRef.current = { browserSessionId, observation };
|
|
1176
|
+
if (observation) lastObservationAtRef.current = Date.now();
|
|
1114
1177
|
setState(
|
|
1115
1178
|
(current) => current.browserSessionId === browserSessionId ? {
|
|
1116
1179
|
...current,
|
|
@@ -1156,6 +1219,7 @@ function useBrowserSession(options) {
|
|
|
1156
1219
|
browserSessionId,
|
|
1157
1220
|
observation: receipt.observation
|
|
1158
1221
|
};
|
|
1222
|
+
lastObservationAtRef.current = Date.now();
|
|
1159
1223
|
setState(
|
|
1160
1224
|
(current) => current.browserSessionId === browserSessionId ? {
|
|
1161
1225
|
...current,
|
|
@@ -1244,6 +1308,9 @@ function replaceTarget(targets, target) {
|
|
|
1244
1308
|
next.push(target);
|
|
1245
1309
|
return next.sort((left, right) => left.createdAt.localeCompare(right.createdAt));
|
|
1246
1310
|
}
|
|
1311
|
+
function sameObservationTarget(observation, target) {
|
|
1312
|
+
return target !== null && observation.target.id === target.id && observation.target.controllerGeneration === target.controllerGeneration && observation.target.targetGeneration === target.targetGeneration && observation.target.documentGeneration === target.documentGeneration;
|
|
1313
|
+
}
|
|
1247
1314
|
function isMissingBrowserTarget(error) {
|
|
1248
1315
|
return error instanceof OpenGeniApiError && error.code === "target_not_found";
|
|
1249
1316
|
}
|
|
@@ -1649,6 +1716,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
1649
1716
|
function BrowserViewer({
|
|
1650
1717
|
sessionId,
|
|
1651
1718
|
enabled = true,
|
|
1719
|
+
active = true,
|
|
1652
1720
|
className,
|
|
1653
1721
|
onNotify,
|
|
1654
1722
|
webSocketFactory,
|
|
@@ -1776,6 +1844,7 @@ function BrowserViewer({
|
|
|
1776
1844
|
);
|
|
1777
1845
|
const controllerReady = selectedRegistrySession?.lifecycle === "active";
|
|
1778
1846
|
const resumeSession = registry.resume;
|
|
1847
|
+
const [hasLiveFrame, setHasLiveFrame] = useState8(false);
|
|
1779
1848
|
const wakeBrowser = useCallback8(
|
|
1780
1849
|
async (session, retry = false) => {
|
|
1781
1850
|
const current = resumeAttemptsRef.current.get(session.id);
|
|
@@ -1830,7 +1899,8 @@ function BrowserViewer({
|
|
|
1830
1899
|
const browser = useBrowserSession({
|
|
1831
1900
|
...override,
|
|
1832
1901
|
browserSessionId: selection?.sessionId ?? null,
|
|
1833
|
-
enabled: enabled && selection !== null && controllerReady
|
|
1902
|
+
enabled: enabled && selection !== null && controllerReady,
|
|
1903
|
+
semanticObservationEnabled: active && !hasLiveFrame
|
|
1834
1904
|
});
|
|
1835
1905
|
useEffect8(() => {
|
|
1836
1906
|
if (!isSourcePlacementChangedError(browser.error, "browser_session")) return;
|
|
@@ -1879,6 +1949,10 @@ function BrowserViewer({
|
|
|
1879
1949
|
browser.session,
|
|
1880
1950
|
browser.selectedTarget
|
|
1881
1951
|
) ? frames.frame : null;
|
|
1952
|
+
const frameIsLive = frames.state === "live" && displayedFrame !== null;
|
|
1953
|
+
useEffect8(() => {
|
|
1954
|
+
setHasLiveFrame(frameIsLive);
|
|
1955
|
+
}, [frameIsLive]);
|
|
1882
1956
|
const supportsLiveFrames = browser.session?.capabilities.liveFrames === true;
|
|
1883
1957
|
const displayConnectionState = supportsLiveFrames ? frames.state === "live" && !displayedFrame ? "connecting" : frames.state : "semantic";
|
|
1884
1958
|
const selectedProfile = useMemo2(
|
|
@@ -3904,4 +3978,4 @@ export {
|
|
|
3904
3978
|
useBrowserFrameStream,
|
|
3905
3979
|
BrowserViewer
|
|
3906
3980
|
};
|
|
3907
|
-
//# sourceMappingURL=chunk-
|
|
3981
|
+
//# sourceMappingURL=chunk-CP6IFD2Z.js.map
|