Response Versions
Step between regenerated answers with "2 / 3", and regenerate without losing the old ones.
Install with the shadcn CLI
npx 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.
components.json
{
"registries": {
"@cavemio": "https://registry.cavemio.dev/r/cavemio-{name}.json"
}
}Overview
Step between regenerated answers with "2 / 3", and regenerate without losing the old ones.
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. |