Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
Project persistence
Paths are relative to the webv2 src/ directory.
Backend project record is authoritative. Writes use expected_revision; divergent revision or remotely deleted project needs explicit user decision. Editing can continue while that decision pends. Saving a copy reuses one reserved identity through createProjectSettled, including after a lost response.
ProjectDocumentV3 allowlists editable document fields. Optional fields added within schema 3 (lastFloatingGeometry, presetWorkingLayouts) are additive: absent means none, so older schema-3 documents load unchanged, and a build predating a field ignores it and drops it from the next document it saves to the server instead of refusing the project (a schema bump would refuse it). settingsLayering: 1 marks a document whose settings values are the project's pins over the user's defaults (workbench/settings/README.md); it travels in the workspace half, which holds those values. migrateProjectDocument gives a document without it the marker and drops each stored value its owner read as the built-in (the frozen first-version table in getLayeredSettings: widget values a settings contribution edits and the three generation flags; a malformed value read as the built-in counts too), since before layering such a value read the same as an absent one, and drops the retired per-project antialias flag (the account preference starts off). A marker above 1, from a newer build, counts as layered and is left alone; this build's saves still write 1, so that build re-runs its own steps from version 1, and each step above 1 must be idempotent (re-running it on a document it already migrated changes nothing; another drop of values equal to the built-in would damage pins set in that build). A build predating the marker drops it on save. The next load then coerces again: a pin equal to the built-in is dropped, and the project follows the user's default for that setting. Accepted: only a project edited in such a build, and only pins equal to the built-in. Queue runs, events, undo and per-workflow edit histories are not project documents. Documents capped at 32 MiB of UTF-8 JSON on both sides of the API.
Stored media URLs are derived, never authoritative: the name beside each one is. A URL names the origin that saved it (http://localhost:9090/...), which another origin or computer cannot reach, and .invk transfer blanks it. So every load (deserializeProjectDocument: server records, drafts, .invk import, duplication) rebuilds each image and video URL the document stores (gallery selection, compare and recents in every gallery instance, canvas staging candidates, regional reference images in the canvas and its snapshots) from its name for the deployment the page runs on (projectMediaUrls.ts, with Gallery's URL helpers injected). Untouched subtrees keep their identity. Sync baselines are taken from the loaded project, so the rebuild alone never saves; the next real edit saves this origin's URLs.
Content and workspace
The server holds a project as two documents (document schema 4): its content, what the project is and every member shares (name; the canvas document, its snapshots and revision counter; workflow entries), and each member's workspace, how they work on it (layout, widgets and generation settings, prompt history, project settings, the canvas selection and staging area, the open workflow and each workflow's last run). The browser keeps one whole document per project, in memory, drafts and the unload journal; workbench/projects/projectHalves.ts splits it at the server boundary and joins the two halves back when a project loads. A member with no workspace yet joins onto the workspace a new project starts with.
Each half has its own revision. A project the server holds whole (saved before the split) is split by its next save, whether or not anything changed, unless it is conflicted or refused: one PUT /projects/{id} carries the content, the document floor of 4 (so a build that predates the split is refused the project rather than saving it whole) and the member's workspace, which the server stores with the content in one transaction and answers beside it. The split of a whole project never lands without the member's workspace (the server refuses it without one), so a page gone right after that request (sign-out deletes its drafts) loses nothing; a workspace revision mismatch refuses the content with it. Every create is one request the same way: a project's first save, a save as a copy, an import and a duplicate send the content with the creator's workspace (POST /projects with workspace), and the answer carries the workspace it stored, so the server never holds a split project's content without its creator's workspace. A document created whole (below) carries the workspace inside and sends none; the server refuses a workspace beside a whole document. A create settled by a read of an earlier attempt that committed unanswered is judged by its content, so the workspace it answers with is taken as pushed only when it is the one this save sent; otherwise it stays owed and is saved next against the revision the answer named. Which board a created workspace names follows two conventions, both right because load applies applyAuthoritativeProjectBoard(..., { selectBoard: false }): import and duplicate stage the inbox first, so the workspace in the create already names it; a project's first save sends the workspace without a board, and pendingBoardAssignments applies the one the answer minted locally, which the next save writes. Only once split are the halves saved separately, and a save then sends only the half that changed: the content first, then the workspace, one after the other, since the server takes one project write per account at a time; every project write declares the canvas and document schemas the build reads, and the server refuses one above them. Each half is recorded as acknowledged as soon as it is, so a retry sends only what is still owed, and a content acknowledgement rebases the lineage's draft and journal entry before the workspace is sent, so recovery after a failed workspace save builds on the saved content. The draft is acknowledged when both are. A revision conflict in either half follows the same "changed elsewhere" flow, and the banner says when it is the caller's settings; using the server version then takes the server's workspace and keeps this tab's latest content, unless the server's content has moved since this tab's base, which is then reported as a content conflict instead. On a revision conflict a half the server holds as one of the page's own recent sends (its answer lost) is retried, not reported, which covers the split whose answer was lost. A project whose workflow repeats an item id (possible only before the split) keeps saving whole instead, and its first save, a save as a copy, or a duplicate of it creates it whole, since split content repeating one would be refused by every later load. A split project whose workflow comes to repeat one (only an editing bug could) is not saved, and the error asks for the change to be undone; export would flush the same save, so it cannot be the way out.
Drafts and journal entries carry a base revision for each half (baseRevision for the content, baseWorkspaceRevision, absent in records written before the split, for the workspace). A recovered draft is judged half by half: a half equal to the server's needs no base, which covers a page that saved the content and was gone before the workspace, and a changed half conflicts only when the server moved it past the draft's base.
Workflows
Project owns an ordered workflow collection (workflows.entries) and remembers its active workflow. Each entry carries the editable document, optional source metadata (library template it was opened from or last explicitly saved to, with the content revision then observed, or null when unknown) and the newest successful run's output. Source metadata sits beside the document, outside graph edit history, so undoing an edit never undoes a save. workbench/projectWorkflows.ts owns membership, selection and session histories (one per workflow, 40 entries per project across all, structurally shared); Workflow owns editing, serialization, library transport, presentation.
Projects autosave their workflows. Library changes only through explicit publication (features/workflow/data/publication.ts): save as new template, or update the source at exactly the revision the copy last saw; stale revision is a 409 the user resolves. Every media reference in every workflow, active or not, joins reference indexing, cleanup protection, duplication and archive export.
migrateProjectDocument is the one migration boundary. Unversioned (schema 1) and schema 2 documents become schema 3 with their single projectGraph as first, active workflow; a libraryWorkflowId becomes a source with unknown revision, never assumed to match the library's current contents. Server loads (after joining a split project's halves), recovery drafts, duplication and .invk import all pass through it; every local document is schema 3. Every sync-engine save is the split of one, except a project whose workflow repeats an item id (above); renaming a closed project the server holds whole still writes a whole document, which the project's next save from an editor splits. .invk import (format v3: project.json content beside optional workspace.json, which becomes the importer's workspace) and duplication create the content and the creator's workspace in one request, the workspace already open on the inbox board the create claims: an inbox is always staged first (an empty one for a file without boards), so its id is known before the create and nothing is written after it but the other boards' placement. Malformed collections (dangling active id, repeated ids, damaged entries) and structurally damaged workflow documents are refused, not repaired or replaced with blanks; refused document is reported, left untouched on the server, raw content stays exportable. Same-server duplication keeps source references; .invk import clears them, since a portable file never names a library write target.
Canvas uploads carrying a project id await that identity’s acknowledged server creation through the mounted persistence service. Uploads waiting on an unacknowledged project share one serialized creation attempt; a failed attempt answers further uploads for a few seconds before another is made; later uploads use the acknowledged identity without flushing unrelated edits. Only a closed project, account change, engine disposal or the operation's own cancellation stops an upload, and those stop the wait immediately. Any other outcome (creation failed or offline, conflict, or server that no longer knows the project and refuses the id) sends the upload without project id. Such uploads are never re-associated with the project later, so project's intermediates cleanup does not see them.
Project links are consumed after successful open, so reload restores the saved active project, not an earlier link. New-project startup selects the newly created draft before saving the session.
Workflow reads the active workflow through the App-composed port and edits, publishes, presents documents; it never replaces authored project work. Library is written only by the Workflow-owned publication controller, which captures account, project, workflow and content before start, refuses to overlap itself per workflow, reconciles a lost answer against the destination record before resending, and records resulting library id and revision on the originating workflow alone. Queue submissions carry the originating project workflow so seed advances, node progress and run previews return to it whatever is active later. For Generate, Workflow, Upscale and Video, submission orchestration captures ephemeral device, template and board-eligibility values immediately before dispatch, after asynchronous prerequisites; compilation consumes those values without reading live device, template or board caches. Workflow retains the template owner’s published snapshot by reference because refreshes replace snapshots rather than mutate them; non-workflow submissions do not capture template data. Canvas selects its noise device during lazy graph preparation. Canvas and one-click model-only upscale commands capture only board eligibility before enqueueing their already compiled graphs. Board eligibility follows Gallery's cached-listing policy for that dispatch, not permanent server authorization. The aggregate still uses current project settings and validates the originating workflow, prompt-expansion source and upscale input before atomically enqueueing and advancing seeds; preparation never replaces the project with its older snapshot.
Persistence runtime
Workbench persistence is scoped to one mounted Workbench and its account lifetime. createWorkbenchPersistenceRuntime owns hydration ordering, debounced autosave, hidden-page saves, revision/generation checks, conflict application, reconnect replay, status publication, exit checkpoint, without importing React. createSyncedWorkbenchPersistence builds local/remote project sync state for one mounted Workbench; no process-wide maps, sets, flags, or caches hold that state. It also owns the unload journal: runtime asks it, via its persistence port, to journal unsaved state synchronously when page is hidden or unloads, and its load reconciles the journal into the draft store under the draft store's fencing rules. WorkbenchProvider constructs these lifetimes, starts the runtime and ends it with its exit checkpoint through the mount lifecycle adapter, and selects aggregate hydration state. Checkpoint and persistence lease outlive the unmount until it settles. Provider also hands the checkpoint to the account lifetime's next editor through a module-level map keyed by account scope; that editor loads after it, waiting at most 10 seconds; the tab's editor session is reference-counted across the two. Project transition commands commit pending editor drafts themselves, so callers do not flush before creating, opening, switching, or closing a project.
Save, project-flush and server-identity requests capture the current journal identity before queuing. A distinct held edit journaled after that intent cannot be superseded by the older request's stage or retired as an undo; it stays pending while older acknowledgements may rebase it. A journal of the same document can still be covered by the save, and an explicit later save or undo can replace an already existing journal. Retiring a journal keeps only its session and generation as intent metadata for the owner lifetime: an older queued undo must remain fenced even if another save has already staged or acknowledged the redone document and removed its journal. This metadata retains no document payload and resets with workbench load or terminal clear; it tracks the same resolved project identities as the writer generations. Returning to a document already in recovery also advances this intent, even though the checkpoint only retires an older journal. That journal's payload cannot authorize an older queued request; its physical identity stays separate so the next save can still write its settled mark if the blind deletion failed. A different in-flight stage can replace the current recovery document, so a checkpoint of that document still writes a payload journal until the stage settles. Matching physical journal bytes skip a checkpoint only while that entry still names the current intent; a failed retirement leaves the newer intent authoritative even if storage still holds older bytes. Sharing a pending stage's generation likewise requires that it is still the writer's latest issued generation. An undo-retired journal is never rewritten by an older acknowledgement's rebase.
Project record reads, content/workspace writes, and project deletion have a 150-second request deadline, including response-body consumption. This allows the server's 120-second maximum request upload duration plus 30 seconds for processing and the response, so supported large documents can save over slower connections. Client-state reads have a 30-second deadline. Cancellation aborts the request and ends the wait, with timer/listener cleanup on every settlement. Uploads and model operations have no universal deadline; an import’s project creation uses these project budgets. Busy project writes admit at most nine attempts within 125 seconds; every started attempt gets its full 150 seconds, so a late admitted attempt may finish about 275 seconds after the operation began. A project request that stalls releases the serialized save queue, so later edits and project switches in the same mounted editor can save once any following session write settles. Dirty drafts remain pending on unavailable reconciliation; normal autosave retry/status policy applies, without parallel writes.
A deadline does not prove a write failed. Creates repeat their reserved identity only within the write admission budget and reconcile matching content; absence after unanswered attempts never authorizes cleanup. Content/workspace timeouts use revision/content reconciliation: acknowledge held bytes, retry unchanged or previously sent server state once at its revision, or report divergence. Unanswered state survives that retry, so a late commit followed by a revision conflict does not invent a competing writer. An inconclusive read or exhausted unanswered retry leaves the draft pending. Undo to previously acknowledged bytes still sends revision-fenced writes for any half with an unanswered different body. A read holding the desired bytes at a strictly newer revision also proves the fence; an unchanged revision cannot prove that older body will not commit later. Whole documents retain the same sent-body evidence. A reconciled create applies its server board assignment and refreshes board lists.
A timed-out delete repeats the same identity and board policy once; settled idempotent deletion confirms the outcome even if the first attempt committed. Reconciliation reads have their own 150-second deadline. An immediately unanswered create exhausts its 125-second write admission window in the first 150-second attempt, then reads once inside the API and once more in durable persistence: an unanswered result can take 450 seconds. Busy backoff before a final admitted request and both reads can extend that to about 575 seconds. Each project half and reconciliation read has its own budget; an entire multi-project save has no single wall-clock deadline. Browser suspension can delay timers. Server work may commit after cancellation; identity/revision fencing, rather than cancellation alone, prevents duplicate creation and stale acknowledgement.
Client-state writes (session, account settings, and cover index) are unconditional and have no application deadline. Their callers keep writes ordered until the request settles; a timed-out request could otherwise commit after a newer write and overwrite it. A hung session write can still hold the autosave queue, and a hung settings or cover-index write holds its own queue. Account cancellation, unload journaling, and bounded editor re-entry retain their existing limits; bounding these writes safely requires server-side write ordering or revision fencing.
Browser recovery
Widget module recovery (projects/reloadWorkbench.ts) prepares a fresh document only after the separately named Reload editor action is confirmed. Ordinary Retry never reloads. Confirmation warns that Canvas undo and per-workflow histories for all open projects will be lost; cancel leaves them intact. A repeated import rejection only makes this additional recovery action available. It commits registered drafts, flushes every open project's live pixels, commits drafts typed during that flush, and saves the captured state. After the save it crosses the paint barriers again, the visible project last, then flushes drafts once more. A Canvas history/registration change during the save or final barriers, a newer persisted revision, pending changes or a user decision refuses reload. The originating account and recovery owner must remain current and the session open throughout. Failure leaves the editor usable and the action retryable; it never exits the persistence runtime or discards a conflict to obtain code.
- Account-owned IndexedDB stores only unacknowledged project drafts, unload journal entries, active queue runs, receipt acknowledgements, bounded recall values. Clean server documents not mirrored. Journal has its own database, deleted with the workbench database by account cleanup and by clearing workspace data.
- Draft generations fence acknowledgements. Draft writer ownership and cross-tab notifications stop one editor overwriting another editor's unacknowledged work.
- Unload journal. Staging a draft takes fenced read-then-write transactions, which an unloading page never finishes. So when page is hidden or unloads, before save starts, each open project whose document is not what next load would restore (its durably staged draft, or without one the acknowledged server copy) is written as one blind, explicitly committed IndexedDB write. Own database because Chromium drops such a write at unload while a read-write transaction of the same database is still open, which a stage in flight is. Entry carries account, project, lineage (an editor session, possibly another tab's that the session blob handed on), editor session of the page that wrote it, writer, base revisions and canvas schema floor, and a draft generation: above everything the writer staged or journaled before, or equal to a still-in-flight stage of the same document while its generation is still the writer's latest issued generation and its journal identity is live. A redo after retirement or settlement gets a fresh generation, so an older queued undo cannot retire it. A writer's generations never restart while its page lives, even when a project is closed and reopened. Each write also deletes the writer's lower generations for the lineage, so at most one entry per lineage and writer, however long saves cannot be acknowledged.
- Settled mark. A lineage's writer claim records the generation through which its writer settled its journal: everything it acknowledged, discarded, or holds in recovery. Acknowledgement and draft deletion write it in the same transaction that settles or deletes the draft; a document back to what recovery holds (an undo, say) writes it on its next save, and claims the lineage for the writer if it has none. Optional claim field, so earlier claims read as settled nothing and workbench database stays at version 4; an earlier writer's mark is ignored. It tells "never staged" from "acknowledged and moved on" once an acknowledgement deleted the draft, so an entry whose deletion failed, or that another tab reconciles at the moment of acknowledgement, can never come back.
- Next load of the account reconciles every entry, in pages, before any writer claims a lineage. Entry becomes its lineage's next draft only where its writer could still have staged it: lineage unclaimed or still claimed by that writer, writer has not settled that far, and lineage holds no generation at or above the entry's. It keeps the stored draft's conflict, schema refusal, copy reservation, and base revision, as staging does, then goes through usual load rules, so a server revision the base no longer matches surfaces as conflict. One exception: when the entry replaced a staged draft whose document the server now holds exactly (its save arrived, its answer did not), the draft is rebased onto that revision, as the late answer would have done, instead of conflicting with the writer's own save. Entry discarded when another writer adopted, reclaimed, or retargeted the lineage, when its writer settled it, when lineage already holds it or something newer, when it belongs to another account, or when its record schema is unknown or it is damaged. Draft written before entry removed, so a crash between leaves an entry the next pass discards as superseded.
- Another tab's load reconciles only entries of pages that are gone. Page proves it still runs by its editor session's Web Lock, held until its last editor releases it or the page unloads or crashes; an entry whose writing page (the editor session it names, not the lineage it is written under) another page still holds is left in place (a merely hidden tab still writes its lineages, and staging its entry elsewhere would hand that tab's unsaved edit to another tab, where an undo could never retire it). Entry written before it named its page counts as a gone page's. Hidden page settles the entry with its own saves, or next load after it is gone recovers it. Browser that keeps a page holding its session in the back/forward cache keeps the lock held, so the entry waits until the page is restored (and saves) or evicted; one that evicts such pages (Chromium today) releases the lock, and the entry is recovered as a gone page's. Reload of same tab reclaims its session, retrying up to half a second (five retries 100 ms apart) while old document lets go, then reconciles its own entries. Two cases fall outside it. If old document holds the lock longer, reload takes a fresh session, its own entries and staged drafts count as a running page's on that load, and a later load recovers them once old document is gone. Duplicated tab waits the same half second before taking its own session; if the original reloads within it, the duplicate can take the original's session instead and then takes the original's entries and staged drafts, while reloaded original takes a fresh session. Staged drafts follow same rule: a load does not adopt, auto-open, or offer for recovery a draft whose lineage is named after another running page's session, and editor route does not count it. Draft records its lineage, not the page staging it, so it is judged by the session that lineage is named after: a lineage isolated for an unopenable draft names no page and is adopted as before. A lineage the session blob hands on (today only isolated ones) is not judged at all: loading page claims its handed-on lineage directly, whether or not the page staging it still runs. Without Web Locks (plain-HTTP deployment, say) liveness cannot be told, so every entry is reconciled and every draft adopted as before. Hidden event during save-as-new journals the source project: if page goes away before the copy exists, edit is recovered into the conflicted source and retried copy keeps its reserved document; once copy exists, source lineage has moved, so entry is discarded and copy is never written from it.
- Entry the draft store cannot take waits. One for a damaged lineage waits for that lineage's cleanup, at most 7 days, then is discarded. One refused for lack of storage is applied by a later load only while its lineage is unclaimed; the load that refused it usually claims the lineage when it opens the project, and then the edit is lost. Both report degraded local recovery for that project until its next stage succeeds. Unavailable journal (database will not open, or reconciliation fails) is logged, not reported: recovery then works exactly as without the journal. A journal operation failing on its own (a deletion whose transaction could not open, say) fails alone; next hidden event journals again.
- Writer settles and removes its entries when server acknowledges a generation at or above them, when document returns to what recovery holds (on next save; a hidden event meanwhile also deletes the entry, and the save still writes the mark), and when it deletes the project or discards its draft; failed removal leaves the entry settled, and one whose mark fails is retried with the next save. When an older generation is acknowledged, a newer entry is rewritten onto the acknowledged revision, as a newer staged draft is rebased. Aborted journal write is written again on next hidden event. Nothing journaled for a closed session, after account lifetime ended, for a project being deleted, or beyond 8 MiB of documents per event; larger projects rely on autosave, the skip is logged, and leaving before their stage lands brings up the unload prompt. Editor route counts projects with entries as ones that would open, so a new project typed into and reloaded before its first save reopens.
- Queue ownership uses Web Locks; without them a tab treats its runs as its own, with no cross-tab exclusion. Journal writes precede submission; backend receipts make retries safe after lost responses. Accepted IDs must be durable before their receipt can expire. Fresh runs that never reached browser storage use best-effort terminal acknowledgement instead.
- Project delete, conflict discard and save as new take the project's lifecycle lock, which every tab's active queue run holds shared, then check the queue-run journal. Without Web Locks (a plain-HTTP origin) they run in single-tab mode (
withSingleTabFallbackinprojectLifecycleLocks.ts): only the journal check guards them, and the server fences the rest, since a deleted project answers every later write with 404, saves are revision-checked, and a copy reuses its reserved identity. Where the API exists, a failed lock request is refused instead, because other tabs may hold the lock. A run another tab never journaled delivers its images to Uncategorized. Queue-recovery discard has nothing on the server to fence it, so it keeps refusing there and offers export. The Launchpad tells the viewer once per origin. - Completed, failed, and cancelled runs keep exact recall values in an LRU cache, capped at 500 entries / 32 MiB. Eviction removes recall convenience, not project data or active-run recovery.
- Projects with journal entries stay reachable even if another tab saved an empty session. Automatic reopening is bounded; remaining entries can be opened, exported as queue-recovery JSON, or explicitly discarded. Discarding local recovery does not cancel backend work.
- Browser-storage failures do not block backend project loads or saves. Recovery warnings separate degraded local durability from successful server persistence.
Leaving the editor
Navigation never blocked in the app; local capture of committed state is the contract, within limits below. Only the browser's own unload prompt can hold a leaving page, and only when that capture would fail (below).
- Exit checkpoint. When editor unmounts while its account is current, persistence runtime stops observing the aggregate and commits drafts editors still hold (the draft registry). Then requests a save of committed state at once, queued behind any save in flight, and meanwhile flushes live Canvas pixels for at most 3 seconds. If that flush (or anything else) moved the state on, it saves once more; otherwise exactly one write. Each save stages the local recovery draft before pushing to backend. Runtime and its persistence lease outlive the unmount until checkpoint settles; if page is hidden or unloads meanwhile (leaving editor and reloading at once), it writes the unload journal for committed state, unless a newer editor superseded it. Failed or unacknowledged save, and pixel flush that failed or timed out, are logged; recovery left exactly as after a failed autosave.
- Closing the last tab. Empty session is marked closed when requested. From then until editor leaves, nothing saves, so project cannot be written back into the session. If close does not complete (queue work started, project changed, or session write failed), session is reopened and written again, and a save that came due while closed (an edit committed meanwhile) runs at once, so its outcome reaches autosave status and retries as usual.
- Account changes. Ended account lifetime abandons its checkpoint: nothing of the old account is written afterwards.
- Re-entry. Remounted editor of same account loads only after previous checkpoint settled and its persistence closed, so it never hydrates an older snapshot and two editors never write at once. Provider keeps that handoff per account lifetime, keyed by its scope, so another account never waits on it.
- Re-entry after 10 seconds. New editor loads anyway. Previous checkpoint is superseded: starts no further write and gives up its project mutation locks. If it still had an unsaved revision, it logs that the revision was not written. Staging happens inside the persistence queue, so while a request stalls nothing newer than the save before it reaches local recovery; edits committed after that are lost in this case, before any unload, so no unload prompt can keep them. A tab closed during the wait instead journals them through the exit checkpoint (above), and is prompted as an editor is. A project request still pending at the handoff keeps its own 150-second deadline and is cancelled when that expires; an unconditional client-state write has no deadline (above). Until it settles, or tab closes, superseded persistence keeps its draft-store connection and its hold on the tab's editor session. New editor holds the same session, which stays locked to this tab until its last holder releases it. Late write is fenced like another tab's, by draft-writer claims and revision conflicts.
- Hidden pages and unload checkpoints. On
beforeunload,pagehide, and when the page becomes hidden, runtime commits drafts editors still hold (the draft registry), writes the unload journal for an unsaved revision (including one whose save is in flight), then saves it at once instead of after autosave debounce. Committing a draft leaves control's value, caret and focus as they were. Revision whose save failed, or one already being saved, is not sent again; while session is closed nothing is committed, journaled, or saved. Save is asynchronous, so it completes when the hidden page keeps running (switching tabs or apps, minimising, or entering back/forward cache), and its acknowledgement retires the journal. It cannot complete while page unloads (reload, closing tab, navigating away), so across an unload the journal is what survives: next load of the account recovers the edit as a pending draft and saves it. Tab restored from back/forward cache writes through the same account-scope, draft-writer, and revision checks as every other write. - Unload prompt. One
beforeunloadlistener commits held drafts, writes the journal, starts the save, then asks the browser to confirm leaving (its own generic wording) only when an unsaved revision would not survive the unload: a project the journal skipped for its budget, an edit it could not write, or one journaled for a project whose local recovery is failing, in each case until a stage succeeds or the server acknowledges the revision.hasChangesUnloadWouldLoseanswers from what that journal recorded, without serializing again. The early checkpoint is necessary because WebKit can discard even an explicitly committed IndexedDB write started later inpagehide. This always registered listener can reduce back/forward-cache eligibility in engines such as Firefox; the smoke report records actual restoration rather than promising eligibility. An ordinary edit the journal holds never prompts, nor does anything while the session is closed, before load, after the account lifetime ended, or for an exit checkpoint a newer editor superseded; an exit checkpoint still saving keeps its listener until it settles. A journal write that aborts after starting (storage filling during the unload) cannot be known in time and does not prompt. - What is and is not guaranteed. In Chromium, an ordinary reload, tab close, or navigation away right after an edit keeps the edit, including one still held in a debounced field: journal write is committed before the handler returns and the browser finishes it. Nothing guaranteed when browser or OS is killed, crashes, or loses power before the write reaches disk (transaction uses default, relaxed durability), when a page is discarded without a
pagehideor hidden event (edit made after last hidden event is lost), for projects over the journal budget, or when browser storage is unavailable or full; those last two bring up the unload prompt while they hold an unsaved revision, so leaving anyway is the user's choice. Undo made just before page goes away is retired by the same kind of blind write and can be lost the same way: then the undone edit comes back on next load, silently when server revision has not moved. The targeted smoke also verifies held-field reload recovery in the locked Firefox and Playwright WebKit builds on the recorded platform; this does not establish the same guarantee for every browser version, real Safari, or other Apple platforms. - Journal side effects. Entry kept for a damaged lineage or full storage reports degraded local recovery for its project on every load that keeps it, even when that project is not opened in the session. Editor route counts any project with an entry of a gone page (or of this page, by the session it persisted) as one that would open, so with an empty session such an entry, or one reconciliation will discard, opens the editor instead of Home; an entry or staged draft of another still-running page does not, since editor would leave it alone.
- Project transitions. Creating, opening, switching, and closing projects commit pending editor drafts the moment open or active projects change, so an edit typed while a caller awaited hydration or a close push lands on the project it was typed in. Close can require the version it pushed; drafts that change the project refuse it, and close flow pushes again.
Intentional cutover
Old workbench mirror, sync map, and refused-project localStorage keys are deleted on initialization. Contents not migrated. Export any needed browser-only work with the old build before upgrading.
Cold-start offline editing not supported. When backend cannot load, unavailable screen offers retry and local draft/run exports. Conflicted or schema-refused drafts kept until explicitly resolved or deleted; never silently evicted.
Additive canvas values
The optional canvas.document.stacks.vector forest requires Canvas schema 7, even when empty after its last layer is removed. Vector layers retain their Bezier paths and layer-owned appearance in the document and snapshots without image assets. Stroke color and width are required; new layers use black strokes at 50 pixels. A document that has never used vectors omits that forest, preserving its existing compatibility floor. Schema adoption is sticky; older clients refuse schema 7 instead of dropping vector data.
A raster layer's regenerate region drops on load when its fill does not parse, without refusing the document. A Diagonal Left (diagonal_left) fill on a raster regenerate region therefore makes the canvas schema 8 in the live document or any snapshot, so a schema 7 build refuses the canvas instead of autosaving it without the region. Inpaint masks and Regional Guidance refuse an unknown fill style, so diagonal_left on them keeps the schema unchanged.
New value in a closed canvas set, such as a control layer's adapter kind (anima_lllite), is added without raising canvas schema version or project's compatibility floor. Builds that know the value load and save it unchanged; builds that do not refuse the canvas instead of rewriting it, since coercing an unknown kind to a known one would replace the user's adapter on next autosave. In an older build the project is not opened and user sees that it "contains canvas data this version of Invoke cannot read"; saved copy is untouched and exportable, and a build that knows the value opens it as saved. Raise schema version instead when older builds could misread a document without refusing it.
Adjustment stacks are such a case: load drops a stack holding any entry it cannot parse, so an older build would load a document with a new adjustment type minus that layer's whole stack and autosave the loss. A new adjustment type therefore raises the canvas schema for documents that use it. A noise, clarity, texture or dehaze adjustment, enabled or not, on any layer or group at any depth of the live document or a saved snapshot, makes the canvas schema at least 5 (canvasMigration.ts, writableCanvasSchemaVersion); control-layer derivation fields raise it to 6 (see Control layer derivation). A document with neither keeps its version. Adoption is sticky: removing the last such entry leaves the document at its adopted schema, matching the server's monotonic floor. A build whose maximum is lower refuses the project at the server and the canvas at load as an unsupported version.
Load does not reinterpret a known value either. A control layer saved with a kind the selected main model cannot run (an Anima layer saved as ControlNet before ControlNet-LLLite was supported) keeps its kind and model. Choosing a control type for it re-resolves the model for the selected main model, and the kind follows the resolved model.
Font dependencies
Custom text keeps an immutable font reference and explicit variation coordinates. Browser registration names are runtime state, never enter the project document. New typography requires Canvas schema 4; documents without it keep their existing compatibility floor.
Project archives record font dependencies by content hash. Export defaults to references only; Include font files embeds original referenced files, once per hash, after authenticated download and checksum verification. Failed required font download fails the embedded export instead of producing a silently incomplete archive.
Import verifies declared entries and checksums, then validates all embedded fonts before creating server resources. Fonts uploaded privately; canonical document's references remapped to destination IDs. Duplicate uploads reuse existing private records. Rollback removes only newly created fonts and only when project creation was not attempted or has confirmed absence; ambiguous create response keeps the resources. Font quota failures offer explicit references-only retry. Changing accounts cancels the operation and prevents cleanup under another user's credentials.
Control layer derivation
A control layer may keep the image it derives its map from, so detection can re-run. Four optional fields on the control leaf (canvas-engine/contracts.ts) carry it: controlType (what the image controls; a closed set, so an unknown value refuses the canvas), detection (the detector and its settings; null means "use the image as-is"; the detector name stays open), original (the pre-detection image or paint bitmap, a persisted image reference) and originalTransform (the original's frame inside the map's layer frame; absent means identity). source stays the pixels generation uses (the map once detected) and filter what produced them. Invariants, owned by canvas-engine/document/controlDerivation.ts: no type means none of the other three; a null detection keeps no original; an original implies a detection and a derived source. Load repairs violations silently by dropping the bookkeeping that no longer holds, never the pixels.
A build that predates these fields would strip them on load and lose the original on its next save, so a control leaf carrying any of them makes the canvas schema 6 (canvasMigration.ts, writableCanvasSchemaVersion), one above the schema 5 that noise, clarity, texture and dehaze adjustments raise: a schema 5 build cannot read the fields and refuses the canvas instead. Documents without them keep their version, and adoption is sticky like the server's floor. original names an image by imageName like every other reference, so asset holding, cleanup and .invk export cover it unchanged.
Verification
Run pnpm lint, pnpm test, pnpm test:browser, and pnpm run test:performance:build from webv2. Queue receipt tests also cover backend admission, account isolation, project deletion, partial acceptance, idempotent retries. Browser tests exercise real IndexedDB transactions and Web Locks.
pnpm test:browser:smoke exercises held-prompt reload recovery, duplicated-tab editor-session lock ownership and
release, and route exit/re-entry against real storage in Chromium, Firefox and Playwright WebKit. It records actual
BFCache entry separately from history reload. See the package performance guide
for capabilities, artifacts and limits. These smoke results do not expand the Chromium unload guarantee above to
all browser versions, real Safari, crashes or storage failure.
Linked workflow runs capture their library id and owner in the queue snapshot at enqueue. Completion credits that saved binding, even if the project copy is later relinked or removed. Recovered runs without a captured binding skip the optional last-run update; they never infer a template from the current project copy. This metadata stays local to the submission snapshot and is stripped from backend enqueue requests.
Image and queue metadata recall
Canvas generation captures its document after paint persistence, together with its detached generation composites. Image canvas_v3_metadata version 1 holds that authored document, portable control-model identities and Canvas settings, without project identity, staging, undo history or stored media URLs. Controls that ran are pinned to the resolved model, kind, weight and schedule; the core metadata's control_layers, controlnets and t2iAdapters describe the executed composites. The queue recall cache keeps the same canvas record beside Generate values under its existing account and byte limits. Manual Save Canvas records the exported document and authored Canvas and common Generate settings, model, prompts, concepts and reference images, labelled metadata_source: canvas_save; it records neither an executed seed nor a generation mode. Its destination follows the Gallery settings at click time. After paint persistence and export, metadata is captured synchronously from the originating project only if its document is still the one exported, so settings edits during the save are recorded with the unchanged document. A changed document, a closed project or an expired account prevents upload.
All/Remix share one recall path across Gallery, Preview, staging and local queue snapshots. Current canvas records pass the project canvas loader, then referenced assets are checked in sequential bulk reads of at most 1,000 distinct images (the Gallery API limit) and models resolved by installed identity. Account expiry, a closed/different originating project, a Canvas edit during lookup, or failed paint persistence prevents that canvas commit. A complete recall replaces the canvas and keeps the old document and staging candidates as a History restore point. Partial recall and API append add usable layers with new ids and preserve existing work; staged candidates or running Canvas results also force this merge, so a recall cannot silently discard a generation session. API replacement of control_layers replaces only that stack; an explicit empty list clears it, absence changes nothing. Invalid or unavailable nonempty records never mean Clear Canvas. Generate/settings recalls remain independent of unavailable canvas content and report partial results.
Standalone legacy controlnets and t2iAdapters records restore executed maps only when no modern Canvas or control_layers record is present. Name-only image fields are hydrated from Gallery DTOs, preferring recorded processed maps; those reads are deduplicated and reused by Canvas validation. Resolved installed models determine the adapter kind, including Control LoRA, LLLite and Fun models. These generation-wide maps fit the current Canvas frame, including its origin, because they carry no authored world position; modern control_layers keep their recorded geometry. Old empty, invalid or unavailable adapter lists preserve existing work. Unsupported per-step weight lists and crop/fill resize modes report partial recall rather than replacing them with scalar weights or stretched maps.
Legacy ipAdapters records restore global Generate reference images with their model, image, weight, CLIP Vision encoder, method and step window. Modern ref_images take precedence, including explicit empty lists; historical Canvas reference-image arrays and entity containers are also accepted. Every Generate graph of a family that takes references records ref_images, empty when none ran. A v6+ generation record (one with generation_mode and an app_version of 6 or later) whose model is recalled and takes references, but which has no reference entry, is read as an empty list: older v6+ graphs omitted it only when no references ran, while v5 Canvas-staged records dropped the references they used. Exceptions keep the current references: Krea-2, whose legacy graphs used a style reference without recording it; a ref_images that cannot be read, such as the nested Kontext lists of v6.3–6.10; and v4.2 object-form control_layers, which held global IP-Adapters. A model that takes no references keeps them, switched off. Name-only images use actual Gallery dimensions, and asset lookup failures leave independent Generate fields recallable. Single-image lists are equivalent to one image; multi-image embeddings and per-step weight lists are unsupported and report partial recall. Reference projection examines at most 10,000 entries and reports truncation; image reads use sequential batches of at most 1,000 distinct names and stop when the account or originating project expires.
Legacy canvas_v2_metadata is an image-metadata adapter, separate from project schema migration. Its image-backed layers are projected directly; ordered paint, masks, gradients, erasure and layer adjustments are flattened into intermediate paint bitmaps, retaining local offsets, layer position, opacity, stack order, prompts and adapters. Preparation uploads stay intermediate, including unanswered uploads and results abandoned by account, project or document changes. After synchronous Canvas and Generate commits, only images produced by that preparation and retained in the committed Canvas are promoted to durable Canvas assets. Adoption captures its names once, continues for the originating project across navigation, and stops scheduling requests when its account expires. Rejected layers and failed commits never promote their uploads; borrowed Gallery assets are untouched. Promotion failure preserves the applied recall and reports that pixels remain temporary: recent-upload grace, open-project and undo holds, and saved references protect them under the existing intermediates policy. Decoding and uploads are sequential and account-fenced; each raster conversion is limited to 16,777,216 pixels and 16,384 pixels per side, with 64 megapixels and 128 raster uploads per recall; pressure opacity strokes also preflight a shared limit of 67,108,864 work units per recall: layer surfaces, full-output buffers/copies and stamp sampling retain their pixel charges, with 20 preparation units reserved per raw (x, y, pressure) point before smoothing and one per planned stamp. Reservations and attempted preparation remain charged when a layer is refused, so later layers cannot repeat expensive work after the limit is exhausted. An over-budget layer is reported and skipped before raster allocation; usable layers remain available for partial recall. Unsupported legacy vector layers force partial recall; their paths are not silently discarded during a complete replacement. Unsupported layer composite operations are reported and skipped because the current canvas blend contract has no Porter-Duff layer modes. A legacy record with no layers retains legacy's no-op behavior. Current records retain groups, original/derived control sources and transforms through the ordinary canvas contract. Details displays recorded settings, layer/control summaries, components, concepts and references without model or asset lookups; the complete raw JSON remains available.