state

package
v0.74.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package state manages persistent user state such as diff mode preferences, pane widths, and plugin-specific state per working directory across sessions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearLastWorktreePath

func ClearLastWorktreePath(mainRepoPath string) error

ClearLastWorktreePath removes the saved worktree path for a main repo.

func GetActivePlugin

func GetActivePlugin(workdir string) string

GetActivePlugin returns the saved active plugin ID for a given working directory.

func GetConversationsSideWidth

func GetConversationsSideWidth() int

GetConversationsSideWidth returns the saved conversations sidebar width. Returns 0 if no preference is saved (use default).

func GetFileBrowserTreeWidth

func GetFileBrowserTreeWidth() int

GetFileBrowserTreeWidth returns the saved file browser tree pane width. Returns 0 if no preference is saved (use default).

func GetGitDiffMode

func GetGitDiffMode() string

GetGitDiffMode returns the saved diff mode.

func GetGitGraphEnabled

func GetGitGraphEnabled() bool

GetGitGraphEnabled returns whether the commit graph is enabled.

func GetGitStatusSidebarWidth

func GetGitStatusSidebarWidth() int

GetGitStatusSidebarWidth returns the saved git status sidebar width. Returns 0 if no preference is saved (use default).

func GetLastWorktreePath

func GetLastWorktreePath(mainRepoPath string) string

GetLastWorktreePath returns the last active worktree path for a main repo.

func GetLineWrapEnabled

func GetLineWrapEnabled() bool

GetLineWrapEnabled returns whether line wrapping is enabled.

func GetWorkspaceDiffMode

func GetWorkspaceDiffMode() string

GetWorkspaceDiffMode returns the saved workspace diff mode.

func GetWorkspaceSidebarWidth

func GetWorkspaceSidebarWidth() int

GetWorkspaceSidebarWidth returns the saved workspace sidebar width. Returns 0 if no preference is saved (use default).

func Init

func Init() error

Init loads state from the default location.

func InitWithDir

func InitWithDir(dir string) error

InitWithDir loads state from a specified directory. This is primarily for testing to avoid reading real user state.

func Load

func Load() error

Load reads state from disk.

func Save

func Save() error

Save writes state to disk.

func SetActivePlugin

func SetActivePlugin(workdir, pluginID string) error

SetActivePlugin saves the active plugin ID for a given working directory.

func SetConversationsSideWidth

func SetConversationsSideWidth(width int) error

SetConversationsSideWidth saves the conversations sidebar width.

func SetFileBrowserState

func SetFileBrowserState(workdir string, fbState FileBrowserState) error

SetFileBrowserState saves the file browser state for a given working directory.

func SetFileBrowserTreeWidth

func SetFileBrowserTreeWidth(width int) error

SetFileBrowserTreeWidth saves the file browser tree pane width.

func SetGitDiffMode

func SetGitDiffMode(mode string) error

SetGitDiffMode saves the diff mode preference.

func SetGitGraphEnabled

func SetGitGraphEnabled(enabled bool) error

SetGitGraphEnabled saves the commit graph preference.

func SetGitStatusSidebarWidth

func SetGitStatusSidebarWidth(width int) error

SetGitStatusSidebarWidth saves the git status sidebar width.

func SetLastWorktreePath

func SetLastWorktreePath(mainRepoPath, worktreePath string) error

SetLastWorktreePath saves the last active worktree path for a main repo.

func SetLineWrapEnabled

func SetLineWrapEnabled(enabled bool) error

SetLineWrapEnabled saves the line wrap preference.

func SetNotesListWidth

func SetNotesListWidth(width int) error

SetNotesListWidth saves just the notes list width for a given working directory.

func SetNotesState

func SetNotesState(workdir string, notesState NotesState) error

SetNotesState saves the notes state for a given working directory.

func SetWorkspaceDiffMode

func SetWorkspaceDiffMode(mode string) error

SetWorkspaceDiffMode saves the workspace diff mode preference.

func SetWorkspaceSidebarWidth

func SetWorkspaceSidebarWidth(width int) error

SetWorkspaceSidebarWidth saves the workspace sidebar width.

func SetWorkspaceState

func SetWorkspaceState(workdir string, wtState WorkspaceState) error

