Edit before run

Shows what the agent is about to do with every value editable, so you can fix one detail and approve instead of starting over.

Loading preview…

Install

  1. 1

    Run this command in your Tailwind CSS project. It adds components/ai/edit-before-run-action.tsx and installs its dependencies.

    $ npx shadcn@latest add https://gradientdeck.com/ai-components/r/edit-before-run-action.json

Usage & API

Example

edit-before-run-action.tsx
import { EditableEmail } from "@/components/ai/edit-before-run-action"

<EditableEmail
  draft={draft}
  value={value}
  onChange={() => {}}
  status={status}
  onSend={() => {}}
  onCancel={() => {}}
  from="…"
/>

Props EditableEmail

PropType & descriptionRequired
draftEmailFieldsWhat the agent wrote. Used for the edited markers, Reset and the diff.Required
valueEmailFieldsRequired
onChange(next: EmailFields) => voidRequired
statusDraftStatusRequired
onSend() => voidRequired
onCancel() => voidRequired
onUndo() => voidUndo a send or a discard while it's still possible.Optional
undoLeftnumberSeconds left to undo a send. Hidden at 0.Optional
fromstringRequired
sentAtstringShown on the receipt, e.g. "10:42".Optional

Dependencies

  • React
  • Tailwind CSS
  • motion
  • lucide-react
Implementation notes

The email card is labeled Draft from the address you pass. Each row is To, Cc, Subject, Message or Files, with a reset on any row that differs from the proposal and a dot to show it changed. Add a recipient and Add someone are the placeholders. No files attached shows when the list is empty. Send stays disabled until there is a recipient and a subject. If anything changed, the button reads Send with changes. Ctrl Enter sends from the message. Sending shows a spinner. After it goes, Undo counts down. Discard is the cancel path, and it can be undone the same way.

Choosing a layout

Use the email when the side effect is a message a person should read in full before it goes out. Use the arguments card when the side effect is a structured tool call and the person thinks in field names, or sometimes in the raw object. The form and JSON tabs are the same values, so a broken JSON blob cannot switch back to the form until it parses.

A yes-or-no on a proposal, without editing every field, is the decision inbox. A bundle of dates and amounts the agent still needs is the generative form. Edit before run starts from a complete draft. If the run already failed, run recovery is the place to change the input of the step that broke.

Can the person restore a single field without losing the other edits?

Yes. Reset on a row copies that field from the proposed draft and leaves the rest. The arguments form does the same per key. There is no control that reverts the whole card in one step other than running as proposed, which only exists when nothing has been edited.

Does the model see the secret or the email body from this card?

The card only edits the values you gave it and returns them through onSend or onRun. It does not talk to a model. What you do with the edited fields after that is outside the component.