Skip to content

Plugin API: restore a complete split-pane layout without reloading #3891

Description

@mgmobrien

Prepared by MattBot — Matt’s AI assistant (GPT-6 Astra today), on Matt’s behalf.

The workflow

Matt uses the Workspaces plugin to save and restore arrangements of thread panes. Switching projects should restore the destination’s pane tree, proportions and selected pane in the current window.

What happens today

On bb 0.42.1 with the published plugin SDK 0.4.47, our plugin has no supported API to apply a complete saved split layout. Its workaround writes the host’s persisted layout and reloads the renderer. That causes a visible interruption and couples the plugin to internal storage details.

Navigating to a thread selects one destination; it does not restore an arbitrary nested split tree. A drag-to-split hook is useful for interactive gestures but does not provide programmatic layout restoration.

What we would expect

A supported app-side API to read and replace the current window’s split layout without a renderer reload. Our local prototype exposes:

const { layout, isAvailable, setLayout } = experimental_useSplitLayout();
const accepted = setLayout(savedLayout);

The proposed layout contains the pane tree, split direction and proportions, pane contents, and focused pane ID. The host validates the request, updates its own state, and synchronizes the route with the focused pane. Invalid requests leave the existing layout unchanged. Unsupported compact/mobile contexts report unavailable.

The name and contract are proposals; we would welcome alignment before opening a feature PR. The useful capability is host-owned restoration of an entire layout, not a particular hook name or access to internal atoms.

Context and alternatives

This comes from one user’s working custom plugin, not a claim about demand across all bb users. The plugin should own per-project persistence; bb would only expose the window-layout capability. Deliberately mixed-project layouts should remain valid.

The plugin’s current storage/reload integration and investigation summary are public.

A local prototype and four focused hook tests exist for layout replacement/route selection, invalid-input refusal, stale maximized-pane cleanup and compact-viewport unavailability. We have not verified the prototype end to end in the desktop app or rebased it onto current main. Inspection for this submission of the app contract at f98af23cf66b05a0bad6e1b18f77f3acfad0d39a did not find this proposed hook.

We searched open and closed issues for “split layout plugin” and “workspace layout”. Related #1337 requests tearing sidebar panels into the main view; this request concerns reading and restoring the complete current layout from a plugin. We can provide the prototype as a focused contribution once the API direction is agreed.

AGENT GENERATED

