Skip to content
Twentyfirst UIHalo

Message Editor

AI · MessageEditor, VersionSwitch

View as Markdown

Editing a sent message in place, and stepping between the versions it leaves behind. ChatMessage uses both (onEdit, versionCount); they work on their own too.

MessageEditor: value / defaultValue / onChange, onSubmit(text), onCancel, hint (default "The conversation runs again from here"), submitLabel, busy, autoFocus.

  • Enter sends, Shift+Enter adds a line, Esc cancels. The field grows with the text and opens with the caret at the end.
  • Say what happens: sending an edit runs the conversation again from that message.

VersionSwitch: "‹ 2/3 ›". count, index (0-based, default the newest) / defaultIndex / onChange, busy (the arrows wait while a new version is made), label.

  • Show it on an edited user message and on a regenerated answer; the answer below follows the version shown.
The conversation runs again from here
2/33/3

Props

MessageEditor

PropTypeNotes
value?string
defaultValue?string
onChange?(v: string) => void
onSubmit?(text: string) => voidEnter (or the button) sends the new text.
onCancel?() => voidEsc (or the button) cancels.
hint?stringThe line under the field (default "The conversation runs again from here").
submitLabel?string
label?string
busy?boolean
autoFocus?booleanFocuses the field with the caret at the end (default true).
className?stringExtra class on the root element.
style?CSSPropertiesInline style on the root element.

VersionSwitch

PropTypeNotes
countnumberHow many versions there are.
index?numberThe version shown, 0-based (default the newest).
defaultIndex?number
onChange?(index: number) => void
busy?booleanWhile a new version is being made: the arrows wait.
label?string
className?stringExtra class on the root element.
style?CSSPropertiesInline style on the root element.