Description
When the server restarts while an AI message is being processed, the session gets permanently stuck showing the "..." loading indicator with no way to recover. Users must create a new session to continue.
Steps to Reproduce
- Open an AI chat session
- Send a message to the AI
- While the AI is processing (showing "..."), restart the server
- Reconnect/refresh the page
- The session shows "..." forever with no way to cancel or send another message
Root Cause
- When server restarts mid-processing, the message remains in DB with
status: :processing
- On reconnect, frontend loads this status via channel join and sets
isLoading = true
- No recovery mechanism exists to detect orphaned processing messages
Why This Is Tricky
We can't simply "auto-fail messages in processing state on join" because in collaborative sessions, another user might have legitimately sent a message that's actively being processed.
Potential Solutions
Option 1: Time-based recovery
Add a background job that marks messages as :error if stuck in :processing for > 5 minutes:
- Check
inserted_at or add processing_started_at timestamp
- Run periodic Oban job to clean up orphaned messages
Option 2: Verify Oban job exists
On session load, check if the Oban job for processing messages actually exists in the queue. If not, the message is orphaned and should be failed.
Option 3: Client-side timeout warning
After X minutes of :processing status, show a warning with a "Retry" or "Cancel" button.
Description
When the server restarts while an AI message is being processed, the session gets permanently stuck showing the "..." loading indicator with no way to recover. Users must create a new session to continue.
Steps to Reproduce
Root Cause
status: :processingisLoading = trueWhy This Is Tricky
We can't simply "auto-fail messages in processing state on join" because in collaborative sessions, another user might have legitimately sent a message that's actively being processed.
Potential Solutions
Option 1: Time-based recovery
Add a background job that marks messages as
:errorif stuck in:processingfor > 5 minutes:inserted_ator addprocessing_started_attimestampOption 2: Verify Oban job exists
On session load, check if the Oban job for processing messages actually exists in the queue. If not, the message is orphaned and should be failed.
Option 3: Client-side timeout warning
After X minutes of
:processingstatus, show a warning with a "Retry" or "Cancel" button.