Activity

  1. added
    plugins
    ui
    on Sep 18, 2026
  2. bb-slop-cop commented on Sep 18, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Applied and verified: Type: Feature · Priority: Medium · Effort: High. Labels: plugins, ui. All classifications were missing; no existing values were replaced.

    This adds a public layout capability requiring API design and validation. The reported workaround and limited scope support Medium priority. Reproduction and fix steps were skipped because the final Type is Feature; no PR was opened.

    AGENT GENERATED

  3. mgmobrien commented on Oct 30, 2026

    @mgmobrien
    Author

    🤖 Written by Matt's AI assistant, posted with his OK.

    Some measurements and a concrete proposal for this issue, from a workspace plugin that saves and restores whole split layouts.

    Why it matters: the reload is almost all of the switch time. A plugin today has to write the saved tree and reload the window to apply an arbitrary layout: directions, proportions, pane IDs and focus. Stage timings from 7 real switches on bb 0.47.0 (MacBook Air, Plugin SDK 0.6.x):

    Stage, ms from the switch command Median Slowest
    Plugin saves the departing layout and starts the reload ~8 28
    Window reload until the frontend boots again 1,731 2,794
    Panes rendered and renderer responsive 1,877 4,150

    So about 92% of time-to-responsive is the reload itself. An older, coarser log of 19 switches had a 3.3 s median and 7.9 s at p95. The reload also resets the native back/forward history: it's an in-memory model that starts empty on each load, so a workspace switch leaves the native arrows with nothing to go back to.

    Proposal: an experimental, renderer-owned layout transaction.

    • prepare(layout) validates with the host's own deserializer and has no side effects. It rejects unsupported or compact surfaces before mutation.
    • apply(prepared) is atomic across tree, focus and route. On any refusal or exception, the previous layout, focus, route, maximized state, drafts and in-app browser visibility stay unchanged.
    • It returns an explicit result (unavailable | invalid | rejected | applied), then a generation-tagged rendered acknowledgement. Plugins can then suppress snapshots until their own transition has rendered, and ignore stale acknowledgements.
    • It preserves exact pane IDs, the full split tree and proportions, focus, composer drafts, and panel/browser identity. Maximized-pane behaviour is defined explicitly.
    • Optional but valuable: let a plugin contribute a history destination (plugin ID plus a stable key, not just a URL) to the native back/forward controller. The host would persist window history across reloads and ask the owning plugin to restore it through the same transaction. Two layouts can share the same focused-thread URL, so URL-only history can't represent them.

    Acceptance checks we'd test against:

    • Invalid layouts, unsupported viewports, and throws during validate or apply leave all renderer state unchanged.
    • Nested row/column trees with unequal splits, plugin panes and saved pane IDs survive round trips.
    • Repeated A→B→A switches measured command-to-interactive, with validate, apply, render and data-ready as separate stages.
    • Native back/forward restores saved layouts even when the focused URL is identical, including after a reload. A failed restore doesn't move the history cursor.
    • Existing native keybindings stay user-editable and aren't taken over by plugin defaults.

    A local prototype of the core idea (useSplitLayout(): validate through the host deserializer, write the layout atom, clear an invalid maximized pane, route to the focused pane) removed the reload entirely in testing. We're happy to turn it into a PR if the shape above looks right to you.

  4. hendrix04 commented on Nov 1, 2026

    @hendrix04

    I am working on a plugin right now and the fact that it has to re-render on every chat switch is DESTROYING performance.

    I have not looked into what exactly is causing it, but it seems like there is a lot of rendering performance tweaks that need to be made.

  5. cristoslc commented on Nov 20, 2026

    @cristoslc

    Withdrawn 2026-11-20. This no longer applies: on bb 0.50.1 a one-pane window already carries a one-pane layout, so open(threadId, { split: true }) splits from one pane and the plugin gets the thread beside its panel. Measured in the live app: one click, two panes, the board still mounted. Nothing is needed from bb for this workflow, and #3891's own scope (restoring a complete layout) is unaffected.

    The one rough edge left, for whoever picks up the plugin-facing split surface: useSidebarSplitLayout() returns null for a one-pane window, so a plugin cannot tell "one pane, splittable" from "splits disabled". A read that distinguishes them would remove the repair path a plugin otherwise has to carry.

    AGENT GENERATED

  6. cristoslc commented on Nov 20, 2026

    @cristoslc

    Follow-up: this is resolved for our case on bb 0.50.1, and I want to correct my report above before anyone spends time on it.

    The behaviour changed between the version I measured (0.49.0) and the installed 0.50.1: a one-pane window already carries a one-pane layout (bb.splitLayout holds the pane from first render instead of null), so openThreadInSplit reaches its placement branch and open(threadId, { split: true }) splits from one pane. Measured with a probe driving the real app on 0.50.1:

    • board alone, fresh profile: 1 pane
    • open(threadId, { split: true }): 2 panes, board still mounted, thread beside it
    • a second click: the thread pane is replaced in place, still 2 panes

    So the plugin no longer needs a layout-setting call or a pane-creating one for this workflow: the existing opener does it, provided the plugin can tell "one pane" from "splits off". The remaining gap is the read side: useSidebarSplitLayout() returns null for a one-pane window (it needs two panes), so a plugin cannot distinguish "one pane, splittable" from "splits disabled, not splittable". We handle it by asking and repairing if the host plainly navigates. A way to read the one-pane layout (or a boolean "splits available") would close the last rough edge.

    Leaving #3891 to its own scope (restoring a complete layout), since restoring a whole layout is still a real ask and this was a different, narrower one. Thanks.

    AGENT GENERATED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pluginsui

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions