workspace

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 24 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 workspace holds the mutable state of the application: the projects that are open, the tabs in each, the pane tree in each tab, and the live sessions behind those panes.

It deliberately knows nothing about rendering or key bindings, so the layout and session lifecycle can be exercised without a user interface.

A tab belongs to a project and so does a pane, and the two need not agree: a tab can show agents from more than one project side by side. The tab's project decides which tab bar draws it. The pane's project decides what the agent is told it is working in, whose summary counts it as waiting, and what stops it when a project closes — so anything grouping panes by project asks rootOf, never the tab the pane happens to sit on.

Index

Constants

View Source
const MaxTasks = maxTasks

MaxTasks is maxTasks for callers that start the agents themselves, so the limit is one number rather than one per fan-out path.

Variables

This section is empty.

Functions

func BranchNameFor

func BranchNameFor(task string) string

BranchNameFor derives a git branch name from a task description.

Letters are letters in every script. Keeping only a-z threw away every character of a task written in Cyrillic, Greek, Japanese or anything else, which left nothing at all — so each of those tasks came out as the fallback name, and a whole fan-out landed on agent/task, agent/task-2, agent/task-3, naming nothing. git takes UTF-8 in a ref, and the worktree directory derived from it keeps the same characters already.

func ExtractTasks

func ExtractTasks(text string) []string

ExtractTasks finds the work items in a plan.

A lead agent asked for a plan answers with a list, so list markers are the signal: bullets, numbers and checkboxes. Everything else is prose. The result is a suggestion the user edits before anything is started, so it is better to offer a few plausible lines than to guess cleverly.

Types

type Choice

type Choice struct {
	Kind  session.Kind
	Agent string
	Model string
}

Choice is what a new pane should run: a shell, or an agent and one of its models. An empty Agent means the default one, and an empty Model whatever that agent is already set to, so a caller with nothing to say passes the kind alone and gets exactly what one keystroke has always given.

type Options

type Options struct {
	// Root is the project to open first.
	Root string
	// OnWake is called whenever any session changes and the interface should
	// refresh. It may be called from any goroutine.
	OnWake func()
	// HookBinary overrides the executable agent panes invoke to report their
	// lifecycle. It defaults to this process, and exists so tests and the
	// development harness can point at a built binary.
	HookBinary string
}

Options configures a new workspace.

type Pane

type Pane struct {
	ID   string
	Kind session.Kind
	Cwd  string
	Name string
	// Agent is the id of the agent this pane runs, and Model the model it was
	// asked for. Both are empty on a shell pane. A new agent pane records what
	// its choice resolved to, so a restart and a saved layout come back as the
	// same agent; an empty Agent, which only a layout written before panes
	// could choose holds, means the catalog's default. An empty Model means
	// whatever the agent is already set to, which is not the same as naming
	// its default model.
	Agent string
	Model string
	// Routed names the routing rule that chose Model, and RoutedFrom the
	// model the pane would otherwise have run. Both are empty for a model
	// chosen by hand or by default.
	Routed     string
	RoutedFrom string
	// Root is the open project this pane belongs to. It is usually the project
	// of the tab the pane sits on, but need not be: a tab can show agents from
	// more than one project side by side, and this is what says which one an
	// agent is working in. Cwd may be deeper still, since a pane can be put
	// into a worktree inside its project.
	Root string
	// Branch is the git branch checked out in Cwd, shown in the pane header so
	// agents running in parallel worktrees can be told apart at a glance.
	Branch string
	// Git is a periodically refreshed summary of the checkout the pane works
	// in: whether it has uncommitted work and how it stands against upstream.
	Git gitx.Status
	// GitTimedOut is set while the last refresh of the checkout gave up before
	// git answered. Git then still holds what was read before, which is kept
	// for when git answers again but must not be shown as though it were
	// current: nothing says it still is.
	GitTimedOut bool

	// Cols and Rows are the terminal size the viewer last measured for this
	// pane. They are remembered so a restart comes back at the size the pane
	// is really being drawn at, instead of reflowing at the default until the
	// window happens to be resized again.
	Cols int
	Rows int

	Sess *session.Session
	// Err records why a pane failed to start, so the UI can show it in place
	// rather than the app dying at launch.
	Err error

	// Task is what the pane was spawned to do, kept after the opening prompt
	// has been spent so the agent can still be told why it exists — after a
	// restart, or after its context has been compacted away.
	Task string
	// Conversation is the agent's own id for the conversation the pane is in,
	// once that is no longer the pane's id; empty means the pane's id. It is
	// set from the hook goroutine, so it is only touched under the lock — read
	// it through conversationOf.
	Conversation string
	// contains filtered or unexported fields
}

