feat: prefill the input with the ?q= prompt while provisioning (chat#1848 follow-up)#1849
Conversation
…1848 follow-up) After #1848 the deep-link message correctly waits for the session, but the wait is dead space: nothing on screen tells the customer their AGENTS click worked. Prefill the input with the prompt immediately, then auto-fire when the workspace goes ready — sending whatever is in the input at that moment, so an edit made while waiting sends the edited text and a cleared input sends nothing, exactly like pressing Send. - lib/chat/getInitialMessageText.ts (SRP, unit-tested): first text part of the deep-link message, undefined when nothing meaningful. - useVercelChat: one-shot prefill effect (never clobbers an existing conversation or typed text) + auto-fire builds the message from the live input; one-shot ref prevents double-sends. TDD RED->GREEN (3-case extractor suite); full suite 83 passed; tsc no new errors vs main; prettier clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Warning Review limit reached
Next review available in: 8 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
✨ 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: f36c460970
ℹ️ 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".
| handleSendQueryMessages({ | ||
| id: generateUUID(), | ||
| role: "user", | ||
| parts: [{ type: "text", text }], | ||
| }); |
There was a problem hiding this comment.
Preserve attachments when auto-sending the edited prompt
When a ?q= chat is still provisioning, the input remains editable and the toolbar still allows attachments/mentions, but the new auto-fire path constructs a text-only UIMessage and bypasses the same handleSubmit logic that folds in attachments, textAttachments, mentionAttachments, and mentioned-file text context. In that scenario, a user who edits the prefilled prompt by adding a file/mention before the workspace becomes ready will have the prompt auto-sent without the selected context, unlike pressing Send after readiness.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
1 issue found across 3 files
Confidence score: 3/5
- In
hooks/useVercelChat.ts, the auto-fired?q=flow appears to bypass the normal send pipeline, so edited input can be posted as raw text without the same mention/text/audio context handling or selected-model persistence, which can cause inconsistent chat behavior and surprising outputs for users; route?q=submissions through the exact same send path before merging.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="hooks/useVercelChat.ts">
<violation number="1" location="hooks/useVercelChat.ts:423">
P2: Auto-fired `?q=` sends can diverge from a normal Send: edited input is posted as raw text and skips the same pre-send pipeline (mention/text/audio context + selected-model persistence). Reusing the same send path as manual submit would keep provisioning auto-fire behavior consistent with what users see in the input.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| // (they opted out; send nothing), exactly as if they pressed Send. | ||
| const text = input.trim() ? input : ""; | ||
| if (!text) return; | ||
| handleSendQueryMessages({ |
There was a problem hiding this comment.
P2: Auto-fired ?q= sends can diverge from a normal Send: edited input is posted as raw text and skips the same pre-send pipeline (mention/text/audio context + selected-model persistence). Reusing the same send path as manual submit would keep provisioning auto-fire behavior consistent with what users see in the input.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At hooks/useVercelChat.ts, line 423:
<comment>Auto-fired `?q=` sends can diverge from a normal Send: edited input is posted as raw text and skips the same pre-send pipeline (mention/text/audio context + selected-model persistence). Reusing the same send path as manual submit would keep provisioning auto-fire behavior consistent with what users see in the input.</comment>
<file context>
@@ -384,31 +385,57 @@ export function useVercelChat({
+ // (they opted out; send nothing), exactly as if they pressed Send.
+ const text = input.trim() ? input : "";
+ if (!text) return;
+ handleSendQueryMessages({
+ id: generateUUID(),
+ role: "user",
</file context>
…n extension hook (OCP) Review feedback on #1848/#1849: useVercelChat grew in both PRs, being modified for every deep-link change instead of extended. Move the whole ?q= behavior (prefill + provisioning-gated auto-fire + one-shot guards) into hooks/useInitialMessageAutoSend, composed like the existing extension hooks (useChatTransport, usePersistSelectedModel, useMessageLoader). useVercelChat now carries one hook call and is smaller than it was before #1848 (422 lines vs 424); future deep-link changes touch only the dedicated hook. No behavior change: the hook is a verbatim move of the two effects over the tested pure helpers (shouldAutoSendInitialMessage, getInitialMessageText). Full suite 83 passed; tsc no new errors vs main; prettier clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Refactored per review feedback ( |
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="hooks/useInitialMessageAutoSend.ts">
<violation number="1" location="hooks/useInitialMessageAutoSend.ts:68">
P0: The auto-send can silently fail when the session is already provisioned before the prefill's `setInput` commits. Move `didAutoFireRef.current = true` below the `if (!text) return` guard so the effect can fire on the next render when the prefilled text is available.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| sessionId, | ||
| }); | ||
| if (!mayAutoSend || didAutoFireRef.current) return; | ||
| didAutoFireRef.current = true; |
There was a problem hiding this comment.
P0: The auto-send can silently fail when the session is already provisioned before the prefill's setInput commits. Move didAutoFireRef.current = true below the if (!text) return guard so the effect can fire on the next render when the prefilled text is available.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At hooks/useInitialMessageAutoSend.ts, line 68:
<comment>The auto-send can silently fail when the session is already provisioned before the prefill's `setInput` commits. Move `didAutoFireRef.current = true` below the `if (!text) return` guard so the effect can fire on the next render when the prefilled text is available.</comment>
<file context>
@@ -0,0 +1,84 @@
+ sessionId,
+ });
+ if (!mayAutoSend || didAutoFireRef.current) return;
+ didAutoFireRef.current = true;
+ const text = input.trim() ? input : "";
+ if (!text) return;
</file context>
authenticated/userId come from usePrivy/useUserProvider directly instead of riding through params — the hook's params now carry only what is chat-instance-scoped (initialMessages, status, messagesLength, sessionId, input/setInput, send). Suite 83 passed; tsc clean vs main. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Requires human review: Auto-approval blocked by 2 unresolved issues from previous reviews.
Re-trigger cubic
Preview verification — 2026-07-04 ✅Preview
One observation not related to this PR: the assistant stream on the preview cut off mid-sentence with a Retry button — the send itself was a 200, Behavior identical across all three commits' semantics (prefill → live-input fire → opt-out on clear). Ready for review/merge. |
Follow-up to #1848 / #1847. The queued
?q=send fixed the 400, but the provisioning wait became dead space — nothing on screen confirms the AGENTS click landed.What
?q=prompt the moment the page renders (one-shot; never over an existing conversation or already-typed text).shouldAutoSendInitialMessagegate as fix: gate ?q= auto-send on the provisioned sessionId (chat#1847) #1848), the message fires from the live input — an edit made while waiting sends the edited text; a cleared input sends nothing (opt-out). Exactly the semantics of pressing Send yourself.lib/chat/getInitialMessageText.tsextracted (SRP) with a 3-case unit suite (TDD RED→GREEN).Full suite 83 passed; tsc no new errors vs main; prettier clean.
Verification
Preview verification (real login → prompt visible in the input during "Preparing your workspace" → auto-fires on ready → 200 + streamed response) to follow as a PR comment.
🤖 Generated with Claude Code
Summary by cubic
Prefills the chat input with the
?q=prompt during provisioning and auto-sends it when the workspace is ready. This gives instant feedback, uses the live input on send (edits respected, cleared input sends nothing), and prevents double-sends.New Features
?q=text; never overwrites existing messages or typed text.shouldAutoSendInitialMessage; respects edits, skips if cleared; one-shot refs guard against double-sends.Refactors
useInitialMessageAutoSendto encapsulate prefill + auto-send;useVercelChatnow composes it. AddedgetInitialMessageText(unit-tested) to read the first text part.useInitialMessageAutoSendnow sources auth state internally via@privy-io/react-authanduseUserProvider; hook params carry only chat-instance-scoped data.Written for commit 1a4f98a. Summary will update on new commits.