feat(chat): enhance chat component with workflowChatId and isBootstrapPreparing props#1764
feat(chat): enhance chat component with workflowChatId and isBootstrapPreparing props#1764ahmednahima0-beep wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 23 minutes and 1 second. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThe PR threads ChangesWorkflow Bootstrap State Plumbing and UI Gating
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: acfa0435a4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const isBootstrapPreparing = | ||
| authenticated && | ||
| (state.status === "idle" || state.status === "bootstrapping"); |
There was a problem hiding this comment.
Keep send disabled until bootstrap is ready
When the user is not yet authenticated (or Privy is still resolving), authenticated is false while the bootstrap state remains idle, so this computes isBootstrapPreparing as false and renders an enabled chat input even though no sessionId/workflowChatId exists yet. In that window, submitting a message falls back to the legacy transport with the random placeholder chat id and produces a failed/unauthorized send instead of waiting for the workflow chat to be provisioned. The disabling condition should be based on bootstrap not being ready, not only on authenticated idle/bootstrapping states.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
components/VercelChat/ChatInput.tsx (1)
88-93: ⚡ Quick winAnnounce "Preparing…" to assistive tech via a live region.
The status is conveyed visually only; screen-reader users get a disabled submit button with no explanation. Wrapping it in a polite live region (or
role="status") lets the state change be announced. As per coding guidelines, "Provide proper ARIA roles/states and test with screen readers."♿ Proposed accessibility tweak
- {isBootstrapPreparing ? ( - <span className="text-xs text-muted-foreground whitespace-nowrap"> - Preparing… - </span> - ) : null} + {isBootstrapPreparing ? ( + <span + role="status" + aria-live="polite" + className="text-xs text-muted-foreground whitespace-nowrap" + > + Preparing… + </span> + ) : null}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@components/VercelChat/ChatInput.tsx` around lines 88 - 93, The visual "Preparing…" indicator in ChatInput (where isBootstrapPreparing is checked) must be announced to assistive tech: update the span rendered when isBootstrapPreparing is true to include an accessible live region (e.g., add aria-live="polite" and role="status") so screen readers announce the state change; locate the JSX in ChatInput where isBootstrapPreparing is used and add those ARIA attributes to that span (ensure the text remains visible and not aria-hidden).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@components/VercelChat/ChatInput.tsx`:
- Around line 88-93: The visual "Preparing…" indicator in ChatInput (where
isBootstrapPreparing is checked) must be announced to assistive tech: update the
span rendered when isBootstrapPreparing is true to include an accessible live
region (e.g., add aria-live="polite" and role="status") so screen readers
announce the state change; locate the JSX in ChatInput where
isBootstrapPreparing is used and add those ARIA attributes to that span (ensure
the text remains visible and not aria-hidden).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4b5b28cf-7713-4c3f-9d97-5917a4fc6a28
📒 Files selected for processing (5)
components/VercelChat/ChatInput.tsxcomponents/VercelChat/NewChatBootstrap.tsxcomponents/VercelChat/chat.tsxhooks/useVercelChat.tsproviders/VercelChatProvider.tsx
There was a problem hiding this comment.
2 issues found across 5 files
Confidence score: 3/5
- There is a concrete regression risk in
components/VercelChat/NewChatBootstrap.tsx:isBootstrapPreparingbeing gated byauthenticatedmay allow send actions before bootstrap completes during auth initialization, which could cause inconsistent chat startup behavior for users. - The issue in
providers/VercelChatProvider.tsxis primarily maintainability-focused (file size/readability single-responsibility limit), so it raises medium implementation risk rather than an immediate runtime breakage. - Given one user-impacting medium-severity behavior bug plus a structural concern, this sits at some merge risk and is worth addressing or closely validating before release.
- Pay close attention to
components/VercelChat/NewChatBootstrap.tsxandproviders/VercelChatProvider.tsx- bootstrap/auth timing correctness and provider complexity are the key risk areas.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
2 issues found across 5 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Requires human review: This is a substantial refactor and feature addition that modifies core chat session management logic, including new props, placeholder IDs, and deferred initial messages, which carries risk of breaking existing chat functionality and requires human review.
Re-trigger cubic
…pPreparing props This update introduces two new props, `workflowChatId` and `isBootstrapPreparing`, to the Chat component, improving the handling of chat sessions. The `workflowChatId` is used for workflow transport when the chat ID is a client placeholder, while `isBootstrapPreparing` indicates when session provisioning is in progress. Additionally, the ChatInput component now disables message sending during bootstrap preparation, enhancing user experience. The NewChatBootstrap component has been updated to manage these new props effectively.
This commit refactors the NewChatBootstrap component to utilize the new `isNewChatBootstrapPreparing` function for determining bootstrap preparation status, improving clarity and maintainability. Additionally, it removes the dependency on the `usePrivy` hook, simplifying the authentication logic. The VercelChatProvider is also updated to pass the `isBootstrapPreparing` prop, ensuring consistent state management across components.
This commit removes the redundant `originalReload` function and directly utilizes the `reload` prop. Additionally, it refactors the message sending logic in `handleSendMessageWithClear` to ensure attachments are cleared after sending, regardless of success or failure, improving the reliability of the message handling process.
bfb0ae3 to
b8bad91
Compare
This update introduces two new props,
workflowChatIdandisBootstrapPreparing, to the Chat component, improving the handling of chat sessions. TheworkflowChatIdis used for workflow transport when the chat ID is a client placeholder, whileisBootstrapPreparingindicates when session provisioning is in progress. Additionally, the ChatInput component now disables message sending during bootstrap preparation, enhancing user experience. The NewChatBootstrap component has been updated to manage these new props effectively.Summary by cubic
Enable parallel new‑chat bootstrap with
workflowChatIdandisBootstrapPreparing; the chat UI renders immediately with a placeholder ID and blocks send until the session is ready. Also simplifies the provider with a newuseVercelChatProviderValuehook and keeps session‑based chat APIs.New Features
NewChatBootstrapmounts<Chat>with a client placeholder ID and passesworkflowChatId/isBootstrapPreparingviaisNewChatBootstrapPreparing.useVercelChatusestransportChatId = workflowChatId ?? idfor transport, initial message load, and URL; defers the first send until auth andsessionIdexist.ChatInputdisables send and shows “Preparing…” during bootstrap.Refactors
UserProvider; removeduseAutoLoginacross pages/components.VercelChatContextanduseVercelChatProviderValue;VercelChatProvidernow passesisBootstrapPreparing.Written for commit b8bad91. Summary will update on new commits.
Summary by CodeRabbit