Pane couples a live session with the configuration needed to restart it.

func (*Pane) Alive

func (p *Pane) Alive() bool

Alive reports whether the pane has a running process.

func (*Pane) IsAgent

func (p *Pane) IsAgent() bool

IsAgent reports whether the pane runs an agent rather than a plain shell.

A pane is one or the other, so this is written as "not a shell": which agent it runs is the Spec's business, and everything the workspace does with the distinction — resuming on restart, renaming a tab after the first prompt, counting a project as waiting — is true of every agent and of none of them.

func (*Pane) Status

func (p *Pane) Status() (session.Status, string)

Status returns the pane's status and detail, accounting for panes that never started.

type PaneContext

type PaneContext struct {
	PaneID   string
	PaneName string
	Shell    bool

	Tab      string
	TabPanes int

	ProjectRoot string
	ProjectName string
	Cwd         string
	Branch      string
	// Worktree reports that the pane works in a checkout of its own — a
	// directory outside the project altogether, which is what fan-out gives
	// each child, since Flockdeck puts a worktree beside the repository it came
	// from rather than inside it.
	Worktree bool
	// Subdirectory reports a working directory below the project root: the
	// same checkout, a directory or two down. It is not a worktree, and an
	// agent told that it is one is told to keep out of the rest of its own
	// repository.
	Subdirectory bool

	// Task is the opening prompt the pane was spawned with, when it was
	// started by a fan-out or by another agent rather than by hand. Which of
	// the two it was is not recorded, so the pane is not told either.
	Task string

	Siblings []Sibling
	// SiblingsOmitted counts the live panes left out of Siblings once the list
	// hit its limit, so the agent is told the list is partial rather than
	// assuming it has seen everyone.
	SiblingsOmitted int

	OtherProjects []string

	// Taken is when the snapshot was made. It is written out only for an agent
	// briefed through its opening prompt, because that briefing arrives once
	// and is never replaced: everything below it is true of the moment the
	// pane started and of no moment after, and an agent that is not told so
	// will read a list of other agents that has since changed as current.
	Taken time.Time

	// CanSpawn reports whether spawning helpers will work from this pane.
	CanSpawn bool
	// SpawnCommand is how Flockdeck itself is run from inside the pane: the name
	// on PATH where there is one, and the binary's own path where there is not.
	SpawnCommand string
}

PaneContext is everything an agent is told about the situation it is running in: which pane it is, which checkout it has, and who else is working.

It is a snapshot taken on the workspace's own goroutine and rendered elsewhere, so it holds values rather than pointers into live state.

func (PaneContext) OpeningPrompt

func (c PaneContext) OpeningPrompt() string

OpeningPrompt is what an agent with no hooks to answer is started with: the same briefing, fenced, and then the task.

The fence is there so the two can be told apart. Everything inside it is Flockdeck describing the pane; everything after it is what the user asked for, and an agent that reads the first as part of the second sets about documenting the window instead of doing the work. A pane started with no task gets the block on its own, which is still worth sending: knowing which checkout it has and who else is in the repository changes what the agent does with the first thing the user types.

func (PaneContext) Render

func (c PaneContext) Render() string

