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.
Widget placement, focus, and windows
Paths are relative to the webv2 src/ directory.
Placement: workbench/floatingWindows.ts; focus: workbench/focusRegions.tsx; shortcut hints: workbench/hotkeys/; window chrome: workbench/widget-frame/.
Placement and floating windows
Project places each widget instance in regions (widgetRegions) or a floating window (floatingWidgets), never both. workbench/floatingWindows.ts owns rules; reducer, placement normalization, and rails all read placement through it.
A floating instance belongs to no region's
instanceIds. Floating removes every membership, repairs active selections it leaves behind, and records one return destination (returnRegion,returnIndex).A return region keeps a marker for each of its windows.
getRegionOrderis region's complete order (docked members plus markers); a marker'sreturnIndexis its position in it. Docking counts docked members ahead of marker, so docking in any order never moves what rail shows. Reducer edits that add, remove, or move members go through that order so indices stay in step; reordering docked members fills docked positions around stationary markers.Empty-center recovery is the one exception to origin-only docking. A center emptied by a float keeps naming instance in
activeInstanceId. While still empty and still naming that instance, Dock restores center membership plus origin; Remove restores center membership only (no rail slot, no panel). No extra field persisted; a center that gained a view or changed its pointer is left alone. "Empty" means no members at all: reducer has no widget registry, so a center holding only a disabled or unregistered view is not recovered and shows that view's unavailable state until another view is chosen.An instance opened in the center is shown once. It may stay a member of a side panel, but a left or right panel fronting it fronts its next member instead, or collapses when it holds nothing else. Only pointer moves, so a hidden panel stays hidden. Bottom region left alone: reducer has no registry to tell its panels from tooltip-only status items. This lets every "open in Preview" path, and center Preview toggle, reuse the Preview a rail holds.
Region requests never discard a window. Selecting, moving, or reordering an instance a region does not hold is a no-op; so is enabling an instance that floats. Opening a widget type whose instance floats restores its return placement first, then opens the requested one, and auto-routes once.
Layout history is undoable, layout only. Every placement change the user makes is one project undo step: opening, adding or removing a widget, floating, docking or closing a window, moving or reordering a tab, alignment, collapsing a panel, the center view, a window's mode, preset switches, reverts and route changes. A dragged divider or moved window folds into one step per region or window (same key within 1.5 s); raising a window or selecting a tab is navigation, not a step.
undoProjectChangelays out the step's snapshot (placements, panels, route, preset copies) while every widget keeps its current values; an instance the step removed returns with its own, and one created since stays, unplaced, with its values, so adding it again brings them back. A step carrying aLayoutUndoNotice(revert, discard copy, switch preset, remove widget) reports itself throughshell/LayoutUndoNotices.tsxwith an Undo toast, withdrawn as soon as that step stops being the project's latest;app.undoLayoutChangeandapp.redoLayoutChangestep one at a time. History is session-only, at most 40 steps, never persisted.One list of every widget. The Widgets dialog (
shell/WidgetsDialog.tsx), opened from the app menu, the foot of each rail's and the status bar's widget menu, and the palette's "Show widgets", lists every widget placed in this layout (with where: a rail, the center, the status bar, a window) and every one it lacks, with Show, Add, Dock and Remove. The palette also has a Show entry per widget. Show closes the dialog and moves focus to the widget; the other actions keep it open and keep focus on that widget's row; closing it otherwise returns focus to the control that opened it, or the app menu trigger when that control is gone.One normalization.
normalizeFloatingPlacementruns on project hydration, on stored presets, on preset application, and inside preset comparison (which includesreturnIndex), so an applied preset always matches snapshot it came from. Idempotent. Indices stored before markers were counted are read deterministically (ascending, ties by instance id, missing ones appended); best-effort, does not reconstruct original arrangement.A closed window leaves its geometry behind. When a window closes (docked, removed, or closed by a preset or an undo), its position and size move to
Project.lastFloatingGeometry(rememberClosedWindows); floating instance again takes them back out and reopens window there, windowed; only a first float cascades. Float command passes viewport, so a rectangle remembered in a larger one is brought wholly on screen, not reopened as a sliver. Memory holds only instances that exist and are not floating now, in every state the reducer produces, so a save is exactly what a load reads back. Persisted with project and validated on load, but not layout: preset snapshots, drift comparison, and undo snapshots do not carry it.Each preset keeps its working arrangement per project. Switching away stores outgoing arrangement in
Project.presetWorkingLayoutswhen it differs from saved preset; switching to a preset lays out its copy there when it has one, else saved snapshot.- Copies are an ordered list, oldest first, at most one per preset and at most 16 (oldest goes first). Each is a
LayoutPresetSnapshot(placement, panels, center view, instance identity and title — never widget state) and never names active preset: live layout is its copy. - Opening or hydrating a project drops copies of presets the account no longer has and copies equal to their saved preset; every switch drops the former, so orphans never hold one of the 16 places. Deleting a preset drops its copies from every open project; a project that was on it moves to the default preset the way a switch would. Renamed preset keeps its id and its copy.
- Save on active preset writes live layout; on another preset it writes that preset's copy to account and leaves copy in place, where it no longer reads as unsaved because it equals saved preset, so a lost account write still leaves arrangement recoverable until hydration proves copy redundant. Saving a preset also drops every other open project's copy of it that equals its previous or its new saved arrangement: such a copy was no change of that project's own, and keeping it would show outdated arrangement as unsaved and could overwrite newer save.
- Revert on active preset reapplies saved snapshot, as choosing active preset again does; on another it drops copy as an undoable step. Pressing active tab while a cold switch is still loading cancels that switch instead. Saving arrangement as a new preset moves project onto new preset.
- Copies are persisted, validated on load like stored presets, and captured in undo snapshots with
layout.presetId, so undoing a switch restores both.
- Copies are an ordered list, oldest first, at most one per preset and at most 16 (oldest goes first). Each is a
Rails subscribe to placement only (getWidgetPlacementProject projects floatingPlacements), so a window's geometry, mode, and stacking change without re-rendering them. A marker is not a tab: it stays out of sortable list, activating it raises and expands its window, and its context menu offers Dock and Remove (the window's own title bar has both too). Marker UI exists only on left and right rails.
Focus
Workbench focus is transient, never persisted. WorkbenchFocusProvider (workbench/WorkbenchRuntime.tsx) owns one controller (workbench/focusRegions.tsx) above UI ports, hotkey runtime, and shell; no module-level focus state. Target is a docked region or one floating instance.
Keyboard navigation.
Alt+Shift+Arrow(Ctrl+Cmd+Arrowon macOS, where Option+Shift+Arrow selects text by word or paragraph, Ctrl+Arrow chords belong to Mission Control, and Ctrl+Option+Arrow is VoiceOver's navigation chord) moves focus to nearest visible docked region in that direction, using current frame geometry and preferring alignment; with no current target it enters center. Preserves widget selections, skips hidden regions, stops at edge. From a floating window, its center is starting point on movement axis so overlapping docks stay reachable; when no dock lies beyond it in that direction, focus returns to dock under its center.Alt+PageUpandAlt+PageDowncycle focused docked region's enabled panel views in placement order, wrapping at either end and focusing owning region once selected instance is visible. Side frames wait for their lazy view to load; persistent center frame can take focus immediately. Toolbar, tooltip, popover, and floating placements excluded; a single eligible widget stays open. All six commands are customizable in Hotkeys settings, work from editable fields (defaults are chords no text field binds on that platform), and respect modal suspension. Ordinary Tab and arrow-key handling unchanged.One judge of the target.
getTarget()returns target only while it describes something on screen: set under current project and account, and (for a window) still floating. Provider also clears eagerly when active project changes, account changes, or workbench unmounts; that notifies subscribers and abandons a focus move still waiting for its widget to mount. Returning to a project never brings old focus back.Activation. Pointer-down and keyboard focus activate a region or window; hover does not. Active window carries the same accent outline, under the same preference, as a focused region; no region is outlined while a window is active. Window passes project id it was rendered for, so a late event from a project that left screen is refused before it can raise anything.
Raising. A press inside a window always asks reducer to raise it (no-op for topmost window). Focus raises a window only when it makes that window the active one: focus moving inside already-active window, or returning from a closing dialog or popover, writes nothing. Ordinary focus leaves a shaded window shaded; explicit reveal (marker, center "Show window", recall) expands it.
Recall is the one reveal that moves no focus. Recall raises and expands its window but leaves keyboard focus, outline, and hotkey target where user had them; next press or focus change brings them back into agreement. Since focus inside active window does not re-raise, it cannot re-bury the window a recall just revealed.
Keys follow the outline. A press inside a window moves keyboard focus into it when focus was elsewhere; a press on a docked region pulls focus out of a floating window. Floating layer renders windows in fixed DOM order and stacks them by z-index alone: raising a window never moves its node, which would drop the focus that raised it.
Focus follows placement: into window after Float and after a marker or "Show window" reveal; into the region a docked rail tab shows in when it is selected, so keys stop going to a window that held them; into return region after Dock; after Remove from a marker's menu, into center when it gets its view back, else into the panel the window's own rail is showing, or center when that rail shows none (emptied by float or collapsed). Removing a window from a rail's enable menu moves no focus: that menu stays open and keeps it. A focus move targets region frame on screen (side regions keep earlier panels mounted but hidden), waits a bounded time for its widget to mount, and is abandoned if user presses elsewhere first. A newer modal opening cancels an older waiting or settling move, so that move cannot steal focus during the modal’s close. A move requested while an existing dialog closes remains valid; closing releases presence without starting a new modal generation. Every panel frame carries its instance's identity, including stand-in for a widget whose view cannot render, so a move into it lands.
Hotkeys read the same target.
HotkeyContext.focusedRegionisWidgetRegion | 'floating' | null; persistedWidgetRegionunchanged. A key press is aimed at widget under event target first and, outside any widget's DOM, at active floating instance or focused region's active member (resolveHotkeyTarget). A region's active pointer counts only while it names a member, so a view that floated out of an emptied center answers as a window, not as center. Floating command source carriesregion: 'floating'and is never used to indexwidgetRegions. Genericfocused-regionshortcuts match under a window, shortcuts tied to a named docked region do not, and a floating widget's ownfocused-regioncontribution follows its window at the same priority it has when docked. A binding with atargetSelector(prompt weighting: an editable prompt whose model reads attention syntax) is a candidate only while the key press's target matches it; elsewhere the next candidate wins, or nothing claims the key and it keeps its browser behavior. Canvas engine's own keys (Enter, Escape, C, and the Space and Alt holds) ask the same judge with the same inputs: the canvas surface maps the target to this canvas, a companion Layers widget, or elsewhere.Modal dialogs suspend application shortcuts. Every dialog is built on Platform
Dialogroot (platform/ui/Dialog.tsx; lint rejects Chakra's dialog and its drawer, which has no such root yet), which registers withplatform/ui/modalPresencewhile its own open state holds, unless declaredmodal={false}. A dialog whose module is still loading usesDialog.Pendingas suspense fallback, so it is modal from keypress that opened it. While any registration stands, hotkey runtime runs only hotkeys markedallowInModal(command palette toggle), so invoke, global and widget shortcuts stay inactive wherever focus is, and keys the dialog handles itself (Enter, Escape, typing) keep browser behavior; Canvas engine's own key listener takes no key either. Both ask about the key press they are handling: a press that began under a modal still counts as aimed at it, because the Escape that dismisses a dialog releases its presence before the same press reaches bubble-phase listeners. Presence follows interactivity, not DOM: a closing dialog that stays mounted through its exit animation is inert and releases at close, so next press reaches application; reopening re-registers at once, an outer dialog stays registered while an inner one closes, and an unmount releases without a close. Media paste reads the same presence. Popovers and menus do not register.
Contextual shortcut guidance
Shortcuts is a bottom-only popover widget. Built-in layouts put it on right immediately before Notifications; saved and custom layouts keep their placements and can enable it from the Status bar widgets menu. Whole chip opens its guide; normal widget controls own reordering, alignment, visibility and dismissal. Its compactSizing metadata asks status-bar host for remaining capacity: host observes its strip, two clusters and spacer; guide measures only its own keycaps. Up to four whole hints fit without increasing status bar height; a keyboard icon keeps access when no hint or label fits. Status-bar chips take their accessible name from compact content, never a host aria-label, so speech-input users can say the status they see (WCAG 2.5.3 Label in Name). Once its view loads (until then its busy fallback reads "Loading
Workbench focus lifecycle also owns transient hint-source registry and last editing element. A keyed Canvas registration mounts one stable source for its project/instance engine lease. Generation and staged results never change Canvas hints: nothing locks the canvas. Narrow tool/session subscriptions cache scalar hint inputs; guide never acquires an engine lease or imports property forms. Sources are fenced by project and instance and released with their owner. Project/account changes clear editing origin. Widget's preserveWorkbenchFocus metadata keeps its compact chip and portal from replacing that origin; closing returns focus there. Healthy preserve-focus guides are suppressed under unrelated modals and do not reopen when the modal closes; their hidden sortable is disabled and their measured chip DOM is released. A failed item keeps its recovery mounted through its own confirmation, while modal presence still suspends application shortcuts. Guide activation and Escape do not reach Canvas session handlers; configured global chords keep normal runtime handling.
Command hints resolve against runtime catalog and mounted extension contributions, including custom bindings, scope conflicts, editable fields and modal exclusions. Command bindings reserved for guide activation or dismissal (bare Enter/Space and Escape chords) are omitted in favor of a usable alternative; fixed Canvas instructions may still describe those keys. Fixed gestures stay Canvas-owned and distinguish selection modifiers at press from constraints during drag. Properties shows them as “On Canvas”; active modal presence hides background guide. Pointer coordinates and pixel epochs are not hint subscriptions.
Window interactions
- Geometry is stored once and adapted in CSS. All windows share one static rule set; stored geometry and stacking rank arrive as inline custom properties (registered as non-inheriting, so a drag restyles window, not widget inside it), so a commit changes values rather than minting a class. Position keeps a 48px sliver reachable (
FLOATING_VIEWPORT_MARGIN_PX, the same marginclampWindowToViewportapplies to commits); displayed size is capped to viewport. So a shrinking viewport persists nothing; stored geometry applies again when there is room. - Gestures start from the rendered rectangle, not stored geometry, so a window CSS is clamping or capping does not jump. A gesture commits only what it changed: a move keeps stored size, and a move or resize keeps stored values of any axis it did not change (
commitChangedAxes), because what is on screen there may only be viewport's clamp or cap. Viewport clamp applies to changed axes alone, so a vertical move or resize never rewrites a stored x, nor a horizontal one a stored y. An axis counts as changed only when the clamp lets the change show: a push against the viewport's edge keeps the stored value too. Gestures clamp against the viewport as CSS resolves100vw/100vh, measured from a hidden fixed probe in the window, notinnerWidth/innerHeight: at a fractional zoom the viewport is fractional pixels, which those round, and a rounded edge would read a push into the real one as a move. A press that never moves, or a drag against minimum, cap, or edge, commits nothing. Keyboard steps follow the same rules. - One commit per gesture. Pointer moves are coalesced to animation frames and previewed as inline custom properties on window element; store is written once, when gesture ends: on release, or when pointer is taken away (
pointercancel, a release the page never saw), which keeps what was dragged so far. Escape discards preview. Each keyboard step is its own commit. - Resize handles. Eight pointer-only handles (four edges, four corners) straddle border with matching cursors and non-overlapping hit areas, above an isolated content frame so widget stacking cannot cover them. Inside bottom-right corner sits
ResizeCorner, the single labelled, keyboard-operable resize control; pointer-only handle there is clipped to band outside border. That control announces size on screen (stored size as viewport caps it) and follows viewport, so its value and keyboard steps agree, to within the sub-pixel difference at a fractional zoom: it announces whole pixels frominnerWidth/innerHeight, while steps cap at the measured viewport.resizeFloatingGeometryanchors opposite side, holds size between minimum and viewport (a viewport smaller than minimum lowers it to viewport, so shown size is not mistaken for a resize), and stops top edge at viewport's top. - One gesture path. Title bar, grip, and every handle start through window's single pointer session, so a new gesture replaces the one before it and resize gestures all raise platform's resize-drag signal. Preview names the mode the gesture began in and applies only while window is still in that mode: a window that maximizes or collapses under a gesture shows its new frame at once, and gesture ends itself (releasing drag cursor, committing nothing) next time it hears from pointer. Docking, removing, or switching project unmounts host (hosts keyed by project and instance), which aborts session.
- Title bar. Double-click maximizes or restores, and expands a collapsed window; Restore returns to windowed geometry, which maximizing never touches. Collapse and Expand are explicit buttons; Close removes the window as a marker's Remove does (an undoable layout step), sending focus to the center when it gets its view back, else to the panel the window's rail shows, else the center. Label truncates first, down to its icon; contributed widget actions then give way in a strip that scrolls, without a scrollbar, by focus, sideways scroll, or touch, so a focused action is always in view with its ring; window's own controls never shrink.
- Shaded bodies stay mounted. Shaded body is hidden with React
Activity, so its local state survives and no second copy mounts. Drafts are flushed before shading, docking, and removing, because hiding or unmounting an editor stops its flusher.
Docked bodies
A left, right or bottom panel puts its widget's body in one vertical Scrollable (PanelBodySlot in WidgetRenderer.tsx); the manifest's chrome.body says how the view meets it.
flow(default). The scroll content grows with the view and is never shrunk below it, because the scroll area sizes its thumb from that element: a squeezed one leaves the scrollbar stale as sections open and fold. A view'sh="full"means at least the body's height, never a bound.fill. For views that bound their own regions: inner lists and trees that scroll themselves, resizable panes, filters or footers that stay in view. The frame wraps the view in a size-contained column, so the view's rows never count toward the body's height and the view gets exactly the body's height. Past the view's own minimum heights the overflow still spills into the body, which then scrolls instead of crushing them. Center and floating hosts give every view exactly their height, with no outer scroll, whatever the manifest says.
Center chrome
Center view's header floats over its body as two islands (workbench/shell/CenterArea.tsx): view menu and widget label at start, toolbar widgets and header actions at end.
- Start gives way first. End island keeps its natural width up to the center width less the start island's floor and a gap; start island takes what remains. The floor (
getChromeIslandMinWidth) is the view menu's own minimum (5rem: its icon, a few letters, its chevron) plus the island's border, row padding, and end cue, so the menu's minimum stays clear of the cue. Islands never overlap or leave the center. - Rows scroll, then cue. Inside an island, labels truncate to their own minimums first; past that the row scrolls sideways without a scrollbar, by wheel, swipe, or focus (
workbench/shell/ChromeIsland.tsx). Each end hiding controls shows a fade into the island's background and a chevron button that scrolls to that end, smoothly unless reduced motion is on. The whole cue takes the pointer: the half-hidden controls under the fade neither take clicks nor show hover, and a press on the fade does nothing, not even move focus. A wheel or trackpad swipe over a cue still scrolls the row. The row is its own stacking context, so a control's z-index cannot lift it above the cues. Cues re-measure on scroll, on resizes of the row and its controls, and on any change inside the row, such as a counter gaining a digit. The buttons stay out of the tab order like other pointer shortcuts: focus already scrolls each control into view, clear of the cues.
Render recovery
The editor store creates transient recovery entries for the active project's instances before publishing its snapshot. Leaving the project or removing an instance drops its entries. The requesting view subscription fences pending reloads through hide, unmount and development remounts; disposal releases its store when pending actions settle. Late callbacks and reload confirmations are fenced by account, project, entry identity, view lifetime and generation. Old-generation failures in unmounted slots are retired after retry; mounted newly failing slots remain isolated. This retirement is not rendering proof for a closed tooltip: a recovered announcement describes currently mounted surfaces, and opening a deterministic failing tooltip can report the failure again.
Boundaries contain failures in their own host and slot (body, label, actions, icon, header, footer or tooltip). They share one retry generation and one implementation load, never another slot's render error. Retry resets failed boundaries without remounting healthy bodies or discarding their local state. Center implementation-load failures expose one expanded recovery action; menu icons keep their static identity. An explicit non-isolation policy still propagates errors.
Compact recovery uses a Platform button named with the widget label, failure and action; only Enter/Space activation is stopped. Its tooltip uses the error message, while expanded recovery and logs retain stacks. A failed compact row suspends its enclosing open action; a tooltip-only failure keeps the healthy row and panels and adds a sibling retry. Status popover triggers retain their DOM shape; closing returns to the usable trigger or the named failed host. Expanded popovers/dialogs and compact status recovery focus a stable named host; docked and floating recovery use the focus controller, including pending-import cancellation. Mounted empty live regions announce failure, retry and committed recovery without entering the compact chip's name.
Retry only reimports through the shared resource and never reloads the document. A repeated rejection offers a separate Reload editor action. Its confirmation explains that registered edits are saved first but Canvas undo and per-workflow edit histories are lost for all open projects, and a persistent module error may remain. Cancel preserves the histories. Only confirmation runs the Workbench save/pixel barriers before requesting a fresh document. Pending changes, conflicts, failed uploads/saves or newer edits refuse the reload and report an error while the shell stays usable. Ended accounts and removed owners cannot authorize a reload. A confirmation expires across hide/reveal or a later retry generation. Confirming it while the same account, project and instance remain current and its view is visible reports the localized inactive reason without invoking persistence or reload; account/project departure, instance removal and an unmounted or still-hidden view stay silent. No module URL is rewritten. Render failures in an already-loaded implementation retry in place. Shell docking, closing and placement controls remain outside implementation failure slots.