Skip to content

fix(console): the AI chat user bubble shows the person's words and attached files, not the model note - #39263

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-39249-chat-bubble-attachments
Dec 3, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-39249-chat-bubble-attachments

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Part of #39249

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:在控制台的 AI 对话里附文件发送后,员工自己的消息气泡只显示他打的字,图片显示缩略图、其他文件显示文件名标签,点开即可查看;没发出去的文件会用一句看得懂的话说明原因。
  • 为什么做:员工原来在自己的气泡里看到的是写给模型的说明,看不到自己发了哪张图(AI 对话附件那张卡)。
  • 出错会怎样:最坏是气泡里少画了附件或提示,模型收到的内容与原来一致;改动只在控制台界面,可以直接撤回。
  • 要你做什么:无。

What changes

The AI chat user bubble now shows the person's own words and the files sent with the turn. It no longer shows the note written for the model.

  • The turn's parts (ui/packages/plugin-chatbot/src/chat/userTurn.ts, new). A user turn carries:

    • the person's words as its text part;
    • the stored files as file parts, as before;
    • the model-only text (the spreadsheet brief and the lines about files that were not sent) as a separate text part marked providerMetadata.objectstack.modelNote;
    • a data-local-attachments part listing the attachments that are not file parts.

    The mark is set where the note is made. Nothing strips text from the drawn string by pattern.

  • The mapper (mapMessages.ts). A marked text part is not part of the message's content. File parts become attachments, and the data part becomes localAttachments. Both are new optional keys on ChatbotEnhancedMessage.

  • The bubble (chat/userAttachments.tsx, new). A stored image is a thumbnail and any other stored file is a chip with its name; each is a link that opens the stored file in a new tab. A spreadsheet read in the page is a chip with no link, because its bytes never leave the page. A file that was not sent is a muted chip, with one sentence per reason in the console's language:

    • too large: reuses chatbot.composer.fileTooLarge;
    • unsupported type: reuses fields.file.typeNotAccepted;
    • upload failed: new chatbot.attachment.uploadFailed;
    • spreadsheet not read: new chatbot.attachment.notRead.

    Both new keys are added to all 11 language packs. ChatbotEnhanced.tsx gets only an import and one UserAttachments block in the user branch of renderMessage.

  • The send. useObjectChat().sendMessage takes an optional fourth argument, ChatTurnExtras (modelNote, localAttachments). A turn with no words now sends when it carries a file part or a model note. ChatPane.tsx prepareTurn returns the words and these extras, and no longer appends notes to the text.

  • What the model receives (a change). The "sent as files" lines (filesSent, English and Chinese) are gone. The server already names each stored file part to the model: chatFileReferenceLine in cloud packages/service-ai/src/chat-files/chat-file-parts.ts, plus the per-file read status block in chat-file-turn.ts (statusText). I measured this by reading both files at cloud c3ed329. A file that was not sent never reaches the server, and a spreadsheet is never uploaded, so their lines still reach the model, now inside the marked model-note part. The chat route joins a message's text parts as they are (cloud routes/message-utils.ts normalizeMessage), so the model reads the words followed by the note, separated by a blank line.

Remainder of the card, not in this PR (item 3: the same display after a reload or reopening history). Measured, not reachable in this surface. The stored user row is the text parts joined plus one [Attached file "NAME", fileId ID] line per file. After this PR the text parts are the words plus the marked note. The file parts themselves are not kept. A reload therefore draws the note and the reference lines as text. Two halves are needed:

Once both halves land, this PR's mapper and bubble draw a reloaded turn unchanged. The seat files the follow-up cards.

Serial constraints:

