Documentation
¶
Overview ¶
Package workspace holds what a workspace manager reports, as values, and names its worktree as a unit.
Index ¶
- Constants
- func ActivityOf(panes []Pane) map[string]Activity
- func MainOnDefault(w Workspace, r Repo) bool
- func UnitOf(path string) unit.Unit
- type Activity
- type Codec
- type Custody
- type Pane
- type Part
- type Repo
- type Scope
- type Scopes
- type Snapshot
- func (s *Snapshot) Activity() map[string]Activity
- func (s *Snapshot) Terminal(handle string) (Terminal, bool)
- func (s *Snapshot) TerminalsComplete(manager string) bool
- func (s *Snapshot) TerminalsOf(workspaceID string) []Terminal
- func (s *Snapshot) Workspace(id string) (Workspace, bool)
- func (s *Snapshot) WorkspacesComplete(manager string) bool
- type Terminal
- type Workspace
Constants ¶
const LocalHost = "local"
LocalHost is the host id of a workspace on this machine.
Variables ¶
This section is empty.
Functions ¶
func ActivityOf ¶
ActivityOf folds panes into the activity of each workspace they belong to.
func MainOnDefault ¶
MainOnDefault reports whether w is the main checkout of r sitting on the default branch, which is never a pull request's workspace: a release pull request from it would otherwise run its rounds there.
Types ¶
type Activity ¶
type Activity struct {
// Busy is true when an agent of the workspace is working or waiting for
// input.
Busy bool
// Waiting is true when an agent stopped on a permission prompt or a
// question: typed text would answer it.
Waiting bool
UserActive bool
States []turn.AgentState
}
type Codec ¶
type Codec struct{}
Codec is the unit codec of provider "workspace".
func (Codec) Provider ¶
func (Codec) Provider() unit.ProviderID
type Custody ¶
type Custody struct {
Path string
// Repo is the main checkout's path, "" when unknown.
Repo string
Manager string
// WorkspaceID is the owner's id of the worktree.
WorkspaceID string
// CreatedBy is the manager that created the worktree, "" for one the loop
// found.
CreatedBy string
At time.Time
Units []unit.Unit
}
Custody is a worktree in the custody of one manager, its owner, as the loop records it: the store, not the manager, says who owns a worktree and which units it stands for.
type Pane ¶
type Pane struct {
Manager string
WorkspaceID string
// Pane is "<tab-id>:<leaf-id>" for Orca; opaque to readers.
Pane string
State turn.AgentState
// StateSince is when the agent entered State; a repaint does not move it.
StateSince time.Time
LastMessage string
// UserActive means the workspace is the one open in the app.
UserActive bool
}
Pane is one agent the manager sees in a workspace. A Pane with no State is no agent: it marks the workspace open in the app while no agent runs there.
type Part ¶
type Part uint8
Part names one listing of a Snapshot; parts combine as a bit set.
const ( PartRepos Part = 1 << iota PartWorkspaces PartPanes PartTerminals PartMutable = PartWorkspaces | PartPanes | PartTerminals PartAll = PartRepos | PartMutable )
type Repo ¶
type Repo struct {
ID string
Path string
// Manager is the workspace manager the repository is registered with.
Manager string
// RemoteKey identifies the remote as host/owner/name, e.g.
// github.com/owner/repo. Empty when the repository has no remote.
RemoteKey string
// DefaultBranch is the branch origin/HEAD names; empty when unknown.
DefaultBranch string
}
func FindRepos ¶
FindRepos returns the registered checkouts of a remote, preferring the one that owns preferRepoID and then the one whose directory is named after the repository.
func (Repo) IsDefaultBranch ¶
IsDefaultBranch counts main and master besides what origin/HEAD names, which may be unknown or stale.
type Scope ¶
type Scope struct {
Hosts []string
Complete bool
// RuntimeID is the manager instance that answered; it changes on restart.
RuntimeID string
}
Scope is which hosts a listing covered. Complete is false when a host was omitted, the listing was truncated or the manager was not ready: absence from it proves nothing.
type Snapshot ¶
type Snapshot struct {
// Gen increases by one each time a reloaded part's projection differs from the one it
// replaces. Projections: Repos and Workspaces all fields, Panes without LastMessage,
// Terminals without LastOutput.
Gen uint64
Repos []Repo
Workspaces []Workspace
Panes []Pane
Terminals []Terminal
WorkspaceScope Scope
TerminalScope Scope
// Scopes are each manager's own scopes in a snapshot merged from several;
// nil in one manager's snapshot.
Scopes map[string]Scopes
// Loaded is the set of parts this snapshot holds; ReadAt is when each was read.
Loaded Part
ReadAt map[Part]time.Time
}
Snapshot is one generation of the manager's listings. Readers never modify its slices.
func (*Snapshot) Activity ¶
Activity is each workspace's agents folded together, keyed by workspace id.
func (*Snapshot) TerminalsComplete ¶
TerminalsComplete says whether the listing holds every terminal of manager.
func (*Snapshot) TerminalsOf ¶
TerminalsOf is the workspace's usable terminals, in listing order.
func (*Snapshot) WorkspacesComplete ¶
WorkspacesComplete says whether the listing holds every workspace of manager.
type Terminal ¶
type Terminal struct {
Manager string
Handle, WorkspaceID, TabID, Title, Agent string
LastOutput time.Time
// Usable is connected, writable and not orphaned.
Usable bool
}
Terminal is a terminal the manager lists, usable or not.
type Workspace ¶
type Workspace struct {
// Manager owns the workspace; ID is its id there.
Manager string
ID string
RepoID string
Path string
DisplayName string
// Branch is the local branch without refs/heads/.
Branch string
// PushBranch is the remote branch the workspace pushes to, when known.
PushBranch string
Status string
HostID string
LinkedPR int
IsMain bool
// Comment is the note on the workspace's card, on a manager with a board.
Comment string
// BranchRenamed is set by Create when the manager put the workspace on
// another branch than the requested head, which is taken.
BranchRenamed bool
// Unread is the card's unread mark.
Unread bool
// Created is set when the manager made the worktree, rather than found
// one another tool made: it owns the worktree over a manager that only
// lists it.
Created bool
}
func (Workspace) HeadBranch ¶
HeadBranch is the branch name a pull request from this workspace would carry on GitHub.