workspace

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 7 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 what a workspace manager reports, as values, and names its worktree as a unit.

Index

Constants

View Source
const LocalHost = "local"

LocalHost is the host id of a workspace on this machine.

Variables

This section is empty.

Functions

func ActivityOf

func ActivityOf(panes []Pane) map[string]Activity

ActivityOf folds panes into the activity of each workspace they belong to.

func MainOnDefault

func MainOnDefault(w Workspace, r Repo) bool

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.

func UnitOf

func UnitOf(path string) unit.Unit

UnitOf is the unit of the worktree at path: a workspace's unit key is its worktree's path, whichever manager owns it.

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

func (Codec) Valid

func (Codec) Valid(key string) error

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.

func (Pane) Agent

func (p Pane) Agent() bool

Agent reports whether p is an agent rather than the open-workspace mark.

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

func FindRepos(repos []Repo, remoteKey, preferRepoID string) []Repo

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

func (r Repo) IsDefaultBranch(branch string) bool

IsDefaultBranch counts main and master besides what origin/HEAD names, which may be unknown or stale.

func (Repo) OwnerName

func (r Repo) OwnerName() (owner, name string, ok bool)

OwnerName splits a github.com remote key. ok is false for other hosts.

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 Scopes

type Scopes struct{ Workspaces, Terminals Scope }

Scopes are one manager's scopes.

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

func (s *Snapshot) Activity() map[string]Activity

Activity is each workspace's agents folded together, keyed by workspace id.

func (*Snapshot) Terminal

func (s *Snapshot) Terminal(handle string) (Terminal, bool)

func (*Snapshot) TerminalsComplete

func (s *Snapshot) TerminalsComplete(manager string) bool

TerminalsComplete says whether the listing holds every terminal of manager.

func (*Snapshot) TerminalsOf

func (s *Snapshot) TerminalsOf(workspaceID string) []Terminal

TerminalsOf is the workspace's usable terminals, in listing order.

func (*Snapshot) Workspace

func (s *Snapshot) Workspace(id string) (Workspace, bool)

func (*Snapshot) WorkspacesComplete

func (s *Snapshot) WorkspacesComplete(manager string) bool

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

func (w Workspace) HeadBranch() string

HeadBranch is the branch name a pull request from this workspace would carry on GitHub.

func (Workspace) Local

func (w Workspace) Local() bool

Local tells whether w is on this machine at an absolute path.

func (Workspace) PRBranch

func (w Workspace) PRBranch() string

PRBranch is the branch by which the workspace matches a pull request. A main checkout matches only by the branch it has checked out.

Jump to

Keyboard shortcuts

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