refactor(web): normalize Ask user message text extraction#1371
Draft
whoisthey wants to merge 2 commits into
Draft
refactor(web): normalize Ask user message text extraction#1371whoisthey wants to merge 2 commits into
whoisthey wants to merge 2 commits into
Conversation
Introduce a shared `getUserMessageText` helper in the chat utils and use it everywhere the user's typed text is read from an `SBChatMessage`. Previously several call sites assumed the text lived at `parts[0]`, which silently drops the user's text if any non-text part (e.g. a file attachment) is ever first. The helper finds the first text part instead, making extraction robust to non-text parts. This is behavior-preserving today (user messages currently have a single leading text part) and is a prerequisite for chat file attachments. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Minor item in preparation of file/multi-part input in 'Ask' mode
Summary
The Ask chat feature represents messages as Vercel AI SDK
UIMessages (SBChatMessage). Several call sites extracted the user's typed text with amessage.parts[0]assumption, which silently drops the text if any non-text part (e.g. a file attachment) is ever first.This PR introduces a shared
getUserMessageTexthelper inpackages/web/src/features/chat/utils.tsthat finds the first text part, and replaces the brittleparts[0]extraction at all call sites with it.This is behavior-preserving today (user messages currently have a single leading text part) and is a prerequisite for adding chat file attachments.