Session persistence state for the Editor.
Groups the Editor's session-related fields into a focused sub-struct: the periodic save timer and the directory paths for session files and swap files. These are set once at startup and only the timer mutates during the Editor's lifetime.
All mutations go through functions on this module.
Summary
Functions
Records a timer reference created by the session workflow.
Moves the matching native quit request to its decision prompt.
Begins one correlated native application-quit attempt.
Cancels or fails the matching native quit request and makes retry possible.
Returns a pure instruction for canceling the save timer.
Clears a completed or canceled quit request.
Completes the matching lifecycle response only after transport admission.
Latches completion of the one-time editor startup workflow.
Returns true if session persistence is enabled (session_dir is set).
Creates a new session state from startup options.
Reserves one lifecycle response before attempting nonblocking transport admission.
Accepts Discard or a clean quit and records that orderly shutdown is proceeding.
Reopens the policy workflow before retrying an undelivered Proceeding response.
Remembers the command and project root used by the last test run.
Requests quit confirmation for the editor or all editor instances.
Returns a pure instruction for restarting the save timer.
Returns keyword options for Minga.Session functions.
Accepts Save for the matching native quit request.
Returns a pure instruction for starting the periodic save timer.
Returns true if swap file recovery is enabled (swap_dir is set).
Returns keyword options for swap recovery functions.
Returns the interval used by the session workflow's periodic save timer.
Types
@type application_quit() :: :idle | {:requesting, application_quit_request_id()} | {:awaiting_decision, application_quit_request_id()} | {:saving, application_quit_request_id()} | {:responding, application_quit_request_id(), application_quit_policy_intent(), application_quit_response_outcome()} | {:proceeding, application_quit_request_id()}
@type application_quit_policy_intent() :: :inventory | :save | :discard | :cancel
@type application_quit_request_id() :: 0..4_294_967_295
@type application_quit_response_outcome() ::
:needs_decision | :proceeding | :cancelled | :save_failed
@type pending_quit() :: :quit | :quit_all | nil
@type t() :: %MingaEditor.State.Session{ application_quit: application_quit(), last_test_command: last_test_command(), pending_quit: pending_quit(), session_dir: String.t() | nil, session_started?: boolean(), swap_dir: String.t() | nil, timer: reference() | nil }
Functions
Records a timer reference created by the session workflow.
@spec await_application_quit_decision(t(), application_quit_request_id()) :: {:ok, t()} | :stale
Moves the matching native quit request to its decision prompt.
@spec begin_application_quit(t(), application_quit_request_id()) :: {:started | :duplicate | :stale, t()}
Begins one correlated native application-quit attempt.
@spec cancel_application_quit(t(), application_quit_request_id()) :: {:ok, t()} | :stale
Cancels or fails the matching native quit request and makes retry possible.
Returns a pure instruction for canceling the save timer.
Clears a completed or canceled quit request.
@spec complete_application_quit_response( t(), application_quit_request_id(), application_quit_response_outcome() ) :: {:ok, t(), application_quit_policy_intent()} | :stale
Completes the matching lifecycle response only after transport admission.
Latches completion of the one-time editor startup workflow.
Returns true if session persistence is enabled (session_dir is set).
Creates a new session state from startup options.
@spec prepare_application_quit_response( t(), application_quit_request_id(), application_quit_policy_intent(), application_quit_response_outcome() ) :: {:ok, t()} | :stale
Reserves one lifecycle response before attempting nonblocking transport admission.
@spec proceed_application_quit(t(), application_quit_request_id()) :: {:ok, t()} | :stale
Accepts Discard or a clean quit and records that orderly shutdown is proceeding.
@spec reconcile_application_quit_proceeding(t(), application_quit_request_id()) :: {:inventory | :save | :discard, t()} | :stale
Reopens the policy workflow before retrying an undelivered Proceeding response.
@spec remember_test_command(t(), last_test_command()) :: t()
Remembers the command and project root used by the last test run.
Requests quit confirmation for the editor or all editor instances.
Returns a pure instruction for restarting the save timer.
Returns keyword options for Minga.Session functions.
@spec start_application_quit_save(t(), application_quit_request_id()) :: {:ok, t()} | :stale
Accepts Save for the matching native quit request.
Returns a pure instruction for starting the periodic save timer.
Returns true if swap file recovery is enabled (swap_dir is set).
Returns keyword options for swap recovery functions.
@spec timer_interval() :: pos_integer()
Returns the interval used by the session workflow's periodic save timer.