Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: summary does not load indefinitely if there are no votes #10669

Merged
merged 6 commits into from
Jan 14, 2025

Conversation

nickoferrall
Copy link
Contributor

Demo: https://www.loom.com/share/974d623e1e5f4864bc0fbd4947cac20b

Fix #10499

In prod, if the AI summary fails to generate because of a problem with ChatGPT or because the retro doesn't have any votes so generateRetroSummary doesn't have any valid reflection groups, the AI meeting summary will load indefinitely.

In this PR, if we fail to generate the AI summary, we won't show the loading UI indefinitely.

AC

  • If there is a valid AI summary, we see the loading UI followed by the summary
  • If there is not a valid AI summary, e.g. when there are no votes on any reflection groups, we don't see an AI summary

@@ -112,7 +112,8 @@ const safeEndRetrospective = async ({
endedAt: sql`CURRENT_TIMESTAMP`,
phases: JSON.stringify(phases),
usedReactjis: JSON.stringify(insights.usedReactjis),
engagement: insights.engagement
engagement: insights.engagement,
summary: '' // empty string signals "loading" to the client
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other ideas are:

  1. Setting it to a specific string like "Loading" to make this clearer in the WholeMeetingSummary
  2. Adding a value to the meeting like isSummaryLoading, but that feels like overkill
  3. Checking in WholeMeetingSummary whether there are no votes in the Retro, but that wouldn't handle the situation where OpenAI fails.

@@ -47,7 +47,7 @@ const WholeMeetingSummary = (props: Props) => {
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.useAI || !hasAiApiKey) return null
if (!wholeMeetingSummary) return <WholeMeetingSummaryLoading />
if (wholeMeetingSummary === '') return <WholeMeetingSummaryLoading /> // summary is undefined if it hasn't been generated yet. it's null if unsuccessful
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 GraphQL does not distinguish between null and undefined like this, so while it does not change anything here, the comment is wrong.
I think because the summary is only used for the AI summary, it's ok to have a placeholder in the db indicating loading, but I would prefer if on GraphQL level we would add a field isSummaryLoading which checks the placeholder. We could also filter it out for the summary field. This way it's contained to the server only. Not sure '' is the best placeholder though, maybe something like <loading> would be more explicit?

@@ -14,6 +14,7 @@ const RetrospectiveMeeting: RetrospectiveMeetingResolvers = {
const res = await dataLoader.get('meetingMembersByMeetingId').load(meetingId)
return res as RetroMeetingMember[]
},
isLoadingSummary: ({summary}) => summary === '<loading>',
Copy link
Contributor

@Dschoordsch Dschoordsch Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to ensure we never accidentally render the placeholder on the client, we could add a resolver here

summary: ({summary}) => summary === '<loading>' ? null : summary,

@nickoferrall nickoferrall merged commit 84b8d60 into master Jan 14, 2025
6 checks passed
@nickoferrall nickoferrall deleted the fix/10499/ai-summary-loading branch January 14, 2025 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AI Summary stuck on loading UI
2 participants