Skip to main content
Ora Browser provides robust session management features to help you restore closed tabs, recover from crashes, and maintain your browsing context.

Tab Restoration

Recover accidentally closed tabs with built-in undo functionality.

Restore Last Closed Tab

1

Close a Tab

Close any tab using ⌘W or the close button
2

Restore Immediately

Press ⌘Z to restore the last closed tab
3

Multiple Undos

Press ⌘Z multiple times to restore multiple closed tabs in reverse order
// From OraCommands.swift:46-49
Button("Restore Last Tab") {
    NotificationCenter.default.post(name: .restoreLastTab, object: NSApp.keyWindow)
}
.keyboardShortcut(KeyboardShortcuts.Tabs.restore.keyboardShortcut)
The restore command uses ⌘Z, leveraging the system’s undo mechanism for intuitive recovery.

Restore Implementation

Tab restoration is powered by SwiftData’s undo manager:
// From TabManager.swift:352-356
func restoreLastTab() {
    guard let undoManager = modelContext.undoManager else { return }
    undoManager.undo() // Reverts the last deletion
    try? modelContext.save() // Persist the undo operation
}

Alternative Restore Method

You can also use the dedicated keyboard shortcut:
// From KeyboardShortcuts.swift:20-25
static let restore = KeyboardShortcutDefinition(
    id: "tabs.restore",
    name: "Restore Tab",
    category: "Tabs",
    defaultChord: KeyChord(keyEquivalent: .init("z"), modifiers: [.command])
)
Or reopen with:
// From KeyboardShortcuts.swift:26-31
static let reopenClosed = KeyboardShortcutDefinition(
    id: "tabs.reopenClosed",
    name: "Reopen Closed Tab",
    category: "Tabs",
    defaultChord: KeyChord(keyEquivalent: .init("t"), modifiers: [.command, .shift])
)

Keyboard Shortcuts

Restore Last Tab

⌘Z - Undo tab closure

Reopen Closed Tab

⌘⇧T - Alternative restore method

Close Tab

⌘W - Close current tab

Close Window

Closes the window if the Settings window is active

Window Management

Manage multiple windows and their sessions.

Close Behavior

// From OraCommands.swift:33-42
Button("Close Window") {
    if let keyWindow = NSApp.keyWindow, keyWindow.title == "Settings" {
        keyWindow.performClose(nil)
    }
}
.keyboardShortcut("w", modifiers: .command)
.disabled({
    guard let keyWindow = NSApp.keyWindow else { return true }
    return keyWindow.title != "Settings"
}())
The close window command intelligently handles different window types, with special handling for the Settings window.

Creating New Windows

// From OraCommands.swift:13-14
Button("New Window") { openWindow(id: "normal") }
    .keyboardShortcut(KeyboardShortcuts.Window.new.keyboardShortcut)
Press ⌘N to open a new window with your default settings.

Tab Lifecycle

Tab Closing

// From OraCommands.swift:29-31
Button("Close Tab") {
    NotificationCenter.default.post(name: .closeActiveTab, object: NSApp.keyWindow)
}
.keyboardShortcut(KeyboardShortcuts.Tabs.close.keyboardShortcut)
When you close a tab:
  1. Tab is marked for deletion in the model context
  2. Undo manager records the deletion operation
  3. UI updates to remove the tab
  4. State is preserved for potential restoration

Tab Activation

When switching tabs, the session state is preserved:
// From TabManager.swift:365-390
func activateTab(_ tab: Tab) {
    // Toggle Picture-in-Picture on tab switch
    togglePiP(tab, activeTab)

    // Activate the tab
    activeTab?.maybeIsActive = false
    activeTab = tab
    activeTab?.maybeIsActive = true
    tab.lastAccessedAt = Date()
    activeContainer = tab.container
    tab.container.lastAccessedAt = Date()

    // Lazy load WebView if not ready
    if !tab.isWebViewReady {
        tab.restoreTransientState(
            historyManager: tab.historyManager ?? HistoryManager(
                modelContainer: modelContainer,
                modelContext: modelContext
            ),
            downloadManager: tab.downloadManager ?? DownloadManager(
                modelContainer: modelContainer,
                modelContext: modelContext
            ),
            tabManager: self,
            isPrivate: tab.isPrivate
        )
    }
}

Session Persistence

Ora Browser automatically saves your session state:

What’s Saved

  • Open tabs and their URLs
  • Tab order and organization
  • Active tab selection
  • Window positions and sizes
  • Container assignments for tabs
  • Pinned tab states

What’s Not Saved (Private Mode)

  • Browsing history in private windows
  • Cookies and cache from private sessions
  • Form data entered in private tabs
  • Download history from private browsing
Private browsing windows are not restored after the app is closed. This is intentional to maintain privacy.

Lazy Tab Loading

