Mischief

42 / Agent UI

Response Actions

The row under an answer: copy it, ask again, and rate it. Drops into the actions slot on Message.

Live previewSource

Mischief

Rate limiting belongs in middleware so every route inherits it. Keep the counter in Redis with a sliding window, and return 429 with a Retry-After header once the window is full.

Not rated

Installation

Copy the source into your project, or keep it behind a package.

npx shadcn@latest add Tinkerers-Labs/mischief-ui/response-actions
import { ResponseActions } from "mischief-ui/response-actions"

Usage

export function Answer() {
  return (
    <Message
      role="assistant"
      actions={
        <ResponseActions
          copyText={answer}
          onRetry={regenerate}
          onFeedbackChange={record}
        />
      }
    >
      {answer}
    </Message>
  )
}

API

copyTextstringCopies this text. The copy control is absent without it.
onRetry() => voidAdds the try-again control.
retryLabelstringNames that control. Defaults to "Try again".
onFeedbackChange(feedback: ResponseFeedback) => voidTurns the rating controls on.
feedback, defaultFeedback"up" | "down" | nullControlled and uncontrolled rating.
labelstringNames the group. Defaults to Response actions.

Accessibility

The row is a labelled group of named buttons, so each one reads on its own. Ratings are toggles carrying aria-pressed, and choosing the current rating again clears it. Copying announces itself through a polite live region. The controls are 32px, matching the other compact toolbars in this set rather than the 44px targets used for primary actions; pass a className to enlarge them where this row is the main way to act.

Dependencies

  • lucide-react