Render writes the context as the text handed to an agent at session start, in answer to its own lifecycle hook.

It is prose rather than JSON because it is read by the model, and it is deliberately specific about the two things an agent cannot work out for itself: that its conversation is private to one pane among several, and that the other panes may be editing other checkouts of the same repository.

type PlanSource

type PlanSource struct {
	// SessionID names the pane's transcript, when its agent keeps one, and
	// Spec is that agent, which is what knows where the transcript is.
	SessionID string
	Spec      agent.Spec
	// Screen is the pane's recent terminal output. It is the fallback: a shell
	// pane has no transcript, and neither has an agent that has not yet spoken.
	Screen string
}

PlanSource is where a fan-out looks for the work it should propose.

func (PlanSource) Tasks

func (s PlanSource) Tasks() ([]string, bool)

Tasks proposes the work items in the plan, and reports whether they came from the agent's own words rather than from the screen.

It reads from disk, so call it away from the goroutine that owns the workspace. The most recent reply that yields any work wins: an agent that has laid out a plan and then answered a follow-up should not lose the plan.

type Project

type Project struct {
	Root    string
	Name    string
	Active  bool
	Tabs    int
	Waiting int
	Working int
}

Project is an open project and a summary of what is happening inside it.

type Sibling

type Sibling struct {
	Name   string
	Tab    string
	Cwd    string
	Branch string
	Status string
	Shell  bool
	Task   string
	// Agent and Model are what the pane is running: the agent's id and the
	// model it was asked for, as the pane header shows them. Which agent is in
	// the next pane changes what is worth asking of it — a plan is worth
	// handing to one, a mechanical edit to another — and neither is anything
	// the reader can work out from a directory and a branch.
	Agent string
	Model string
	// SameCheckout marks a pane working in the reader's own directory. It is
	// the one fact in the list that changes what the agent should do, and it
	// is easy to miss when it has to be read off two long paths.
	SameCheckout bool
}

Sibling is another pane, as described to an agent.

type SpawnOptions

type SpawnOptions struct {
	// Task is given to the agent as its opening prompt.
	Task string
	// Cwd is where it works. Empty means the parent's directory.
	Cwd string
	// Branch, when set, puts the child in its own git worktree on that branch
	// so parallel children cannot collide over one checkout.
	Branch string
	// Split places the child beside its parent instead of in a new tab.
	Split bool
	// Tab names an existing tab for the child to join, where it is arranged
	// into a grid with the panes already there. It is how a fan-out gathers a
	// dozen children into one tab rather than scattering them a tab each, and
	// it takes precedence over Split. A tab that has since been closed is
	// ignored, and the child is placed as it would have been without it.
	Tab   string
	Kind  session.Kind
	Title string
	// Agent names the agent.Spec the pane runs, and Model the model that agent
	// is asked for. Empty means the default, which is how a fan-out started
	// without a thought about either keeps running what Flockdeck already ran. An
	// empty model is not "no model": it leaves the choice to the agent, so a
	// CLI keeps whatever it was configured with.
	Agent string
	Model string
	// Routed names the routing rule that chose Model, and RoutedFrom the
	// model the child would otherwise have run. They are recorded on the pane
	// so its header says the model was routed, and why.
	Routed     string
	RoutedFrom string
}

SpawnOptions describes a child agent to start.

type Tab

type Tab struct {
	ID    string
	Root  string // the project this tab belongs to
	Title string
	Tree  *layout.Node
	Focus string
	// Zoom temporarily gives the focused pane the whole window.
	Zoom bool
	// AutoTitle is set while the title is still the directory name the tab was
	// given automatically, so the first prompt may replace it. Renaming a tab
	// by hand clears it and the title is then left alone.
	AutoTitle bool
	// Named is set while the tab carries a name chosen by hand. The title it
	// would otherwise have goes on being kept behind that name, in auto and
	// autoOpen, so that giving the name up puts back what the tab would be
	// called had it never been renamed: renaming used to clear AutoTitle for
	// good, and a tab named once could never go back.
	Named bool
	// contains filtered or unexported fields
}

