Skip to content

Preview and debug

Press Preview in the top bar to run the open document for real. Mica first checks the document’s interactions with the same validators import uses; if anything is wrong it shows Fix document errors before previewing. and stays in edit mode. When Preview starts, it closes Map and clears field highlights.

The preview takes a snapshot of the document and seeds a fresh session store from its state, plus each declared business object’s design sample at /objects/{alias}/data. It then binds an offline mock host built from those declarations, samples, and any fixtures in the document’s {stem}.mica-design.json sidecar. With no sidecar, every declared verb auto-plays its sample (host actions succeed). Then:

  • Buttons fire their actions. setState writes the session store and goToPage switches the preview’s page.
  • $bindState form controls are editable and write the session store. An Input fires its commit actions when you press Enter (a text area: never) or leave the field after changing it (a typed date too, a date picked from a calendar at once); a NumberField, Choice or Toggle on each change; a Slider when you let go of it. Unbound controls stay read-only. A control whose writable reads a declared field follows the mock: fields are writable when the alias declares update.
  • visible conditions and $cond markers react to every change.
  • Business-object verbs and declared host actions run against the mock. Fixture outcomes are sample, error, fieldErrors, delay and not-found; host actions succeed, or reject as cancelled or failed. A rejection stops the rest of the event, so a Save that then goToPages stays on the form when the mock returns field errors. A delete, and a create or update that carries a confirmation, first asks it exactly as the runtime would; declining records cancelled.
  • lifecycle.startup does run against the mock, so fetch-on-start is visible.
  • A later fetch of the same alias returns the session’s current data, including writes this preview made, until Reset. A record with no design sample fetches as not-found.

While the preview is open, authoring and document undo are disabled.

The customer profile example in the designer’s preview: the sample record shows, Edit profile and Close account are visible because the mock reports those operations as allowed, and the event log records the mock’s startup fetch.

Declared capabilities report as implemented and allowed in this mock, so a control gated on …/capabilities/update/allowed shows. A live host can still hide it. The canvas (edit mode) stays disconnected: samples render, verbs do not run.

The panel on the right records every action dispatch and settle, newest last: the action name, a summary of its parameters, whether it succeeded, how long it took, and the state paths it changed as path: before → after. Object action rows name the object and its declared input names and kinds — never the values — plus the element whose event fired it (a Button’s press or a form control’s commit) and the resulting phase. Hide collapses the panel and Clear log empties it.

  • Reset preview recreates the session from the entry snapshot and returns to the first page.
  • Exit preview, or Esc, discards the session and returns to editing.

Nothing done in the preview is ever written to the document, exported, or added to undo history.

The designer preview is offline on purpose: it plays samples and sidecar fixtures, never a live host. To exercise real fetches, writes, permission answers and host errors, run the document in a host. The live examples on this site do that with in-browser stand-in hosts, and examples/mock-host does it with a hand-written binding you can edit.