Response Versions
Response Versions
Step between regenerated answers with "2 / 3", and regenerate without losing the old ones.
Dependencies
Installation
Add this component with your preferred package manager.
pnpm dlx shadcn@4.21.5 add @cavemio/response-versionsFirst install? Configure @cavemio once
Run npx shadcn@4.21.5 init if shadcn is not set up, then merge this entry into the registries field in your existing components.json. Keep your other settings and registries.
{
"registries": {
"@cavemio": "https://registry.cavemio.dev/r/cavemio-{name}.json"
}
}Usage
A separate assistant-answer wrapper sharing Number Roll with Message Edit. Demo regeneration is simulated locally. The caller owns version history, selected index, and generation requests.
import { ResponseVersions } from "@/components/response-versions";
<ResponseVersions count={versions.length} index={index} onIndexChange={setIndex} onRegenerate={regenerate} regenerating={busy}>
{versions[index]}
</ResponseVersions>Props
| Prop | Type | Description |
|---|---|---|
| count | number | Required. Total number of response versions. |
| index | number | Required. Zero-based index of the version shown. |
| onIndexChange | (index: number) => void | Required. Called with the zero-based index to display. |
| onRegenerate | () => void | Optional. Called when a new response is requested. |
| regenerating | boolean | Optional. Whether a new response is being generated. |
| children | React.ReactNode | Required. The current version's content. |
Accessibility & motion
Native previous/next buttons are disabled at the ends. The version counter is announced politely. Leaving content is inert and hidden from assistive technology. Regenerate is disabled while busy; reduced motion swaps content immediately and disables the spinner and counter movement.
pnpm dlx shadcn@4.21.5 add @cavemio/response-versions