Documentation
¶
Index ¶
- func CleanupStaleSessions(database *db.DB, maxAge time.Duration) (int, error)
- func FormatSessionID(database *db.DB, sessionID string) string
- func GetCurrentBranch() string
- func ParseDuration(s string) (time.Duration, error)
- type AgentFingerprint
- type AgentType
- type Session
- func ForceNewSession(database *db.DB) (*Session, error)
- func Get(database *db.DB) (*Session, error)
- func GetOrCreate(database *db.DB) (*Session, error)
- func GetWithContextCheck(database *db.DB) (*Session, error)
- func ListSessions(database *db.DB) ([]Session, error)
- func SetName(database *db.DB, name string) (*Session, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupStaleSessions ¶ added in v0.4.26
CleanupStaleSessions removes sessions older than maxAge
func FormatSessionID ¶
FormatSessionID formats a session ID with optional name lookup.
func GetCurrentBranch ¶ added in v0.4.26
func GetCurrentBranch() string
GetCurrentBranch returns the current git branch (exported for display)
Types ¶
type AgentFingerprint ¶ added in v0.4.26
type AgentFingerprint struct {
Type AgentType
PID int
ExplicitID string // set when TD_SESSION_ID is used
}
AgentFingerprint identifies a specific agent session
func GetAgentFingerprint ¶ added in v0.4.26
func GetAgentFingerprint() AgentFingerprint
GetAgentFingerprint detects the agent running this process by walking the process tree. The expensive process tree walk is cached; env var checks are always re-evaluated.
func (AgentFingerprint) String ¶ added in v0.4.26
func (af AgentFingerprint) String() string
String returns a filesystem-safe string representation
type AgentType ¶ added in v0.4.26
type AgentType string
AgentType identifies the type of AI agent
const ( AgentClaudeCode AgentType = "claude-code" AgentCursor AgentType = "cursor" AgentCodex AgentType = "codex" AgentWindsurf AgentType = "windsurf" AgentZed AgentType = "zed" AgentAider AgentType = "aider" AgentCopilot AgentType = "copilot" AgentGemini AgentType = "gemini" AgentUnknown AgentType = "unknown" AgentTerminal AgentType = "terminal" )
type Session ¶
type Session struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Branch string `json:"branch,omitempty"` // git branch for session scoping
AgentType string `json:"agent_type,omitempty"` // agent type (claude-code, cursor, terminal, etc.)
AgentPID int `json:"agent_pid,omitempty"` // stable parent agent process ID
ContextID string `json:"context_id,omitempty"` // audit only, not used for matching
PreviousSessionID string `json:"previous_session_id,omitempty"`
StartedAt time.Time `json:"started_at"`
LastActivity time.Time `json:"last_activity,omitempty"` // heartbeat for session liveness
IsNew bool `json:"-"` // True if session was just created (not persisted)
}
Session represents the current terminal session
func ForceNewSession ¶
ForceNewSession creates a new session on the current branch/agent, regardless of existing session
func GetOrCreate ¶
GetOrCreate returns the current session for the current git branch and agent. Sessions are scoped by branch + agent fingerprint - same agent on same branch = same session. Creates a new session if none exists for this branch/agent combination.
func GetWithContextCheck ¶
GetWithContextCheck returns the current session and checks if context changed.
func ListSessions ¶ added in v0.4.26
ListSessions returns all sessions
func (*Session) Display ¶
Display returns the session ID with name if set: "ses_abc123 (my-name)" or just "ses_abc123"
func (*Session) DisplayWithAgent ¶ added in v0.4.26
DisplayWithAgent returns session info including agent: "ses_abc123 [claude-code]" or with name