AI message turn
Shown as Lathe, a made-up product
One turn with a coding agent and everything you can do with it: edit your question into a new version, copy, rate (a bad rating asks why), retry shorter or in more detail, page through versions, and select words in the answer to ask about them.
Installation
pnpm dlx shadcn@latest add "https://propui.dev/r/lathe-message.json?token=…"Adds the piece to components/propui/10-lathe-message/ and installs motion. Needs a free account: sign in and the command includes your token. Fonts load from Prop UI; download the zip to self-host them.
When to use
Reach for it when
- A single turn in an assistant or agent chat, with the actions people expect under a reply.
- Answers that include code people copy, rate and retry.
- Letting people follow up on part of an answer by quoting it.
Something else fits when
- A whole conversation that scrolls: put turns like this one in a thread that keeps your place.
- Messages between people: a messaging layout with avatars and read state fits better.
- A reply with tool calls and evidence: show those steps with the reply, not only its text.
Usage
Fills a full window: give it a container with a definite height.
import Piece from "@/components/propui/10-lathe-message/Section";
export default function Page() {
return (
<main className="h-dvh w-full overflow-hidden">
<Piece />
</main>
);
}Replace QUESTION, REPLIES, RETRY_OPTIONS and BAD_REASONS in data.ts. Each reply kind has its own text, code, time and token count, and Retry adds one as a new version.
Your data
Replace these and everything on screen follows.
REPLIESRecord<"default" | "shorter" | "detail", { ms; tokens; text; code: { file; lines } }>- The answer for each kind of retry, with its code block.
RETRY_OPTIONS{ kind; label; hint }[]- The items in the Retry menu.
BAD_REASONSstring[]- The reasons offered after a bad rating.
QUESTION, AGENTstring, { name }- The person's first message and the agent's name.
Interactions
- Edit your question: it reopens in place, and sending asks again while keeping the old version.
- Page through versions of your question and of the reply.
- Copy the reply or just its code; the icon turns to a check for two seconds.
- Rate the reply; a bad rating asks what went wrong, with reasons to pick.
- Retry the same answer, shorter, or with more detail.
- Select words in the answer, then Ask about this to quote them into the field.
Keyboard
- Enter
- In the edit field or the reply field, send.
- Shift+Enter
- Add a new line.
- Esc
- Cancel an edit, or close the Retry menu.
- ↑or↓
- In the Retry menu, move between options.
Behaviour
Read from the code: roles, motion, breakpoints and what runs.
Accessibility
- Icon buttons have names and show a label on hover and keyboard focus.
- Good and Bad are toggles with aria-pressed.
- Retry is a menu button with aria-expanded; its items are menuitems and focus moves into it.
- The reply is a polite live region and is marked busy while it streams.
- The code block is focusable so it can scroll with the keyboard; line numbers are hidden from screen readers.
Motion
- A new version fades in; the code block rises in once the text has streamed.
- The copy icon swaps to a check; the feedback panel and the quote open with a short height ease.
- Reduced motion streams in larger steps and stops the caret.
Responsive
- The card is at most 720px wide and grows with its content.
- At 640px and below the reply and actions use the full width.
- At 480px and below the Retry menu spans the actions row; at 400px and below the code block shows only the file name.
Performance
- Streaming is one 24ms interval that only runs while a reply streams.
- The selection button listens to selectionchange once; one local font file.
Notes for AI
Give your coding assistant the Markdown, not a screenshot.
- Keep every reply kind consistent: the same cause and the same fix, said shorter or longer.
- Wire Retry to regenerate with the reply kind as an instruction, and append the result as a new version.
- Every class is prefixed lm- and scoped under .lm; keep colours in the tokens at the top of post.css.
/p/lathe-message/markdownThe whole library for assistants: llms.txt, or the MCP server in AI tools and MCP.