Tab is one tab: a pane tree, which pane has focus, and the project it belongs to.

type Workspace

type Workspace struct {
	// Tabs holds every tab across every open project, in creation order.
	Tabs []*Tab

	// Broadcast, when enabled, sends what is written in the prompt bar to every
	// pane in the broadcast set as well as the focused one; with it off the
	// prompt bar reaches the focused pane and any panes picked by hand, which
	// stay picked. Typing into a pane's own terminal is never copied anywhere.
	Broadcast    bool
	BroadcastSet map[string]bool
	// contains filtered or unexported fields
}

Workspace is the whole application state.

func New

func New(opts Options) (*Workspace, error)

New creates a workspace, starting the hook server that panes report to.

func (*Workspace) ActiveRoot

func (w *Workspace) ActiveRoot() string

ActiveRoot returns the project currently being shown.

func (*Workspace) ActiveTabID

func (w *Workspace) ActiveTabID() string

ActiveTabID returns the id of the focused tab.

func (*Workspace) AgentSpec

func (w *Workspace) AgentSpec(id string) (agent.Spec, error)

AgentSpec resolves the agent a pane was asked to run, and says why it cannot be run when it cannot. An empty id means the default agent of the project on screen.

The question asked here is about one spec rather than about Claude. A fan-out may now give four of its tasks to one agent and eight to another, and the half whose agent is installed should start whatever is true of the other half -- which it cannot while the only question Flockdeck knows how to ask is whether Claude Code is on this machine.

func (*Workspace) Agents

func (w *Workspace) Agents() ([]agent.Spec, string)

Agents returns the catalog this workspace runs from: every agent that is not hidden, and the id of the one a pane takes when nothing has chosen.

func (*Workspace) AttentionCount

func (w *Workspace) AttentionCount() (waiting, working int)

AttentionCount returns how many panes across every open project are waiting on the user, and how many are actively working.

func (*Workspace) BroadcastTargets

func (w *Workspace) BroadcastTargets() []*Pane

BroadcastTargets returns the panes that should receive broadcast input in the active tab, always including the focused pane.

func (*Workspace) Catalog

func (w *Workspace) Catalog() *agent.Catalog

Catalog is the agents this workspace runs from, for a caller that needs more of it than Agents reports -- the defaults a project was given, and what the user's file had to say for itself. It is safe to call from any goroutine, so that probing a catalog full of agents need not happen on the one goroutine that owns the workspace.

func (*Workspace) ClaudeAvailable

func (w *Workspace) ClaudeAvailable() bool

ClaudeAvailable reports whether the claude CLI was found.

func (*Workspace) Close

func (w *Workspace) Close()

Close terminates every session and stops the hook server.

func (*Workspace) ClosePane

func (w *Workspace) ClosePane()

ClosePane closes the focused pane. Closing the last pane in a tab closes the tab.

func (*Workspace) CloseProject

func (w *Workspace) CloseProject(root string)

CloseProject saves a project's layout, closes its tabs and removes it. The last open project cannot be closed, since the window would have nothing to show.

func (*Workspace) CloseTab

func (w *Workspace) CloseTab(id string)

CloseTab closes a tab and every session in it.

func (*Workspace) ConversationOf added in v0.2.3

func (w *Workspace) ConversationOf(paneID string) string

ConversationOf reports the conversation a pane is in, for a caller outside the package: the history panel marks a conversation as open by the conversation a pane is in, not by the id the pane was started under. It is "" for a pane that is not open.

func (*Workspace) CurrentTab

func (w *Workspace) CurrentTab() *Tab

CurrentTab returns the active tab, or nil when there is none.

func (*Workspace) FocusPane

func (w *Workspace) FocusPane(id string)

FocusPane focuses a pane by id if it is in the active tab.

