Line data Source code
1 : <template>
2 : <div
3 4029 : v-if="isIntegratedTabBar"
4 : data-testid="integrated-tab-bar-actions"
5 : :data-agent-gate-settled="agentPanelStore.gateSettled || undefined"
6 : :data-agent-flags-settled="agentPanelStore.flagsSettled || undefined"
7 : class="ml-auto flex shrink-0 items-center gap-2 px-2"
8 : >
9 : <TopbarBadges />
10 : <TopbarSubscribeButton />
11 : <div
12 : v-if="topbarBadgeStore.badges.length"
13 : data-testid="environment-badge-separator"
14 : class="h-5 w-px shrink-0 bg-border/50"
15 : />
16 : <Button
17 : v-if="isCloud || isNightly"
18 : :tooltip="$t('actionbar.feedbackTooltip')"
19 : variant="muted-textonly"
20 : size="icon"
21 : class="size-6 shrink-0 rounded-sm p-0"
22 : :aria-label="$t('actionbar.feedback')"
23 : @click="openFeedback"
24 : >
25 : <i class="icon-[lucide--megaphone]" />
26 : </Button>
27 : <CurrentUserButton v-if="showCurrentUser" compact class="shrink-0 p-1" />
28 : <LoginButton v-else-if="showLoginButton" class="p-1" />
29 : <template v-if="showAgentEntry">
30 : <div
31 : data-testid="agent-entry-separator"
32 : class="h-5 w-px shrink-0 bg-border/50"
33 : />
34 : <AgentEntryButton
35 : :active="agentPanelStore.isVisible"
36 : :inviting="!agentPanelStore.hasEverOpened"
37 : :comfy-agent="comfyAgentNotReady"
38 : @click="onAgentEntryClick"
39 : />
40 : </template>
41 : </div>
42 : <div v-else class="ml-auto flex h-full shrink-0 items-center">
43 : <TopbarBadges />
44 : <TopbarSubscribeButton />
45 : </div>
46 : </template>
47 :
48 : <script setup lang="ts">
49 : import { computed, ref } from 'vue'
50 :
51 : import AgentEntryButton from '@/components/topbar/AgentEntryButton.vue'
52 : import CurrentUserButton from '@/components/topbar/CurrentUserButton.vue'
53 : import LoginButton from '@/components/topbar/LoginButton.vue'
54 : import TopbarBadges from '@/components/topbar/TopbarBadges.vue'
55 : import TopbarSubscribeButton from '@/platform/billing/components/TopbarSubscribeButton.vue'
56 : import Button from '@comfyorg/design-system/button/Button'
57 : import { useCurrentUser } from '@/composables/auth/useCurrentUser'
58 : import { useAppMode } from '@/composables/useAppMode'
59 : import { useFeatureFlags } from '@/composables/useFeatureFlags'
60 : import { isCloud, isNightly } from '@/platform/distribution/types'
61 : import { useSettingStore } from '@/platform/settings/settingStore'
62 : import { openFeedbackDialog } from '@/platform/support/feedbackDialog'
63 : import { useTelemetry } from '@comfyorg/telemetry'
64 : import { useTopbarBadgeStore } from '@/stores/topbarBadgeStore'
65 : import { useAgentConsent } from '@/workbench/extensions/agent/composables/agent/useAgentConsent'
66 : import { useAgentPanelStore } from '@/workbench/extensions/agent/stores/agent/agentPanelStore'
67 :
68 2020 : const settingStore = useSettingStore()
69 2020 : const agentPanelStore = useAgentPanelStore()
70 2020 : const topbarBadgeStore = useTopbarBadgeStore()
71 2020 : const { withConsent, isChecking } = useAgentConsent()
72 2020 : const isOpeningAgent = ref(false)
73 2020 : const { isLoggedIn } = useCurrentUser()
74 2020 : const { flags } = useFeatureFlags()
75 2020 : const { isBuilderMode } = useAppMode()
76 :
77 2020 : const isIntegratedTabBar = computed(
78 : () => settingStore.get('Comfy.UI.TabBarLayout') !== 'Legacy'
79 : )
80 2020 : const isSignedIn = computed(() => isCloud || isLoggedIn.value)
81 2020 : const showCurrentUser = computed(
82 : () => isSignedIn.value && (!flags.billingNewUxEnabled || isBuilderMode.value)
83 : )
84 2020 : const showLoginButton = computed(() => !isSignedIn.value)
85 2020 : const comfyAgentNotReady = computed(() =>
86 : agentPanelStore.enabled || agentPanelStore.comfyAgent?.state === 'ready'
87 : ? undefined
88 : : agentPanelStore.comfyAgent
89 : )
90 2020 : const showAgentEntry = computed(
91 : () =>
92 : (agentPanelStore.enabled || comfyAgentNotReady.value !== undefined) &&
93 : !(agentPanelStore.isOpen && isChecking.value)
94 : )
95 :
96 0 : function openFeedback() {
97 0 : openFeedbackDialog('topbar')
98 : }
99 :
100 3 : async function onAgentEntryClick(): Promise<void> {
101 3 : if (isOpeningAgent.value || comfyAgentNotReady.value) return
102 1 : isOpeningAgent.value = true
103 :
104 3 : try {
105 3 : if (agentPanelStore.isVisible) {
106 0 : useTelemetry()?.trackAgentEntryButtonClicked({
107 : resulting_state: 'closed'
108 : })
109 0 : agentPanelStore.toggle()
110 0 : return
111 : }
112 :
113 1 : agentPanelStore.suppressRestoredOpen()
114 1 : await withConsent('button_click', () => {
115 0 : if (!agentPanelStore.enabled) return
116 0 : useTelemetry()?.trackAgentEntryButtonClicked({
117 : resulting_state: 'opened'
118 : })
119 0 : agentPanelStore.open()
120 : })
121 : } finally {
122 0 : isOpeningAgent.value = false
123 : }
124 : }
125 : </script>
|