Skip to content

refactor(web): normalize Ask user message text extraction#1371

Draft
whoisthey wants to merge 2 commits into
mainfrom
whoisthey/normalize-user-message-text-extraction
Draft

refactor(web): normalize Ask user message text extraction#1371
whoisthey wants to merge 2 commits into
mainfrom
whoisthey/normalize-user-message-text-extraction

Conversation

@whoisthey

@whoisthey whoisthey commented Jun 26, 2026

Copy link
Copy Markdown

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 a message.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 getUserMessageText helper in packages/web/src/features/chat/utils.ts that finds the first text part, and replaces the brittle parts[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.

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>
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d2dd7239-4c75-45fe-9fe5-99a56000a6f2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch whoisthey/normalize-user-message-text-extraction

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.

Co-authored-by: Cursor <cursoragent@cursor.com>
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