@opengeni/react 6.0.0-canary.1 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,7 +63,7 @@ import {
63
63
  useSession,
64
64
  useSessionEvents,
65
65
  useTurnQueue
66
- } from "./chunk-PZ27MCZP.js";
66
+ } from "./chunk-L2NBTKRX.js";
67
67
  import {
68
68
  useComposer
69
69
  } from "./chunk-NYESIADM.js";
@@ -6188,6 +6188,55 @@ function MessageTimeline({
6188
6188
  }, [items, events, shouldRenderAuthNeeded]);
6189
6189
  const sourceItems = events ?? items;
6190
6190
  const olderBoundaryKey = sourceItems?.[0]?.id;
6191
+ const newerBoundaryKey = `${events?.[0]?.sessionId ?? ""}:${olderBoundaryKey ?? ""}`;
6192
+ const newerScopeRef = useRef8(newerBoundaryKey);
6193
+ newerScopeRef.current = newerBoundaryKey;
6194
+ const newerAttemptRef = useRef8(null);
6195
+ const newerRetryButtonRef = useRef8(null);
6196
+ const [newerRetryPending, setNewerRetryPending] = useState15(false);
6197
+ const [newerFailure, setNewerFailure] = useState15(null);
6198
+ useEffect10(() => {
6199
+ newerScopeRef.current = newerBoundaryKey;
6200
+ newerAttemptRef.current = null;
6201
+ setNewerFailure(null);
6202
+ setNewerRetryPending(false);
6203
+ return () => {
6204
+ newerScopeRef.current = "";
6205
+ newerAttemptRef.current = null;
6206
+ };
6207
+ }, [newerBoundaryKey]);
6208
+ const requestNewer = useCallback2(
6209
+ (explicitRetry = false) => {
6210
+ if (newerScopeRef.current !== newerBoundaryKey || !onLoadNewer || loadingNewer || newerAttemptRef.current && (!explicitRetry || newerAttemptRef.current.pending)) {
6211
+ return;
6212
+ }
6213
+ const attempt = { pending: true };
6214
+ newerAttemptRef.current = attempt;
6215
+ if (explicitRetry) setNewerRetryPending(true);
6216
+ const isCurrent = () => newerAttemptRef.current === attempt && newerScopeRef.current === newerBoundaryKey;
6217
+ void Promise.resolve().then(() => isCurrent() ? onLoadNewer() : void 0).then(
6218
+ () => {
6219
+ if (!isCurrent()) return;
6220
+ newerAttemptRef.current = null;
6221
+ if (document.activeElement === newerRetryButtonRef.current) {
6222
+ scrollRef.current?.focus({ preventScroll: true });
6223
+ }
6224
+ setNewerFailure(null);
6225
+ setNewerRetryPending(false);
6226
+ },
6227
+ (reason) => {
6228
+ if (!isCurrent()) return;
6229
+ attempt.pending = false;
6230
+ setNewerRetryPending(false);
6231
+ setNewerFailure({
6232
+ key: newerBoundaryKey,
6233
+ message: reason instanceof Error ? reason.message : String(reason)
6234
+ });
6235
+ }
6236
+ );
6237
+ },
6238
+ [onLoadNewer, loadingNewer, newerBoundaryKey]
6239
+ );
6191
6240
  const previousSourceIdsRef = useRef8(/* @__PURE__ */ new Set());
6192
6241
  const previousSourceBoundaryRef = useRef8(void 0);
6193
6242
  const readingAnchorRef = useRef8(null);
@@ -6951,14 +7000,14 @@ function MessageTimeline({
6951
7000
  const observer = new IntersectionObserver(
6952
7001
  (entries) => {
6953
7002
  if (maxScrollOf(root) > 1 && entries.some((entry) => entry.isIntersecting)) {
6954
- onLoadNewer();
7003
+ requestNewer();
6955
7004
  }
6956
7005
  },
6957
7006
  { root, rootMargin: "0px 0px 1200px 0px" }
6958
7007
  );
6959
7008
  observer.observe(target);
6960
7009
  return () => observer.disconnect();
6961
- }, [hasNewer, loadingNewer, onLoadNewer, firstGroupKey]);
7010
+ }, [hasNewer, loadingNewer, onLoadNewer, requestNewer, firstGroupKey]);
6962
7011
  useEffect10(() => {
6963
7012
  const node = scrollRef.current;
6964
7013
  const inner = node?.firstElementChild;
@@ -7298,6 +7347,32 @@ function MessageTimeline({
7298
7347
  );
7299
7348
  }),
7300
7349
  groups.length > 0 && trailingState ? /* @__PURE__ */ jsx19("div", { "data-og-timeline-trailing-state": "", children: trailingState }) : null,
7350
+ hasNewer && newerFailure?.key === newerBoundaryKey ? /* @__PURE__ */ jsxs13(
7351
+ "div",
7352
+ {
7353
+ "data-og-newer-error": "",
7354
+ className: "flex flex-col items-center gap-2 px-4 py-3 text-center text-og-menu text-og-fg-muted",
7355
+ children: [
7356
+ /* @__PURE__ */ jsxs13("p", { role: "status", className: "max-w-prose [overflow-wrap:anywhere]", children: [
7357
+ "Couldn\u2019t load later activity. ",
7358
+ newerFailure.message
7359
+ ] }),
7360
+ /* @__PURE__ */ jsx19(
7361
+ "button",
7362
+ {
7363
+ ref: newerRetryButtonRef,
7364
+ type: "button",
7365
+ "data-og-retry-newer": "",
7366
+ className: "min-h-11 rounded-og-md border border-og-border px-3 py-2 text-og-fg hover:bg-og-surface-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-og-accent",
7367
+ "aria-disabled": loadingNewer || newerRetryPending,
7368
+ "aria-busy": newerRetryPending,
7369
+ onClick: () => requestNewer(true),
7370
+ children: newerRetryPending ? "Retrying later activity\u2026" : "Retry later activity"
7371
+ }
7372
+ )
7373
+ ]
7374
+ }
7375
+ ) : null,
7301
7376
  hasNewer ? /* @__PURE__ */ jsx19(
7302
7377
  "div",
7303
7378
  {
@@ -9205,9 +9280,7 @@ function Conversation({
9205
9280
  onLoadOlder: feed.loadOlder,
9206
9281
  hasNewer: feed.hasNewer,
9207
9282
  loadingNewer: feed.loadingNewer,
9208
- onLoadNewer: () => {
9209
- void feed.loadNewer();
9210
- },
9283
+ onLoadNewer: feed.loadNewer,
9211
9284
  onJumpToStart: async () => {
9212
9285
  await feed.loadOldest();
9213
9286
  },
@@ -10802,4 +10875,4 @@ export {
10802
10875
  SessionCommandsPanel,
10803
10876
  StartupTimings
10804
10877
  };
10805
- //# sourceMappingURL=chunk-CC7AVRIJ.js.map
10878
+ //# sourceMappingURL=chunk-TDSEILUH.js.map