Programmatic Control

Imperative control exposed through the Tilery ref, panel objects, and tab objects.

Controller Ref

The Tilery ref exposes a TileryController. Use it when the application, not a direct drag gesture, needs to change the workspace.

Common workflows

WorkflowUseWhy
Open a file, query, or issue tab onceopenOrActivateTab()Activates an existing resource tab by id or inserts it if missing.
Rename a temporary resource tabchangeTabId()Moves a draft or untitled tab to a durable id without rebuilding the layout.
Split a workspace regionsplitPanel() or panel.split()Creates a new panel beside an existing panel.
Move a whole panelmovePanel() or panel.moveTo()Repositions a panel while preserving its identity and mounted content.
Move a tab from app codemoveTab() or tab.moveTo()Supports panel, before-tab, after-tab, and split targets.
Float or pop out contentfloatPanel(), floatTab(), popoutPanel(), popoutTab()Extracts existing content without closing its tabs.
Persist or restore the workspacegetLayout() and setLayout()Round-trips the serializable snapshot shape.

Controller methods

MethodDescription
getPanel(id)Returns a TileryPanel or null
getTab(id)Returns a TileryTab or null
getPanels()Returns all TileryPanel[]
getTabs()Returns all TileryTab[]
movePanel(panelId, target)Moves a tiled panel to a split or root target while preserving its identity
splitPanel(panelId, direction, opts?)Splits a panel and returns the new TileryPanel
removePanel(panelId)Removes a panel and redistributes space
maximizePanel(panelId)Shows one panel fullscreen
restorePanel(panelId)Restores a fullscreen panel
floatPanel(panelId, opts?)Detaches a panel into the floating layer with optional bounds and behavior
dockPanel(panelId, target?)Docks a floating panel into the tiled tree
popoutPanel(panelId, opts?)Opens a panel in a native same-origin browser window
returnPanelToFloating(panelId, bounds?)Returns a popped-out panel to the in-page floating layer
focusPanel(panelId)Raises a floating panel above its peers
setFloatingPanelBounds(panelId, bounds)Sets floating panel position and size
setPopoutWindowBounds(panelId, bounds)Stores the native window position and size for a popped-out panel
appendTab(panelId, tab, opts?)Appends a tab to a panel
insertTab(panelId, tab, index, opts?)Inserts a tab at a specific index
openOrActivateTab(tab, target)Activates an existing tab by id, or opens it once at a tab-row target
changeTabId(oldTabId, newTabId)Renames a tab id and returns the renamed TileryTab, or null if the rename cannot be applied
removeTab(tabId)Removes a tab and removes panel if last
moveTab(tabId, target)Moves a tab to a target location
floatTab(tabId, opts?)Extracts a tab into a new floating panel
popoutTab(tabId, opts?)Extracts a tab into a new native-window panel
setTabBehavior(tabId, behavior)Updates tab close and drag behavior
setActiveTab(tabId)Activates a tab
swapPanels(panelA, panelB)Swaps two panels positions
getLayout()Returns a serializable TileryLayoutSnapshot
setLayout(layout)Restores a TileryLayoutSnapshot
getState()Returns the current TileryLayoutState

Tab Workflow APIs

Use openOrActivateTab() when app resources have stable ids, such as file paths, issue ids, or routes. If the id already exists, Tilery activates that tab and does not update its data or create a duplicate. If the id is missing, Tilery inserts the tab at the supplied target and activates it.

Edge panels are normal tab targets once they exist in the root layout. Move a tab into a pinned sidebar with { panel: edgePanelId }, or inspect panel.kind === 'edge' when the app needs to treat sidebars differently from main tiled panels.

Use changeTabId() when a temporary tab receives a durable id later, for example after saving a draft file. The rename updates panel tab order and active tab references; it returns null when the old id is missing or the new id is already in use.

tilery.openOrActivateTab(
  {
    id: filePath,
    data: { title: basename(filePath), filePath },
  },
  { afterTab: relatedTabId },
);

tilery.changeTabId('untitled-1', savedFilePath)?.activate();

Panel Objects

TileryPanel objects are returned by getPanel() and getPanels().

