@opengeni/react 7.1.0 → 7.1.2-canary.36079201993001

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.
Files changed (78) hide show
  1. package/dist/artifacts-document.js +2 -2
  2. package/dist/artifacts-presentation.js +2 -2
  3. package/dist/artifacts-spreadsheet.js +2 -2
  4. package/dist/artifacts.js +4 -4
  5. package/dist/{browser-viewer-MN7MOYQT.js → browser-viewer-K2H3SLIW.js} +2 -2
  6. package/dist/{chunk-4ACTWOOW.js → chunk-6N3AZUOV.js} +31 -14
  7. package/dist/chunk-6N3AZUOV.js.map +1 -0
  8. package/dist/{chunk-KCGXPP5V.js → chunk-6P7T4RPE.js} +7 -3
  9. package/dist/chunk-6P7T4RPE.js.map +1 -0
  10. package/dist/{chunk-SHRCATV6.js → chunk-7J4DUR3E.js} +12 -5
  11. package/dist/chunk-7J4DUR3E.js.map +1 -0
  12. package/dist/{chunk-ZC2DK5SC.js → chunk-AWIX4UAC.js} +88 -7
  13. package/dist/chunk-AWIX4UAC.js.map +1 -0
  14. package/dist/{chunk-UQS7BGNQ.js → chunk-ETA37UZ7.js} +82 -11
  15. package/dist/chunk-ETA37UZ7.js.map +1 -0
  16. package/dist/{chunk-VR4Z73EU.js → chunk-G2SCXNXW.js} +9 -2
  17. package/dist/chunk-G2SCXNXW.js.map +1 -0
  18. package/dist/{chunk-5UONOQ3Y.js → chunk-K3MQZO7R.js} +150 -67
  19. package/dist/chunk-K3MQZO7R.js.map +1 -0
  20. package/dist/{chunk-OWHPKAOV.js → chunk-L6MYP3QU.js} +4 -2
  21. package/dist/{chunk-OWHPKAOV.js.map → chunk-L6MYP3QU.js.map} +1 -1
  22. package/dist/{chunk-VI7HELBI.js → chunk-SJ5HE4ZA.js} +21 -2
  23. package/dist/chunk-SJ5HE4ZA.js.map +1 -0
  24. package/dist/{chunk-XMXRI5JK.js → chunk-ZZ4744OZ.js} +128 -71
  25. package/dist/chunk-ZZ4744OZ.js.map +1 -0
  26. package/dist/components/artifacts/artifact-surface.d.ts +3 -1
  27. package/dist/components/artifacts/document-editor.d.ts +4 -2
  28. package/dist/components/artifacts/editable-document.d.ts +1 -1
  29. package/dist/components/artifacts/editable-presentation.d.ts +1 -1
  30. package/dist/components/artifacts/editable-spreadsheet.d.ts +2 -1
  31. package/dist/components/artifacts/presentation-editor.d.ts +4 -2
  32. package/dist/components/browser-viewer.d.ts +4 -1
  33. package/dist/components/markdown.d.ts +2 -0
  34. package/dist/components/session-capability-frame.d.ts +5 -1
  35. package/dist/composer.js +1 -1
  36. package/dist/connect.js +2 -2
  37. package/dist/hooks/use-browser-session.d.ts +3 -0
  38. package/dist/index.js +7 -6
  39. package/dist/index.js.map +1 -1
  40. package/dist/interaction.js +1 -1
  41. package/dist/session-ui.js +4 -4
  42. package/dist/session.js +1 -1
  43. package/dist/timeline/types.d.ts +2 -0
  44. package/package.json +3 -3
  45. package/src/components/artifacts/artifact-surface.tsx +39 -19
  46. package/src/components/artifacts/document-editor.tsx +77 -9
  47. package/src/components/artifacts/editable-document.tsx +3 -0
  48. package/src/components/artifacts/editable-presentation.tsx +3 -0
  49. package/src/components/artifacts/editable-spreadsheet.tsx +3 -0
  50. package/src/components/artifacts/presentation-editor.tsx +6 -0
  51. package/src/components/browser-viewer.tsx +11 -5
  52. package/src/components/composer-transcription-control.tsx +4 -2
  53. package/src/components/composer.tsx +20 -9
  54. package/src/components/markdown.tsx +9 -2
  55. package/src/components/sandbox-workspace.tsx +1 -0
  56. package/src/components/session-capability-frame.tsx +11 -3
  57. package/src/components/session-mcp-capability-card.tsx +174 -70
  58. package/src/hooks/use-browser-frame-stream.ts +3 -1
  59. package/src/hooks/use-browser-session.ts +107 -3
  60. package/src/hooks/use-voice-input.ts +12 -1
  61. package/src/timeline/compaction-copy.ts +2 -0
  62. package/src/timeline/parsers.ts +2 -2
  63. package/src/timeline/projection.ts +31 -5
  64. package/src/timeline/tool-renderers.tsx +105 -16
  65. package/src/timeline/turn-summary.tsx +10 -2
  66. package/src/timeline/types.ts +2 -0
  67. package/styles/compiled.css +6 -0
  68. package/styles/session-capability.css +2 -0
  69. package/dist/chunk-4ACTWOOW.js.map +0 -1
  70. package/dist/chunk-5UONOQ3Y.js.map +0 -1
  71. package/dist/chunk-KCGXPP5V.js.map +0 -1
  72. package/dist/chunk-SHRCATV6.js.map +0 -1
  73. package/dist/chunk-UQS7BGNQ.js.map +0 -1
  74. package/dist/chunk-VI7HELBI.js.map +0 -1
  75. package/dist/chunk-VR4Z73EU.js.map +0 -1
  76. package/dist/chunk-XMXRI5JK.js.map +0 -1
  77. package/dist/chunk-ZC2DK5SC.js.map +0 -1
  78. /package/dist/{browser-viewer-MN7MOYQT.js.map → browser-viewer-K2H3SLIW.js.map} +0 -0
