Overview
TheTabsController is the central manager for all tab-related operations in Flow Browser. It handles tab creation, lifecycle management, activation, grouping, and persistence across windows and spaces.
Import:
import { tabsController } from '@/controllers/tabs-controller'The controller is a singleton instance exported as tabsController.Key Concepts
Tab Identity
Each tab has multiple identifiers:id: Stable numeric ID that persists across sleep/wake cyclesuniqueId: Globally unique string identifier for persistenceprofileId: The profile this tab belongs tospaceId: The space this tab is currently in
Tab States
Visible
Tab is currently displayed in the window
Asleep
Tab’s WebContents destroyed to save memory (~20-50MB per tab)
Fullscreen
Tab is in fullscreen mode
Picture-in-Picture
Tab is floating as a PiP window
Tab Managers
Each tab has three associated managers:- TabLifecycleManager: Handles sleep/wake, fullscreen, and PiP
- TabLayoutManager: Manages visibility, bounds, and positioning
- TabBoundsController: Calculates and applies tab bounds
Core Methods
Tab Creation
createTab()
Creates a new tab with automatic profile and space resolution.Window to create the tab in. Defaults to focused window.
Profile ID for the tab. Defaults to last used profile.
Space ID for the tab. Defaults to last used space in profile.
Electron WebContentsView options for customization.
Additional options:
url: Initial URL to loadasleep: Create tab in sleep modeposition: Tab position in stacktitle,faviconURL: Restored statenavHistory,navHistoryIndex: Navigation history
The newly created Tab instance
Tab Queries
getTabById()
Retrieve a tab by its numeric ID.getTabByWebContents()
Find the tab associated with a WebContents instance.getTabsInSpace()
Get all tabs in a specific space across all windows.getTabsInWindow()
Get all tabs in a specific window across all spaces.getTabsInWindowSpace()
Get tabs in a specific window and space combination.Active Tab Management
setActiveTab()
Set the active tab or tab group for a space.- Updates the active tab map
- Maintains activation history
- Shows/hides tabs as needed
- Updates focus
- Emits
active-tab-changedevent
getActiveTab()
Get the currently active tab or group for a window/space.isTabActive()
Check if a tab is currently active in its space.Tab Groups
createTabGroup()
Create a new tab group (Glance or Split view).- glance: Stack tabs with quick switching
- split: Display tabs side-by-side
Array of at least 2 tab IDs to group together
Custom group ID (for session restore)
getTabGroupById()
Retrieve a tab group by its string ID.getTabGroupByTabId()
Get the group containing a specific tab.destroyTabGroup()
Destroy a tab group and ungroup its tabs.Manager Access
getTabManagers()
Get all managers for a tab.lifecycle: TabLifecycleManagerlayout: TabLayoutManagerbounds: TabBoundsController
getLifecycleManager()
Get just the lifecycle manager for a tab.getLayoutManager()
Get just the layout manager for a tab.Events
The TabsController extendsTypedEventEmitter with these events:
Emitted when a new tab is created
Emitted when a tab is removed from the controller
Emitted when the active tab changes in a window/space
Emitted when a window switches to a different space
Advanced Usage
Picture-in-Picture
Space Management
Position Normalization
Prevents tab position drift by resetting positions to sequential values.Page Bounds Updates
Data Structures
TabManagers
TabCreationOptions
Related
Tab Class
Individual tab implementation
Windows Controller
Window management
Spaces Controller
Space management
Profiles Controller
Profile management