Response Versions

View registry JSON

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-versions
First 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

PropTypeDescription
countnumberRequired. Total number of response versions.
indexnumberRequired. Zero-based index of the version shown.
onIndexChange(index: number) => voidRequired. Called with the zero-based index to display.
onRegenerate() => voidOptional. Called when a new response is requested.
regeneratingbooleanOptional. Whether a new response is being generated.
childrenReact.ReactNodeRequired. The current version's content.