fix(B01): preserve question routing and nested disclosure state

This commit is contained in:
Codex committed 2026-10-21 13:13:16 +09:00
1 parent 21ca0e0fc3
commit 51531dcae8
15 files changed
+341 -55

No files matched your search

@@ -44,3 +44,32 @@ const expandedGrouped=renderToStaticMarkup(<CompletedFold parts={message.parts!}
assert.deepEqual([...expandedGrouped.matchAll(/data-index="(\d+)"/g)].map(m=>Number(m[1])),[0,1,2,3,4,5])
assert.deepEqual([...expandedGrouped.matchAll(/data-local-group="(\d+)"/g)].map(m=>Number(m[1])),[1,4],
'opening completion must preserve independently controlled local summaries')
// A01: exercise the real native name through MessageBubble, not just its projection.
const nativeQuestion = {...question, status: 'done' as const, tools: question.tools!.map(tool => ({...tool, output: 'RAW SDK ANSWER'}))}
for (const name of ['AskUserQuestion', 'askuserquestion', 'ask_user_question', 'AskFollowupQuestion', 'ask-followup-question']) {
const fixture = {...nativeQuestion, tools: nativeQuestion.tools.map(tool => ({...tool, name}))}
const before = JSON.stringify(fixture)
const markup = renderToStaticMarkup(<MessageBubble message={fixture}/>)
assert.match(markup, /ask-user-question--completed/, `${name} routes to dedicated question card`)
assert.doesNotMatch(markup, /RAW SDK ANSWER/, `${name} suppresses raw SDK answer`)
assert.equal(JSON.stringify(fixture), before, 'rendering does not rewrite recorded names or metadata')
}
const ordinary = renderToStaticMarkup(<MessageBubble message={{...nativeQuestion, interactions: [], tools: [{...nativeQuestion.tools[0], name: 'CustomQuestionReporter', metadata: undefined}]}}/>)
assert.doesNotMatch(ordinary, /ask-user-question--completed/)
assert.match(ordinary, /RAW SDK ANSWER/, 'ordinary tools retain their raw output')
console.log('A01 native MessageBubble identity aliases, immutable inputs and ordinary raw output passed')
const importedNative = {...nativeQuestion, interactions: [], tools: nativeQuestion.tools.map(tool => ({...tool,
args: {questions: [{id: 'q1', question: 'Imported native question'}]}, output: 'q1 -> imported answer', metadata: {importedHistory: true}
}))}
const importedMarkup = renderToStaticMarkup(<MessageBubble message={importedNative}/>)
assert.match(importedMarkup, /ask-user-question--completed/)
assert.equal(importedNative.tools[0].name, 'AskUserQuestion', 'historical display adaptation does not rewrite stored name')
const duplicateMarkup = renderToStaticMarkup(<MessageBubble message={{...nativeQuestion, interactions: [...nativeQuestion.interactions!, ...nativeQuestion.interactions!]}}/>)
assert.equal((duplicateMarkup.match(/ask-user-question--completed/g) || []).length, 1, 'linked answers have one dedicated card')
const legacyNative = {...nativeQuestion, parts: undefined, tools: nativeQuestion.tools.map(tool => ({...tool, metadata: {questionAnswer: {questions: [{id: 'legacy', question: 'Unknown-position question', answers: ['legacy answer']}]}}})), interactions: []}
const legacyNativeMarkup = renderToStaticMarkup(<MessageBubble message={legacyNative}/>)
assert.match(legacyNativeMarkup, /历史问答(原始位置不可用)/)
assert.equal((legacyNativeMarkup.match(/Unknown-position question/g) || []).length, 1)
assert.doesNotMatch(legacyNativeMarkup, /RAW SDK ANSWER/)
console.log('A01 imported native card, linked dedup and unknown-position compatibility passed')