Skip to content

feat(plugin-chatbot): QuestionCard, the card an AI clarifying question is answered on - #37932

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-vhuyc7
Nov 27, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-vhuyc7

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU

Requested by Tesla · project thread
Fixes #37873

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

维护者速读

  • 用户暂时看不到变化:这次只做问题卡组件本身(单题点一下就答、两题停在「发送」、自己输入、跳过、键盘和读屏、11 种语言),还没接进对话。
  • 属于「问题卡」专题第一段,让 AI 提澄清问题时用户点一下就能回答,接入对话是同专题的下一张卡。
  • 出错只影响这张卡本身,目前没有任何页面用到它,可以直接撤回。
  • 要你做什么:无。

What changes

  • New QuestionCard in @object-ui/plugin-chatbot (exported with QuestionCardProps, QuestionCardQuestion, QuestionCardOption): a pure component, questions in, onAnswer(text) / onSkip() out. Nothing renders it yet; wiring it in the composer's place is 问题卡专题 Q2b:问题卡接进对话(findPendingQuestion、顶替输入框且不卸载、对话内摘要、隐藏重新生成、跳过记号) #37874 (Q2b).
  • One question: a click on an option answers at once. Two questions: an option on question 1 moves to question 2; question 2 never answers on its own, it waits on Send with a one-line summary; Back keeps both choices.
  • "Type something else…" is always the last row: a one-line input, typing clears the picked option, Enter moves on or sends. IME composition is ignored.
  • Answer text: the label or typed text for one question; one header: answer line per question for two (question text when no header). The separator is the chatbot.questionCard.answerLine string, so zh-Hans/zh-Hant/ja write a full-width colon and fr its space-before-colon.
  • Options show description as a grey second line and recommended as a "Recommended" tag.
  • Keyboard: focus is never moved into the card from outside; while focus is inside, 1–4 pick, ↑/↓ move (options then the text row, wrapping), Ctrl/⌘+Enter moves on or sends. After a move to the next question, focus lands on that question's option (only when the move started inside the card).
  • Screen reader: a radiogroup labelled with "Question 1 of 2" and the question, one tab stop on the checked option; announce puts "A question is waiting for your answer" into a polite live region the host triggers.
  • Size: max-h-[60vh], the body scrolls inside, the button row stays fixed; className overrides.
  • Choices live in component state and survive a re-render with new props (the retry after a failed send); a new question is a remount with a new key.
  • Ten chatbot.questionCard.* strings in all 11 locale packs (ar, de, en, es, fr, ja, ko, pt-BR, ru, zh-Hans, zh-Hant generated from zh-Hans); the card sets dir from the session language, so Arabic is right-to-left.
  • README and content/docs/frontend/plugins/plugin-chatbot.mdx gain a "Question card" section; changeset @object-ui/plugin-chatbot + @object-ui/i18n patch.

Read first:

  1. ui/packages/plugin-chatbot/src/QuestionCard.tsx — pick / advance / compose (the stop-on-send rule and the answer text) and onKeyDown.
  2. ui/packages/plugin-chatbot/src/__tests__/QuestionCard.test.tsx — the behaviour pins.
  3. ui/packages/i18n/src/__tests__/untranslated-identity-4376.test.ts — one allowlist row for the format string.

Tests

  • QuestionCard.test.tsx (21, provider-less): single-click send, description and tag, typed answer and blank refusal, skip, re-render keeps the choice for a retry, two-question flow with summary and Back, Next disabled until answered, typed text on both questions, no focus move on mount, digits / Ctrl+Enter / Cmd+Enter, IME Enter ignored, ↑/↓ wrap, focus kept on page change, roving tab stop, radiogroup name, live region, defaults map equals the en pack.
  • QuestionCard.i18n.test.tsx (3, with provider): zh-Hans strings and the full-width-colon answer, ar is dir="rtl" and translated, en is ltr.
  • Ablation: making question 2 send on pick reds 2 of 21 (the two-question flow and the digit test); restored.

Acceptance notes

Verification

Two-minute check: pnpm --dir ui exec vitest run packages/plugin-chatbot/src/__tests__/QuestionCard.test.tsx packages/plugin-chatbot/src/__tests__/QuestionCard.i18n.test.tsx — expect 24 passed.

