session

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package session provides session persistence for LazyCurl. It manages saving and restoring application state to .lazycurl/session.yml.

Index

Constants

View Source
const (
	// SessionVersion is the current session file format version
	SessionVersion = 1
	// SessionFileName is the name of the session file
	SessionFileName = "session.yml"
	// SessionDir is the directory containing session files
	SessionDir = ".lazycurl"
)

Variables

This section is empty.

Functions

func GetSessionPath

func GetSessionPath(workspacePath string) string

GetSessionPath returns the full path to the session file.

Types

type CollectionsPanelState

type CollectionsPanelState struct {
	ExpandedFolders []string `yaml:"expanded_folders,omitempty"`
	ScrollPosition  int      `yaml:"scroll_position"`
	SelectedIndex   int      `yaml:"selected_index"`
}

CollectionsPanelState represents collections panel state.

type CursorPosition

type CursorPosition struct {
	Line   int `yaml:"line"`
	Column int `yaml:"column"`
}

CursorPosition represents cursor in multi-line editor.

type PanelsState

type PanelsState struct {
	Collections CollectionsPanelState `yaml:"collections"`
	Request     RequestPanelState     `yaml:"request"`
	Response    ResponsePanelState    `yaml:"response"`
}

PanelsState contains state for all panels.

type RequestPanelState

type RequestPanelState struct {
	ActiveTab  string          `yaml:"active_tab"`
	URLCursor  int             `yaml:"url_cursor,omitempty"`
	BodyCursor *CursorPosition `yaml:"body_cursor,omitempty"`
}

RequestPanelState represents request panel state.

type ResponsePanelState

type ResponsePanelState struct {
	ActiveTab      string `yaml:"active_tab"`
	ScrollPosition int    `yaml:"scroll_position"`
}

ResponsePanelState represents response panel state.

type Session

type Session struct {
	Version           int         `yaml:"version"`
	LastUpdated       time.Time   `yaml:"last_updated"`
	ActivePanel       string      `yaml:"active_panel"`
	ActiveCollection  string      `yaml:"active_collection,omitempty"`
	ActiveRequest     string      `yaml:"active_request,omitempty"`
	ActiveEnvironment string      `yaml:"active_environment,omitempty"`
	Panels            PanelsState `yaml:"panels"`
}

Session represents the complete application state at a point in time.

func DefaultSession

func DefaultSession() *Session

DefaultSession returns a new Session with sensible default values.

func LoadSession

func LoadSession(workspacePath string) (*Session, error)

LoadSession loads session from .lazycurl/session.yml in the given workspace. Returns DefaultSession if file is missing, invalid, or has unsupported version.

func (*Session) Save

func (s *Session) Save(workspacePath string) error

Save saves session to .lazycurl/session.yml in the given workspace. Uses atomic write (temp file + rename) for safety.

func (*Session) Validate

func (s *Session) Validate(workspacePath string) *Session

Validate validates session references and clears invalid ones. Returns the same session with invalid references cleared.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL