Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

6.9 KB
Raw Blame

Splits tile like a window manager: any split can be split again beside (left/right) or stacked (above/below), nested to any depth.

Tiling

The split router owns the tiling as a tree (lib/split-router/panes/layout-tree.ts): row and column splits whose leaves, depth-first, are the open panes in order. TiledSplits renders desktop panes from it. Every pane stays in one keyed list and is positioned absolutely at the rectangle split-geometry.ts solves, so splitting or closing a neighbour never moves a pane's content to another parent and remounts it. Keep it that way: don't nest a Resize.Zone per split. Gutters reuse Resize's Gutter and moveHandleShares; sizes live in the tree but not in the URL. A split is at least DEFAULT_SPLIT_MIN_WIDTH wide and, stacked, DEFAULT_SPLIT_MIN_HEIGHT tall (splitContentSizing.ts). With desktop tabs, SplitLayout renders one TiledSplits per tab layer: the live layer tiles as router.layout(), and a parked one keeps the tiles its panes were parked in (router.layoutOf), so a background tab comes back stacked as it was. Only the live layer reports its area or resizes.

Open beside a split with beside: { split, side } on openWithSplit or createNewSplit; without it a new split is a full-height column at the end. The new-split keys (\, |) and title-bar buttons open beside the active split. canAppendSplit() checks room for that column and canSplit(id, side) for a split along side's axis, both against the area TiledSplits measured. A Shift-click that also holds Option (Alt) opens below the split it came from: split-below-intent.ts remembers the click, as tab-layout/open-in-tab-intent.ts does for Cmd-click. Moving panes (swap left/right, mobile bring-to-front) keeps the tiles and their sizes and changes which split shows where.

browser-test/ is a backend-free Playwright regression over the real router and TiledSplits: bunx playwright test --config src/components/app/split-layout/browser-test/playwright.config.ts.

Opt-in view restoration

SplitLayoutProvider owns a memory-only, account-scoped view-state store. A view opts in by calling useViewRestoration() in its stable route component. The default key comes from the current router location, with Agents conversations normalized to agents; pass an explicit key to override that grouping.

The hook captures its current location, route state, and entry-state slices in useBeforeLeave. It stages the snapshot with the navigation's onCommit callback, so a refused, cancelled, failed, or superseded navigation cannot replace the saved snapshot. Solid cleanup only unregisters the hook; it never saves state.

Ordinary rail, Go To, and mobile dock navigation sets resume: true on the existing layout actions. Only opted-in views resume. A mounted view can supply its current state directly, and the last focused instance wins when several splits show a view. Explicit links and new-split actions stay fresh. Native dock navigation still resets the pane stack, and dock Search starts a fresh session. Reload, sign-out, and account changes retire the saved state. Views still unmount normally.

Desktop app switches skip a retained destination claimed by another pane or its inline preview, opening the requested root view in the target pane instead. Check router claims, including preview owners, before applying the snapshot; do not bypass entity deduplication. Native dock stack replacement still resumes the retained destination.

Views retain local context through useEntryState or registerEntryStateCaptor. These slices restore through both pane Back/Forward and opted-in app switches; route/schema state stays separate. Restores use the existing router, including leave guards, middleware, URL updates, and single-owner content claims.

Resolve restoration keys and initial entry-state slices from the current router entry, not the layout mirror: an outlet can mount before the mirror updates.

The remaining notes below describe the original split layout.

SplitLayoutRouter is responsible for handling the routing of the splits.

url schema stays the same app/<split_type>/<split_id>/<split_type>/<split_id>

a split_type can either be a BlockName or the string literal component

components should get resolved by a ComponentRegistry

resolveComponent should resolve a component by its name, and parameters

BlockOrchestrator owns creating and destroying the blocks themselves.

Blocks can exist either mounted to a layout, another block, or completely detached

LayoutManager owns the layout state, which is managed through the url

LayoutManager must exist within the tree of a SolidRouter, while BlockOrchestrator can exist outside of it.

LayoutManager::insertSplit(splitContent?: SplitContent) should insert a new split into the layout, and return a LayoutSplit object handle to manage the split

Composable utilities should tie them together.

LayoutManager::getSplit() should return a LayoutSplit object which you can use to navigate the splits back and forth.

Each split should have a SplitContext with its own LayoutSplit object handle to manaipulate its own split

LayoutSplit::goBack() and LayoutSplit::goForward() should navigate the split back and forth

LayoutSplit::replace(splitContent: SplitContent) should replace the current split content with a new one, this will automatically apply to the splits history

TODO:

  • figure out what is wrong with split history. It will occasionally not work as expected
  • replace existing usages of blockLayout with the layoutManager
  • figure out some clean alternative to a global layout manager. Maybe passing it through context?
  • wrap all non block components with a SplitLayout Top Bar tha thas all the navigation buttons
  • port over nested block implementation to use block orchestrator
  • add a temporary settings menu to the global bottom bar
  • disable the right bar for now.
  • port over BlockRoute to the new SplitRoute
  • fix instances of stripOtherBlocksFromUrl

Things that might be broken

  • command menu will always open things in a new split
  • query params are broken
  • Browser history changes won't live update
  • Right hand side panel has been temporarily removed
  • No way to see channel notifications.

TODO AFTER:

  • better resizing for panels, should resize based on the existing ratio
  • need a split dialog (a dialog that is centered on the split)
  • useBeforeLeave won't work as expected going forward, since we use the split layout as the source of truth. Lots of places use isLeavingCurrentBlock to run some side effects, we need to abstract this under the split Might need something like useBeforeSplitClose or useBeforeBlockClose

Priority collapse

Split headers and toolbars create their own controllers from src/components/priority-collapse/. layoutUtils.ts keeps only the split-specific header and toolbar registration wrappers; other rows register with the shared controller directly.