Drafts and fixes
How a value gets into a field: a fix on a check, applyCheckFix, the model's ui.prefillDraft tool, the draft shown in the field, approval and rejection.
Baseera never writes to your form. It proposes a value, shows it beside the field, and writes only when the person approves, through the onChange you gave BaseeraField. A rejection writes nothing, so there is nothing to restore.
There are two sources of drafts: a check's fix, and the model.
A fix on a check
Return a fix from a failing check:
{
id: "tax-id-missing",
severity: "blocking",
fields: ["taxId"],
run: (r) =>
r.taxId
? { ok: true }
: {
ok: false,
message: "The tax ID is missing.",
fix: { field: "taxId", value: customer.taxId, reason: "From the customer record." },
},
}fix is { field, value, reason? }. field must be a declared field, and value is JSON of at most 2 KB. The reason is shown to the person with the draft; without one the check's message is used.
The type also accepts a tool call, { tool, input }. The built-in review panel applies field fixes only.
In the review panel, a check with a field fix gets an Apply fix button. Pressing it closes the panel, scrolls to the field and shows the draft there. A check without a fix gets Ask Baseera instead, which sends the message to the chat.
applyCheckFix in your own UI
If you draw your own review, call applyCheckFix(checkId) from useBaseeraImmersiveState():
const { openChecks, applyCheckFix } = useBaseeraImmersiveState();
{openChecks.blocking.map((c) => (
<button key={c.id} onClick={() => void applyCheckFix(c.id)}>
Apply fix
</button>
))}It resolves with the person's decision, { approved: true } or { approved: false, reason? }, or with null when there is nothing to show: no open check with that id has a field fix, or the field is not on the screen.
Drafts from the model
While a record is open and at least one field is on screen, the SDK offers the model two tools. You do not define them.
| Tool | Kind | Input | Result |
|---|---|---|---|
ui.focusField | read | { field } | { ok: true }, or an error "That field isn't on the screen" |
ui.prefillDraft | draft | { field, value, reason? } | approved: true, or { rejected: true, reason } |
ui.prefillDraft is how the model says "this field should be that". The field must be declared in useBaseeraImmersive and be on screen, and value must be JSON of at most 2 KB, or the call fails with an error result the model can read.
Unlike other draft tools, it is not approved on an approval card. Its call stays pending until the person decides in the field. If the person asks the model to fix the tax ID in chat, the draft appears under the Tax ID input while the conversation continues.
What the person sees
The draft is drawn right after the input, in a panel tagged Baseera draft (Baseera fix when it came from a check's fix). It shows the current value, the proposed value and the reason, with Approve and Reject.
- Approve calls your
onChangewith the proposed value and settles the draft. The model getsapproved: true. A check's fix also shows a "Draft applied" toast with Undo. - Reject opens an optional reason field. Confirm and the model gets
{ rejected: true, reason }with whatever the person typed. Nothing is written. Escape closes the reason field. - A newer draft for the same field replaces the older one. The older one resolves as rejected with "replaced by a newer draft".
- Closing the record, or stopping the turn, rejects what is pending. A closed record gives the reason "the record was closed".
Only one draft per field is pending at a time.
The values are shown exactly as onChange will receive them: a string as it is, anything else as JSON. Nothing is formatted, so what the person approves is what is written.
Wiring the field
import { BaseeraField } from "@baseera/ui/connected";
<BaseeraField name="taxId" value={taxId} onChange={(v) => setTaxId(String(v))}>
<input value={taxId} onChange={(e) => setTaxId(e.target.value)} />
</BaseeraField>name is the field's name in useBaseeraImmersive({ fields }). The wrapper is position: relative; display: block with data-baseera-field="taxId". Nothing is styled on your input.
With React Hook Form, pass field.onChange so an approved draft goes through the form's state:
<Controller
name="taxId"
control={control}
render={({ field }) => (
<BaseeraField name="taxId" value={field.value} onChange={field.onChange}>
<Input {...field} />
</BaseeraField>
)}
/>BaseeraField takes optional locale, dir, digits, labels and className to override its language and wording.
Headless
useBaseeraField(name, { onChange }) from @baseera/react returns { draft, flag, focused, approve, reject, bindRef, focusControl } if you want to draw the draft yourself. Put bindRef on your wrapper. approve() calls your onChange and settles the draft. reject(reason?) settles it with the reason and writes nothing.
Accessibility
The draft sits right after the input, so Tab reaches Approve and then Reject. The panel is in an aria-live="polite" region, and after a decision focus returns to the input. A flag's message is added to the input's aria-describedby, so screen readers read it with the field.
In the trail
draft_proposed, draft_approved and draft_rejected are written to the record's trail with the field, the reason and, unless the agent does not store tool data, the value. See Trail and webhook.
Next steps
AI checks
Write a rule in plain words on the agent, opt a screen into it by id, and let Baseera check the record against your knowledge, with sources, caching and a cost cap.
Notices and focus
How Baseera speaks up when a person pauses, how Later and Got it behave, how it moves them to a field, and what is not available yet.