Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

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

  • Created StreamingContext to manage streaming sessions globally using React Context
  • Updated useStream hook to sync with the global context, allowing streaming to persist across page navigations
  • Removed the navigation guard that was aborting streams when users navigated away

Pre-Page-Transition API Requests

  • Implemented usePreNavigationStream hook that starts the API request immediately before page navigation
  • Updated useSessionNavigation to trigger streaming before the page transition
  • This overlaps page transition time with API response time, making the app feel faster

Session History Progress Indicator

  • Created SessionItemClient component to display "In Progress" badges for sessions that are actively streaming
  • Added CSS styling for the streaming badge

Benefits

  1. Streaming continuation: Users can navigate between pages without interrupting ongoing AI responses
  2. Faster perceived performance: API requests start before page navigation, overlapping the two operations
  3. Better visibility: Session History shows which sessions are currently in progress

Important Review Points

⚠️ Critical: This implementation has not been tested in a running environment. Please thoroughly test:

  • Streaming behavior during page navigation
  • Multiple concurrent streaming sessions
  • Error handling when navigation happens very quickly
  • Memory usage with multiple session creates/destroys

🔍 Key areas to review:

  1. Memory management (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.
  2. Race conditions (usePreNavigationStream.ts): The fetch is started without awaiting. Verify the session detail page correctly picks up the in-progress stream.
  3. useEffect dependencies (useStream.ts:106-120): Multiple useEffect calls with interdependencies. Check for potential infinite re-render loops.
  4. Error handling (usePreNavigationStream.ts:56-60): Only logs errors and doesn't update the global context. Should we set an error state?
  5. CSS workaround (SessionItem.tsx:9): Using void styles.streamingBadge to satisfy linter. The class is used in SessionItemClient.tsx but the linter can't detect cross-file usage.

Link to Devin run: https://app.devin.ai/sessions/5dc30b57988a4170b6bd77248ffaafdf
Requested by: [email protected]

…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-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@giselles-ai
Copy link

giselles-ai bot commented Oct 22, 2025

Finished running flow.

Step Status Updated(UTC)
1 Oct 22, 2025 3:02am
2 Oct 22, 2025 3:04am
3 Oct 22, 2025 3:04am

@vercel
Copy link

vercel bot commented Oct 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
liam-app Ready Ready Preview Comment Oct 22, 2025 3:09am
liam-assets Ready Ready Preview Comment Oct 22, 2025 3:09am
liam-storybook Ready Ready Preview Comment Oct 22, 2025 3:09am
2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
liam-docs Ignored Ignored Preview Oct 22, 2025 3:09am
liam-erd-sample Skipped Skipped Oct 22, 2025 3:09am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 22, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

@supabase
Copy link

supabase bot commented Oct 22, 2025

Updates to Preview Branch (devin/1761102013-global-streaming-state) ↗︎

Deployments Status Updated
Database Wed, 22 Oct 2025 03:05:17 UTC
Services Wed, 22 Oct 2025 03:05:17 UTC
APIs Wed, 22 Oct 2025 03:05:17 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Wed, 22 Oct 2025 03:05:24 UTC
Migrations Wed, 22 Oct 2025 03:05:28 UTC
Seeding Wed, 22 Oct 2025 03:05:29 UTC
Edge Functions Wed, 22 Oct 2025 03:05:29 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

@giselles-ai
Copy link

giselles-ai bot commented Oct 22, 2025

Check changeset necessity

Status: NOT REQUIRED

Reason:

  • All changes are in the application code under frontend/apps/app, which belongs to @liam-hq/app (listed in the ignore list).
  • No code changes in target publishable packages: @liam-hq/cli, @liam-hq/erd-core, @liam-hq/schema, or @liam-hq/ui.
  • User-facing behavior changes (global streaming state, pre-navigation streaming, UI badges) are confined to the app; no exported APIs or library behavior changed.
  • Imports from @liam-hq/ui are used but the package itself is not modified.

Changeset (copy & paste):

<!-- No changeset required: this PR only modifies @liam-hq/app (ignored). -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants