import type { Meta, StoryObj } from 'storybook-solidjs-vite';
import {
ChainOfThought,
ChainOfThoughtStep,
ChainOfThoughtTrigger,
ChainOfThoughtContent,
ChainOfThoughtItem,
} from './chain-of-thought';
import { componentDescription } from '../stories/docs/element-controls';
const meta = {
title: 'Solid (Advanced)/Elements/ChainOfThought',
component: ChainOfThought,
tags: ['autodocs'],
parameters: {
layout: 'padded',
docs: {
description: componentDescription([
'A vertical, collapsible timeline that reveals an agent\'s reasoning as a series of connected steps. Composed of `ChainOfThought` (root) wrapping `ChainOfThoughtStep` items, each with a `ChainOfThoughtTrigger`, `ChainOfThoughtContent`, and one or more `ChainOfThoughtItem`s.',
'**When to use:** to surface multi-step reasoning, tool calls, or research progress behind an assistant response, letting users expand each step on demand.',
'**How to use:** map each reasoning step to a `ChainOfThoughtStep` (mark the final one with `isLast`); put the summary in `ChainOfThoughtTrigger` and the detail inside `ChainOfThoughtContent` / `ChainOfThoughtItem`.',
'**Placement:** above or within an assistant message, typically before the final answer.',
]),
controls: { exclude: ['use:eventListener'] },
},
},
argTypes: {
children: {
control: false,
description: 'The `ChainOfThoughtStep` items that make up the timeline.',
},
class: {
control: 'text',
description: 'Extra classes for the root wrapper.',
},
},
args: {},
render: (args) => (
Understanding the question
The user is asking about reactive programming concepts in SolidJS.
Formulating response
Combining insights from documentation and examples into a clear answer.
),
} satisfies Meta;
export default meta;
type Story = StoryObj;
const IMPORT = `import {
ChainOfThought, ChainOfThoughtStep, ChainOfThoughtTrigger,
ChainOfThoughtContent, ChainOfThoughtItem,
} from '@kitn.ai/chat';`;
const src = (code: string) => ({
parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } },
});
/** Interactive playground — expand the steps to reveal each reasoning item. */
export const Playground: Story = {
...src(`
Understanding the question
The user is asking about SolidJS reactivity.
Formulating response
Combining insights into a clear answer.
`),
};
export const SingleStep: Story = {
render: () => (
Analyzing the question
Breaking down the user's query into key concepts and identifying relevant knowledge areas.
),
...src(`
Analyzing the question
Breaking down the query into key concepts.
`),
};
export const MultipleSteps: Story = {
render: () => (
Understanding the question
The user is asking about reactive programming concepts in SolidJS.
Searching knowledge base
Found 3 relevant documents about SolidJS signals and reactivity.
Formulating response
Combining insights from documentation and examples to create a comprehensive answer.
),
...src(`
Understanding the question
The user is asking about SolidJS reactivity.
Searching knowledge base
Found 3 relevant documents.
Formulating response
Combining insights into a clear answer.
`),
};
export const WithCustomIcons: Story = {
render: () => (
}
>
Searching documents
Found 5 relevant results.
}
>
Analysis complete
All sources have been analyzed and synthesized.
),
...src(`
}>Searching documents
Found 5 relevant results.
}>Analysis complete
All sources analyzed and synthesized.
`),
};