@@ -74,7 +74,8 @@ var RELAY_TAG_CLOSE = 4;
74
74
  var MAX_AUTOMATIC_RECONNECTS_WITHOUT_A_FRAME = 2;
75
75
  function useBrowserFrameStream(options) {
76
76
  const { client, workspaceId } = useEmbeddedBrowserInteraction(options);
77
- const enabled = options.enabled ?? true;
77
+ const pageLive = usePageLiveActivity();
78
+ const enabled = (options.enabled ?? true) && pageLive;
78
79
  const [nonce, setNonce] = useState(0);
79
80
  const [result, setResult] = useState({
80
81
  state: "idle",
@@ -855,6 +856,13 @@ function useBrowserSession(options) {
855
856
  const { client, workspaceId } = useEmbeddedBrowserInteraction(options);
856
857
  const browserSessionId = options.browserSessionId;
857
858
  const enabled = (options.enabled ?? true) && browserSessionId !== null;
859
+ const semanticObservationEnabled = options.semanticObservationEnabled ?? true;
860
+ const semanticObservationEnabledRef = useRef5(semanticObservationEnabled);
861
+ semanticObservationEnabledRef.current = semanticObservationEnabled;
862
+ const previousSemanticObservationRef = useRef5({
863
+ browserSessionId,
864
+ enabled: semanticObservationEnabled
865
+ });
858
866
  const pageLive = usePageLiveActivity();
859
867
  const pollIntervalMs = Math.max(750, options.pollIntervalMs ?? 2e3);
860
868
  const [state, setState] = useState5(() => emptyState4(browserSessionId, enabled));
@@ -862,7 +870,12 @@ function useBrowserSession(options) {
862
870
  const refreshBlocked = isNonRetryableInteractionError(visible.error);
863
871
  const selectedTargetIdRef = useRef5(visible.selectedTargetId);
864
872
  selectedTargetIdRef.current = visible.selectedTargetId;
873
+ const selectedTargetRef = useRef5(
874
+ visible.targets.find((target) => target.id === visible.selectedTargetId) ?? null
875
+ );
876
+ selectedTargetRef.current = visible.targets.find((target) => target.id === visible.selectedTargetId) ?? null;
865
877
  const observationRef = useRef5({ browserSessionId, observation: visible.observation });
878
+ const lastObservationAtRef = useRef5(0);
866
879
  if (observationRef.current.browserSessionId !== browserSessionId) {
867
880
  observationRef.current = {
868
881
  browserSessionId,
@@ -903,19 +916,21 @@ function useBrowserSession(options) {
903
916
  if (!mountedRef.current || requestRef.current.id !== id) return;
904
917
  const selected = chooseTarget(targetResponse.targets, selectedTargetIdRef.current);
905
918
  selectedTargetIdRef.current = selected?.id ?? null;
906
- observationRef.current = { browserSessionId, observation: null };
919
+ const previousObservation = observationRef.current.browserSessionId === browserSessionId ? observationRef.current.observation : null;
920
+ const retainedObservation = selected && previousObservation && sameObservationTarget(previousObservation, selected) ? previousObservation : null;
921
+ observationRef.current = { browserSessionId, observation: retainedObservation };
907
922
  setState(
908
923
  (current) => current.browserSessionId === browserSessionId ? {
909
924
  ...current,
910
925
  session,
911
926
  targets: targetResponse.targets,
912
927
  selectedTargetId: selected?.id ?? null,
913
- observation: null,
928
+ observation: retainedObservation,
914
929
  loading: false,
915
930
  error: null
916
931
  } : current
917
932
  );
918
- if (!selected) return;
933
+ if (!selected || !semanticObservationEnabledRef.current) return;
919
934
  try {
920
935
  const observation = await client.observeBrowserTarget(
921
936
  workspaceId,
@@ -925,6 +940,7 @@ function useBrowserSession(options) {
925
940
  );
926
941
  if (!mountedRef.current || requestRef.current.id !== id) return;
927
942
  observationRef.current = { browserSessionId, observation };
943
+ lastObservationAtRef.current = Date.now();
928
944
  setState(
929
945
  (current) => current.browserSessionId === browserSessionId && current.selectedTargetId === observation.target.id ? { ...current, observation } : current
930
946
  );
@@ -948,6 +964,33 @@ function useBrowserSession(options) {
948
964
  }
949
965
  }
950
966
  }, [browserSessionId, client, enabled, workspaceId]);
967
+ const refreshSemantic = useCallback5(async () => {
968
+ if (!enabled || !browserSessionId) return;
969
+ const target = selectedTargetRef.current;
970
+ if (!target) return;
971
+ const id = requestRef.current.id + 1;
972
+ requestRef.current.controller?.abort();
973
+ const controller = new AbortController();
974
+ requestRef.current = { id, controller };
975
+ try {
976
+ const observation = await client.observeBrowserTarget(
977
+ workspaceId,
978
+ browserSessionId,
979
+ target.id,
980
+ { signal: controller.signal }
981
+ );
982
+ if (!mountedRef.current || requestRef.current.id !== id) return;
983
+ if (!sameObservationTarget(observation, selectedTargetRef.current)) return;
984
+ observationRef.current = { browserSessionId, observation };
985
+ lastObservationAtRef.current = Date.now();
986
+ setState(
987
+ (current) => current.browserSessionId === browserSessionId && current.selectedTargetId === target.id ? { ...current, observation } : current
988
+ );
989
+ } catch {
990
+ } finally {
991
+ if (requestRef.current.id === id) requestRef.current = { id, controller: null };
992
+ }
993
+ }, [browserSessionId, client, enabled, workspaceId]);
951
994
  useEffect5(() => {
952
995
  mountedRef.current = true;
953
996
  if (!enabled) {
@@ -964,6 +1007,24 @@ function useBrowserSession(options) {
964
1007
  invalidateRefresh();
965
1008
  };
966
1009
  }, [browserSessionId, enabled, invalidateRefresh, refresh]);
1010
+ useEffect5(() => {
1011
+ const previous = previousSemanticObservationRef.current;
1012
+ previousSemanticObservationRef.current = {
1013
+ browserSessionId,
1014
+ enabled: semanticObservationEnabled
1015
+ };
1016
+ if (enabled && semanticObservationEnabled && previous.browserSessionId === browserSessionId && !previous.enabled) {
1017
+ const currentObservation = observationRef.current.observation;
1018
+ if (currentObservation && sameObservationTarget(currentObservation, selectedTargetRef.current) && Date.now() - lastObservationAtRef.current < pollIntervalMs) {
1019
+ return;
1020
+ }
1021
+ observationRef.current = { browserSessionId, observation: null };
1022
+ setState(
1023
+ (current) => current.browserSessionId === browserSessionId ? { ...current, observation: null } : current
1024
+ );
1025
+ void refreshSemantic();
1026
+ }
1027
+ }, [browserSessionId, enabled, pollIntervalMs, refreshSemantic, semanticObservationEnabled]);
967
1028
  useEffect5(() => {
968
1029
  if (!enabled || !pageLive || visible.mutating || refreshBlocked) return;
969
1030
  const timer = setInterval(() => {
@@ -1055,6 +1116,7 @@ function useBrowserSession(options) {
1055
1116
  }
1056
1117
  selectedTargetIdRef.current = target.id;
1057
1118
  observationRef.current = { browserSessionId, observation };
1119
+ lastObservationAtRef.current = Date.now();
1058
1120
  setState(
1059
1121
  (current) => current.browserSessionId === browserSessionId ? {
1060
1122
  ...current,
@@ -1083,6 +1145,7 @@ function useBrowserSession(options) {
1083
1145
  const target = observation.target;
1084
1146
  selectedTargetIdRef.current = target.id;
1085
1147
  observationRef.current = { browserSessionId, observation };
1148
+ lastObservationAtRef.current = Date.now();
1086
1149
  setState(
1087
1150
  (current) => current.browserSessionId === browserSessionId ? {
1088
1151
  ...current,
@@ -1111,6 +1174,7 @@ function useBrowserSession(options) {
1111
1174
  const observation = selected ? await client.observeBrowserTarget(workspaceId, browserSessionId, selected.id) : null;
1112
1175
  selectedTargetIdRef.current = selected?.id ?? null;
1113
1176
  observationRef.current = { browserSessionId, observation };
1177
+ if (observation) lastObservationAtRef.current = Date.now();
1114
1178
  setState(
1115
1179
  (current) => current.browserSessionId === browserSessionId ? {
1116
1180
  ...current,
@@ -1156,6 +1220,7 @@ function useBrowserSession(options) {
1156
1220
  browserSessionId,
1157
1221
  observation: receipt.observation
1158
1222
  };
1223
+ lastObservationAtRef.current = Date.now();
1159
1224
  setState(
1160
1225
  (current) => current.browserSessionId === browserSessionId ? {
1161
1226
  ...current,
@@ -1244,6 +1309,9 @@ function replaceTarget(targets, target) {
1244
1309
  next.push(target);
1245
1310
  return next.sort((left, right) => left.createdAt.localeCompare(right.createdAt));
1246
1311
  }
1312
+ function sameObservationTarget(observation, target) {
1313
+ return target !== null && observation.target.id === target.id && observation.target.controllerGeneration === target.controllerGeneration && observation.target.targetGeneration === target.targetGeneration && observation.target.documentGeneration === target.documentGeneration;
1314
+ }
1247
1315
  function isMissingBrowserTarget(error) {
1248
1316
  return error instanceof OpenGeniApiError && error.code === "target_not_found";
1249
1317
  }
@@ -1649,6 +1717,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
1649
1717
  function BrowserViewer({
1650
1718
  sessionId,
1651
1719
  enabled = true,
1720
+ active = true,
1652
1721
  className,
1653
1722
  onNotify,
1654
1723
  webSocketFactory,
@@ -1776,6 +1845,7 @@ function BrowserViewer({
1776
1845
  );
1777
1846
  const controllerReady = selectedRegistrySession?.lifecycle === "active";
1778
1847
  const resumeSession = registry.resume;
1848
+ const [hasLiveFrame, setHasLiveFrame] = useState8(false);
1779
1849
  const wakeBrowser = useCallback8(
1780
1850
  async (session, retry = false) => {
1781
1851
  const current = resumeAttemptsRef.current.get(session.id);
@@ -1821,16 +1891,13 @@ function BrowserViewer({
1821
1891
  setResumeAttempt(
1822
1892
  (visible) => visible?.sessionId === selectedRegistrySession.id ? null : visible
1823
1893
  );
1824
- return;
1825
1894
  }
1826
- if (selectedRegistrySession.lifecycle === "suspended") {
1827
- void wakeBrowser(selectedRegistrySession);
1828
- }
1829
- }, [selectedRegistrySession, wakeBrowser]);
1895
+ }, [selectedRegistrySession]);
1830
1896
  const browser = useBrowserSession({
1831
1897
  ...override,
1832
1898
  browserSessionId: selection?.sessionId ?? null,
1833
- enabled: enabled && selection !== null && controllerReady
1899
+ enabled: enabled && selection !== null && controllerReady,
1900
+ semanticObservationEnabled: active && !hasLiveFrame
1834
1901
  });
1835
1902
  useEffect8(() => {
1836
1903
  if (!isSourcePlacementChangedError(browser.error, "browser_session")) return;
@@ -1879,6 +1946,10 @@ function BrowserViewer({
1879
1946
  browser.session,
1880
1947
  browser.selectedTarget
1881
1948
  ) ? frames.frame : null;
1949
+ const frameIsLive = frames.state === "live" && displayedFrame !== null;
1950
+ useEffect8(() => {
1951
+ setHasLiveFrame(frameIsLive);
1952
+ }, [frameIsLive]);
1882
1953
  const supportsLiveFrames = browser.session?.capabilities.liveFrames === true;
1883
1954
  const displayConnectionState = supportsLiveFrames ? frames.state === "live" && !displayedFrame ? "connecting" : frames.state : "semantic";
1884
1955
  const selectedProfile = useMemo2(
@@ -3904,4 +3975,4 @@ export {
3904
3975
  useBrowserFrameStream,
3905
3976
  BrowserViewer
3906
3977
  };
3907
- //# sourceMappingURL=chunk-UQS7BGNQ.js.map
3978
+ //# sourceMappingURL=chunk-ETA37UZ7.js.map