Preview mode internals
Section titled “Preview mode internals”This page is for integrators and platform engineers who need to know how preview mode works under the designer: the request header, what the backend does with it, how sample data is generated, and the contract between the page designer and the embedded mobile client.
Two mechanisms
Section titled “Two mechanisms”Two mechanisms sit under the name. The first is a request-level mode: a request is tagged as preview, and the services answering it return generated data shaped exactly like the real thing instead of reading the store. The second, in the page builder, is a live mobile preview: the real mobile client, embedded in the builder and driven by the page you are editing.
Sample content is generated for the main data surfaces: entries (list, kanban board, tree, entry details), collections, saved queries and quick filters, system buttons, entry history and email logs, workflow status, dashboards and their statistics, timeline (post) feeds, and comment threads.
Which previews request sample data
Section titled “Which previews request sample data”Only the view designer’s preview panel requests sample data. On the web, the
panel provides the PREVIEW_MODE injection token and only components rendered
inside it flag their reads (view-preview-panel.component.ts,
dashboard-card.component.ts, entities-list.service.ts); the view designer’s
mobile tab asks the embedded client to do the same. The page designer (pages /
GenericView) does not: its canvas and its live mobile preview show the real,
already-saved records. In the mobile client, PreviewModeService.isActive marks a
preview build (write guards, realtime opt-outs) while the narrower
fakeDataHeaderEnabled — true only for the DataView preview — decides whether
PreviewModeInterceptor adds X-Preview-Mode: true
(mobile-app/lib/core/services/preview/preview_mode_service.dart).
Marking a request as preview
Section titled “Marking a request as preview”The X-Preview-Mode header
Section titled “The X-Preview-Mode header”Preview is request-scoped, not a stored property of a view or page. A request opts in by carrying the header X-Preview-Mode: true — nothing else about the request changes: same route, same authentication, same query parameters. Only the exact value true (case-insensitive) counts; any other value, or an absent header, means a normal request.
On the web side you never set the header by hand. The builder’s preview panel marks itself as a preview context, every runtime component rendered inside that panel flags its own reads, and a single HTTP interceptor adds the header to those flagged requests only. Ordinary portal traffic is untouched.
sequenceDiagram
participant Panel as Builder preview panel
participant Comp as Runtime component
participant API as data-service controller
participant Gen as Sample-data generator
Panel->>Comp: render inside preview context
Comp->>API: GET /v1/... + X-Preview-Mode: true
API->>API: authenticate + authorize (as usual)
API->>Gen: build sample DTOs for this entity
Gen-->>API: deterministic sample data
API-->>Comp: sample data (never persisted)
What preview relaxes — and what it does not
Section titled “What preview relaxes — and what it does not”Preview mode is not a permission bypass. The request is still authenticated, and the same authorization voters that guard the real endpoints still run. Access levels, restricted views, and sensitive-field rules are all still in force.
There is exactly one relaxation, and it is narrow. Some routes authorize by loading the target resource by id (a view, a saved query, a collection). Sample data is addressed by fabricated ids that deliberately do not exist in the store, and a resource that cannot be found causes the request to be denied before the controller ever runs. So, in preview mode only, a genuine not-found on that lookup is allowed through, letting the controller answer with sample data. Any other failure — a database error, for example — is not masked; it still fails.
The practical consequence: preview is a rendering aid, not an inspection tool. It cannot show you data you are not entitled to, and it is not a reliable way to judge what a restricted end user will see. Verify that against a normal, non-preview view once the design is published; see Permissions.
One thing is deliberately never faked: relation definitions. The name and target entity of a relation are schema metadata, so they always come back real. Only the entries rendered under a relation tab are sample data.
The generated sample data
Section titled “The generated sample data”Sample values are produced by a deterministic generator seeded from a stable key — the sample entry’s id, the entity and field, the widget id, and so on. Same key, same values, every time. That is what keeps a list row and its own detail page in agreement, and what keeps a preview from reshuffling itself after an unrelated edit.
Where the entity has real configuration to draw on, the generator prefers it over inventing something: category options, tags, and kanban columns come from the entity’s real configured values (only which sample entry carries them is fabricated), and system buttons and saved queries are the view’s real ones with only their ids replaced — so a real button can never be fired against a sample entry, and selecting a sample saved query does nothing.
Values by field type
Section titled “Values by field type”| Field type | Sample value |
|---|---|
| Number | A random integer between 1 and 9999. |
| Date | A past date. |
| Time | A recent time of day. |
| Date & time | A recent timestamp. |
| Yes/no | A random boolean. |
| Localized text | A sentence per configured language. |
| Geolocation (GeoJson) | A real GeoJSON point feature with randomized longitude/latitude, so map fields render instead of breaking. Since 1.8 |
| Object / JSON | An empty object — the only shape that stays compatible with a renderer that writes nested properties onto the value. Since 1.8 |
| File | Empty (no file). |
| Text (and any other type) | Content-aware text: an email address, phone number, URL, or person name when the field’s name suggests one, otherwise a sentence of filler text. |
Two structural rules matter as much as the per-type values:
- Blocks are faked field by field, recursing into the block’s own sub-fields. A repeatable block is filled to its configured minimum number of repetitions, and each repetition is seeded separately so the repetitions do not come out identical.
Since 1.8 - Workflow status is built from the entity’s real first workflow and its real step ids and ordering; only the execution state is fabricated, and the step owner is deliberately left empty so nothing in the preview looks executable.
Reference-field pickers
Section titled “Reference-field pickers”Opening a relation or user-reference picker inside a preview returns a short list of sample entries to choose from. Since 1.8
This used to fail: the picker resolved the entry being edited against the real store, and the entry being edited in a preview is a fabricated, unsaved one — so the request came back with “entity not found” and the picker stayed empty. The picker now short-circuits to sample entries after its normal field-validation and source-authorization checks, before any real lookup.
Dashboards, statistics, and timeline feeds
Section titled “Dashboards, statistics, and timeline feeds”A brand-new entity has an auto-created dashboard with zero widgets and no timeline posts, so previewing either would show a permanently empty screen. Both now fall back to sample content. Since 1.8
- Dashboard — when the real dashboard resolved for the request has no widgets at all, the preview substitutes a sample dashboard with two demo widgets. A dashboard that does have widgets configured keeps its real layout; only the aggregated numbers are sample values.
- Statistics — a sample widget resolves to a fabricated widget definition (name, chart type, aggregation) plus sample category rows and a total. A real, already-configured statistic query keeps its real resolved source criteria and view scoping; only its numbers are faked.
- Timeline — a preview always renders a small sample feed, whether or not real posts exist, with the publish and pin state populated so the timeline widget renders its controls.
- Comments — a short sample thread, including one sample attachment, anchored to the entry being previewed. The mention/autocomplete list comes back empty.
Mobile Preview
Section titled “Mobile Preview”The builder can also show you how your design renders on a phone, without leaving the browser and without a device. In the view builder this is a mobile preview tab beside the web preview; in the page builder it is a live panel next to the canvas.
Note: The mobile preview renders the real mobile client inside the builder, but it is still a preview: it is a single embedded screen, not a full app session. Some surfaces are web-only — reports, for example, are not available on the mobile client — so preview those on the web.
Live mobile preview in the page builder Since 1.8
Section titled “Live mobile preview in the page builder Since 1.8”The page builder’s Content tab hosts a live mobile preview: the actual mobile client, embedded in the builder, rendering the page you are editing right now — including unsaved changes. Every edit is pushed to it, so the phone follows the canvas without a save or a reload.
Because it is the real client, what you see is the real mobile rendering of your widgets, not a browser approximation of it: the same layout engine, the same widget implementations, the same theme. The embedded client makes its own authenticated calls for widget data. For a page these calls do not carry X-Preview-Mode, so the widgets show real, already-saved records (see Which previews request sample data); only the view designer’s mobile tab requests sample data.
The builder-to-app bridge
Section titled “The builder-to-app bridge”The builder and the embedded client talk over a small, versioned message contract:
- Handshake — the embedded client announces that it is ready; the builder replies with the session’s access token, the current page configuration, and the display settings.
- Live configuration push — after every edit (debounced, so typing does not flood it) the builder re-sends the page configuration. The client re-applies it in place rather than remounting, which is why your scroll position and any local form state survive an edit.
- Display settings — locale plus a theme override carrying the portal’s live primary colour, because the preview build fetches no theme of its own; an invalid or missing colour simply leaves the mobile theme alone.
- Device frame — a fixed logical phone frame, scaled uniformly to fit the space available and never scaled up, so the frame never blurs.
- Origin isolation — messages are posted only to the preview host’s own origin, never a wildcard, and the embedded client validates the sender’s origin before accepting a message.
sequenceDiagram
participant Builder as Page builder (web)
participant Frame as Embedded mobile client
participant API as Backend services
Frame-->>Builder: ready
Builder->>Frame: authToken
Builder->>Frame: config (unsaved page JSON)
Builder->>Frame: settings (locale, theme override)
loop on every edit (debounced)
Builder->>Frame: config
end
Frame->>API: authenticated data requests
API-->>Frame: data (sample data in preview)
What the mobile preview renders
Section titled “What the mobile preview renders”The preview mounts the production page screen in preview mode, so widget rendering is identical to the real app, with three deliberate differences: the app bar is drawn (for visual parity) but its navigation is inert, there is no help button, and redirection rules never fire — a redirect would navigate the embedded client away from the very page you are previewing.
Configuration parsing is tolerant per component rather than all-or-nothing, because the builder pushes half-finished states constantly:
- A malformed widget is dropped and the rest of the page still renders.
- Missing or partial display options are backfilled with defaults (full width, no forced new row, stretch alignment).
- If a pushed configuration cannot be parsed at all, it is ignored and the last good configuration stays on screen — the preview never blanks on a bad intermediate edit.
Sort rows during a live edit
Section titled “Sort rows during a live edit”Sort rows get one specific rule of their own: a row is kept only if it carries both a field and a direction. A row that has one but not the other — the state you are in for a moment after adding a sort row and picking the field but not yet ascending/descending — is dropped, and only that row. Since 1.8
Without the rule, that half-finished row made the whole configuration update unparseable, so the push was discarded and the preview silently froze at its previous sort while you kept editing.
Staying inside the preview
Section titled “Staying inside the preview”The preview is a single embedded screen with no surrounding app shell, so a real navigation would strand it. Two guards keep it in place: navigation calls are swallowed, and any route that is not a preview route is redirected back to the preview host.
Both guards carry the same exemption for entry-extension routes — the discussion, workflow, history, and information tabs on an entry’s details screen. Since 1.8
Those tabs are meant to render in place, nested inside the previewed page. Before the exemption was applied to both guards, opening one of them inside a previewed entry tripped the redirect, bounced the route back to the preview host, and blanked the whole preview instead of showing the tab.
Preview fidelity fixes
Section titled “Preview fidelity fixes”A few 1.8 fixes make preview mode more reliably show real data — accuracy corrections rather than new capabilities. Since 1.8
In the page builder’s live mobile preview, the Summary, Timeline, and Timeline hero-slider widgets used to go on rendering whatever they had fetched the first time they mounted, rather than following later edits. Because the mobile preview keeps the same widget tree mounted across live edits (see What the mobile preview renders), a widget whose fetch ran only once at mount time never noticed when the page was pointed at a different view, entity, or element — so it could silently keep showing data tied to a source you had already replaced. All three widgets now detect that kind of change and force a refetch.
Separately, the page builder’s live mobile preview could show outright fabricated data, not just stale data: it was inadvertently inheriting the view builder’s fake-sample-data behavior, so the backend generated synthetic rows for it exactly as it does for an unsaved view. The mobile client now keeps that decision separate: only the view builder’s mobile preview — which is meant to show synthetic rows for an unsaved, in-progress view — requests fake data; the page builder’s live preview always reflects the real, already-saved content the canvas shows.
The page builder’s preview panel also picked up two smaller fixes: it now includes the page’s real id in the configuration it pushes to the mobile preview, so page-scoped widget requests (such as the Timeline widget’s feed) resolve against the actual page instead of falling back to an unscoped request; and it gained the same expand-to-dialog icon the mobile preview already had in the view builder.
Availability
Section titled “Availability”| Capability | Availability |
|---|---|
Request-level preview mode (X-Preview-Mode) | Since 1.8 |
| Deterministic sample entries, collections, queries, buttons, history | Since 1.8 |
| Geolocation and object-field sample values; block / repeatable-block faking | Since 1.8 |
| Reference-field pickers return sample entries | Since 1.8 |
| Dashboard, statistics, and timeline sample data with zero real widgets/posts | Since 1.8 |
| Live mobile preview in the page builder | Since 1.8 |
| Sort-row coercion during a live edit | Since 1.8 |
| Redirect guard honouring entry-extension routes | Since 1.8 |
Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27