func (*Workspace) FocusedPane

func (w *Workspace) FocusedPane() *Pane

FocusedPane returns the pane with focus in the active tab.

func (*Workspace) HookServer

func (w *Workspace) HookServer() *hooks.Server

HookServer is the loopback API panes call back on, so the server can install the handler that lets an agent spawn helpers.

func (*Workspace) InBroadcast

func (w *Workspace) InBroadcast(id string) bool

InBroadcast reports whether a pane receives broadcast input.

func (*Workspace) MergeTab

func (w *Workspace) MergeTab(id, targetID string, dir layout.Dir) error

MergeTab folds one tab into another, leaving a single tab holding every pane of both, side by side along dir. The tab that was merged away closes, and, as with every other move here, nothing in it is stopped: its agents come across still running, with their conversations and scrollback intact.

This is the counterpart to dragging a pane out into a tab of its own. Two agents started in separate tabs are put side by side without restarting either of them.

func (*Workspace) MergeTabsInProject

func (w *Workspace) MergeTabsInProject(targetID string, dir layout.Dir) error

MergeTabsInProject folds every other tab of a project into one, which is the quickest way from agents scattered across tabs to all of them on screen at once.

The panes come out in the order the tab bar showed them, whichever tab was gathered into: a tab that was two to the left stays two to the left. Folding each tab in on the near side and working outwards is what gets that, since each merge only ever places a tab's panes against what has already been gathered.

func (*Workspace) MovePane

func (w *Workspace) MovePane(paneID, targetID string, edge layout.Edge) error

MovePane moves a pane so that it sits on one edge of another, in whichever tab that other pane lives in.

func (*Workspace) MovePaneDir

func (w *Workspace) MovePaneDir(dir layout.Direction) error

MovePaneDir moves the focused pane past its neighbour in a direction, which is the keyboard equivalent of dragging it there.

Neighbours are chosen by geometry rather than by tree order, so that moving a pane right sends it where the user can see the space is.

func (*Workspace) MovePaneToNewTab

func (w *Workspace) MovePaneToNewTab(paneID string) error

MovePaneToNewTab pulls a pane out into a tab of its own, which is how a pane that has outgrown its split gets the room to itself.

func (*Workspace) MovePaneToTab

func (w *Workspace) MovePaneToTab(paneID, tabID string) error

MovePaneToTab moves a pane into another tab, beside that tab's focused pane.

func (*Workspace) MoveTab

func (w *Workspace) MoveTab(id, beforeID string) error

MoveTab reorders a tab within its project, placing it before the tab named by beforeID. An empty beforeID moves it to the end.

func (*Workspace) NameTab added in v0.2.10

func (w *Workspace) NameTab(id, name string)

NameTab gives a tab a name chosen by hand, which no prompt replaces. The title the tab had been giving itself is kept, for UseAutoTitle to put back.

func (*Workspace) NewTab

func (w *Workspace) NewTab(kind session.Kind, cwd, title string) *Tab

NewTab appends a tab to the active project and focuses it.

The tab belongs to the active project, since that is the tab bar it is drawn on, but the pane belongs to whichever open project its directory is in — the same rule a split follows. Opening a checkout that is itself open as a project, which is how a worktree usually reaches a new tab, otherwise gave an agent working in one project every reason to think it was in another.

func (*Workspace) NewTabWith

func (w *Workspace) NewTabWith(c Choice, cwd, title string) *Tab

NewTabWith is NewTab with the agent and model to run in the new tab's pane named, which is what the agent picker asks for.

func (*Workspace) NextTab

func (w *Workspace) NextTab()

NextTab and PrevTab cycle through the active project's tabs, wrapping.

func (*Workspace) OpenConversation

func (w *Workspace) OpenConversation(id, cwd, title string) error

OpenConversation opens a stored conversation in a new tab.

