Skip to content

fix(plugin-chatbot): name an over-size attachment and the limit to the user instead of only console.warn - #35272

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-34463-composer-oversize-notice
Nov 19, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-34463-composer-oversize-notice

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Bill · project thread
Fixes #34463

Clause-②: yes (widening)
Metadata-protocol: none

The two widenings are additive: the new key chatbot.composer.fileTooLarge in every locale pack @object-ui/i18n publishes through ./locales, and the optional files field on the onError argument of PromptInputProps, exported as AIElements from @object-ui/plugin-chatbot.

维护者速读

  • 改了什么:聊天输入框里超过大小上限的文件,现在会在输入框上方显示一条提示,写明文件名和上限(按用户语言,11 种语言都有);一次选多个文件时,小文件照常附上,超限的逐个点名。
  • 为什么改:以前超限文件只进 console.warn,用户看到的是文件「没附上」却不知道原因;一次选了大小混合的文件时,大文件连 console.warn 都没有。
  • 风险与回滚:风险低,只动前端提示和 onError 的上报时机(混合选择多报一次,多带一个可选的 files 字段);回滚即还原本 PR。
  • 先看:ui/packages/plugin-chatbot/src/elements/prompt-input.tsx(addLocal 的超限分支);ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx(handlePromptInputError 与 ComposerNotice);ui/packages/i18n/src/locales/zh-Hans.ts(新键译文)。
  • 两分钟验证:在仓根跑 pnpm --dir ui exec vitest run packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.sendError.test.tsx,预期 14 个测试全绿,其中 5 个是本卡新增的超限提示用例。
  • 需要你做的:无,席位落地。

