Views and layouts
The window shows one view at a time: a layout of widgets declared with ctx.views.define(id, { title, layout })
(omfp://docs/init). Without a declared view the window shows the core’s, the header over the chat:
["col", {}, "omfp:header", ["tabs", { "id": "main" }, "omfp:chat"]]The default flavor (omfp://docs/flavor) declares a default view with side tabs holding the empty canvas:
["row", { "sizes": [3, 1] }, ["col", {}, "omfp:header", ["tabs", { "id": "main" }, "omfp:chat"]], ["tabs", { "id": "side" }, "omfp:canvas"]]A layout node is a reference ("omfp:chat", a declared widget’s name), [reference, props], or
[container, props, ...children] with container row, col, tabs or stack; props.sizes (optional) gives one
positive flex weight per child. omfp://schemas/views.json is the manifest’s JSON Schema.
- Keep the main slot,
["tabs", { "id": "main" }, …, "omfp:chat"], in every view: the files the user opens and the widgets something reveals become its tabs, after its children. Without it they float in a panel. ["tabs", { "id": "side" }, …]is where:widget addandviews.mountput side tabs; a view without it gets them at the end of its root container.
Props every node takes
Section titled “Props every node takes”title: the tab’s label (default: the built-in’s name, else the reference).instance: names the node’s state.useStoredanduseJobkeep state per workspace, instance and key (default instance: the reference), so two nodes of one widget share it unless each gets its own (["tests", { "instance": "tests-api" }]). It also names the node inwindows.check_widget’s report.
Switching views
Section titled “Switching views”The mode line shows the views as tabs (Default · Review · Ops) in the order the init files declare them: the user’s
init file’s first, then the workspace’s, then those of evals; a view declared again (a workspace redefining the user’s
default, an eval) keeps its place, and a view a live change creates (views.mount with a new view) comes last. The
picker lists them in the same order. The window opens default when it exists, else the first view. A click, :view <id>, Space v (fuzzy picker) or
] v / [ v switch. The window remembers the view per thread; a new thread and a draft open on the default view.
From code: windows.run { command: "view.switch", args: ["<id>"] }, or chooseView(host, id) in a widget.
Hidden views stay mounted: the window keeps the 2 views shown most recently before the current one, hidden. Their
widgets keep React state and DOM, but their effects are cleaned up as on unmount (subscriptions, useFile polls,
timers, useCommand commands) and run again when the view shows. Write effects that clean up after themselves and
refresh when they run again; never rely on an unmount to reset state.
Live changes
Section titled “Live changes”What the user or an agent changes in the layout (:widget add, closing a live tab, views.mount, views.set) is a
live change, shown by every window until the init files reload or change their views. Declarations are owned by code:
what should stay goes into .omfp/init.ts. Live changes survive an omfp restart (the daemon stores them, mounted
code included), unless the declared views changed meanwhile: then they are dropped, as on a reload. :view-reset
(views.reset { workspaceId }) drops them for good. Each window also reopens where it was: the thread (or new
thread’s workspace), with the view and tabs it showed. Splitters resize for this window only.
A view with live changes carries a • in the mode line’s view tabs (its tooltip points at :view-reset), and
windows.state reports it with live: true. The views/<id> topic’s declared is the declared manifest while live
changes replace it (null without any).
Closing tabs
Section titled “Closing tabs”- A tab the init files declare closes in that window only: hidden there (remembered per workspace and view),
never removed from the view, so every other window, its widget’s commands and
windows.runkeep working. It comes back with the↺ Nbutton at the end of its tab bar,:tabs-restore,:view-reset, a reveal of its widget, or awindows.runof a command named<widget>.<…>(e.g.viewer.open), which shows the tab, waits for the widget to register the command and runs it.windows.statelists such tabs per view ashiddenTabs. - A tab not selected pauses its widget: its commands are not registered until it shows.
windows.runof a command named<widget>.<…>of a widget of the shown view in such a tab selects the tab (and every tab around it), waits (up to 3 s) for the widget to register the command and runs it, so a script can runviewer.openwhile a file tab is selected. If the window shows another workspace, thread or view meanwhile, it answersunknowninstead. - A live tab (
views.mount,:widget add,views.set) closes for every window, as a live change; the toast’s Undo puts it back. - Declare a widget in
.omfp/init.tswhen scripts or other windows rely on it being there.
Mounts: showing a widget now
Section titled “Mounts: showing a widget now”Without editing the init file, through omfp_call (workspaceId defaults to your workspace):
views.mount { id: "preview", widget: "omfp:web", props: { url: "http://localhost:5173/" } }views.mount_update { id: "preview", props: { url: "http://localhost:5173/docs" } }views.unmount { id: "preview" }widgetis a reference;codeis a component’s source instead (it becomes the widget<id>).viewpicks the view (default: the default view; a new id creates a view showing only the mount — a dashboard —, listed after the others).place:side_tab(last tab ofside),main_tab(last tab ofmain) orend(end of the root container); without one,side_tabwhen the view hassidetabs, elseend.panel: truefloats it over every view instead.- Mounting an id again replaces it.
views.mount_updatemergesprops(nulldeletes one) or replacescode; the widget re-renders in place with its state, so drive a progress or a status this way. - The node gets
instance: <id>. A mount is a live change: declare in.omfp/init.tswhat should stay; content of one moment of the conversation goes in a card (omfp://docs/cards).
Reveals
Section titled “Reveals”REVEAL_WIDGET (omfp://docs/sdk) shows a widget: the view’s tabs holding it are selected, nested ones included.
A view without it opens it as a closable tab of the main slot after the open files;
only a view without a main slot floats it in a panel.
reference is the node’s reference as the manifest holds it: ./widgets/<name> for a declared widget, also when it
was mounted by its bare name. Several nodes of one widget (one views.mount per item, each with its own instance)
are told apart by instance: { reference, instance, nonce } selects the tab of the node whose instance prop is
instance (a mount’s is its id); a view without that node opens a tab (or panel) of that instance, rendered with
instance as its only prop. Without instance the first node of the widget is shown.
// In a window module (a widget sets it with useWindowState(REVEAL_WIDGET)'s setter),// after views.mount { id: "item-12", widget: "./widgets/item", place: "main_tab", props: { … } }:host.window.set(REVEAL_WIDGET, { reference: "./widgets/item", instance: "item-12", nonce: Date.now() });