@arbidocs/react 0.5.143 → 0.5.145

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.
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { useEffect, useMemo, useState } from "react";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
3
  import { ArbiHost } from "../host/index.js";
4
4
  import { createArbiSessionStore, useArbiSessionState } from "../session/index.js";
5
5
  function ConversationScope({
@@ -18,8 +18,11 @@ function ConversationScope({
18
18
  useEffect(() => {
19
19
  session.setWorkspaceId(scopeWorkspaceId);
20
20
  }, [session, scopeWorkspaceId]);
21
+ const opened = useRef(conversationId);
21
22
  useEffect(() => {
22
- if (conversationId !== void 0) session.setConversationId(conversationId);
23
+ if (conversationId === void 0 || conversationId === opened.current) return;
24
+ opened.current = conversationId;
25
+ session.setConversationId(conversationId);
23
26
  }, [session, conversationId]);
24
27
  const config = useMemo(() => ({ session }), [session]);
25
28
  return /* @__PURE__ */ jsx(ArbiHost, { config, children });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/chat/ConversationScope.tsx"],
4
- "sourcesContent": ["/**\n * A session of its own for a chat surface: inside it, `useConversation` (and the rest of the chat\n * engine) keeps its own open conversation, line and composer, so a docked or embedded chat does\n * not switch the page's main conversation, and the page does not switch it. Everything else in the\n * host configuration (the client, the host's chat callbacks) is the enclosing host's.\n */\n\nimport { useEffect, useMemo, useState, type ReactNode } from 'react'\nimport { ArbiHost } from '../host'\nimport { createArbiSessionStore, useArbiSessionState } from '../session'\n\nexport interface ConversationScopeProps {\n /** The workspace the scoped chat is in (default: the enclosing session's). */\n workspaceId?: string | null\n /** The conversation it opens on (default: a new chat). */\n conversationId?: string | null\n children: ReactNode\n}\n\nexport function ConversationScope({\n workspaceId,\n conversationId,\n children,\n}: ConversationScopeProps) {\n const outerWorkspaceId = useArbiSessionState((s) => s.workspaceId)\n const scopeWorkspaceId = workspaceId ?? outerWorkspaceId\n const [session] = useState(() =>\n createArbiSessionStore({\n workspaceId: scopeWorkspaceId,\n conversationId: conversationId ?? null,\n })\n )\n useEffect(() => {\n session.setWorkspaceId(scopeWorkspaceId)\n }, [session, scopeWorkspaceId])\n useEffect(() => {\n if (conversationId !== undefined) session.setConversationId(conversationId)\n }, [session, conversationId])\n const config = useMemo(() => ({ session }), [session])\n return <ArbiHost config={config}>{children}</ArbiHost>\n}\n"],
5
- "mappings": "AAuCS;AAhCT,SAAS,WAAW,SAAS,gBAAgC;AAC7D,SAAS,gBAAgB;AACzB,SAAS,wBAAwB,2BAA2B;AAUrD,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACF,GAA2B;AACzB,QAAM,mBAAmB,oBAAoB,CAAC,MAAM,EAAE,WAAW;AACjE,QAAM,mBAAmB,eAAe;AACxC,QAAM,CAAC,OAAO,IAAI;AAAA,IAAS,MACzB,uBAAuB;AAAA,MACrB,aAAa;AAAA,MACb,gBAAgB,kBAAkB;AAAA,IACpC,CAAC;AAAA,EACH;AACA,YAAU,MAAM;AACd,YAAQ,eAAe,gBAAgB;AAAA,EACzC,GAAG,CAAC,SAAS,gBAAgB,CAAC;AAC9B,YAAU,MAAM;AACd,QAAI,mBAAmB,OAAW,SAAQ,kBAAkB,cAAc;AAAA,EAC5E,GAAG,CAAC,SAAS,cAAc,CAAC;AAC5B,QAAM,SAAS,QAAQ,OAAO,EAAE,QAAQ,IAAI,CAAC,OAAO,CAAC;AACrD,SAAO,oBAAC,YAAS,QAAiB,UAAS;AAC7C;",
4
+ "sourcesContent": ["/**\n * A session of its own for a chat surface: inside it, `useConversation` (and the rest of the chat\n * engine) keeps its own open conversation, line and composer, so a docked or embedded chat does\n * not switch the page's main conversation, and the page does not switch it. Everything else in the\n * host configuration (the client, the host's chat callbacks) is the enclosing host's.\n */\n\nimport { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'\nimport { ArbiHost } from '../host'\nimport { createArbiSessionStore, useArbiSessionState } from '../session'\n\nexport interface ConversationScopeProps {\n /** The workspace the scoped chat is in (default: the enclosing session's). */\n workspaceId?: string | null\n /** The conversation it opens on (default: a new chat). */\n conversationId?: string | null\n children: ReactNode\n}\n\nexport function ConversationScope({\n workspaceId,\n conversationId,\n children,\n}: ConversationScopeProps) {\n const outerWorkspaceId = useArbiSessionState((s) => s.workspaceId)\n const scopeWorkspaceId = workspaceId ?? outerWorkspaceId\n const [session] = useState(() =>\n createArbiSessionStore({\n workspaceId: scopeWorkspaceId,\n conversationId: conversationId ?? null,\n })\n )\n useEffect(() => {\n session.setWorkspaceId(scopeWorkspaceId)\n }, [session, scopeWorkspaceId])\n // Only a change opens another conversation: the store starts on `conversationId`. Opening it\n // again once mounted (after the chat inside has set up its new chat) would reset that new chat,\n // e.g. an agent card's chat lost its agent and its first turn ran as the person.\n const opened = useRef(conversationId)\n useEffect(() => {\n if (conversationId === undefined || conversationId === opened.current) return\n opened.current = conversationId\n session.setConversationId(conversationId)\n }, [session, conversationId])\n const config = useMemo(() => ({ session }), [session])\n return <ArbiHost config={config}>{children}</ArbiHost>\n}\n"],
5
+ "mappings": "AA6CS;AAtCT,SAAS,WAAW,SAAS,QAAQ,gBAAgC;AACrE,SAAS,gBAAgB;AACzB,SAAS,wBAAwB,2BAA2B;AAUrD,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACF,GAA2B;AACzB,QAAM,mBAAmB,oBAAoB,CAAC,MAAM,EAAE,WAAW;AACjE,QAAM,mBAAmB,eAAe;AACxC,QAAM,CAAC,OAAO,IAAI;AAAA,IAAS,MACzB,uBAAuB;AAAA,MACrB,aAAa;AAAA,MACb,gBAAgB,kBAAkB;AAAA,IACpC,CAAC;AAAA,EACH;AACA,YAAU,MAAM;AACd,YAAQ,eAAe,gBAAgB;AAAA,EACzC,GAAG,CAAC,SAAS,gBAAgB,CAAC;AAI9B,QAAM,SAAS,OAAO,cAAc;AACpC,YAAU,MAAM;AACd,QAAI,mBAAmB,UAAa,mBAAmB,OAAO,QAAS;AACvE,WAAO,UAAU;AACjB,YAAQ,kBAAkB,cAAc;AAAA,EAC1C,GAAG,CAAC,SAAS,cAAc,CAAC;AAC5B,QAAM,SAAS,QAAQ,OAAO,EAAE,QAAQ,IAAI,CAAC,OAAO,CAAC;AACrD,SAAO,oBAAC,YAAS,QAAiB,UAAS;AAC7C;",
6
6
  "names": []
7
7
  }
@@ -2370,6 +2370,7 @@ function SharingEntity({
2370
2370
  const [open, setOpen] = React.useState(false);
2371
2371
  const lastPointer = React.useRef("mouse");
2372
2372
  const canToggle = !!onToggle && !disabled;
2373
+ const blocked = !!onToggle && disabled;
2373
2374
  const label = shared ? SHARING_LABELS.workspace : SHARING_LABELS.onlyMe;
2374
2375
  const hint = disabled ? disabledTooltip : shared ? tooltipActive : tooltipInactive;
2375
2376
  const handleClick = (e) => {
@@ -2395,7 +2396,8 @@ function SharingEntity({
2395
2396
  "data-testid": testId
2396
2397
  }
2397
2398
  );
2398
- if (!shared) return pill;
2399
+ if (!shared)
2400
+ return blocked ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex", "aria-disabled": "true", children: pill }) : pill;
2399
2401
  return /* @__PURE__ */ jsxRuntime.jsxs(HoverCard, { open, onOpenChange: setOpen, openDelay: 200, closeDelay: 100, children: [
2400
2402
  /* @__PURE__ */ jsxRuntime.jsx(
2401
2403
  HoverCardTrigger,
@@ -2410,6 +2412,7 @@ function SharingEntity({
2410
2412
  className: "inline-flex",
2411
2413
  role: "group",
2412
2414
  "aria-label": `${SHARING_LABELS.workspace}: shared with all workspace members`,
2415
+ "aria-disabled": blocked || void 0,
2413
2416
  children: pill
2414
2417
  }
2415
2418
  )
@@ -5331,5 +5334,5 @@ exports.toggleVariants = toggleVariants;
5331
5334
  exports.useAudioRecorder = useAudioRecorder;
5332
5335
  exports.useDictateContext = useDictateContext;
5333
5336
  exports.usesOriginalBytesForViewer = usesOriginalBytesForViewer;
5334
- //# sourceMappingURL=chunk-4NGWDVHD.cjs.map
5335
- //# sourceMappingURL=chunk-4NGWDVHD.cjs.map
5337
+ //# sourceMappingURL=chunk-B6T54X65.cjs.map
5338
+ //# sourceMappingURL=chunk-B6T54X65.cjs.map