fix(storybook): support prompt state capture (#33798)

This commit is contained in:
Brendan Allan
2026-06-25 13:50:09 +08:00
committed by GitHub
parent 40ddede2b1
commit 6ec6db4ad6
@@ -73,7 +73,7 @@ export function createPromptState() {
key: item.key ?? `ctx:${++index}`, key: item.key ?? `ctx:${++index}`,
}) })
return { const value = {
ready, ready,
current: () => store.prompt, current: () => store.prompt,
cursor: () => store.cursor, cursor: () => store.cursor,
@@ -87,6 +87,7 @@ export function createPromptState() {
setStore("cursor", 0) setStore("cursor", 0)
setStore("items", (current) => current.filter((item) => !!item.comment?.trim())) setStore("items", (current) => current.filter((item) => !!item.comment?.trim()))
}, },
capture: () => value,
context: { context: {
items: () => store.items, items: () => store.items,
add(item: Omit<ContextItem, "key"> & { key?: string }) { add(item: Omit<ContextItem, "key"> & { key?: string }) {
@@ -116,6 +117,7 @@ export function createPromptState() {
}, },
}, },
} }
return value
} }
const prompt = createPromptState() const prompt = createPromptState()