Tests

  • New ui/packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.userAttachments-39249.test.tsx (real userTurnParts, mapper and bubble):
    • part order and the note mark;
    • an image with no words draws a thumbnail linking to the stored file and none of the note;
    • words plus a PDF draw the words and a chip linking to the file;
    • files that were not sent draw chips and readable sentences, none of the model wording;
    • control;
    • only a stored chat attachment with a drawable address is drawn: a file part without objectstack.fileId, or whose url is data:, blob:, javascript:, protocol-relative (// or slash-backslash), another scheme or a bare relative path, draws nothing; a same-origin path and an https url do (control).
  • New ui/packages/app-shell/src/console/ai/__tests__/AiChatPage.bubbleAttachments-39249.test.tsx (real ChatPane send path and useObjectChat transport):
    • an image-only turn sends exactly one file part and no text;
    • with words plus a PDF, the text part is the words;
    • the not-read lines for refused files ride the marked note, while the bubble message gets the words plus localAttachments;
    • the spreadsheet brief rides the note;
    • control.
  • Two existing pins updated, because this change makes their old assertions false by design:
    • AiChatPage.attachmentNotesLanguage-34461.test.tsx asserted that the "Files the user attached … sent as files" line and its Chinese form are in the turn. Those lines no longer exist, because the server names sent files itself. The pins now assert they are absent. The "no words, thread language" case used an uploaded image, which now carries no note at all, so it uses an over-cap file whose not-read line still follows the thread's language.
    • AiChatPage.attachmentsUpload-32749.test.tsx asserted that the turn text contains the sent file names (receipt.png, invoice.pdf) from the same removed line. It now asserts that the text is exactly the person's words.
Runs at the head of this PR
  • vitest run packages/plugin-chatbot/ packages/i18n/ packages/app-shell/src/console/ai/: Test Files 240 passed (240), Tests 3008 passed, 13 skipped (3021).
  • At 8a96d7a77 (REWORK 1): vitest run packages/plugin-chatbot/ packages/app-shell/src/console/ai/: Test Files 130 passed (130), Tests 1143 passed; the bubble file alone 16 passed (7 earlier, 9 new). Turbo type-check for @object-ui/plugin-chatbot and @object-ui/app-shell, 74/74 successful.
  • Type-checks: turbo type-check for @object-ui/plugin-chatbot and @object-ui/i18n, 55/55 successful; for @object-ui/app-shell, 73/73 successful.
  • Ablation (source-resolved, one behaviour): in mapMessages.ts, the anchor p.type === 'text' && !isModelNotePart(p) was replaced by p.type === 'text' && true. Result: 4 failed, 8 passed across the two new files (each bubble and note assertion went red). Restored: blob equals HEAD, and git diff HEAD is empty.
  • Derived local gate families (dispatch-gates --commands), 41 in all: 39 ran with exit 0. Two were not measured: check:query-options-erasure (killed by a local 240 s per-command timeout) and the ui root vitest run scripts/ (not run). Both are left to CI.

Acceptance notes

  • ChatPane.tsx grows from 1000 to 1016 lines. The change stays inside prepareTurn, doSend and the import list; no new concern was added there.
  • A spreadsheet chip has no link: the file is parsed in the page and never stored, so there is nothing to open.
  • The model-note mark is an internal seam between app-shell and plugin-chatbot. The server ignores providerMetadata on text parts and the data-local-attachments part.

Verification

Files to read first, in risk order:

  1. ui/packages/plugin-chatbot/src/chat/userTurn.ts: the part shapes and the mark.
  2. ui/packages/app-shell/src/console/ai/ChatPane.tsx, prepareTurn: what the model still receives.
  3. ui/packages/plugin-chatbot/src/mapMessages.ts, extractText: the one line that keeps the note out of the bubble.

Two-minute check: open the console AI chat, attach a PNG, and send with no text. The bubble shows the image thumbnail and no "(Files the user attached …)" line. Clicking the thumbnail opens the image.


Generated by Claude Code

@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 3, 2026
… drop stray stored-answer lines

Claude-Session: https://claude.ai/code/session_012dn2AcfwnfHMghyeNLFvob
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-bob · os-bob · session_012dn2AcfwnfHMghyeNLFvob

维护者速读

席位意见:接受。返工 1 后气泡只画带 fileId 的已存附件、地址只认同源路径或 http/https,与注释和 cloud 的认法一致。

席位核对 — ACCEPT · repo:objectstack@os-bob · head 8a96d7a77f7f9cb959444b559cdc5ab2a040b338

  • Form: 27 files, +1074/−81. Part of #39249 is right: the card's items 1 and 2 (the bubble shows the person's words and the files) are delivered; item 3 (the same display after a reload) is not, see Out of scope. Clause-②: no, Metadata-protocol: none, no skills/**, no governed path: an ordinary landing, no contract review owed. Changeset patch on @object-ui/app-shell, @object-ui/plugin-chatbot, @object-ui/i18n. The seat read the diff and asked for one fix (REWORK 1): extractFileAttachments (ui/packages/plugin-chatbot/src/chat/userTurn.ts) took any file part with a url, against its own comment. It now takes a part only when providerMetadata.objectstack.fileId is a non-blank string (cloud chatFileRefsOf's test) and its url is a same-origin path (not // or slash-backslash) or http:/https:; 9 new pins cover the skipped schemes and a control. Two dead lines in storedAnswerData (mapMessages.ts) are gone.
  • Premise, measured: cloud 44a7c80 routes/message-utils.ts:62–74 stores a v6 user turn as its text parts joined plus one chatFileReferenceText line per file, so the server already names the sent files; the console's old "sent as files" line was a duplicate, and the model's input keeps every fact. The model note rides a text part marked providerMetadata.objectstack.modelNote, which the server ignores and the mapper filters out of the bubble.
  • Gates (check-runs at 8a96d7a7): 47 success, 17 skipped, 0 failed, 0 pending; check-expected-skips --pr 39263 reads every skip in main's roster (exit 0). Test UI 16/16, Type Check UI, Lint UI and Lint · scoped · query-options erasure (one of the two families the dev left to CI) success. Dev local at this head: 130 files, 1143 tests passed; type-check 74/74.
  • Accepted deviation: two existing pins edited because their old assertions are false by design: AiChatPage.attachmentNotesLanguage-34461.test.tsx and AiChatPage.attachmentsUpload-32749.test.tsx asserted the removed "sent as files" line. The 11-line ChatbotEnhanced.tsx hunk (import plus one UserAttachments block) is inside the claim's surface (ui/packages/plugin-chatbot/src/) but shared that file with fix(ai): the app AI page's first question box takes pasted and attached files #39257 in flight; the seat let it stand after the dev's report 7368326659. fix(ai): the app AI page's first question box takes pasted and attached files #39257 has merged; git merge-tree of this head with main is clean.
  • Out of scope: item 3 of the card (same display after a reload) cannot be met in this surface: the stored user row keeps no file parts. Server half filed objectstack-ai/cloud#5401 (store the words apart from the model note and keep the file fields structured). The hydrate half (useChatConversation.ts, console AI drawer: the conversation history defaults to the current app, has an All switch, and navigates to a conversation's app before opening it (#35014 item 4, after cloud#4835) #35081's surface) stays on AI 对话附文件发送后,用户自己的消息气泡里显示的是给模型看的说明「(Files the user attached (1): image.png — sent as files with this message.)」,看不到附件本身 #39249, which this PR does not close; once it merges the card goes to pm:blocked with Blocked-by: objectstack-ai/cloud#5401. Skills-docs: not owed (kind none).
  • Landing: K = 6 first-parent commits behind main (under 15). No generated artifact. Ready and auto-merge in this stroke.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/xl tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants