Offline forms (Genie Player)
Genie Player runs wizards offline. It is an installable web app (PWA) that your host project
builds and serves next to the main app, usually at /player/. People fill forms on a device with no
connection, every change is saved on the device and optionally into a file, and the form is
submitted later from the original wizard in the main app.
Player has no login and never calls the API. It never submits, even when the device is online. Anything that needs the server is either carried in the document or completed online.
How it fits together
Section titled “How it fits together” main app (/form/{wizard}?OrderId=42) Genie Player (/player/) ┌───────────────────────────────┐ Open in Player / file ┌────────────────────────────┐ │ wizard runner (online) │ ─────────────────────────▶ │ same runner, offline adapter│ │ Offline ▾ Download .gwiz │ │ autosave → IndexedDB + file │ │ Upload .gwiz │ ◀───────────────────────── │ "Complete in …" / the file │ │ Open in Player │ Upload / hand back └────────────────────────────┘ └───────────────────────────────┘ │ reopen where it stopped, run deferred steps, re-validate, submit (once per document) ▼ POST /api/v1/genie/wizard/{id}/submit (ClientSubmissionId = document id)Both sides use the same wizard runner. Only its execution adapter differs:
| Wizard capability | Online (main app) | Offline (Player) |
|---|---|---|
| Ordinary fields, static options | Editable | Editable |
| Conditions, Decisions on known values, validation | Run locally | Run locally |
| SQL-backed dataset field, value already chosen | Editable | Shown with its label, locked |
| SQL-backed dataset field, empty | Editable | Locked, labelled Complete online |
ExecuteSQL / SQL SetVariable nodes |
Run | Deferred, run when reopened online |
| Decision over values only the server can give | Runs | Stops at the review page, continues online |
| Attachments | Uploaded | Stored on the device, carried in the file |
| Submit | Submits | Never. “Save on this device” marks the form ready |
Offline, a required field that is deferred doesn’t block saving. It is validated online.
The .gwiz document
Section titled “The .gwiz document”A .gwiz file is a ZIP (application/vnd.genie.wizard+zip) holding one wizard activity:
| Entry | Holds |
|---|---|
manifest.json |
Format version, document id, wizard id/name/label/version hash, source origin, the activity (responseId, flowId, URL parameters, title), status, deferred items, the app/release that last wrote it, the linked file’s name |
wizard.json |
The wizard definition with every SQL body removed (<OptionsSql>, <SQL>, <TerminalSql>, …) |
responses.json |
The resumable run: answers, current step, history, review state, deferrals, and the chosen option labels of dataset fields |
resources/ |
Optional bundled option sets (<nodeId>__<field>.json). A field with a bundled set stays editable offline |
attachments/ |
Files captured offline, or uploaded online before the hand-over, as binaries plus metadata |
A document never contains tokens, credentials or executable SQL. The server resolves SQL-backed
fields and nodes by id when the document is completed online. The format is versioned
(formatVersion, currently 2); older files are migrated on open, and files from a newer Player are
refused.
Activity title and file name. A wizard opened with parameters, typically from a task or a view
action (/form/PmChecklist?OrderId=WO-1042), gets the title <wizard label>-<first parameter value>.
That gives the default file name PM Checklist-WO-1042.gwiz. Without parameters, the name is
<label>-<short id>.gwiz.
From the main app: the Offline menu
Section titled “From the main app: the Offline menu”With modules.player on, the wizard page shows an Offline ▾ menu:
- Download .gwiz saves the activity with everything filled so far: answers, the current step, history, and files uploaded in this session. On Chrome/Edge desktop you choose where to save it, and the file stays linked (see below). Elsewhere it is a normal download.
- Upload .gwiz brings a document filled offline back into this wizard flow (see Completing online).
- Open in Player hands the activity, with everything filled so far, to Player and opens it there.
The same activity keeps one document id for the browser tab session, so pressing Download or Player again updates the same document instead of making copies.
In Player
Section titled “In Player”- My forms lists every activity on the device, grouped by wizard. Each shows its status (Draft, Ready for online completion or Exported), the number of items to complete online, and the linked file. You can open, rename, save or delete an activity, and import files.
- Autosave. Every field change, step change and attachment is saved to IndexedDB immediately (the toolbar shows Saving… / Saved locally / Save failed). Documents stay until the user deletes them; nothing expires.
- Reopen exactly where you stopped. Reloading, or reopening the document or its file, restores the step, answers, review state and attachments.
- One editor at a time. A second Player window on the same activity opens read-only, with Edit here instead to take over (Web Locks).
- Complete in … hands the document back to the main app’s
/wizard-importroute. It only works online and on the same installation; otherwise use the file.
Linked files: the file stays in sync
Section titled “Linked files: the file stays in sync”On browsers with the File System Access API (Chrome/Edge desktop), a .gwiz behaves like a saved
spreadsheet. Once it is linked, every change Player saves to IndexedDB is also written into that
file, debounced by about 1.5 s. A file becomes linked when it is:
- saved with Download .gwiz in the main app,
- opened through Import Wizard in Player,
- double-clicked when Player is installed (it registers as the handler for
.gwiz), or - saved with Player’s Save file.
The toolbar shows the file name and its state. If the browser revokes write permission, a Reconnect button asks again. When a file and the device copy of the same document differ, the newer one wins; if the device copy is newer, the user chooses.
On other browsers (Firefox, Android, iOS), IndexedDB is still live, and Save file downloads an up-to-date copy under the activity’s name.
Completing online
Section titled “Completing online”Upload .gwiz on the wizard page, or Complete in … from Player, opens the /wizard-import page.
There Genie:
- checks the document came from this installation (origin), that the user can load the wizard, and which version it was filled against. A changed wizard shows a warning to review every step;
- uploads the offline attachments through the normal temp-upload endpoint and swaps their local tokens for upload keys;
- reopens the run where it stopped: the review page if it was finished, otherwise the step it reached. The SQL steps deferred offline run now, and a Decision that couldn’t be resolved offline continues from there. Every value is editable again and dataset fields load live;
- re-validates on submit: every visited step is checked again, and a missing required value (typically a field left Complete online) takes the user to that step;
- submits with
ClientSubmissionIdset to the document id, so a document is accepted once (see Duplicate protection).
Duplicate protection
Section titled “Duplicate protection”POST /{id}/submit accepts an optional ClientSubmissionId. It needs no extra table:
- the document id is stored in the response’s own
ReferenceIdcolumn, which the response grid shows as Reference, so a submission is traceable to its file; - before inserting, the server looks for a live response in that wizard’s table with the same
ReferenceId. If it finds one, it returns that response (“already submitted”) instead of creating a second one or starting the workflow again; - concurrent submits of the same document are serialized by a lock per document (
IGenieLock, Redis-backed when Redis is configured, so it holds across processes); - a failed submission writes nothing, so the corrected document can simply be submitted again;
- ordinary online submissions don’t send an id and are unaffected.
Hosting Player in your project
Section titled “Hosting Player in your project”Player ships as its own package, @genie/genie-player. It builds on the runner,
field controls and .gwiz format from @genie/genie-engine-ui (a peer dependency), so
it doesn’t duplicate them. You give it a page of your own:
1. The page (e.g. player/index.html → src/player/main.tsx):
import { createGeniePlayer } from "@genie/genie-player";import "@genie/genie-engine-ui/styles.css";import "@genie/genie-player/styles.css";
const Player = createGeniePlayer({ appName: "Acme Player", basePath: "/player/", // must match the plugin importPath: "/wizard-import", // main-app route that completes documents completeLabel: "Complete in Acme", theme: { mode: "system", logo: <AcmeMark />, accent: "acme", accents: ["acme"], css: ACME_CSS },});createRoot(document.getElementById("root")!).render(<Player />);createGeniePlayer option |
Default | Purpose |
|---|---|---|
appName |
"Genie Player" |
Header, page title and messages |
basePath |
"/player/" |
Where the page is served (the service-worker scope) |
importPath |
"/wizard-import" |
Main-app route for “Complete in …” |
completeLabel |
"Complete in Genie" |
Hand-back button label |
mainAppUrl |
"/" |
Header link back to the main app; null hides it |
theme |
{} |
Same shape as the main app’s theme (logo, mode, accent, CSS) |
onboarding |
default card | false hides it; { title, body } replaces it |
serviceWorker |
true |
Register the generated service worker (production builds) |
Player reuses the main shell’s look (.genie-shell header, breadcrumb, table cards, buttons, badges,
themed dialogs), so it matches your app’s branding automatically.
2. The Vite plugin in the same vite.config as your main app:
import { geniePlayer, gitVersion } from "@genie/genie-player/vite";
plugins: [ react(), geniePlayer({ name: "Acme Player", basePath: "/player/", themeColor: "#0b6bcb", icons: [{ src: "icon.svg", sizes: "any", type: "image/svg+xml" }], // public/player/icon.svg version: gitVersion(repoRoot), // releases follow your git tags }),],The plugin:
- adds the page as a second build input;
- emits
/player/manifest.webmanifest(install name, icons,.gwizfile handler) and/player/version.json; - generates
/player/sw.js, a service worker scoped to the Player path that precaches the page and every chunk it can load; - links the manifest into the Player page only, so the main app isn’t installable as Player;
- in dev, serves
/playerand the manifest. The service worker exists only in production builds, so test offline withvite build+vite preview(or your hosted build).
3. The main app: turn on modules.player, and tell it where Player lives with
player: { path: "/player/" } (see Frontend integration). Add a navbar link
to /player/. Its visibility is checked against a permission resource named like the navbar item.
The activity database. Player and the main app’s autosaved wizard drafts
share one IndexedDB database, genie-player (PLAYER_DB_NAME). @genie/genie-engine-ui
exports its API, so a host can list or tidy local activities itself:
| Export | Purpose |
|---|---|
listActivities, getActivity, putActivity, deleteActivity |
Read and write activities. Deleting one also removes its attachments and file link |
importDocument, loadDocument |
Store a .gwiz document / rebuild it with attachment bytes |
saveAttachment, readAttachment |
Store / read one attachment’s bytes |
findDraft, saveActivitySnapshot |
Look up a wizard-page draft by its key / replace an activity’s run state |
getFileLink, listFileLinks, putFileLink, deleteFileLink |
Linked .gwiz files |
requestPersistence |
Ask the browser not to evict the database under storage pressure |
playerDb |
The underlying idb connection |
Activities autosaved by the wizard page carry a draftKey. Documents imported into Player don’t.
4. Serving it: with UseGenieSpa, the default
Genie:Spa:SubAppPaths = ["/player"] serves /player/* from player/index.html. Behind your own
proxy, do the same.
Versions and updates
Section titled “Versions and updates”- Releases follow the version you pass to the plugin.
gitVersion()readsgit describe --tags:v1.4.0→1.4.0,1.4.0+3.1a2b3c4after three more commits, and the commit hash before the first tag. The version shows in Player’s footer, on the update banner, and in each saved document (writtenBy). - Updates never interrupt a form. A new release downloads in the background and waits. Player
offers Update now on My forms and applies it there, after the open document has saved. The
cache is named
genie-player-<version>-<content hash>, and old caches are removed on activation. - Wizard versions are separate. Each document keeps the
VersionHashit was filled against, and/wizard-importwarns when the wizard has changed since.
Copyright © 2026 Orbyn Technologies. All rights reserved.