SSE connection fixed for direct AI page navigation
Messages sent to the AI assistant now arrive reliably on first load, even when navigating directly to the page from elsewhere in the app.
When navigating directly to the AI assistant page from elsewhere in the app for the first time, users found their message replies had vanished—despite the backend generating responses. The culprit was Vue's <Suspense> boundary in the app layout, which caused the AI view to unmount and remount during navigation transitions. Each unmount closed the SSE connection, and if a user sent a message before the component finished remounting and reconnecting, the response events disappeared into the void.
The fix introduces a guard that checks whether the SSE connection is active before sending any message. If the connection has been closed—whether by a Suspense remount or any other circumstance—it reconnects immediately as a safety net. This ensures messages sent during navigation transitions still receive their replies.
The change lives in the frontend editor's AI store, which manages real-time communication between the client and the AI assistant backend.
View Original GitHub Description
Summary
If user navigated to /instance-ai from another page for the first time and sent a message they wouldn't see the reply backend tried to send to it. The reply got generated, but user had to refresh the page or something to see it. This happened every time if you first loaded the app on home page, navigated to /instance-ai and sent a message to the prompt without loading any older threads.
This was caused by Vue's <Suspense> in AppLayout.vue causing InstanceAiView to mount -> unmount -> remount during navigation, causing SSE to end up closed.
Ensure SSE is in connected state with a guard to fix this.
Related Linear tickets, Github issues, and Community forum posts
<!-- Include links to **Linear ticket** or Github issue or Community forum post. Important in order to close *automatically* and provide context to reviewers. https://linear.app/n8n/issue/ --> <!-- Use "closes #<issue-number>", "fixes #<issue-number>", or "resolves #<issue-number>" to automatically close issues when the PR is merged. -->Review / Merge checklist
- PR title and summary are descriptive. (conventions) <!-- **Remember, the title automatically goes into the changelog. Use `(no-changelog)` otherwise.** -->
- Docs updated or follow-up ticket created.
- Tests included. <!-- A bug is not considered fixed, unless a test is added to prevent it from happening again. A feature is not complete without tests. -->
- PR Labeled with
Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)