store

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 13 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

Overview

Package store persists the window layout between runs.

Only the shape of the workspace is saved — tabs, splits, working directories, pane ids, and which agent and model each pane runs. Conversation history lives in the agent's own transcript store and is reattached by id, which is why pane ids are generated as UUIDs.

Index

Constants

View Source
const Version = 2

Version is the schema version of the persisted state.

Version 2 is where a pane began saying which agent it runs and which model it was asked for. Version 1 knew only one agent, so its panes are "claude" or "shell"; they are brought forward on the way in rather than being thrown away, because a layout is the user's open tabs and losing them on an upgrade would be unforgivable.

Variables

This section is empty.

Functions

func BrowserProfileDir

func BrowserProfileDir() (string, error)

BrowserProfileDir returns the directory holding the browser profile used for the application window. Keeping it separate from the user's own profile means the window opens clean and does not disturb their browsing session.

func ClearInstance

func ClearInstance() error

ClearInstance removes the record, and does nothing if it is already gone.

A record naming another process that is still running is left alone. There are two callers — an instance shutting down, and a launch that found the recorded address unreachable — and neither can tell whether the record it is about to delete is still its own. It often is not: an instance whose server briefly failed to answer a probe has its record cleared and then overwritten by the rival launch, and when the first one finally exits it would delete the second one's record, leaving a running instance that no later launch can find and attach to.

func Dir

func Dir() (string, error)

Dir returns the per-user directory holding Flockdeck's state.

It is kept private to the user. Below it sit the local server's auth token, the browser profile the application window signs in through, and the generated settings handed to each agent; the files themselves are written 0600, but a world-readable directory still lets any other account on the machine list them and read whatever was not written by this package.

func ForgetRecent

func ForgetRecent(root string) error

ForgetRecent drops a project from the remembered list.

func Save

func Save(root string, s *State) error

Save writes the state atomically so an interrupted write cannot leave a truncated layout behind.

func SaveInstance

func SaveInstance(inst *Instance) error

SaveInstance records this process as the running instance.

func SavePrefs

func SavePrefs(p Prefs) error

SavePrefs writes the preferences.

func SaveSession

func SaveSession(s *Session) error

SaveSession records which projects are open.

func SessionsDir

func SessionsDir() (string, error)

SessionsDir returns the directory holding generated per-session settings.

func SweepSessions

func SweepSessions(maxAge time.Duration) (int, error)

SweepSessions removes files left behind by runs that were killed rather than closed, and returns how many it deleted: generated per-session settings, and the temporaries of writes that never reached their rename.

Files are only removed once they are older than maxAge. Normal shutdown deletes both as it goes, so what is left after that is orphaned.

Age settles it for a temporary: a write is a few milliseconds, so nothing part-way through is a day old. It does not settle it for a pane's settings. Those are written once when the pane starts and never touched again, so an agent that has been running since yesterday has a settings file that looks a day abandoned — and deleting it takes the hooks out from under a pane that is still working, which is how flockdeck knows whether that agent is waiting on its user. Whether they are in use is not a question about the file, so it is asked of the instance instead: while another one is running, its panes keep their settings and only the temporaries go.

That case is `flockdeck -solo`, which is the one way to get a second instance past a first that is still answering — including one left detached with its agents still going, which is exactly the run with the most to lose.

func TouchRecent

func TouchRecent(root string) error

TouchRecent records that a project was opened, moving it to the front.

Types

type Instance

type Instance struct {
	PID     int       `json:"pid"`
	URL     string    `json:"url"`
	Token   string    `json:"token"`
	Started time.Time `json:"started"`
}

Instance records a running flockdeck so a second launch can attach to it instead of starting a rival server, and so agents can outlive the window.

func LoadInstance

func LoadInstance() (*Instance, error)

LoadInstance returns the recorded running instance, or nil when there is none. A stale record left by a crash is not detected here: the caller has to probe the address, which is the only reliable test.

