SessionBase
Object Hierarchy:
Description:
public abstract class SessionBase : Object, Serializable
Base class for Session implementations.
Contains shared functionality that doesn't depend on chat existing. Subclasses must implement abstract methods for chat-dependent
operations. Provides common properties like id, title, and client management.
Content:
Properties:
- public Base? agent { get; set; }
- public string agent_name { get; set; }
- public bool can_replay { get; set; }
True when the session transcript includes replay markers (e.g. role
agent-stage); gates Runner.replay.
- public ArrayList<string> child_chats { get; set; }
- public string[] css_classes { owned get; set; }
- public string display_date { owned get; }
- public abstract string display_info { owned get; }
- public string display_title { owned get; }
- public int64 duration_seconds { get; set; }
- public string fid { get; protected set; }
- public bool has_unread { get; }
- public int64 id { get; set; }
- public bool is_active { get; protected set; }
- public bool is_running { get; set; }
- public Manager manager { get; set construct; }
- public ArrayList<Message> messages { get; set; }
- public string model { get; set; }
Model property - stored in DB for display, get returns
model_usage.model
- public ModelUsage model_usage { get; set; }
- public string project_path { get; set; }
Active project path for this session. Set when creating a new session
or when loading (from JSON top-level or legacy "project" messages). Stored in DB and in session JSON; lets the UI restore the active
project.
- public string title { get; set; }
- public int total_messages { get; set; }
- public int64 total_tokens { get; set; }
- public int unread_count { get; set; }
- public int64 updated_at_timestamp { get; set; }
Creation methods:
Methods:
- public virtual void activate ()
Activates this session, connecting client signals to relay to UI.
Called when the session becomes the active session in the UI.
- public abstract void activate_agent (string agent_name) throws Error
Activates an agent for this session.
- public void activate_model (ModelUsage model_usage)
Activates a model for this session.
- public void add_message (Message message)
Adds a message to the session and relays it to the UI via Manager
signal.
- public abstract void cancel_current_request ()
Cancels the current request if one is active. Must be implemented by
subclasses.
- public void deactivate ()
Deactivates this session, disconnecting client signals. Called when
the session is no longer the active session in the UI.
- public abstract bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Node property_node)
Handle JSON property mapping and custom deserialization. Must be
implemented by subclasses.
- public void ensure_agent_handler ()
Ensures the agent handler exists for
agent_name. Unknown agent_name in the registry downgrades
session to just-ask.
- public virtual void handle_stream_chunk (string new_text, bool is_thinking, Chat response)
Called by AgentHandler when a streaming chunk is received. Session
relays to Manager signals (Manager doesn't process, just relays to UI).
- public void handle_stream_started ()
Called by AgentHandler when streaming starts. Session relays to
Manager signals.
- public void handle_tool_message (Message message)
Called by AgentHandler when a tool sends a status message. Session
relays to Manager signals.
- public abstract async SessionBase? load () throws Error
Loads the session data if needed (e.g., for SessionPlaceholder). No-op
for sessions that are already loaded.
- protected abstract void on_message_created (Message m)
Handler for message_created signal from this session's client. Handles
message persistence and relays to Manager. Must be implemented by subclasses.
- public abstract async void read () throws Error
Read session from JSON file. Must be implemented by subclasses.
- public void reconstruct_model_usage_from_model ()
Reconstructs model_usage from the model_usage_model field (used when
loading from database).
- public abstract void saveToDB ()
Save session to SQLite database. Must be implemented by subclasses.
- public abstract async void save_async (bool update_timestamp = true)
Save session to both DB and file asynchronously. Must be implemented
by subclasses.
- public abstract async void send (Message message, Cancellable? cancellable = null) throws Error
Sends a Message object to this session.
- public abstract Node serialize_property (string property_name, Value value, ParamSpec pspec)
Handle JSON property mapping for serialization. Must be implemented by
subclasses.
- public abstract string task_dir ()
Directory for task output files (e.g. task-list.md, per-task .md).
Same path as session JSON but as a directory: history_dir / to_path().
- public string to_path ()
Convert file ID to path format. Converts ID format "Y-m-d-H-i-s" to
path format "YYYY/mm/dd/h-i-s"
- public string to_string ()
Returns a string representation of the session for debugging.
- public abstract async void write () throws Error
Write session to JSON file. Must be implemented by subclasses.
Inherited Members:
All known members inherited from class GLib.Object
- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data
- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer
- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref
All known members inherited from interface Json.Serializable
- default_deserialize_property
- default_serialize_property
- deserialize_property
- find_property
- get_property
- list_properties
- serialize_property
- set_property