state

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages persistent state with atomic saves.

func NewManager

func NewManager(workspace string) *Manager

NewManager creates a new state manager for the given workspace.

func (*Manager) GetLastChannel

func (sm *Manager) GetLastChannel() string

GetLastChannel returns the last channel from the state.

func (*Manager) GetLastChatID

func (sm *Manager) GetLastChatID() string

GetLastChatID returns the last chat ID from the state.

func (*Manager) GetTimestamp

func (sm *Manager) GetTimestamp() time.Time

GetTimestamp returns the timestamp of the last state update.

func (*Manager) SetLastChannel

func (sm *Manager) SetLastChannel(channel string) error

SetLastChannel atomically updates the last channel and saves the state. This method uses a temp file + rename pattern for atomic writes, ensuring that the state file is never corrupted even if the process crashes.

func (*Manager) SetLastChatID

func (sm *Manager) SetLastChatID(chatID string) error

SetLastChatID atomically updates the last chat ID and saves the state.

type State

type State struct {
	// LastChannel is the last channel used for communication
	LastChannel string `json:"last_channel,omitempty"`

	// LastChatID is the last chat ID used for communication
	LastChatID string `json:"last_chat_id,omitempty"`

	// Timestamp is the last time this state was updated
	Timestamp time.Time `json:"timestamp"`
}

State represents the persistent state for a workspace. It includes information about the last active channel/chat.

Jump to

Keyboard shortcuts

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