session

package
v0.4.15 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSessionID

func FormatSessionID(baseDir, sessionID string) string

FormatSessionID formats a session ID with optional name lookup. Use this when you only have a session ID string and need to display it. If the session has a name, returns "ses_xxx (name)", otherwise just "ses_xxx".

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses human-readable duration strings

func Save

func Save(baseDir string, sess *Session) error

Save writes the session to disk as JSON

Types

type Session

type Session struct {
	ID                string    `json:"id"`
	Name              string    `json:"name,omitempty"`
	ContextID         string    `json:"context_id"`
	PreviousSessionID string    `json:"previous_session_id,omitempty"`
	StartedAt         time.Time `json:"started_at"`
	IsNew             bool      `json:"-"` // True if session was just created (not persisted)
}

Session represents the current terminal session

func ForceNewSession

func ForceNewSession(baseDir string) (*Session, error)

ForceNewSession creates a new session regardless of context

func Get

func Get(baseDir string) (*Session, error)

Get returns the current session without creating one

func GetOrCreate

func GetOrCreate(baseDir string) (*Session, error)

GetOrCreate returns the current session, creating a new one if: 1. No session file exists 2. The context has changed (new terminal/AI session)

func GetWithContextCheck

func GetWithContextCheck(baseDir string) (*Session, error)

GetWithContextCheck returns the current session and checks if context changed. If context changed, creates a new session automatically.

func SetName

func SetName(baseDir string, name string) (*Session, error)

SetName sets the session name

func (*Session) Display

func (s *Session) Display() string

Display returns the session ID with name if set: "ses_abc123 (my-name)" or just "ses_abc123"

Jump to

Keyboard shortcuts

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