Tabs are loaded on-demand to improve startup performance:
// From TabManager.swift:377-390
// Lazy load WebView if not ready
if !tab.isWebViewReady {
    tab.restoreTransientState(
        historyManager: tab.historyManager ?? HistoryManager(
            modelContainer: modelContainer,
            modelContext: modelContext
        ),
        downloadManager: tab.downloadManager ?? DownloadManager(
            modelContainer: modelContainer,
            modelContext: modelContext
        ),
        tabManager: self,
        isPrivate: tab.isPrivate
    )
}

Benefits

Faster Startup

Only the active tab loads immediately

Lower Memory

Inactive tabs don’t consume memory

Quick Switch

Tabs load instantly when activated

Better Performance

System resources used efficiently

Picture-in-Picture Session

Picture-in-Picture automatically manages media sessions when switching tabs:
// From TabManager.swift:358-363
func togglePiP(_ currentTab: Tab?, _ oldTab: Tab?) {
    if currentTab?.id != oldTab?.id, SettingsStore.shared.autoPiPEnabled {
        currentTab?.webView.evaluateJavaScript("window.__oraTriggerPiP(true)")
        oldTab?.webView.evaluateJavaScript("window.__oraTriggerPiP()")
    }
}
When auto-PiP is enabled, switching away from a tab with playing video automatically opens Picture-in-Picture mode.

Container Sessions

Tabs are organized into containers with independent sessions:

Container Benefits

1

Isolated Contexts

Each container maintains separate cookies, cache, and session data
2

Different Search Engines

Set container-specific default search engines
3

Organized Tabs

Group related tabs by context (Personal, Work, etc.)
4

Session Restoration

Restore entire container sessions

Container Activation

// From TabManager.swift:374-375
activeContainer = tab.container
tab.container.lastAccessedAt = Date()
When you activate a tab, its container becomes active, providing context-aware behavior.

Best Practices

Preventing Data Loss

Pin important tabs to prevent accidental closure:
  • Press ⌘D to pin/unpin a tab
  • Pinned tabs are preserved across sessions
  • They appear first in the tab bar
Ora Browser automatically saves session state:
  • After each tab operation
  • When switching windows
  • Periodically in the background
  • When quitting the application
Organize tabs into containers for better session management:
  • Create containers for different projects
  • Use container-specific settings
  • Restore entire container contexts

Recovery Strategies

For just-closed tabs:
  1. Press ⌘Z immediately
  2. Or use ⌘⇧T to reopen
  3. Multiple undos are supported

Command Menu Integration

Session management is integrated into the command menu:
// From OraCommands.swift:19-21
Button("New Tab") {
    NotificationCenter.default.post(name: .showLauncher, object: NSApp.keyWindow)
}.keyboardShortcut(KeyboardShortcuts.Tabs.new.keyboardShortcut)

Available Commands

CommandShortcutDescription
New Tab⌘TOpens launcher for new tab
Close Tab⌘WCloses current tab
Restore Tab⌘ZUndoes last tab closure
Reopen Closed⌘⇧TAlternative restore
New Window⌘NOpens new window
New Private⌘⇧NOpens private window

Advanced Session Features

Undo Manager

The session system uses SwiftData’s built-in undo manager:
guard let undoManager = modelContext.undoManager else { return }
undoManager.undo() // Reverts the last deletion
try? modelContext.save() // Persist the undo operation
This provides:
  • Multiple undo levels for tab closures
  • Automatic state tracking without manual implementation
  • Efficient memory usage with system-managed undo stack
  • Integration with macOS standard undo behavior

Tab State Persistence

Each tab maintains its state even when inactive:
  • URL and title are always available
  • Scroll position preserved
  • Form data retained (except in private mode)
  • JavaScript state maintained
  • Media playback position saved

Performance Optimizations

Lazy Loading

Tabs load only when needed, not at startup

Memory Management

Inactive tabs release memory automatically

Smart Restoration

Frequently used tabs load first

Background Sync

Session state syncs without blocking UI

Troubleshooting

Tab Won’t Restore

  • Ensure you’re pressing ⌘Z shortly after closing
  • Check if the undo stack has been cleared
  • Verify the tab wasn’t from a private window
  • Try using ⌘⇧T as an alternative

Session Not Restored After Restart

  • Check if you force-quit during a save operation
  • Verify that the app has write permissions
  • Look for tabs in History (⌘Y)
  • Ensure you’re not in private browsing mode

Multiple Tabs Restore Incorrectly

  • Tabs restore in reverse order of closure
  • Press ⌘Z multiple times for multiple tabs
  • Check container assignments for organization
  • Verify that tab data wasn’t corrupted
While the undo stack is robust, it’s cleared when you quit the application. For long-term session recovery, use the History feature (⌘Y).

Build docs developers (and LLMs) love