The pane takes the conversation's own id, which is what makes `--resume` reattach to it and what lets the layout remember it afterwards. A conversation that is already open is focused instead of being started twice: two panes on one conversation would fight over the same transcript.

func (*Workspace) OpenConversationAs added in v0.2.3

func (w *Workspace) OpenConversationAs(id, cwd, title, agentID string) error

OpenConversationAs is OpenConversation for a conversation the history panel knows the agent of. That agent is tried ahead of the rest: every API agent keeps its transcripts in the chat client's one folder, so without it an OpenAI conversation was reopened as whichever API agent came first.

func (*Workspace) OpenProject

func (w *Workspace) OpenProject(path string) error

OpenProject opens a directory as a project and makes it active. A project that is already open is simply selected. Its saved layout is restored the first time it is opened; if it has none, a single tab is created.

func (*Workspace) OpeningPrompt

func (w *Workspace) OpeningPrompt(paneID, task string, mode agent.ContextMode) string

OpeningPrompt is what the agent in a pane should be started with: the task it was given, with the briefing in front of it when the agent has no hooks to answer.

Starting a pane calls this instead of passing the task straight through, because the briefing is the same one the hook returns and there is nowhere else for it to go for an agent that cannot be asked. Any other mode gets the task untouched: an agent with hooks is briefed when it fires its first one, and one asking for no context has said so.

It is called on the goroutine that owns the workspace, like every other read of it.

func (*Workspace) Pane

func (w *Workspace) Pane(id string) *Pane

Pane returns the pane with the given id.

func (*Workspace) PaneContext

func (w *Workspace) PaneContext(paneID string) (PaneContext, bool)

PaneContext describes the situation a pane is running in. It reports false when the pane is unknown.

Everything here comes from state the workspace already holds — no git or filesystem calls — because it is built while a pane's agent session waits on its SessionStart hook.

func (*Workspace) PlanSourceFor

func (w *Workspace) PlanSourceFor(paneID string) PlanSource

PlanSourceFor gathers what a fan-out can read from a pane.

It only touches state already in memory, so it is safe on the goroutine that owns the workspace. Opening the transcript is Tasks's job.

func (*Workspace) PrepareWorktree

func (w *Workspace) PrepareWorktree(cwd, branch string) (string, error)

PrepareWorktree creates (or reuses) a worktree for a branch and returns its path. It only runs git, so it is safe to call away from the goroutine that owns the workspace — which matters, because git is slow.

func (*Workspace) PrevTab

func (w *Workspace) PrevTab()

PrevTab moves to the previous tab.

func (*Workspace) Projects

func (w *Workspace) Projects() []Project

Projects returns the open projects with a summary of each.

An agent is counted against the project it belongs to rather than the project of the tab it is drawn on. The switcher's badge is what says a project is waiting on you, and a borrowed pane counted against the tab it sits on lights up a project that is not the one whose work has stopped — while the project that is actually blocked shows nothing.

func (*Workspace) RefreshGit

func (w *Workspace) RefreshGit(apply func(func()))

RefreshGit updates every pane's git summary.

The git calls are made off the caller's goroutine and only the results are applied, so a slow repository cannot stall the interface. Each checkout's result is handed to apply as soon as it is read, and apply must run it where mutating panes is safe. RefreshGit returns once every checkout it asked about has answered or been given up on.

It applied nothing until every checkout had answered, so one that hung -- on a network drive gone away, behind a hook that never returned -- held every pane's header at its old numbers for the twenty seconds git was given, and then its own panes went on showing numbers from before it hung as though nothing were wrong. Now a checkout holds up only its own panes, for gitDeadline at most, and they are marked when it runs out.

func (*Workspace) ReloadAgents

func (w *Workspace) ReloadAgents() string

ReloadAgents reads agents.json again, so that an edit made by hand takes effect without restarting. It also returns what the file had to say for itself, which is empty unless it could not be read.

func (*Workspace) ResizePaneTerminal

