Documentation
¶
Overview ¶
Package session manages persistent session state for grut. Each working directory gets its own session file stored in the XDG data directory. Sessions capture tab layout and focus state so the TUI can restore its previous configuration on the next launch.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsFirstRun ¶
func IsFirstRun() bool
IsFirstRun returns true when the first-run marker file does not exist, meaning the user has never launched grut before (or has not seen the help overlay).
func IsFirstRunIn ¶
IsFirstRunIn checks for the marker file in the given directory. Used by tests that need to control the marker location.
func MarkFirstRunDone ¶
func MarkFirstRunDone() error
MarkFirstRunDone creates the first-run marker file, indicating that the help overlay has been shown. The operation is idempotent — calling it multiple times has no effect beyond the initial file creation.
func MarkFirstRunDoneIn ¶
MarkFirstRunDoneIn creates the marker file in the given directory. Used by tests that need to control the marker location.
func ResetFirstRun ¶ added in v0.0.2
func ResetFirstRun() error
ResetFirstRun removes the first-run marker file so the welcome screen auto-shows on next launch. The operation is idempotent — calling it when the marker is already absent is a no-op.
func ResetFirstRunIn ¶ added in v0.0.2
ResetFirstRunIn removes the marker file in the given directory. Used by tests that need to control the marker location.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides session persistence backed by TOML files in the XDG data directory. Each working directory maps to a unique file via a truncated SHA-256 hash.
func NewManager ¶
func NewManager() *Manager
NewManager creates a session manager that stores files under the standard XDG data path (~/.local/share/grut/sessions).
func (*Manager) Delete ¶
Delete removes the session file for the given working directory. It returns nil when the file does not exist.
func (*Manager) Load ¶
func (m *Manager) Load(workDir string) (*SessionState, error)
Load reads the session for the given working directory. It returns (nil, nil) when no session file exists for that directory, allowing callers to fall back to the default layout without error handling.
func (*Manager) Save ¶
func (m *Manager) Save(state SessionState) error
Save writes the given session state to disk, creating intermediate directories as needed.
func (*Manager) SessionPath ¶
SessionPath returns the file path for the session associated with workDir. The filename is the first 16 hex characters of the SHA-256 hash of workDir.
func (*Manager) SetDataDir ¶
SetDataDir overrides the data directory (used in tests).