🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(onboarding): end the progress stream when no source is selected (#23289)
YuTengjingaf8cd4ce8268
diff --git a/apps/server/src/routers/lambda/__tests__/user.test.ts b/apps/server/src/routers/lambda/__tests__/user.test.tsindex 9123adf7246..bced3306bc1 100644--- a/apps/server/src/routers/lambda/__tests__/user.test.ts+++ b/apps/server/src/routers/lambda/__tests__/user.test.ts@@ -302,8 +302,11 @@ describe('userRouter', () => {await expect(iterator.next()).resolves.toMatchObject({ done: true });});- /** @example An initialized session without a connected provider is still collecting sources. */- it('keeps an empty pending session in the collecting-sources phase', async () => {+ /**+ * @example An initialized session without a connected provider reports collecting-sources once+ * and ends, because no workflow can publish progress until the client revises its sources.+ */+ it('ends the stream for an empty pending session after its collecting-sources event', async () => {mockUnderstandingService.get.mockResolvedValueOnce({id: 'session-1',sources: {},@@ -331,7 +334,7 @@ describe('userRouter', () => {understanding: 'pending',},});- await iterator.return?.();+ await expect(iterator.next()).resolves.toMatchObject({ done: true });});/** @example A completed source waits for the downstream writer instead of ending the stream. */diff --git a/apps/server/src/routers/lambda/user/onboardingUnderstanding.ts b/apps/server/src/routers/lambda/user/onboardingUnderstanding.tsindex 9cad5dd02d5..4a9177c6922 100644--- a/apps/server/src/routers/lambda/user/onboardingUnderstanding.ts+++ b/apps/server/src/routers/lambda/user/onboardingUnderstanding.ts@@ -2,6 +2,7 @@ import type {ConfirmOnboardingUnderstandingInput,ConfirmOnboardingUnderstandingResult,CreateOnboardingTasksInput,+ OnboardingGenerationProgressEvent,OnboardingTaskRecommendationPollingResult,OnboardingTaskRecommendationTopicInput,OnboardingUnderstandingPollingResult,@@ -143,6 +144,15 @@ const waitForProgressRecovery = (delay: number, signal: AbortSignal | undefined));});+/**+ * A session with no selected source has nothing scheduled, so no workflow will ever publish+ * progress for it. Keeping its stream open only ends in the Vercel 300s timeout followed by an+ * EventSource reconnect, repeating for as long as the onboarding page stays open. The client opens+ * a fresh stream after it adds sources through `revise`, so ending the idle stream loses nothing.+ */+const isIdleOnboardingGenerationProgress = (progress: OnboardingGenerationProgressEvent) =>+ progress.phase === 'collecting-sources' && progress.steps.collectSources === 'pending';+export const onboardingUnderstandingRouter = router({confirmOnboardingUnderstanding: understandingServiceProcedure.input(confirmOnboardingUnderstandingInputSchema)@@ -196,7 +206,8 @@ export const onboardingUnderstandingRouter = router({if (initial.progress.phase === 'completed' ||initial.progress.phase === 'failed' ||- initial.progress.phase === 'partial'+ initial.progress.phase === 'partial' ||+ isIdleOnboardingGenerationProgress(initial.progress)) {return;}