Skip to content

feat(chat): enhance chat component with workflowChatId and isBootstrapPreparing props#1764

Closed
ahmednahima0-beep wants to merge 3 commits into
testfrom
feat/defer-bootstrap-to-send-button
Closed

feat(chat): enhance chat component with workflowChatId and isBootstrapPreparing props#1764
ahmednahima0-beep wants to merge 3 commits into
testfrom
feat/defer-bootstrap-to-send-button

Conversation

@ahmednahima0-beep

@ahmednahima0-beep ahmednahima0-beep commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

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.


Summary by cubic

Enable parallel new‑chat bootstrap with workflowChatId and isBootstrapPreparing; the chat UI renders immediately with a placeholder ID and blocks send until the session is ready. Also simplifies the provider with a new useVercelChatProviderValue hook and keeps session‑based chat APIs.

  • New Features

    • NewChatBootstrap mounts <Chat> with a client placeholder ID and passes workflowChatId/isBootstrapPreparing via isNewChatBootstrapPreparing.
    • useVercelChat uses transportChatId = workflowChatId ?? id for transport, initial message load, and URL; defers the first send until auth and sessionId exist.
    • ChatInput disables send and shows “Preparing…” during bootstrap.
  • Refactors

    • Centralized auto‑login in UserProvider; removed useAutoLogin across pages/components.
    • Extracted VercelChatContext and useVercelChatProviderValue; VercelChatProvider now passes isBootstrapPreparing.
    • Always clear attachments after send (finally), removed a redundant reload wrapper, and kept session‑based delete/rename APIs.

Written for commit b8bad91. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features
    • Chat shows a persistent "Preparing…" status during bootstrap so users know initialization is in progress.
    • Submit button is disabled while preparing to prevent sending messages prematurely.
    • Chat interface now appears immediately during bootstrap (with temporary session handling) to reduce perceived loading time.

@vercel

vercel Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat Ready Ready Preview Jun 1, 2026 6:24pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@ahmednahima0-beep, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 10fada66-c2d4-49f2-a659-a17d89336d63

📥 Commits

Reviewing files that changed from the base of the PR and between a8cc79e and b8bad91.

📒 Files selected for processing (8)
  • components/VercelChat/ChatInput.tsx
  • components/VercelChat/NewChatBootstrap.tsx
  • components/VercelChat/chat.tsx
  • hooks/useNewChatBootstrap.ts
  • hooks/useVercelChat.ts
  • hooks/useVercelChatProviderValue.ts
  • providers/VercelChatContext.tsx
  • providers/VercelChatProvider.tsx
📝 Walkthrough

Walkthrough

The PR threads workflowChatId and isBootstrapPreparing through Chat → VercelChatProvider → context/useVercelChat, mounts Chat early with a placeholder ID during new-chat bootstrap, switches transport/loading to use workflow IDs, and disables message sends while bootstrap is preparing.

Changes

Workflow Bootstrap State Plumbing and UI Gating

Layer / File(s) Summary
Provider context and provider-value hook
providers/VercelChatContext.tsx, hooks/useVercelChatProviderValue.ts, providers/VercelChatProvider.tsx
Adds VercelChatContextType and VercelChatContext + useVercelChatContext; implements useVercelChatProviderValue that composes attachments and useVercelChat, exposes isBootstrapPreparing and attachment lifecycle via context, and refactors VercelChatProvider to use the hook.
Hook: workflow transport, loading, and bootstrap guards
hooks/useVercelChat.ts
UseVercelChatProps gains workflowChatId; hook derives transportChatId = workflowChatId ?? id for transport init, message loader when empty, URL updates, and optimistic new-chat insertion; initial-message effect defers send until workflow/session IDs are available.
Chat component props forwarding
components/VercelChat/chat.tsx
ChatProps adds workflowChatId? and isBootstrapPreparing?; Chat forwards them into VercelChatProvider.
NewChatBootstrap early mount and placeholder ID
components/VercelChat/NewChatBootstrap.tsx, hooks/useNewChatBootstrap.ts
Generates a stable placeholderChatId, always mounts <Chat> unless an error, computes isBootstrapPreparing via isNewChatBootstrapPreparing(state), and conditionally supplies sessionId/workflowChatId when ready.
ChatInput submit gating during bootstrap
components/VercelChat/ChatInput.tsx
Reads isBootstrapPreparing from context, short-circuits handleSend while preparing, shows a "Preparing…" toolbar indicator, and disables/states the PromptInputSubmit button when bootstrap is active.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • recoupable/chat#1760: Modifies NewChatBootstrap initialization and auth/auto-login ordering alongside bootstrap flow changes.
  • recoupable/chat#1752: Changes Chat/provider/hook prop threading and session/workflow routing relevant to this work.
  • recoupable/chat#1748: Updates bootstrapping wiring and transport behavior for new-workflow chats.

Suggested reviewers

  • sweetmantech
  • cubic-dev-ai

Poem

🚀 A placeholder mounts with care,
While bootstrap hums and readies there—
IDs routed, context sings,
Send is paused till the bell rings,
Then messages launch through open air.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Solid & Clean Code ✅ Passed PR shows strong SOLID adherence: context and hook extractions enforce SRP; composition maintains OCP; transportChatId pattern enforces DRY; functions are focused and layered appropriately.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/defer-bootstrap-to-send-button

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +30 to +32
const isBootstrapPreparing =
authenticated &&
(state.status === "idle" || state.status === "bootstrapping");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
components/VercelChat/ChatInput.tsx (1)

88-93: ⚡ Quick win

Announce "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

📥 Commits

Reviewing files that changed from the base of the PR and between 44550b5 and acfa043.

📒 Files selected for processing (5)
  • components/VercelChat/ChatInput.tsx
  • components/VercelChat/NewChatBootstrap.tsx
  • components/VercelChat/chat.tsx
  • hooks/useVercelChat.ts
  • providers/VercelChatProvider.tsx

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 5 files

Confidence score: 3/5

  • There is a concrete regression risk in components/VercelChat/NewChatBootstrap.tsx: isBootstrapPreparing being gated by authenticated may allow send actions before bootstrap completes during auth initialization, which could cause inconsistent chat startup behavior for users.
  • The issue in providers/VercelChatProvider.tsx is 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.tsx and providers/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

Comment thread components/VercelChat/NewChatBootstrap.tsx Outdated
Comment thread providers/VercelChatProvider.tsx Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 5 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread hooks/useVercelChatProviderValue.ts Outdated
Comment thread hooks/useVercelChatProviderValue.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
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