Skip to content

Conversation

robertjdominguez
Copy link
Collaborator

Description

Solid progress on the chat widget error handling and visual feedback system.

Key improvements:

  • Added toast notifications for error states
  • Enhanced streaming visual feedback with brand color glow
  • Fixed loading state management with proper timeout handling
  • Improved error recovery flow

Previously...

Error states would leave the UI stuck in loading mode with no user feedback:

} catch (error) {
  onError(error instanceof Error ? error.message : "Unknown error");
} finally {
  setIsLoading(false);
}

Now...

Comprehensive error handling with visual feedback and proper state cleanup:

// Set a timeout to reset loading state if no response
const timeoutId = setTimeout(() => {
  setIsLoading(false);
  onError("Request timed out");
}, 120000); // 2 minutes

} catch (error) {
  clearTimeout(timeoutId);
  onError(error instanceof Error ? error.message : "Unknown error");
  
  // Add a final empty assistant message to clear the streaming state
  onMessage({
    role: "assistant",
    content: "",
    streaming: false,
  });
} finally {
  setIsLoading(false);
}

The timeout mechanism ensures that even if the client disconnects mid-stream, the UI will automatically reset to allow the user to try again. Toast notifications provide immediate feedback about what went wrong, while the streaming visual effects use the brand color to create a cohesive experience.

Testing: Use Chrome DevTools Network tab → set throttling to "Offline" → send message → toggle back to "No throttling" to verify the error recovery flow works properly.

Copy link

github-actions bot commented Jul 30, 2025

🚀 PromptQL Build Complete

Build Version: f100991b76
Project: pql-docs
PromptQL Playground: Open Playground

Description: PR #22: Chat-widget: Improve ux during responses

Copy link

No description provided.

@robertjdominguez robertjdominguez merged commit c08218f into main Jul 30, 2025
1 check passed
@robertjdominguez robertjdominguez deleted the rob/chat-widget/improve-ux-during-responses branch July 30, 2025 22:39
Copy link

✅ PromptQL Build Applied

Build Version: f100991b76
Status: Successfully applied to production
Applied at: 2025-07-30T22:40:10.123Z

robertjdominguez added a commit that referenced this pull request Aug 10, 2025
## Description

Solid progress on the chat widget error handling and visual feedback
system.

### Key improvements:
- Added toast notifications for error states
- Enhanced streaming visual feedback with brand color glow
- Fixed loading state management with proper timeout handling
- Improved error recovery flow

### Previously...
Error states would leave the UI stuck in loading mode with no user
feedback:

````typescript path=packages/chat-widget/src/hooks/useStreamingChat.ts mode=EXCERPT
} catch (error) {
  onError(error instanceof Error ? error.message : "Unknown error");
} finally {
  setIsLoading(false);
}
````

### Now...
Comprehensive error handling with visual feedback and proper state
cleanup:

````typescript path=packages/chat-widget/src/hooks/useStreamingChat.ts mode=EXCERPT
// Set a timeout to reset loading state if no response
const timeoutId = setTimeout(() => {
  setIsLoading(false);
  onError("Request timed out");
}, 120000); // 2 minutes

} catch (error) {
  clearTimeout(timeoutId);
  onError(error instanceof Error ? error.message : "Unknown error");
  
  // Add a final empty assistant message to clear the streaming state
  onMessage({
    role: "assistant",
    content: "",
    streaming: false,
  });
} finally {
  setIsLoading(false);
}
````

The timeout mechanism ensures that even if the client disconnects
mid-stream, the UI will automatically reset to allow the user to try
again. Toast notifications provide immediate feedback about what went
wrong, while the streaming visual effects use the brand color to create
a cohesive experience.

**Testing**: Use Chrome DevTools Network tab → set throttling to
"Offline" → send message → toggle back to "No throttling" to verify the
error recovery flow works properly.
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.

1 participant