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
- func BrowserProfileDir() (string, error)
- func ClearInstance() error
- func Dir() (string, error)
- func ForgetRecent(root string) error
- func Save(root string, s *State) error
- func SaveInstance(inst *Instance) error
- func SavePrefs(p Prefs) error
- func SaveSession(s *Session) error
- func SessionsDir() (string, error)
- func SweepSessions(maxAge time.Duration) (int, error)
- func TouchRecent(root string) error
- type Instance
- type Node
- type Pane
- type Prefs
- type Project
- type Session
- type State
- type Tab
Constants ¶
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 ¶
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 ¶
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 ¶
ForgetRecent drops a project from the remembered list.
func Save ¶
Save writes the state atomically so an interrupted write cannot leave a truncated layout behind.
func SaveInstance ¶
SaveInstance records this process as the running instance.
func SessionsDir ¶
SessionsDir returns the directory holding generated per-session settings.
func SweepSessions ¶
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 ¶
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 ¶
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.
type Session ¶
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 ¶
LoadSession returns the last workspace, or nil when there is none.