Skip to content

Commit 19d67fd

Browse files
committed
wip: docs, changesets, regenerated spec references
Claude-Session: https://claude.ai/code/session_01L9qibyUpyff7pHe7vkFgA8 Co-authored-by: Claude <noreply@anthropic.com>
1 parent f1179fe commit 19d67fd

7 files changed

Lines changed: 83 additions & 9 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/spec': patch
3+
---
4+
5+
fix(spec): a legacy `ask_which` reading up to 60 characters reads as a question-card option
6+
7+
Clause-②: yes (widening) — widened: `parseAskQuestionEnvelope` now accepts a legacy `ask_which` result whose readings run up to 60 characters (it refused any reading over the envelope's 24-character label), and `ASK_QUESTION_LIMITS` gains `legacyReadingMaxLength: 60`.
8+
Metadata-protocol: none
9+
10+
Real `ask_which` readings are short phrases, most of them longer than the new envelope's 24-character label, so holding them to that label left most of today's questions as plain text. A legacy reading now has its own limit, 60 characters (the envelope's description length), and becomes an option label with no description. Every other rule still applies to the legacy result: one question of at most 120 characters, two to four readings, no duplicate or blank reading, a non-empty reply. The new `asked` envelope keeps its 24-character label.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@object-ui/plugin-chatbot': patch
3+
'@object-ui/app-shell': patch
4+
---
5+
6+
feat(plugin-chatbot): the question card takes the composer's place when the AI ends its turn on a question
7+
8+
Clause-②: yes (widening) — widened: `ChatbotEnhancedProps` gains the optional `conversationId`; `@object-ui/plugin-chatbot` (and its `/core` entry) exports `QUESTION_SKIP_STORAGE_PREFIX`; `QuestionCardQuestion` and `QuestionCardOption` keep their names and shape and are now the envelope types of `@objectstack/spec/ai` (`AskQuestionParsed`, `AskQuestionOptionParsed`), with `options` still read-only.
9+
Metadata-protocol: none
10+
11+
`ChatbotEnhanced` now draws the question card itself. When a turn ends on a question tool's result that `parseAskQuestionEnvelope` reads, and the envelope's `reply` is the turn's last text, the card replaces the composer:
12+
13+
- It shows only once the stream has ended, and never while a typed message is queued (that message is sent, and sending something else skips the question), while a write approval waits in the same turn, after a skip, or on a `readOnly` transcript. Both shapes of a tool-ended turn count: one streamed message, or the two messages a reloaded conversation holds.
14+
- The composer stays mounted, hidden and `inert`, so a draft and its attachments come back after Skip or an answer, and focus that was in it returns to it.
15+
- One click answers: the option label goes out through `onSendMessage` as the next user message. If the send fails and the message is rolled back, the card returns with its choice still made.
16+
- Skip is remembered on this device, per conversation, under `objectstack:ai-chat-question-skip:` plus the conversation id. The console passes its conversation id, and signing out clears these keys with the rest of the chat cache.
17+
- The conversation draws the question from its envelope instead of its plain-text reply: while pending, the question alone; once answered or skipped, a collapsed "AI asks: …" that expands to its options. Copy still copies the full reply, and a pending question shows no Regenerate.

‎content/docs/frontend/plugins/plugin-chatbot.mdx‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,27 @@ export function PendingQuestion({ messageId, onSend, onDismiss }: {
595595
- Strings come from the `chatbot.questionCard.*` keys of `@object-ui/i18n`; the
596596
card is right-to-left in Arabic.
597597

598+
`ChatbotEnhanced` draws the card itself. When a turn ends on a question tool's
599+
result that `parseAskQuestionEnvelope` (`@objectstack/spec/ai`) reads — the
600+
question envelope, or a legacy `ask_which` result — and the envelope's `reply`
601+
is the turn's last text, the card takes the composer's place:
602+
603+
- It shows only once the stream has ended, and never while a typed message is
604+
queued, while a write approval waits in the same turn, after a skip, or on a
605+
`readOnly` transcript.
606+
- The composer is not unmounted: it is hidden and `inert`, so a draft and its
607+
attachments come back after Skip or an answer.
608+
- An answer is sent through `onSendMessage` as the next user message. If the
609+
send fails and the message is rolled back, the card returns with its choice.
610+
- Skip is remembered on this device, per conversation, when the host passes
611+
`conversationId`: the key is `QUESTION_SKIP_STORAGE_PREFIX` followed by
612+
`:` and the conversation id. A host's sign-out cleanup should clear that
613+
prefix.
614+
- The conversation draws the question from its envelope: pending, the question
615+
alone; answered or skipped, a collapsed "AI asks: …" that expands to its
616+
options. Copy still copies the full reply, and a pending question has no
617+
Regenerate.
618+
598619
## Examples
599620

600621
### Simple AI Chat

‎content/docs/references/ai/ask-question.mdx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ Until the question tool emits this envelope, the one producer in the field
3838
is `ask_which`'s existing result,
3939
`{ success: true, status: 'asked_which', question, readings, reply }`.
4040
`parseAskQuestionEnvelope` reads it as one question whose options are
41-
the readings, with no description, and holds the result to the same
42-
`AskQuestionEnvelopeSchema` — one contract and one set of limits, so a
43-
legacy result the card cannot draw (a reading over the label limit, more
44-
than four readings) answers `null` and stays text, as it renders today.
41+
the readings, with no description, under the envelope's limits with one
42+
exception: a reading is a whole sentence-sized phrase, not a short label, so
43+
it is held to its own limit, `ASK_QUESTION_LIMITS.legacyReadingMaxLength`,
44+
and the card wraps it. Every other limit is the envelope's, so a legacy
45+
result the card cannot draw (a reading over its limit, one reading or more
46+
than four, a duplicate) answers `null` and stays text, as it renders today.
4547
Stored conversations keep their old results, so this reading stays as long
4648
as those rows can be shown.
4749

‎docs/audits/2026-07-unknown-key-strictness-ledger.counts/ai.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ hand-patch a number here** — fix the code or the verdict and regenerate.
1919

2020
| Dir | Sites |
2121
|---|---|
22-
| `ai/` | 114 |
22+
| `ai/` | 116 |

‎ui/packages/plugin-chatbot/README.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,27 @@ export function PendingQuestion({ messageId, onSend, onDismiss }: {
522522
- Strings come from the `chatbot.questionCard.*` keys of `@object-ui/i18n`; the
523523
card is right-to-left in Arabic.
524524

525+
`ChatbotEnhanced` draws the card itself. When a turn ends on a question tool's
526+
result that `parseAskQuestionEnvelope` (`@objectstack/spec/ai`) reads — the
527+
question envelope, or a legacy `ask_which` result — and the envelope's `reply`
528+
is the turn's last text, the card takes the composer's place:
529+
530+
- It shows only once the stream has ended, and never while a typed message is
531+
queued, while a write approval waits in the same turn, after a skip, or on a
532+
`readOnly` transcript.
533+
- The composer is not unmounted: it is hidden and `inert`, so a draft and its
534+
attachments come back after Skip or an answer.
535+
- An answer is sent through `onSendMessage` as the next user message. If the
536+
send fails and the message is rolled back, the card returns with its choice.
537+
- Skip is remembered on this device, per conversation, when the host passes
538+
`conversationId`: the key is `QUESTION_SKIP_STORAGE_PREFIX` followed by
539+
`:` and the conversation id. A host's sign-out cleanup should clear that
540+
prefix.
541+
- The conversation draws the question from its envelope: pending, the question
542+
alone; answered or skipped, a collapsed "AI asks: …" that expands to its
543+
options. Copy still copies the full reply, and a pending question has no
544+
Regenerate.
545+
525546
## Bundle considerations
526547

527548
This package depends on `streamdown`, `shiki`, `mermaid`, and `katex`

‎ui/packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.questionCard-37874.test.tsx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,19 @@ describe('Q2b — the card takes the composer place', () => {
127127
expect((screen.getByPlaceholderText('Ask…') as HTMLTextAreaElement).value).toBe('');
128128
});
129129

130-
it('a queued message holds the card back', () => {
130+
it('a message queued during the turn holds the card back and is sent instead', async () => {
131+
const onSendMessage = vi.fn();
131132
const { rerender } = render(
132-
<ChatbotEnhanced messages={ASKED.slice(0, 1)} onSendMessage={vi.fn()} isLoading placeholder="Ask…" />,
133+
<ChatbotEnhanced messages={ASKED} onSendMessage={onSendMessage} isLoading placeholder="Ask…" />,
133134
);
134135
const textarea = screen.getByPlaceholderText('Ask…') as HTMLTextAreaElement;
135136
fireEvent.change(textarea, { target: { value: 'actually, show costs' } });
136137
fireEvent.keyDown(textarea, { key: 'Enter' });
137-
rerender(<ChatbotEnhanced messages={ASKED} onSendMessage={vi.fn()} isLoading placeholder="Ask…" />);
138-
expect(screen.getByTestId('composer-queued-item')).toBeInTheDocument();
138+
await screen.findByTestId('composer-queued-item');
139+
// The turn ends on the question while a message waits: no card, the message goes out.
140+
rerender(<ChatbotEnhanced messages={ASKED} onSendMessage={onSendMessage} placeholder="Ask…" />);
139141
expect(screen.queryByTestId('question-card')).not.toBeInTheDocument();
142+
await waitFor(() => expect(onSendMessage).toHaveBeenCalledWith('actually, show costs', undefined));
140143
});
141144

142145
it('no card on a read-only transcript, which draws the question as past', () => {

0 commit comments

Comments
 (0)