Property / MethodDescription
idPanel identifier
kindPanel kind: tiled, edge, or floating
insetCurrent { top, right, bottom, left } percentages
edgeEdge side for pinned edge panels
edgeSizeEdge width or height percentage for pinned edge panels
edgeDefaultSizeEdge default size percentage, if set
floatingWhether this panel is detached
floatingBoundsFloating { x, y, width, height } percentages, if detached
floatingZIndexCurrent floating z-index, if detached
poppedOutWhether this floating panel is in a native window
popoutWindowBoundsNative window { left, top, width, height } pixels, if popped out
tabsArray of TileryTab for this panel
activeTabThe active TileryTab or null
fullScreenWhether this panel is currently fullscreen
minSizePanel minimum size constraint, if set
maxSizePanel maximum size constraint, if set
appendTab(tab, opts?)Append a tab to this panel
insertTab(tab, index, opts?)Insert a tab at index
moveTo(target)Move this panel while preserving its identity
split(direction, opts?)Split this panel
remove()Remove this panel
maximize()Show this panel fullscreen
restore()Restore this panel from fullscreen
float(opts?)Detach this panel with optional bounds and behavior
popout(opts?)Open this panel in a native browser window
returnToFloating(bounds?)Return this popped-out panel to the in-page floating layer
dock(target?)Dock this floating panel
focus()Raise this floating panel
setFloatingBounds(bounds)Set floating panel bounds
setPopoutWindowBounds(bounds)Store this popped-out panel window bounds
setActiveTab(tabId)Set the active tab

Tab Objects

TileryTab objects are returned by getTab(), getTabs(), and panel tab properties.

Property / MethodDescription
idTab identifier
panelThe parent TileryPanel
indexPosition within the panel tab list
dataThe TData payload
closableWhether close actions are allowed
draggableWhether move actions are allowed
setData(data)Update the tab data
setBehavior(behavior)Update tab close and drag behavior
moveTo(target)Move to a target location
float(opts?)Extract into a new floating panel
popout(opts?)Extract into a new native-window panel
activate()Make this the active tab
remove()Remove this tab

TileryMoveTarget

Used with moveTab() and tab.moveTo():

type TileryMoveTarget =
  | { panel: TileryPanelId; index?: number }
  | { beforeTab: TileryTabId }
  | { afterTab: TileryTabId }
  | ({
      splitPanel: TileryPanelId;
      direction: TileryDirection;
      size?: number;
      minSize?: TilerySize;
      maxSize?: TilerySize;
    } & TileryLayoutBehaviorConfig)
  | ({
      splitRoot: true;
      direction: TileryDirection;
      size?: number;
      minSize?: TilerySize;
      maxSize?: TilerySize;
    } & TileryLayoutBehaviorConfig);

Use splitPanel when the new panel should sit beside one existing panel. Use splitRoot when the new panel should become a full-width or full-height row/column around the whole main tiled layout. If splitRoot omits size, Tilery gives the new panel an equal share of the resulting root rows or columns.

TileryPanelMoveTarget

Used with movePanel() and panel.moveTo():

type TileryPanelMoveTarget =
  | ({
      splitPanel: TileryPanelId;
      direction: TileryDirection;
      size?: number;
      minSize?: TilerySize;
      maxSize?: TilerySize;
    } & TileryLayoutBehaviorConfig)
  | ({
      splitRoot: true;
      direction: TileryDirection;
      size?: number;
      minSize?: TilerySize;
      maxSize?: TilerySize;
    } & TileryLayoutBehaviorConfig);

Use movePanel() when the panel's runtime content should stay mounted while its position changes. Unlike moving each tab into a new split, this keeps the original panel id.

TileryOpenTabTarget

Used with openOrActivateTab() for the insertion path:

type TileryOpenTabTarget =
  | { panel: TileryPanelId; index?: number }
  | { beforeTab: TileryTabId }
  | { afterTab: TileryTabId };

TileryFloatPanelOptions

Used with floatPanel() and panel.float():

type TileryFloatPanelOptions = TileryFloatingPanelBoundsInit &
  TileryLayoutBehaviorConfig;

TileryPopoutPanelOptions

Used with popoutPanel() and panel.popout():

type TileryPopoutPanelOptions = {
  floatingBounds?: TileryFloatingPanelBoundsInit;
  windowBounds?: TileryPopoutWindowBoundsInit;
} & TileryLayoutBehaviorConfig;

TileryFloatTabOptions

Used with floatTab() and tab.float():

type TileryFloatTabOptions = {
  panelId?: TileryPanelId;
  bounds?: TileryFloatingPanelBoundsInit;
} & TileryLayoutBehaviorConfig;

TileryPopoutTabOptions

Used with popoutTab() and tab.popout():

type TileryPopoutTabOptions = {
  panelId?: TileryPanelId;
  floatingBounds?: TileryFloatingPanelBoundsInit;
  windowBounds?: TileryPopoutWindowBoundsInit;
} & TileryLayoutBehaviorConfig;

TileryDockPanelTarget

Used with dockPanel() and panel.dock():

type TileryDockPanelTarget = {
  splitPanel?: TileryPanelId;
  direction?: TileryDirection;
  size?: number;
  minSize?: TilerySize;
  maxSize?: TilerySize;
} & TileryLayoutBehaviorConfig;

TileryDirection

type TileryDirection = 'left' | 'right' | 'top' | 'bottom';