@docyrus/ui-pro-ai-assistant 0.8.1 → 0.8.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.
@@ -11,12 +11,6 @@ interface AgentConsentDialogProps {
11
11
  onDeclined: () => void;
12
12
  t: (key: string) => string;
13
13
  }
14
- /**
15
- * Gates the assistant behind an agent's "Terms & Agreement" consent.
16
- *
17
- * Shown (non-closable) the first time an agent is used (`agent.consent` is
18
- * falsy). Only `super_admin` users can approve; everyone else sees the terms
19
- * but the Approve button stays disabled — mirroring the Vue `KvAssistantView`.
20
- */
14
+ /** Agent "Terms & Agreement" consent gate. Only `super_admin` can approve. */
21
15
  export declare function AgentConsentDialog({ pending, onApproved, onDeclined, t }: AgentConsentDialogProps): import("react/jsx-runtime").JSX.Element;
22
16
  export {};
@@ -33,16 +33,11 @@ interface UseAssistantApiReturn {
33
33
  * an in-flight tool call (e.g. switch to AdaptiveCard rendering).
34
34
  */
35
35
  agentTools: Array<Record<string, any>>;
36
- /**
37
- * Set when the active agent requires consent that has not been given yet
38
- * (`agent.consent` is falsy). `null` once consent is satisfied. Drives the
39
- * "Terms & Agreement" gate. Mirrors the Vue `KvAssistantView` consent flow.
40
- */
36
+ /** Set when the active agent needs consent (not yet given); `null` once satisfied. */
41
37
  consentRequiredFor: {
42
38
  agentId: string;
43
39
  deploymentId?: string;
44
40
  } | null;
45
- /** Clears the pending consent (call after approve, or to dismiss the gate). */
46
41
  setConsentRequiredFor: (value: {
47
42
  agentId: string;
48
43
  deploymentId?: string;
package/dist/index.js CHANGED
@@ -36642,6 +36642,16 @@ var DocyAssistant = ({
36642
36642
  });
36643
36643
  const activeAgentMatchesDetails = agentDetailsForId === activeAgentId;
36644
36644
  const liveAgentDetails = activeAgentMatchesDetails ? agentDetails : null;
36645
+ const consentStatusUnknown = !!activeAgentId && !activeAgentMatchesDetails;
36646
+ const consentGated = !!consentRequiredFor || consentStatusUnknown;
36647
+ const [declinedConsentAgentId, setDeclinedConsentAgentId] = useState(null);
36648
+ const consentTabRef = useRef(activeTabId);
36649
+ if (consentTabRef.current !== activeTabId) {
36650
+ consentTabRef.current = activeTabId;
36651
+ if (declinedConsentAgentId !== null) setDeclinedConsentAgentId(null);
36652
+ }
36653
+ const consentDeclined = !!consentRequiredFor && declinedConsentAgentId === consentRequiredFor.agentId;
36654
+ const consentDialogPending = uiState.activeTab === 0 && !consentDeclined ? consentRequiredFor : null;
36645
36655
  useEffect(() => {
36646
36656
  if (!agentDetailsForId || !agentDetails) return;
36647
36657
  setTabs((prev) => {
@@ -37238,7 +37248,7 @@ var DocyAssistant = ({
37238
37248
  onClearAppContext: clearAppContext,
37239
37249
  chatError,
37240
37250
  onDismissChatError: () => setChatError(null),
37241
- consentRequired: !!consentRequiredFor,
37251
+ consentRequired: consentGated,
37242
37252
  initialModelId,
37243
37253
  initialFeatures,
37244
37254
  enableMicrophone,
@@ -37636,10 +37646,13 @@ var DocyAssistant = ({
37636
37646
  /* @__PURE__ */ jsx(
37637
37647
  AgentConsentDialog,
37638
37648
  {
37639
- pending: consentRequiredFor,
37640
- onApproved: () => setConsentRequiredFor(null),
37649
+ pending: consentDialogPending,
37650
+ onApproved: () => {
37651
+ setConsentRequiredFor(null);
37652
+ setDeclinedConsentAgentId(null);
37653
+ },
37641
37654
  onDeclined: () => {
37642
- onClose?.();
37655
+ setDeclinedConsentAgentId(consentRequiredFor?.agentId ?? null);
37643
37656
  },
37644
37657
  t
37645
37658
  }