From f1c9c392735d468e65ee4e4f711da5a36d571ace Mon Sep 17 00:00:00 2001 From: Nick O'Ferrall Date: Tue, 18 Jun 2024 10:19:01 +0100 Subject: [PATCH 1/2] fix: remove ai ui if no access to ai --- .../MeetingSummaryEmail/WholeMeetingSummary.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/client/modules/email/components/SummaryEmail/MeetingSummaryEmail/WholeMeetingSummary.tsx b/packages/client/modules/email/components/SummaryEmail/MeetingSummaryEmail/WholeMeetingSummary.tsx index 820491bffde..2c843c38bdc 100644 --- a/packages/client/modules/email/components/SummaryEmail/MeetingSummaryEmail/WholeMeetingSummary.tsx +++ b/packages/client/modules/email/components/SummaryEmail/MeetingSummaryEmail/WholeMeetingSummary.tsx @@ -40,19 +40,25 @@ const WholeMeetingSummary = (props: Props) => { `, meetingRef ) + const hasAI = window.__ACTION__.hasOpenAI if (meeting.__typename === 'RetrospectiveMeeting') { const {summary: wholeMeetingSummary, reflectionGroups, organization} = meeting const reflections = reflectionGroups?.flatMap((group) => group.reflections) // reflectionCount hasn't been calculated yet so check reflections length const hasMoreThanOneReflection = reflections?.length && reflections.length > 1 - if (!hasMoreThanOneReflection || organization.featureFlags.noAISummary) return null + if (!hasMoreThanOneReflection || organization.featureFlags.noAISummary || !hasAI) return null if (!wholeMeetingSummary) return return } else if (meeting.__typename === 'TeamPromptMeeting') { const {summary: wholeMeetingSummary, responses, organization} = meeting - if (!organization.featureFlags.standupAISummary || organization.featureFlags.noAISummary) { + if ( + !organization.featureFlags.standupAISummary || + organization.featureFlags.noAISummary || + !hasAI || + !responses || + responses.length === 0 + ) { return null } - if (!responses || responses.length === 0) return null if (!wholeMeetingSummary) return return } From 6bec2ca520c952a23bf784d77c069425fcddc200 Mon Sep 17 00:00:00 2001 From: Nick O'Ferrall Date: Mon, 24 Jun 2024 16:20:32 +0100 Subject: [PATCH 2/2] hasAI checks if ssr --- .../MeetingSummaryEmail/WholeMeetingSummary.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/client/modules/email/components/SummaryEmail/MeetingSummaryEmail/WholeMeetingSummary.tsx b/packages/client/modules/email/components/SummaryEmail/MeetingSummaryEmail/WholeMeetingSummary.tsx index 2c843c38bdc..633cea17a0c 100644 --- a/packages/client/modules/email/components/SummaryEmail/MeetingSummaryEmail/WholeMeetingSummary.tsx +++ b/packages/client/modules/email/components/SummaryEmail/MeetingSummaryEmail/WholeMeetingSummary.tsx @@ -9,6 +9,11 @@ interface Props { meetingRef: WholeMeetingSummary_meeting$key } +const isServer = typeof window === 'undefined' +const hasAI = isServer + ? !!process.env.OPEN_AI_API_KEY + : !!window.__ACTION__ && !!window.__ACTION__.hasOpenAI + const WholeMeetingSummary = (props: Props) => { const {meetingRef} = props const meeting = useFragment( @@ -40,7 +45,6 @@ const WholeMeetingSummary = (props: Props) => { `, meetingRef ) - const hasAI = window.__ACTION__.hasOpenAI if (meeting.__typename === 'RetrospectiveMeeting') { const {summary: wholeMeetingSummary, reflectionGroups, organization} = meeting const reflections = reflectionGroups?.flatMap((group) => group.reflections) // reflectionCount hasn't been calculated yet so check reflections length