Skip to content

fix(plugin-chatbot): composer accept list reads the HTML accept grammar; a refused type is named to the user - #35330

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-35276-composer-accept-tokens
Nov 19, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-35276-composer-accept-tokens

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Bill · project thread

Fixes #35276

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:AI 聊天输入框的附件类型判断改为按 HTML accept 语法(.ext 按文件名后缀、type/* 按 MIME 前缀、其余按 MIME 精确匹配,均不区分大小写);被拒的文件在输入框上方的提示条里点名并列出允许的类型。
  • 为什么改:默认允许列表是 .pdf,.csv,.xlsx… 这类后缀,旧逻辑拿它和 MIME 类型逐字比较,永远不相等——用户选了 CSV / PDF 却静默附不上,只有控制台有一条 warn。
  • 风险与回滚:仅 @object-ui/plugin-chatbot 一个包、纯前端;回滚即 revert 本 PR。onError 对“部分被拒”的选择多回调一次(同 code: 'accept',带 files),不读 files 的宿主行为不变。
  • 先看:ui/packages/plugin-chatbot/src/elements/prompt-input.tsx(fileMatchesAccept 与 addLocal 的拒收上报)、ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx(handlePromptInputError 的 accept 分支与同一次选择的提示合并)、测试文件 ChatbotEnhanced.sendError.test.tsx 新增的 describe。
  • 两分钟验证:pnpm --dir ui exec vitest run packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.sendError.test.tsx,预期 22 passed(含新增 8 条 objectstack#35276 用例)。
  • 需要你做的:无,席位落地。

What changes

  • PromptInput (vendored AI Elements, elements/prompt-input.tsx): the accept check moves into one module-level helper, fileMatchesAccept, that reads the HTML accept grammar: a .ext token matches the end of the file NAME, a type/* token matches the MIME prefix, any other token matches the MIME type exactly, all case-insensitive; an empty list admits everything. The helper is not exported (no new public symbol).
  • addLocal now reports EVERY type-refused file through onError({ code: 'accept', files }), in the all-refused case and in a mixed pick, mirroring the max_file_size shape the previous composer-notice change added. Before, a mixed pick dropped the type-failing files with no report, and the all-refused report carried no files.
  • ChatbotEnhanced: handlePromptInputError shows an accept refusal in the existing ComposerNotice band (chat-attachment-refused), naming the refused files and the accepted list. The sentence reuses the existing pack key fields.file.typeNotAccepted (present in every built-in locale pack), so no locale file changes and no new key. Refusals reported by one pick (wrong type and over size) are joined into one notice instead of the second replacing the first.
  • Changeset: .changeset/35276-composer-accept-tokens.md, patch on @object-ui/plugin-chatbot.

Tests

New top-level describe in the existing composer-notice harness ChatbotEnhanced.sendError.test.tsx (8 cases):

  • a CSV and a PDF picked with the default accept list attach, with no notice;
  • a .ext token matches the name case-insensitively whatever type the browser reported (EXPORT.CSV with an empty type, Book.XLSX as application/octet-stream);
  • extension, wildcard and exact-MIME tokens (image/*,.CSV,application/pdf) each admit their own files and nothing else (video/mp4 and application/x-pdf refused);
  • a refused type shows the notice (role="alert") naming the file and the accepted list, and is not attached;
  • a mixed pick attaches the accepted file and names only the refused one;
  • one pick refused for type and for size names both files;
  • CONTROL: a .png with the default list attaches with no notice;
  • under zh the notice is the zh pack sentence, not the English one (proves the borrowed key resolves through the pack, not only through its English default).
Package run and type-check (head f14d489)
pnpm --filter @object-ui/plugin-chatbot run type-check && pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-chatbot/
 Test Files  103 passed (103)
      Tests  1058 passed (1058)
os-verify-lock: VERDICT command-exit 0
Ablations (each mutation proven on disk by scripts/ablation-replace.mjs, restored to the HEAD blob)

The test resolves ../ChatbotEnhanced from source, so no rebuild is involved.

  1. Extension arm off in fileMatchesAccept (if (token.startsWith(".")) { to if (false && token.startsWith(".")) {): 4 failed / 18 passed, the CSV-and-PDF, case-insensitive-extension, grammar and mixed-pick cases red.
  2. Notice branch off in handlePromptInputError (the e.code === 'accept' arm to false): 5 failed / 17 passed, the grammar, refused-type, mixed-pick, type-and-size and zh cases red.
  3. Mixed-pick report off in addLocal (if (refused.length > 0) { to if (refused.length > 0 && accepted.length === 0) {): 3 failed / 19 passed, the grammar, mixed-pick and type-and-size cases red.

Every restore: blob equals HEAD and git diff HEAD is empty.

Acceptance notes

  • Multi-file refusal grammar: the borrowed sentence is singular ("NAME" is not an accepted file type (LIST)); a pick refusing several files lists their names inside it. A plural-aware sentence would need a new key in every published locale pack (a widening), which the dispatch asked to avoid when an existing sentence fits.
  • Two copies of the accept grammar now exist under ui/: this one and the private matchesAcceptEntry / acceptError in @object-ui/fields FileField.tsx. They differ deliberately in one point: the field widget admits a pick no entry can be weighed against (mirroring the server's save-time check), while the composer has no server check behind it and refuses. Noted, not filed (no defect).
  • PromptInputProvider's attachments.add (provider mode) applies no accept, size or count check at all; ChatbotEnhanced does not use provider mode, so nothing reaches it today. Noted, not filed.
  • Browser: verified in jsdom only (as the card was filed); no live-app run.

Verification

Derived gate families (node scripts/pm/dispatch-gates.mjs --commands, tree f14d489)

All 39 derived families exit 0 locally; reconciliation:

node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-sdui-manifest.mjs :: exit 0
node scripts/check-sdui-manifest.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --dir ui exec vitest run scripts/ :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm --filter @objectstack/spec run check:error-code-provenance :: exit 0
pnpm check:adr-anchors :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0

✓ dispatch-gates --ran: 39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero — all 39 recorded an exit code and none of them is 3).

Also run: pnpm check:new-line-citations (ui): VERDICT new-cross-file-line-citations: 0 new citation(s). Every family CI runs is read from this PR's check-runs, not re-run here.

node scripts/pm/overlap-check.mjs: VERDICT clean exit 0 (against origin/main, 0 PR heads sharing a file).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ

…ar; a refused type is named to the user

Fixes the extension tokens (.pdf, .csv, .xlsx...) of the default accept
list never matching, and reports every type-refused file through
onError({ code: 'accept', files }) in the composer notice band.

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-19T05:28Z
Head: f14d489bcbf498a69f57bcf899c0d7fe24a1e87d — all check runs on it concluded: 39 success, 13 skipped, 0 failed. Mergeable: clean.
Fixes #35276 · Clause-②: no (reuses existing key fields.file.typeNotAccepted, no new export) · Metadata-protocol: none · +215/−31 over 4 files. Not governed.
Review route: L1-a thread. Landing after its ACCEPT, by the area.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

维护者速读

  • 改了什么:AI 对话输入框的附件类型判断改按 HTML accept 规则读:.pdf、.csv 这类扩展名按文件名结尾比对,所以默认列表里的 CSV、PDF、表格能附上了;类型不符的文件会在输入框上方点名提示(沿用现有语言包句子,不加新键)。
  • 为什么改:卡 chat composer: extension accept tokens (.pdf, .csv, .xlsx…) never match, so a picked CSV or PDF is silently refused #35276。以前扩展名一律拿去和 MIME 类型比,永远不等,CSV/PDF 被静默拒绝,只进 console.warn。
  • 风险与回滚:只改聊天插件;一次选择里既有类型不符又有超大的文件时,两句提示合成一条。回滚即 revert 本 PR。
  • 先看:prompt-input.tsx 的 fileMatchesAccept;ChatbotEnhanced.tsx 的 handlePromptInputError。
  • 两分钟验证:跑 ChatbotEnhanced.sendError.test.tsx,新 describe 全绿。
  • 需要你做的:无,区内落地(非受管面、246 行)。L1 意见:可落。

席位核对 — ACCEPT (L1-a) · repo:objectstack#5 · head f14d489bcbf498a69f57bcf899c0d7fe24a1e87d · 2026-11-19T05:30Z

  • 形态: draft → main, 4 files, +215/−31. Fixes #35276. check-governed-merges --pr 35330: 0 of 4 paths governed, 246 lines ≤ 3000 → ordinary queue landing.
    • Clause-②: no holds. PromptInput is reachable from the published @object-ui/plugin-chatbot entry (export * as AIElements from './elements'), but its props type is unchanged: onError's files? was already declared, and code: 'accept' already existed.
    • What changes is that a mixed pick now gets one more onError call, with files set. That widens what a handler sees and narrows nothing. The changeset states it in its last paragraph.
    • The new notice reuses the existing pack key fields.file.typeNotAccepted (en/zh {{name}}/{{accept}}). Metadata-protocol: none.
  • Fixes vs the card: done-when has three parts, all met:
  • Correctness:
    • fileMatchesAccept follows the HTML grammar. .ext tokens match the lowercased name's end and are never compared with File.type. type/* matches the MIME prefix, and any other token matches exactly, all lowercased. An empty list admits all.
    • refused is computed with the same predicate, so accepted ∪ refused = the pick.
    • The size check still runs only over accepted files.
    • The same-pick join holds: both onError calls fire synchronously inside one add, a queueMicrotask closes the tick, and a later pick starts a fresh sentence list and replaces the notice.
  • Changeset: .changeset/35276-composer-accept-tokens.md, patch on @object-ui/plugin-chatbot. I read each sentence against the diff:
    • "compared every token with the MIME type" matches the old matchesAccept.
    • The three-rule grammar sentence matches fileMatchesAccept.
    • "names it, with the accepted list, in the same notice ... fields.file.typeNotAccepted; no new key" matches handlePromptInputError.
    • "When one pick refuses files for type and for size, the notice names both" matches the tick join and its pin.
    • The onError paragraph (every refused file, files set, one more call for a mixed pick) matches the refused branch.
  • 接受的偏差: (1) Same-tick refusals are joined into one notice instead of the later one replacing the earlier. Without the join, the size sentence would erase the type sentence of the same pick. (2) overlap-check was re-run after the two pushes, which is procedural only.
  • Pins:
    • CSV and PDF attach with no notice.
    • A .ext token matches case-insensitively whatever MIME the browser reported.
    • Ext, wildcard and exact tokens each admit only their own files.
    • A refused type is named with the list and not attached.
    • A mixed pick attaches the good file and names only the refused one.
    • Type plus size in one pick names both.
    • CONTROL: .png attaches.
    • zh: the notice is the zh pack sentence.
  • 门禁: check-runs on head f14d489b: 39 success, 13 skipped, 0 failure. The successes include Test UI and its 10 planned shards, Type Check UI, Lint UI, Build & E2E UI, Live E2E UI, Lint & Repo Gates, and Check Changeset.
  • 范围外去向: none.
  • 落地条款: K = 7 first-parent commits on main since merge base 00cfb78f (< 15). No 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: 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-19T05:31Z

reading value
L1-a ACCEPT comment 7000687498 at head f14d489bcbf498a69f57bcf899c0d7fe24a1e87d (= current head); both deviations accepted there
check-governed-merges --pr 35330 NOT governed, 0 of 4 paths, 246 lines ≤ 3000; K = 7 from merge base 00cfb78f, no change on main since to ui/packages/i18n/src/locales or ui/packages/plugin-chatbot

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

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 19, 2026 05:31
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 16d3abc Nov 19, 2026
53 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-35276-composer-accept-tokens branch November 19, 2026 05:53
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: extension accept tokens (.pdf, .csv, .xlsx…) never match, so a picked CSV or PDF is silently refused

2 participants