Local runs at 417e56e (two CI fixes since; CI green at 9179aac: 52 success, 10 skipped, 0 failed)
  • After 417e56e: a052f497 makes the README/docs snippet self-contained (it wraps the card in a small PendingQuestion component, so check:doc-snippets reads no free names); 9179aacd makes the free-text row a label wrapping its input instead of a clickable div (clickableNonControlCensus-13461). The census and the 24 QuestionCard tests pass locally at 9179aac.

  • pnpm exec vitest run packages/plugin-chatbot/ packages/app-shell/src/__tests__/product-neutral-renderer.ratchet.test.ts packages/app-shell/src/__tests__/defaults-maps-mirror-en-pack.test.tsx (from ui/, under the verify lock): Test Files 73 passed, Tests 734 passed.

  • packages/i18n/src/__tests__/: all green after regenerating zh-Hant and the allowlist row (the two reds before were zh-hant-generated and untranslated-identity-4376).

  • pnpm --filter @object-ui/plugin-chatbot run type-check, pnpm --filter @object-ui/i18n run type-check: exit 0.

  • eslint on the changed plugin-chatbot files: 0 errors (the warnings are the existing react-refresh ones in index.tsx).

  • Derived gates, exit 0 each: check:nul-bytes, check:gitlink-declared, check:cross-package-test-inputs, check:test-source-alias, check:undeclared-dep-imports, check:published-files, check:role-word, check-changeset-no-major, check-empty-changeset, check-adr-0087-registration, check:closed-ceremony-text, check-sdui-manifest, check:type-check-coverage, check:type-check-debt, ui check:i18n-keys, ui check:i18n-drift. The rest of the derived list and the full farm are CI's.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (not touched)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 27, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-tesla · session_01L9qibwSEecrzDjKjbk24r1
2026-11-27T12:45Z

L1 ACCEPT at 9179aacd5b4d4d05e3ddbac2cec4f5ceb5b6c05d (L1-a, build zone reviewer for the seat), with the seat's Clause-② review (TIER_DEFAULT, in-thread).

Face. l1-face --pr 37932: shape, Fixes #37873, changeset coverage (@object-ui/plugin-chatbot, @object-ui/i18n), declarations Clause-②: yes (widening) · Metadata-protocol: none all ok; dogfood and skills-docs not owed. CI at this head: 52 success · 10 expected skip · 0 failed · 0 pending; mergeable_state clean.

Head. Reviewed in full at 417e56ea; a052f497 adds one docs-only commit (the plugin-chatbot.mdx and README snippet wrapped in a PendingQuestion component so it compiles on its own, onAnswer={onSend} / onSkip={onDismiss}), read line by line; 9179aacd5b makes the typed row a <label> wrapping its input (cursor-text) instead of a <div> with a click handler that focused the input: the same behaviour, natively, and the input keeps its aria-label.

Card #37873, item by item (read in QuestionCard.tsx and the two test files).

  1. Props in (questions), onAnswer(text) / onSkip() out. ✓
  2. One question: a click sends the label at once (sends the option label on a single click). ✓
  3. Two questions: Q1 advances, Q2 stops on Send with a one-line summary, Back keeps both choices (two tests). ✓
  4. 「自己输入…」 last, one line, typing selects it and clears the option, Enter = next/send, blank text not sent. ✓
  5. Answer text: label/typed for one; header:answer per line for two, question text when no header. ✓
  6. Description as a grey second line, 「推荐」 badge. ✓
  7. No forced focus; digits 1–4 / ↑↓ wrap / Ctrl·⌘+Enter only inside the card; IME composing ignored; radiogroup labelled by progress + question with a roving tab stop; aria-live polite gated by announce (Q2b triggers it). ✓
  8. Card scrolls inside (min-h-0 flex-1 overflow-y-auto) above a shrink-0 button row. ✓ (see nit N1)
  9. All 11 locales carry the strings; dir follows the locale, Arabic RTL tested; zh-Hans tested string by string. ✓
  10. Choices survive a re-render with new props (keeps the picked option across a re-render…). ✓
    Acceptance test list (single-click send, two-question flow with back, typed answer, skip, keyboard, RTL, composition) is all present. Fixes is right: the card is the pure component only; wiring is Q2b 问题卡专题 Q2b:问题卡接进对话(findPendingQuestion、顶替输入框且不卸载、对话内摘要、隐藏重新生成、跳过记号) #37874.

Clause-② (widening). The published surface grows by QuestionCard and three types, and every locale pack gains ten chatbot.questionCard.* keys; nothing existing is removed or narrowed. QUESTION_CARD_DEFAULT_TRANSLATIONS stays off the barrel, and a test holds it byte-identical to en. The changeset's Clause-② line names exactly what the diff exports.

Deviations judged.

Sentences read. .changeset/37873-question-card.md and content/docs/frontend/plugins/plugin-chatbot.mdx match the code sentence by sentence (one-click send, Send on the second question, typed row, focus never taken, keys only inside, re-render keeps choices, key remount, Arabic RTL).

Nits (do not block).

  • N1: item 8 says about 60% of the input area; the card caps at max-h-[60vh]. A fair reading for the full-screen and drawer layouts, and className lets Q2b tighten it if the dock needs it.

Body. The "Local runs at 417e56e" block names an older head and the old snippet; the thread patches it on this head (prose only, no record moves).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU

Landing · 2026-11-27T12:50Z · zone o3-askai (seat card thread)
Head-sha: 9179aacd5b4d4d05e3ddbac2cec4f5ceb5b6c05d

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/l tests 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.

问题卡专题 Q2a:QuestionCard 纯组件(单题点选即发、两题停在发送、自己输入、跳过、键盘读屏、全部语种)

2 participants