func (w *Workspace) ResizePaneTerminal(id string, cols, rows int)

ResizePaneTerminal records the terminal size the viewer measured for a pane and applies it to the PTY. Geometry is decided by the browser, which knows the font metrics, so the server only forwards the result.

func (*Workspace) RestartPane

func (w *Workspace) RestartPane()

RestartPane relaunches the focused pane's process. An agent pane resumes the same conversation wherever its agent can.

func (*Workspace) Restore

func (w *Workspace) Restore() (bool, error)

Restore rebuilds the initial project from its saved layout. It reports whether anything was restored; when it returns false the caller should create a fresh tab.

func (*Workspace) RestoreSession

func (w *Workspace) RestoreSession() int

RestoreSession reopens the projects that were open when the application last exited, alongside the one it was started on. It returns how many extra projects were opened.

The project the user asked for stays active: reopening the rest is meant to bring back context, not to move them somewhere they did not ask to be.

func (*Workspace) RevealPane added in v0.2.10

func (w *Workspace) RevealPane(id string)

RevealPane selects the tab a pane is in, switching project if that tab belongs to another, and focuses the pane there. FocusPane alone only works in the tab on screen, which is no help for a pane that has just been put in a tab of its own. A pane in no tab at all is left alone, and so is the window.

func (*Workspace) RootOf

func (w *Workspace) RootOf(paneID string) string

RootOf reports the project a pane belongs to, for callers outside the package that need to name it rather than the tab it is drawn on.

func (*Workspace) SaveAll

func (w *Workspace) SaveAll() error

SaveAll writes the layout of every open project and the list of which ones were open.

Every project is attempted even when one fails, and each failure is named after the project it belongs to: this runs on the way out, so the message printed to the terminal is the only thing the user gets, and "could not save layout" is no help at all when several projects are open.

func (*Workspace) SaveProject

func (w *Workspace) SaveProject(root string) error

SaveProject writes one project's tabs to its own layout file, so projects are restored independently of one another.

func (*Workspace) SaveSession

func (w *Workspace) SaveSession() error

SaveSession records which projects are open for the next run.

func (*Workspace) SelectProject

func (w *Workspace) SelectProject(root string)

SelectProject shows an already open project.

func (*Workspace) SelectTab

func (w *Workspace) SelectTab(id string)

SelectTab focuses a tab, switching project if it belongs to another.

func (*Workspace) SendPrompt

func (w *Workspace) SendPrompt(text string, submit bool)

SendPrompt types text into every broadcast target and submits it.

Each pane is written to on a goroutine of its own. This runs on the goroutine that owns the workspace, and a terminal whose program has stopped reading its input fills after a few kilobytes on Linux and macOS, after which a write into it blocks until the program reads again — which, done here, held up the whole window for as long as one pane went on not reading.

A prompt of several lines is pasted rather than typed into a pane whose program takes bracketed paste: typed, every line break in it is an Enter, and the first line was submitted on its own with the rest arriving as further messages. Where the program has not asked for bracketed paste the markers would reach it as text, so it is typed as before.

func (*Workspace) SetWake

func (w *Workspace) SetWake(fn func())

SetWake installs the refresh callback. It exists so the server, which needs the workspace to construct, can register itself afterwards.

func (*Workspace) Spawn

func (w *Workspace) Spawn(parentPaneID string, o SpawnOptions) (string, error)

Spawn starts a child agent, optionally in a worktree of its own.

The task is handed to the agent as its opening argument rather than typed into the terminal: typing into a TUI means guessing when it is ready, while an argument is submitted by the agent itself the moment it starts.

func (*Workspace) SplitPane

func (w *Workspace) SplitPane(dir layout.Dir, kind session.Kind)

SplitPane splits the focused pane, starting a new session beside it in the same directory.

func (*Workspace) SplitPaneIn

func (w *Workspace) SplitPaneIn(dir layout.Dir, kind session.Kind, cwd string)

