Raxol.Terminal.SessionManager (Raxol v2.0.1)

View Source

Terminal multiplexing system providing tmux-like session management for Raxol.

This module implements comprehensive terminal session multiplexing with:

  • Multiple terminal sessions with independent state
  • Window and pane management within sessions
  • Session persistence across disconnections
  • Remote session attachment and detachment
  • Session sharing and collaboration features
  • Automatic session recovery and state preservation
  • Advanced session management (naming, grouping, tagging)

Features

Session Management

  • Create, destroy, and switch between multiple sessions
  • Named sessions with metadata and tags
  • Session persistence to disk with state recovery
  • Automatic cleanup of orphaned sessions
  • Session templates and presets

Window and Pane Management

  • Multiple windows per session
  • Split windows into panes (horizontal/vertical)
  • Pane resizing and layout management
  • Window/pane navigation and switching
  • Synchronized input across panes

Advanced Features

  • Session sharing between multiple clients
  • Remote session access over network
  • Session recording and playback
  • Custom session hooks and automation
  • Resource monitoring and limits

Usage

# Create a new session
{:ok, session} = SessionManager.create_session("dev-session", 
  windows: 3, 
  layout: :main_vertical
)

# Attach to an existing session
{:ok, client} = SessionManager.attach_session("dev-session")

# Create window with panes
{:ok, window} = SessionManager.create_window(session, "editor",
  panes: [
    %{command: "nvim", directory: "/home/user/project"},
    %{command: "bash", directory: "/home/user/project"}
  ]
)

# Detach and session continues running
SessionManager.detach_client(client)

Summary

Functions

Attaches a client to a session.

Broadcasts input to all panes in a window (synchronized input).

Returns a specification to start this module under a supervisor.

Creates a new terminal session.

Creates a new window in a session.

Destroys a session and all its windows/panes.

Destroys a window and all its panes.

Detaches a client from their current session.

Enables session sharing for collaboration.

Gets detailed information about a session.

Gets session statistics and resource usage.

Lists all available sessions.

Restores session from persistent storage.

Saves session state to persistent storage.

Sends input to a specific pane.

Switches the active pane in a window.

Switches the active window in a session.

Types

session_config()

@type session_config() :: %{
  name: String.t(),
  windows: integer(),
  layout: Raxol.Terminal.SessionManager.Window.layout_type(),
  working_directory: String.t(),
  environment: map(),
  persistence: boolean(),
  resource_limits: map()
}

Functions

attach_session(session_id, client_config \\ %{})

Attaches a client to a session.

broadcast_input(session_id, window_id, input)

Broadcasts input to all panes in a window (synchronized input).

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

create_session(name, config \\ %{})

Creates a new terminal session.

Examples

{:ok, session} = SessionManager.create_session("dev", 
  windows: 2,
  layout: :main_vertical,
  working_directory: "/home/user/project"
)

create_window(session_id, window_name, config \\ %{})

Creates a new window in a session.

destroy_session(session_id)

Destroys a session and all its windows/panes.

destroy_window(session_id, window_id)

Destroys a window and all its panes.

detach_client(client_id)

Detaches a client from their current session.

enable_session_sharing(session_id, sharing_config \\ %{})

Enables session sharing for collaboration.

get_session(session_id)

Gets detailed information about a session.

get_session_stats(session_id)

Gets session statistics and resource usage.

handle_manager_cast(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_cast/2.

list_sessions()

Lists all available sessions.

resize_pane(session_id, window_id, pane_id, arg)

Resizes a pane.

restore_session(session_name)

Restores session from persistent storage.

save_session(session_id)

Saves session state to persistent storage.

send_input(session_id, window_id, pane_id, input)

Sends input to a specific pane.

split_pane(session_id, window_id, pane_id, direction, config \\ %{})

Splits a pane horizontally or vertically.

start_link(init_opts \\ [])

switch_pane(session_id, window_id, pane_id)

Switches the active pane in a window.

switch_window(session_id, window_id)

Switches the active window in a session.