-
Notifications
You must be signed in to change notification settings - Fork 187
feat: implement global streaming state management and pre-page-transition API requests #3842
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
Conversation
…tion API requests - Add StreamingContext for global streaming state management across page navigations - Implement usePreNavigationStream hook to start API requests before page transitions - Update useStream to sync with global streaming context - Add streaming progress indicator in Session History - Allow streaming to continue during CSR page navigation - Remove navigation guard that aborted streaming on page change This implementation is based on the Nani translation app approach and enables: - Streaming continuation during page navigation - Pre-page-transition API request initiation - Session History progress indicators for in-progress streams - Better perceived performance by overlapping page transition and API response time Resolves route06/liam-internal#5891 Co-Authored-By: [email protected] <[email protected]>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Finished running flow.
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
|
Updates to Preview Branch (devin/1761102013-global-streaming-state) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
Check changeset necessityStatus: NOT REQUIRED Reason:
Changeset (copy & paste):<!-- No changeset required: this PR only modifies @liam-hq/app (ignored). --> |
Issue
Why is this change needed?
This PR implements global streaming state management and pre-page-transition API requests to significantly improve the user experience when working with AI agents. Currently, streaming is aborted when users navigate away from a page, and API requests only start after page navigation completes. This causes perceived delays and interrupts ongoing AI responses.
What changed?
Global Streaming State Management
StreamingContextto manage streaming sessions globally using React ContextuseStreamhook to sync with the global context, allowing streaming to persist across page navigationsPre-Page-Transition API Requests
usePreNavigationStreamhook that starts the API request immediately before page navigationuseSessionNavigationto trigger streaming before the page transitionSession History Progress Indicator
SessionItemClientcomponent to display "In Progress" badges for sessions that are actively streamingBenefits
Important Review Points
🔍 Key areas to review:
StreamingContext.tsx): Sessions are stored in a Map but there's no cleanup mechanism. Consider if we need to implement session deletion on unmount or after a timeout.usePreNavigationStream.ts): The fetch is started without awaiting. Verify the session detail page correctly picks up the in-progress stream.useStream.ts:106-120): Multiple useEffect calls with interdependencies. Check for potential infinite re-render loops.usePreNavigationStream.ts:56-60): Only logs errors and doesn't update the global context. Should we set an error state?SessionItem.tsx:9): Usingvoid styles.streamingBadgeto satisfy linter. The class is used inSessionItemClient.tsxbut the linter can't detect cross-file usage.Link to Devin run: https://app.devin.ai/sessions/5dc30b57988a4170b6bd77248ffaafdf
Requested by: [email protected]