SplitPaneIn splits the focused pane, starting the new session in cwd. An empty cwd inherits the focused pane's directory, which is what a plain split should do; the worktree panel passes a directory to put an agent straight into another checkout.

func (*Workspace) SplitPaneInProject

func (w *Workspace) SplitPaneInProject(dir layout.Dir, kind session.Kind, root string)

SplitPaneInProject splits the focused pane and starts the new session in another open project, which is how two projects come to be worked on side by side in one tab. An unknown or empty project falls back to an ordinary split.

func (*Workspace) SplitPaneInProjectWith

func (w *Workspace) SplitPaneInProjectWith(dir layout.Dir, c Choice, root string)

SplitPaneInProjectWith is SplitPaneInProject with the agent and model named.

func (*Workspace) SplitPaneInWith

func (w *Workspace) SplitPaneInWith(dir layout.Dir, c Choice, cwd string)

SplitPaneInWith is SplitPaneIn with the agent and model named.

func (*Workspace) SwapPanes

func (w *Workspace) SwapPanes(a, b string) error

SwapPanes exchanges two panes' positions, leaving the splits and their proportions exactly as they were. The panes may be in different tabs.

func (*Workspace) Tab

func (w *Workspace) Tab(id string) *Tab

Tab returns the tab with the given id, or nil.

func (*Workspace) TabIDOf

func (w *Workspace) TabIDOf(paneID string) string

TabIDOf returns the id of the tab a pane is drawn in, or "" when the pane is not on screen. It is what a caller starting several panes into one tab needs after the first of them, since that first one is what created the tab.

func (*Workspace) TabNeedsAttention

func (w *Workspace) TabNeedsAttention(t *Tab) bool

TabNeedsAttention reports whether any pane in a tab is waiting on the user.

func (*Workspace) TilePanes

func (w *Workspace) TilePanes() error

TilePanes lays the current tab's panes out as an even grid, in the order they are already in.

It is the way back. Every other move here is relative — beside this one, past that one — and a tab that has been rearranged a dozen times ends up with panes so narrow there is no divider left to take hold of and no room to drop anything into. Rather than ask the user to drag their way out of that, this puts the tab back into rows of even columns in one go.

func (*Workspace) ToggleBroadcast

func (w *Workspace) ToggleBroadcast()

ToggleBroadcast turns broadcast mode on or off.

With no selection of the user's own, broadcast means every agent pane in the tab in front of you. That default is not written down as a set of panes: it is answered from whichever tab is on screen at the time, so switching tabs with broadcast still on broadcasts to the tab you are now looking at rather than to the one you switched it on in — where it would have gone to panes that are not on screen, which looks exactly like broadcast having stopped working.

func (*Workspace) ToggleBroadcastMember

func (w *Workspace) ToggleBroadcastMember()

ToggleBroadcastMember adds or removes the focused pane from the broadcast set.

func (*Workspace) ToggleZoom

func (w *Workspace) ToggleZoom()

ToggleZoom expands or restores the focused pane.

func (*Workspace) UseAgent

func (w *Workspace) UseAgent(id string)

UseAgent fixes which agent a new pane starts as for the rest of this run, which is what -agent asks for.

It sits between the two answers that already exist: above the catalog's own defaults, because naming an agent on the command line is a more immediate statement than a file written weeks ago, and below a pane that names one itself, because a restored layout knows what it was.

func (*Workspace) UseAutoTitle added in v0.2.10

func (w *Workspace) UseAutoTitle(id string) bool

UseAutoTitle gives up a name chosen by hand, and gives the tab the title it would have now had it never been renamed: the directory name, still waiting for the first prompt to replace it, or what the first prompt made of it. It reports whether anything changed, which it does not for a tab that already has its automatic title.

func (*Workspace) VisibleTabs

func (w *Workspace) VisibleTabs() []*Tab

VisibleTabs returns the tabs of the active project, in order.

Jump to

Keyboard shortcuts

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