fix(stream): detect early abort and prevent navigation to non-existent conversation

- Abort controller on job completion to signal pending operations
- Detect early abort (no content, no responseMessageId) in abortJob
- Set conversation and responseMessage to null for early aborts
- Add earlyAbort flag to final event for frontend detection
- Remove unused text field from AbortResult interface
- Frontend handles earlyAbort by staying on/navigating to new chat
This commit is contained in:
Danny Avila 2025-12-18 19:26:34 -05:00
parent d9a5893d4b
commit aa5c18bb29
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
3 changed files with 44 additions and 32 deletions

View file

@ -438,6 +438,21 @@ export default function useEventHandlers({
} = submission;
try {
// Handle early abort - aborted during tool loading before any messages saved
// Don't update conversation state, just reset UI and stay on new chat
if ((data as Record<string, unknown>).earlyAbort) {
console.log(
'[finalHandler] Early abort detected - no messages saved, staying on new chat',
);
setShowStopButton(false);
setIsSubmitting(false);
// Navigate to new chat if not already there
if (location.pathname !== `/c/${Constants.NEW_CONVO}`) {
navigate(`/c/${Constants.NEW_CONVO}`, { replace: true });
}
return;
}
if (responseMessage?.attachments && responseMessage.attachments.length > 0) {
// Process each attachment through the attachmentHandler
responseMessage.attachments.forEach((attachment) => {