SetWorkspaceState saves the workspace state for a given working directory.

Types

type FileBrowserState

type FileBrowserState struct {
	SelectedFile  string                `json:"selectedFile,omitempty"`  // Currently selected file path (relative)
	TreeScroll    int                   `json:"treeScroll,omitempty"`    // Tree pane scroll offset
	PreviewScroll int                   `json:"previewScroll,omitempty"` // Preview pane scroll offset
	ExpandedDirs  []string              `json:"expandedDirs,omitempty"`  // List of expanded directory paths
	ActivePane    string                `json:"activePane,omitempty"`    // "tree" or "preview"
	PreviewFile   string                `json:"previewFile,omitempty"`   // File being previewed (relative)
	TreeCursor    int                   `json:"treeCursor,omitempty"`    // Tree cursor position
	ShowIgnored   *bool                 `json:"showIgnored,omitempty"`   // Whether to show git-ignored files (nil = default true)
	Tabs          []FileBrowserTabState `json:"tabs,omitempty"`
	ActiveTab     int                   `json:"activeTab,omitempty"`
}

FileBrowserState holds persistent file browser state.

func GetFileBrowserState

func GetFileBrowserState(workdir string) FileBrowserState

GetFileBrowserState returns the saved file browser state for a given working directory.

type FileBrowserTabState

type FileBrowserTabState struct {
	Path   string `json:"path,omitempty"`   // File path (relative)
	Scroll int    `json:"scroll,omitempty"` // Preview scroll offset
}

FileBrowserTabState holds persistent tab state for the file browser.

type NotesState

type NotesState struct {
	ListWidth    int    `json:"listWidth,omitempty"`    // Width of list pane
	LastNoteID   string `json:"lastNoteID,omitempty"`   // Last selected note ID
	ShowArchived bool   `json:"showArchived,omitempty"` // Whether to show archived notes
}

NotesState holds persistent notes plugin state.

func GetNotesState

func GetNotesState(workdir string) NotesState

GetNotesState returns the saved notes state for a given working directory.

type State

type State struct {
	GitDiffMode       string `json:"gitDiffMode"`                 // "unified" or "side-by-side"
	WorkspaceDiffMode string `json:"workspaceDiffMode,omitempty"` // "unified" or "side-by-side"
	GitGraphEnabled   bool   `json:"gitGraphEnabled,omitempty"`   // Show commit graph in sidebar
	LineWrapEnabled   bool   `json:"lineWrapEnabled,omitempty"`   // Wrap long lines instead of truncating

	// Pane width preferences (percentage of total width, 0 = use default)
	FileBrowserTreeWidth   int `json:"fileBrowserTreeWidth,omitempty"`
	GitStatusSidebarWidth  int `json:"gitStatusSidebarWidth,omitempty"`
	ConversationsSideWidth int `json:"conversationsSideWidth,omitempty"`
	WorkspaceSidebarWidth  int `json:"workspaceSidebarWidth,omitempty"`

	// Plugin-specific state (keyed by working directory path)
	FileBrowser  map[string]FileBrowserState `json:"fileBrowser,omitempty"`
	Workspace    map[string]WorkspaceState   `json:"workspace,omitempty"`
	Notes        map[string]NotesState       `json:"notes,omitempty"`
	ActivePlugin map[string]string           `json:"activePlugin,omitempty"`

	// Worktree state: maps main repo path -> last active worktree path
	LastWorktreePath map[string]string `json:"lastWorktreePath,omitempty"`
}

State holds persistent user preferences.

type WorkspaceState

type WorkspaceState struct {
	WorkspaceName     string            `json:"workspaceName,omitempty"`     // Name of selected workspace
	ShellTmuxName     string            `json:"shellTmuxName,omitempty"`     // TmuxName of selected shell (empty = workspace selected)
	ShellDisplayNames map[string]string `json:"shellDisplayNames,omitempty"` // TmuxName -> display name
}

WorkspaceState holds persistent workspace plugin state.

func GetWorkspaceState

func GetWorkspaceState(workdir string) WorkspaceState

GetWorkspaceState returns the saved workspace state for a given working directory.

Jump to

Keyboard shortcuts

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