type Node

type Node struct {
	Pane     *Pane   `json:"pane,omitempty"`
	Dir      string  `json:"dir,omitempty"` // "h" or "v"
	Weight   float64 `json:"weight,omitempty"`
	Children []*Node `json:"children,omitempty"`
}

Node mirrors layout.Node in a form that survives a round trip through JSON.

type Pane

type Pane struct {
	ID   string `json:"id"`
	Kind string `json:"kind"` // "agent" or "shell"
	Cwd  string `json:"cwd"`
	Name string `json:"name,omitempty"`
	// Agent is the id of the agent an agent pane runs, and Model the model it
	// was asked for. Both are absent for a shell pane, and an absent Agent on
	// an agent pane means whatever the catalog's default is — which is what a
	// layout written before panes could choose meant, and what a fresh pane
	// opened with one keystroke still means.
	Agent string `json:"agent,omitempty"`
	Model string `json:"model,omitempty"`
	// Task is what a spawned pane was asked to do. It is kept so a restored
	// agent can still be told why its pane exists.
	Task string `json:"task,omitempty"`
	// Root is the project the pane belongs to, written only when it is not the
	// project of the tab holding it. A tab may show agents from more than one
	// project, and without this a borrowed pane would come back counted
	// against the tab's project: shown under the wrong name, stopped when the
	// wrong project was closed, and told it was working somewhere it was not.
	//
	// Absent — which is every layout written before this — means the tab's own
	// project, which is what those layouts meant.
	Root string `json:"root,omitempty"`
}

Pane is a single restored pane.

type Prefs

type Prefs struct {
	// HelpSeen records that the help has been opened at least once, which is
	// what keeps the first-run welcome from reappearing forever.
	HelpSeen bool `json:"helpSeen,omitempty"`
	// DismissedTips holds the ids of the inline hints that have been sent
	// away. A hint that is dismissed should stay dismissed.
	DismissedTips []string `json:"dismissedTips,omitempty"`
}

Prefs is what the interface remembers about the person using it, as opposed to what it remembers about a workspace.

It cannot live in the browser. The server binds a fresh random port on every run, so each run is a different origin as far as the browser is concerned, and anything kept in local storage is gone by the next one.

func LoadPrefs

func LoadPrefs() Prefs

LoadPrefs reads the preferences. Absent or damaged, they are the defaults: nothing here is worth failing a start-up over.

func (*Prefs) Dismiss

func (p *Prefs) Dismiss(id string) bool

Dismiss records that a hint has been sent away, and reports whether that changed anything.

func (Prefs) Dismissed

func (p Prefs) Dismissed(id string) bool

Dismissed reports whether a hint has been sent away.

type Project

type Project struct {
	Root     string    `json:"root"`
	LastUsed time.Time `json:"lastUsed"`
}

Project is a directory the user has opened.

func Recents

func Recents() ([]Project, error)

Recents returns known projects, most recently used first.

type Session

type Session struct {
	Open   []string `json:"open"`
	Active string   `json:"active"`
}

Session is the set of projects that were open when the application last exited, so a restart brings the whole workspace back rather than only the directory named on the command line.

func LoadSession

func LoadSession() (*Session, error)

LoadSession returns the last workspace, or nil when there is none.

type State

type State struct {
	Version int    `json:"version"`
	Tabs    []Tab  `json:"tabs"`
	Active  int    `json:"active"`
	Root    string `json:"root,omitempty"` // directory the workspace was opened on
}

State is the whole persisted workspace.

func Load

func Load(root string) (*State, error)

Load reads the saved state for a workspace root. A missing file is not an error: it simply means there is nothing to restore.

type Tab

type Tab struct {
	Title string `json:"title,omitempty"`
	Focus string `json:"focus,omitempty"`
	Root  *Node  `json:"root"`
}

Tab is one tab and its pane tree.

Jump to

Keyboard shortcuts

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