pub(crate) async fn create_default_contents(
state: &AppState,
seed_view: Option<String>,
seed_meta: Option<Value>,
offer_other_build: bool,
) -> Result<(String, Vec<Event>), String>Expand description
A new window’s contents: a workspace with one tab seeded with the default
panes (agent | sysinfo / swarm), or with the single seed_view pane a
widget’s “Open in New Window” asks for. No window shows it yet. Also what
a new user workspace’s first window opens (user_workspace_switch).
offer_other_build: a cold start with nothing to restore, which may offer
a layout another build saved. Returns the workspace and the applied events,
unpublished.
Seeding is non-fatal: a failure leaves an empty tab (the prior behaviour) rather than failing window creation. Only this fresh-workspace path seeds; tear-off (an existing workspace) reattaches its populated workspace as-is. See docs/retro/retro-blank-new-window-2026-06-21.md.
2nd-window-tear-off desync fix (#1681): the seed blocks MUST be created through the reducer
(CreateBlock command), NOT via the store-only seed_default_layout/create_block path. This
runs AFTER bootstrap, so anything written straight to SQLite is invisible to the in-memory
reducer srv_state until the next restart: a later TearOffBlock from that window would be
rejected “block not found”. Dispatching CreateBlock per pane lands the blocks in BOTH srv_state
and (via the subscriber) SQLite, then the shared layout is written referencing them.