Line data Source code
1 : import { useCurrentUser } from '@/composables/auth/useCurrentUser'
2 : import type { FeedbackSource } from '@/platform/support/config'
3 : import { openFeedbackDialog as openGeneralFeedbackDialog } from '@/platform/support/feedbackDialog'
4 :
5 : import { agentClientSessionId } from './agentClientSession'
6 : import { useAgentComposerStore } from './stores/agent/agentComposerStore'
7 : import { useAgentConsentStore } from './stores/agent/agentConsentStore'
8 : import { useAgentConversationStore } from './stores/agent/agentConversationStore'
9 : import { useAgentPanelStore } from './stores/agent/agentPanelStore'
10 :
11 0 : function consentState(signedIn: boolean) {
12 0 : const consent = useAgentConsentStore()
13 0 : if (consent.accepted) return 'accepted'
14 0 : if (!signedIn) return 'signed_out'
15 0 : if (consent.isChecking) return 'unchecked'
16 0 : return consent.checkFailed ? 'check_failed' : 'not_accepted'
17 : }
18 :
19 0 : export function openFeedbackDialog(source: FeedbackSource) {
20 0 : if (!useAgentPanelStore().enabled) {
21 0 : openGeneralFeedbackDialog(source)
22 0 : return
23 : }
24 :
25 0 : const { resolvedUserInfo } = useCurrentUser()
26 0 : const { heldSendGate } = useAgentPanelStore()
27 0 : openGeneralFeedbackDialog(source, {
28 : typeformId: 'MZ6cjWIB',
29 : extraTags: {
30 : userid: resolvedUserInfo.value?.id,
31 : version: __COMFYUI_FRONTEND_VERSION__,
32 : os: navigator.platform,
33 : session: useAgentConversationStore().threadId,
34 : client: agentClientSessionId(),
35 : consent: consentState(Boolean(resolvedUserInfo.value?.id)),
36 : held: heldSendGate ?? 'none',
37 : composer: useAgentComposerStore().submission?.phase ?? 'idle'
38 : }
39 : })
40 : }
|