Documentation
¶
Index ¶
- func AddTerminalToWorkspace(desktop int, agentSlot bool) (int, error)
- func CheckCanAddTerminal(wsName string, currentCount int, cfg *config.Config) error
- func CheckCanCreateTerminals(wsName string, count int, cfg *config.Config) error
- func CheckCanCreateWorkspace(cfg *config.Config) error
- func ClearActiveWorkspace() error
- func ClearSlotsByDesktop(desktop int) error
- func ClearWorkspace(desktop int) error
- func CloseTerminals(lister TerminalLister) error
- func ConfigPath(name string) string
- func Delete(name string) error
- func GetAllSlots() (map[uint32]SlotInfo, error)
- func GetAllWorkspaces() (map[int]WorkspaceInfo, error)
- func HasSessionInRegistry(sessionName string) bool
- func HasUnsavedChanges(workspaceName string) bool
- func InsertTerminalAtSlot(desktop int, insertSlot int, agentSlot bool) error
- func List() ([]string, error)
- func Load(cfg *WorkspaceConfig, spawnTemplates map[string]string, lister TerminalLister, ...) error
- func MoveTerminalBetweenWorkspaces(srcDesktop, srcSlot, dstDesktop int) (newSlot int, err error)
- func ReconcileRegistry() error
- func RemoveSlotByWindowID(windowID uint32) error
- func RemoveTerminalFromWorkspace(desktop int, slot int) error
- func SetActiveWorkspace(name string, terminalCount int, agentMode bool, desktop int, agentSlots []int) error
- func SetSlotInfo(windowID uint32, slotIndex int, sessionName string, desktop int) error
- func SwapSessionNamesInConfig(workspaceName string, slotA, slotB int) error
- func SwapSlotsInRegistry(desktop, slotA, slotB int) error
- func UpdateSessionNameInConfig(workspaceName string, slot int, newSessionName string) error
- func UpdateSlotIndex(windowID uint32, newIndex int, newSessionName string) error
- func ValidateWorkspaceName(name string) error
- func Write(cfg *WorkspaceConfig) error
- type ActiveState
- type CrossDesktopLister
- type LayoutApplier
- type LoadOptions
- type SlotInfo
- type TerminalConfig
- type TerminalLister
- type TerminalWindow
- type WindowMinimizer
- type WorkspaceConfig
- type WorkspaceInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddTerminalToWorkspace ¶
AddTerminalToWorkspace increments terminal count and optionally adds agent slot. Returns the new slot index. If desktop is -1, auto-detect current desktop.
func CheckCanAddTerminal ¶
CheckCanAddTerminal verifies limits allow adding a terminal to an existing workspace.
func CheckCanCreateTerminals ¶
CheckCanCreateTerminals verifies bulk terminal creation is allowed.
func CheckCanCreateWorkspace ¶
CheckCanCreateWorkspace verifies limits allow creating a new workspace.
func ClearActiveWorkspace ¶
func ClearActiveWorkspace() error
ClearActiveWorkspace removes the workspace on the current desktop. This is a convenience wrapper for ClearWorkspace(-1).
func ClearSlotsByDesktop ¶
ClearSlotsByDesktop removes all slot entries for a specific desktop.
func ClearWorkspace ¶
ClearWorkspace removes the workspace on a specific desktop. If desktop is -1, clear workspace on current desktop.
func CloseTerminals ¶
func CloseTerminals(lister TerminalLister) error
CloseTerminals closes all terminal windows by sending SIGKILL to their processes. This ensures a clean close without "are you sure" prompts from terminals. For agent-mode workspaces using tmux, the tmux sessions survive the terminal close.
func ConfigPath ¶
ConfigPath returns the path to a workspace config file.
func GetAllSlots ¶
GetAllSlots returns all tracked slots.
func GetAllWorkspaces ¶
func GetAllWorkspaces() (map[int]WorkspaceInfo, error)
GetAllWorkspaces returns all registered workspaces keyed by desktop number.
func HasSessionInRegistry ¶
HasSessionInRegistry checks if a session name exists in the registry.
func HasUnsavedChanges ¶
HasUnsavedChanges checks if the current terminal state differs from the saved workspace. This compares the terminal count - if different, there are unsaved changes.
func InsertTerminalAtSlot ¶
InsertTerminalAtSlot inserts a terminal at a specific slot position, shifting existing slots up. If agentSlot is true, the new slot is added to AgentSlots. Returns error if slot is out of range. If desktop is -1, auto-detect current desktop.
func Load ¶
func Load(cfg *WorkspaceConfig, spawnTemplates map[string]string, lister TerminalLister, minimizer WindowMinimizer, applier LayoutApplier, opts LoadOptions) error
func MoveTerminalBetweenWorkspaces ¶
MoveTerminalBetweenWorkspaces moves a terminal slot from one workspace to another. It removes the slot from the source workspace, appends it to the destination, and returns the new slot index in the destination workspace.
func ReconcileRegistry ¶
func ReconcileRegistry() error
ReconcileRegistry removes stale workspace entries from the registry. For agent-mode workspaces, it checks if tmux sessions still exist. Workspaces with no live sessions are removed; workspaces with fewer live sessions than recorded get their count updated.
func RemoveSlotByWindowID ¶
RemoveSlotByWindowID removes a slot from the registry by its window ID.
func RemoveTerminalFromWorkspace ¶
RemoveTerminalFromWorkspace removes a slot from the workspace. Returns error if slot doesn't exist. If desktop is -1, auto-detect current desktop.
func SetActiveWorkspace ¶
func SetActiveWorkspace(name string, terminalCount int, agentMode bool, desktop int, agentSlots []int) error
SetActiveWorkspace registers a workspace on a specific desktop. If desktop is -1, auto-detect current desktop. If agentSlots is provided and agentMode is true, the slots are recorded.
func SetSlotInfo ¶
SetSlotInfo records a terminal slot with its window ID and session name.
func SwapSessionNamesInConfig ¶
SwapSessionNamesInConfig swaps the session_name fields for two slots in the config.
func SwapSlotsInRegistry ¶
SwapSlotsInRegistry swaps two slot indices in the workspace's AgentSlots. This is called after a move/swap operation to keep runtime state in sync. If desktop is -1, auto-detect current desktop.
func UpdateSessionNameInConfig ¶
UpdateSessionNameInConfig updates the session_name field for a specific slot in the saved workspace config file. This is called after renaming tmux sessions.
func UpdateSlotIndex ¶
UpdateSlotIndex updates the slot index and session name for a window.
func ValidateWorkspaceName ¶
ValidateWorkspaceName validates a workspace name (exported version).
func Write ¶
func Write(cfg *WorkspaceConfig) error
Types ¶
type ActiveState ¶
type ActiveState struct {
Name string `json:"name"`
TerminalCount int `json:"terminal_count"`
LoadedAt time.Time `json:"loaded_at"`
}
ActiveState is kept for backwards compatibility during migration. Deprecated: Use WorkspaceInfo instead.
func GetActiveState ¶
func GetActiveState() (*ActiveState, error)
GetActiveState returns the full active workspace state for backwards compatibility. Deprecated: Use GetActiveWorkspace() instead.
type CrossDesktopLister ¶
type CrossDesktopLister interface {
ListTerminalsAllDesktops() ([]TerminalWindow, error)
}
CrossDesktopLister is an optional interface that TerminalLister implementations can support to list terminals across all virtual desktops (not just the current one). Used by workspace new to detect newly spawned windows that may appear on any desktop.
type LayoutApplier ¶
type LoadOptions ¶
type SlotInfo ¶
type SlotInfo struct {
WindowID uint32 `json:"window_id"`
SessionName string `json:"session_name,omitempty"`
SlotIndex int `json:"slot_index"`
Desktop int `json:"desktop"`
}
SlotInfo tracks a single terminal slot with its X11 window ID and tmux session.
func GetSlotByWindowID ¶
GetSlotByWindowID returns slot info for a given window ID. Returns the slot and true if found, empty SlotInfo and false otherwise.
func GetSlotsByDesktop ¶
GetSlotsByDesktop returns all slots for a specific desktop, sorted by slot index.
type TerminalConfig ¶
type TerminalLister ¶
type TerminalLister interface {
ListTerminals() ([]TerminalWindow, error)
ActiveWindowID() (uint32, error)
}
type TerminalWindow ¶
TerminalWindow is a lightweight snapshot of a currently-open terminal window.
type WindowMinimizer ¶
type WorkspaceConfig ¶
type WorkspaceConfig struct {
Name string `json:"name"`
Layout string `json:"layout"`
AgentMode bool `json:"agent_mode,omitempty"`
Terminals []TerminalConfig `json:"terminals"`
}
WorkspaceConfig is a persisted snapshot of a set of terminal sessions.
func Read ¶
func Read(name string) (*WorkspaceConfig, error)
func Save ¶
func Save(name, layout, terminalSort string, includeCmd bool, lister TerminalLister) (*WorkspaceConfig, error)
type WorkspaceInfo ¶
type WorkspaceInfo struct {
Name string `json:"name"`
Desktop int `json:"desktop"`
TerminalCount int `json:"terminal_count"`
AgentMode bool `json:"agent_mode"`
AgentSlots []int `json:"agent_slots,omitempty"`
OpenedAt time.Time `json:"opened_at"`
}
WorkspaceInfo holds information about an active workspace on a specific desktop.
func GetActiveWorkspace ¶
func GetActiveWorkspace() (WorkspaceInfo, error)
GetActiveWorkspace returns the workspace on the current desktop (auto-detected). Returns empty WorkspaceInfo if no workspace on current desktop.
func GetWorkspaceByDesktop ¶
func GetWorkspaceByDesktop(desktop int) (WorkspaceInfo, bool)
GetWorkspaceByDesktop returns workspace on a specific desktop. Returns empty WorkspaceInfo and false if no workspace on that desktop.
func GetWorkspaceByName ¶
func GetWorkspaceByName(name string) (WorkspaceInfo, error)
GetWorkspaceByName finds a workspace by name across all desktops. Returns error if workspace not found.