What changes

  • Producer (PromptInput, vendored AI Elements): addLocal now reports EVERY over-size file of a pick through onError({ code: 'max_file_size', files }). Before, it reported only a pick where every file was over the limit; a mixed pick attached the small files and dropped the large ones with no report at all. The error object gains one optional field, files?: File[] (the refused files); code and message keep their meaning.
  • Consumer (ChatbotEnhanced): the onError handler that only called console.warn now turns a max_file_size refusal into a notice above the composer, naming every refused file and the limit (10 MB by default, spelled by Intl.NumberFormat in the user's locale). It uses the band the chat already shows for an unsent message: SendErrorNotice's markup is now a shared ComposerNotice, so both read the same. The notice closes with its close button or on the next send; a later refusal replaces it. Other codes still go to console.warn (see Acceptance notes).
  • Translation: new pack key chatbot.composer.fileTooLarge ({{limit}}, {{files}}) in all eleven locale files under ui/packages/i18n/src/locales/, next to the composer's existing chatbot.composer.* keys. The close button reuses common.close.
  • Changeset: .changeset/34463-composer-oversize-notice.md, patch on @object-ui/plugin-chatbot and @object-ui/i18n.

Tests

A new top-level describe in ChatbotEnhanced.sendError.test.tsx, the composer-notice file, so no new harness file:

  • over-size file alone: the notice (role="alert") names the file and the limit, and the file is not attached;
  • mixed pick: the small file attaches, the notice names only the large one;
  • CONTROL: a file under the limit attaches with no notice;
  • the close button dismisses the notice;
  • under zh, the notice is the zh pack sentence and not the en one (read from the packs, not from literals).
Ablation (each leg through scripts/ablation-replace.mjs, restored and verified as blob == HEAD)
  • Producer: if (oversized.length > 0) { became if (oversized.length > 0 && sized.length === 0) { (the old mixed-pick silence). Result: × a mixed pick attaches the file under the limit and names only the one over it, Tests 1 failed | 4 passed | 9 skipped (14). Restored: blob == HEAD (5d03375a8c39) and git diff HEAD is empty.
  • Consumer: if (e.code === 'max_file_size' && e.files?.length) { changed so it never matches (the old console.warn-only handler). Result: the over-size, mixed, close and zh cases fail, CONTROL passes, Tests 4 failed | 1 passed | 9 skipped (14). Restored: blob == HEAD (de5e3f172a98).

The test imports ../ChatbotEnhanced from source, so no dist rebuild was needed for either leg.

Package suites and typecheck, at head a4b0e49
  • pnpm --dir ui exec vitest run packages/plugin-chatbot/ packages/i18n/ --maxWorkers=2 exited 0: Test Files 207 passed (207), Tests 3006 passed | 13 skipped (3019). The i18n locale gates (key parity across all locales, glyph and quote rules) are in this run.
  • pnpm --dir ui exec vitest run scripts/ --maxWorkers=2 exited 0: Test Files 171 passed | 2 skipped (173).
  • pnpm --filter @object-ui/plugin-chatbot type-check exited 0, and so did pnpm --filter @object-ui/i18n type-check. Both run tsc -p tsconfig.test.json, which includes src/**/*.test.tsx.

Acceptance notes

  • The accept and max_files codes. accept has the same shape as the bug this PR fixes: it reports only a pick where every file fails the type check, and drops a failing file from a mixed pick silently. Its fix is in other lines of addLocal, so it stays out of this PR. A separate, larger defect sits under it, and the agent's report hands it to the seat as a finding instead of fixing it here: matchesAccept compares each accept token with File.type, so extension tokens (.pdf, .csv, .xlsx …) never match. A probe render of ChatbotEnhanced (enableFileUpload, default acceptedFileTypes) picked claims.csv (text/csv), then r.pdf (application/pdf), then ok.png. The two warnings were ["accept","accept"]: the csv and the pdf did not attach, and only the png did. ChatbotEnhanced passes no maxFiles, so max_files never fires in this composer. Both codes still reach only console.warn here; making them visible needs their own wording and the matchesAccept fix first.
  • Provider mode is not checked. PromptInputProvider's add() applies neither accept nor maxFileSize. ChatbotEnhanced does not mount a provider, so nothing reaches this today.
  • Published declaration surface (measured on the built dist). The new key appears in all eleven dist/locales/*.d.ts of @object-ui/i18n, which the package publishes through its ./locales export: as a readonly literal in en, zh-Hans and zh-Hant, and as string in the others. PromptInputProps['onError'] gains the optional files field. It is exported as AIElements from @object-ui/plugin-chatbot. Both are additive. The seat ruled them Clause-②: yes (widening), and the declaration lines above and in the changeset say so.
  • The size unit. The limit is a binary size (10 * 1024 * 1024), shown with the locale's megabyte unit label as 10 MB. That matches how the composer's default has always been described.

Verification

  • Local derived gates: node scripts/pm/dispatch-gates.mjs --commands named 41 commands at head a4b0e496, and all 41 exited 0. Reconciliation: ✓ dispatch-gates --ran: 41 derived famil(ies) accounted for — 41 run, 0 NOT-MEASURED (a DERIVED zero — all 41 recorded an exit code and none of them is 3).
  • node scripts/check-nul-bytes.mjs exited 0.
  • CI runs the full set, including Lint UI, Type Check UI, Test UI and the type-check lanes.
  • Not measured in a live browser. The behaviour is pinned at the component level in jsdom.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ

…e user instead of only console.warn

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
@github-actions github-actions Bot added size/m 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 Nov 19, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CZrgaiMgTJCnswR6jQ

Final head for review · area ux-2 · 2026-11-19T01:38Z
Head: 4589e54e905c4c58176a68bde1467c1bf74acdda — check runs: 46 success, 15 skipped, 0 failed (the one cancelled PR-body guards run was superseded by a body edit; its rerun on this head is success, 135264033804). The three reds on the earlier head a4b0e496 were aggregators over lanes cancelled when this head was pushed.
Fixes #34463 · Clause-②: yes (widening) (claim amended after the dev's measurement: new published locale key chatbot.composer.fileTooLarge, optional files on exported PromptInputProps.onError) · Metadata-protocol: none · +206/−8.
Review route: L1-a thread, with the ## Contract review record owed for the widening. Landing after its ACCEPT, by the area.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 4589e54e905c4c58176a68bde1467c1bf74acdda
Local-runs: none
Scope: ui/packages/plugin-chatbot/src/elements/prompt-input.tsx, ui/packages/i18n/src/locales/ar.ts, de.ts, en.ts, es.ts, fr.ts, ja.ts, ko.ts, pt-BR.ts, ru.ts, zh-Hans.ts, zh-Hant.ts + ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx, .changeset/34463-composer-oversize-notice.md
Security-touching: no

Face: declaration (Clause-②: yes (widening) on the PR body and the changeset), no published schema, no governed path (check-governed-merges: 0 of 15). Reviewed at this head; the only commit after the dev's reported head a4b0e496 is a 3-line changeset edit adding the declaration lines.

① Derived judgments

  • PromptInputProps.onError gains files?: File[] (optional, additive). PromptInputProps is reachable from the published @object-ui/plugin-chatbot entry as AIElements (export * as AIElements from './elements' in src/index.tsx), so this is a published type widening. A host typed against the old shape still compiles: the field is optional on an argument the host receives.
  • Behaviour change at the same boundary: onError({ code: 'max_file_size' }) now fires for a mixed pick too (before: only when every accepted file was over size). code values unchanged; message gains a second string for the mixed case. A host that treated max_file_size as "nothing attached" now also sees it when some files attached. Declared in the changeset's last paragraph, so a host reading the CHANGELOG is told. Accepted as a widening of when the event fires, not a narrowing: no input the host could send is refused, and no prior call disappears.
  • chatbot.composer.fileTooLarge added to all 11 packs under ui/packages/i18n/src/locales/, published through @object-ui/i18n's ./locales export. Additive key; placeholders {{limit}} and {{files}} are the same in all 11 (read line by line). The PR body reports the dist/locales/*.d.ts reading (literal type in en / zh-Hans / zh-Hant, string elsewhere), which matches how existing keys in those packs are typed.
  • The early return if (sized.length === 0) return; now also covers an empty incoming list (accepted empty, nothing over size). Before, that case fell through to setItems with nothing to add; same visible result.

② Semver level

Metadata-protocol: none ⇒ patch per AGENTS.md (a non-protocol change, widening or breaking, ships patch). The changeset bumps @object-ui/plugin-chatbot and @object-ui/i18n as patch, both packages the diff moves; both are published (no private). Correct.

③ Boundary flags

  • Dev flag 1, accept and max_files codes: accept has the same mixed-pick silence and matchesAccept never matches extension tokens (.pdf, .csv), measured by a probe render. Out of this card; filed as chat composer: extension accept tokens (.pdf, .csv, .xlsx…) never match, so a picked CSV or PDF is silently refused #35276 by the area (serialised after this PR). Answered.
  • Dev flag 2, provider mode (PromptInputProvider.add applies neither accept nor maxFileSize): ChatbotEnhanced mounts no provider (git grep PromptInputProvider outside prompt-input.tsx and tests: 0 hits). Not reachable today. Recorded, no card.
  • Dev flag 3, size unit (binary bytes spelled with the locale's megabyte label): matches how the composer's default has always been described. Accepted.
  • open_questions: none in the report.
  • SQL push-down: no data access in the diff. Not applicable.
  • Findings (all nit, none affects correctness or the contract): (a) the defaultValue passed with the key (Not attached, over the {{limit}} limit: {{files}}) differs from the en pack sentence (Too large to attach (limit {{limit}}): {{files}}); it only shows when the pack lacks the key. (b) The changeset's "closes … on the next send; a later refusal replaces it" is true in code (setAttachmentNotice(null) at the top of handleSubmit, before the queued branch; the setter replaces) but has no pin. Neither blocks.

Implemented-by: claude/issue-34463-composer-oversize-notice
Reviewed-by: session_01Utp6CXsZsKmgG1EcKp5bY4

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

维护者速读

  • 改了什么:聊天输入框里超过大小上限(默认 10 MB)的文件,现在会在输入框上方显示一条提示,写明文件名和上限,11 种语言都有;一次选多个文件时,小文件照常附上,超限的逐个点名。
  • 为什么改:以前超限文件只进 console.warn,用户只看到文件「没附上」不知道原因;大小混合的一次选择里,大文件连 console.warn 都没有。
  • 风险与回滚:只动前端提示和输入框组件的 onError 上报(混合选择多报一次、多一个可选 files 字段),两处都是只增不减的公开面变化,已做契约复审 PASS。回滚即 revert 本 PR。
  • 先看:elements/prompt-input.tsx 的 addLocal 超限分支;ChatbotEnhanced.tsx 的 handlePromptInputError 与 ComposerNotice;zh-Hans.ts 新键译文。
  • 两分钟验证:在 AI 聊天里附一个超过 10 MB 的文件,输入框上方出现带文件名和上限的提示,文件没有附上。
  • 需要你做的:无,区内落地(非受管面、216 行)。L1 意见:修得对,钉子与两腿消融齐全;两处小瑕疵(英文兜底文案与语言包不一致、「下次发送时关闭」没钉子)不挡落地。

席位核对 — ACCEPT (L1-a) · repo:objectstack#5 · head 4589e54e905c4c58176a68bde1467c1bf74acdda · 2026-11-19T01:41Z

  • 形态: draft → main, 15 files, +208/−8, 3 commits. Fixes #34463 on the first content line; no other card number beside a closing keyword. check-governed-merges: not governed, ≤ 3000 lines → ordinary queue landing. Clause-②: yes (widening), Metadata-protocol: none on both the PR body and the changeset.
  • 契约复审: owed by the Clause-②: yes declaration face (TIER_DEFAULT); record on this head: comment 6997046269, PASS, nits only. No needs:contract-review marker needed (PASS on record at this head).
  • Changeset: .changeset/34463-composer-oversize-notice.md, patch on @object-ui/plugin-chatbot + @object-ui/i18n (both published), the correct level for Metadata-protocol: none. Sentences read against the diff: the two additive widenings (key in every pack through ./locales; optional files on onError, exported as AIElements) match the diff; "names every refused file and the limit, in the user's language" matches handlePromptInputError + formatSizeLimit(maxFileSize, language); "closes with its close button or on the next send, and a later refusal replaces it" matches the code (close-button pin; next-send and replace read in code, not pinned, nit in the record); "reported only a pick where every file was over the limit; a pick that mixed sizes … with no report" matches origin/main's accepted.length > 0 && sized.length === 0; "an onError handler that ignores files sees one more call, for a mixed pick" is true.
  • 差异由 L1 读过: producer addLocal reports oversized whenever non-empty, then returns only if nothing fits; consumer turns max_file_size with files into the notice, other codes keep console.warn; SendErrorNotice markup lifted into ComposerNotice with an optional close button (send-error band unchanged: same classes, role="alert", testid passed through); 11 locale lines, same placeholders. Notice hidden in readOnly.
  • Pins: new describe in the existing composer-notice file: over-size alone (named, limit shown, not attached), mixed pick (small attaches, only the big one named), CONTROL under the limit, close button, zh reads the zh pack sentence and not the en one (read from the packs). Ablations in the PR body: producer leg 1 red, consumer leg 4 red with CONTROL green, both restored blob == HEAD.
  • 门禁: check-runs on head 4589e54e: all success or expected skipped; Lint & Repo Gates, TypeScript Type Check, Lint UI, Type Check UI, Test UI (aggregate + 16/16 shards), Build & E2E UI, Live E2E UI, Check Changeset all success. One PR-body guards run is cancelled, superseded on this same head by a later run of that check (body edit) that is success: no action. Dev local readings were at a4b0e496; the only delta to this head is the changeset's two declaration lines, and CI on this head covers every family.
  • 接受的偏差: Clause-② moved from no to yes (widening) after the dev measured the published .d.ts; the area amended the claim on the card. Correct direction.
  • 范围外去向: accept mixed-pick silence and matchesAccept never matching extension tokens → chat composer: extension accept tokens (.pdf, .csv, .xlsx…) never match, so a picked CSV or PDF is silently refused #35276 (filed by ux-2, after this PR). Provider mode applies neither filter → not reachable from ChatbotEnhanced, recorded in the contract record, no card.
  • 落地条款: K = 3 first-parent commits on main since merge base cdb327fd (< 15). It adds a key to existing packs, not a new locale pack. Non-governed ⇒ ux-2 lands per landing-operations.md (pr_ready + auto-merge) after this ACCEPT; on MERGED, close-out on chat composer: a file over maxFileSize is refused with only a console.warn, so the user sees the file silently not attach #34463 naming chat composer: extension accept tokens (.pdf, .csv, .xlsx…) never match, so a picked CSV or PDF is silently refused #35276.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CZrgaiMgTJCnswR6jQ

Landing · area ux-2 · 2026-11-19T01:42Z

reading value
L1-a ACCEPT + contract record ACCEPT 6997063136; ## Contract review 6997046269 (TIER_DEFAULT, PASS, nits only), both at head 4589e54e905c4c58176a68bde1467c1bf74acdda (= current head)
check-governed-merges --pr 35272 NOT governed, 216 lines ≤ 3000; K = 4 (cdb327fd..origin/main), no ui/**/locales/en.ts change on main since the base, no new locale pack, no os-regen path

State: draft → ready + auto-merge (merge queue). #34463 closes on merge via Fixes.

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/m 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.

chat composer: a file over maxFileSize is refused with only a console.warn, so the user sees the file silently not attach

2 participants