Repository navigation
feat(client): add hiddenText to sendMessage - #92
Merged
Merged
Conversation
sendMessage(text, { hiddenText }) sends hiddenText to the AI as a text
part before the visible text. It is saved with the message as a
'hidden_text' part, so later turns and reloads still send it, and
getDisplayTextFromContent leaves it out of the bubble, title and chat list.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Skip whitespace-only hiddenText, like the visible message. - Build the visible text part once and reuse it. - README: the built-in UI hides it; custom message slots and ChatRepository implementations need to handle hidden_text parts. - Test the user bubble by rendering it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ents Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ntent getTextFromContent is only called on assistant and tool messages, so hidden_text never reaches it. getDisplayTextFromContent already reads only text parts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yuma2024
marked this pull request as ready for review
October 28, 2026 08:15
mm-zacharydavison
approved these changes
Oct 28, 2026
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.
Why
An app sometimes collects context before the chat starts (e.g. a form) and wants the AI to use it for the whole conversation without showing it in the chat. The existing inputs don't cover this:
useAI({ prompt })state, even when read from chatmetadata, goes into the system prompt for the current run only. It is not part of the chat history and is not tied to a message.forwardedPropsdon't reach the model's messages.transformed_fileis also sent but not shown, but the server prefixes it with a file header and it needsoriginalFile. What's needed is text attached to a message that stays in the history.Change
SendMessageOptions.hiddenText?: string. It is sent as a text part before the visible text and the attachments. No heading or separator is added. Whitespace-onlyhiddenTextis ignored.PersistedHiddenTextContent({ type: 'hidden_text', text }) part, so later turns and reloads send it again (transformMessagesToClientFormat).getDisplayTextFromContentonly readstextparts, so the built-in bubble, chat title, chat list and save-as-command leave it out. Existing stored messages are read as before.hiddenText, behavior is unchanged. Client only; no server or core change.Messageslot should skiphidden_textparts.API: additive.
PersistedContentPartgainshidden_text, so a consumer with an exhaustive switch over it needs one more case (same as whentransformed_fileandattachment_refwere added).sendFninUseMessageQueueOptionsgains a 4th optional parameter rather than an options object, since that type is exported.Tests
bun run test: client 580, server 370, workflows 27 pass. New tests: wire order and stored order (hidden → visible → attachments), chat title, the rendered user bubble, and that the text reaches the AI on a later turn after a reload. The bubble test fails ifgetDisplayTextFromContentpicks up every part that hastext; the reload test fails with themessageConversion.tschange reverted.Not covered
hiddenTextis stored in localStorage like any other message text, so when storage is full the save can fail silently (same as long messages today). The AI then gets it only while the chat stays open, not after a reload, a reconnect or a chat switch.🤖 Generated with Claude Code