Documentation
¶
Overview ¶
Package workspaceinventory provides the narrow, read-only inventory used by cross-project surfaces. It never creates or reconciles Sidecar state.
Index ¶
- func CanonicalPath(path string) string
- func CanonicalProjectPath(path string) string
- func ServerPIDOf(panes []Pane) int
- type CaptureFunc
- type Collector
- func (c Collector) CollectProject(ctx context.Context, name, root string, allRoots []string, panes []Pane) ProjectResult
- func (c Collector) CollectProjectInventory(ctx context.Context, name, root string) ProjectResult
- func (c Collector) CommitTrackers()
- func (c Collector) ForRefresh(maxCaptures int, claims ...ShellClaims) Collector
- func (c Collector) HostPane(id string) Collector
- func (c Collector) ListPanes(ctx context.Context) ([]Pane, error)
- func (c Collector) Metrics() MetricsSnapshot
- func (c Collector) RefreshProjectStatus(ctx context.Context, previous ProjectResult, allRoots []string, panes []Pane) ProjectResult
- func (c Collector) SeedTrackers(seed map[string]agentactivity.Tracker) Collector
- func (c Collector) TrackerSnapshot() map[string]agentactivity.Tracker
- func (c Collector) ValidateWorkspace(ctx context.Context, workspace Workspace) error
- func (c Collector) WithDefaults() Collector
- func (c Collector) WithShellClaims(claims ShellClaims) Collector
- type ExecRunner
- type Item
- type Kind
- type MetricsSnapshot
- type Pane
- type ProjectResult
- type RefreshMetrics
- type Runner
- type ShellClaims
- type Workspace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalPath ¶
func CanonicalProjectPath ¶
CanonicalProjectPath resolves a configured checkout to its canonical main worktree when Git's linked-worktree metadata is available. Missing and non-Git paths retain their canonical configured identity so they can still produce an independent error result.
func ServerPIDOf ¶ added in v1.11.0
ServerPIDOf returns the tmux server pid a pane listing reported, or 0 when the listing carries none.
Every pane in one listing comes from one server, so the first non-zero value is the answer. Callers use it to qualify a socket-only incarnation with the process behind it, which is the difference between an identity that can be written down and compared later and one that only names a file.
Types ¶
type CaptureFunc ¶ added in v0.98.0
CaptureFunc reads one pane: its capture text and the geometry observed with it. The geometry travels with the capture because a capture's rows alone cannot say where the live grid starts, and a consumer that has to ask separately pairs rows from one instant with a height from another.
type Collector ¶
type Collector struct {
Runner Runner
Capture CaptureFunc
Now func() time.Time
DoneTTL time.Duration
// contains filtered or unexported fields
}
func (Collector) CollectProject ¶
func (c Collector) CollectProject(ctx context.Context, name, root string, allRoots []string, panes []Pane) ProjectResult
CollectProject reads one Git inventory and already-existing Sidecar metadata.
func (Collector) CollectProjectInventory ¶
func (c Collector) CollectProjectInventory(ctx context.Context, name, root string) ProjectResult
CollectProjectInventory reads one project's lightweight Git and existing Sidecar metadata without inspecting tmux or capturing panes. Callers can therefore fan this stage out with the same project bound as the rest of a refresh and paint each result before global shell collision resolution.
func (Collector) CommitTrackers ¶
func (c Collector) CommitTrackers()
CommitTrackers promotes a completed refresh's generation-local activity state. Canceled/stale refreshes are simply never committed.
func (Collector) ForRefresh ¶
func (c Collector) ForRefresh(maxCaptures int, claims ...ShellClaims) Collector
ForRefresh returns a collector sharing provider history with its parent while independently bounding pane captures for one refresh generation.
func (Collector) HostPane ¶ added in v1.4.0
HostPane overrides which pane ID counts as the pane hosting this process. The default comes from TMUX_PANE; tests set a fake one so the exclusion can be exercised against a scripted pane list.
func (Collector) ListPanes ¶
ListPanes takes the single global tmux inventory used by an Overview refresh.
func (Collector) Metrics ¶
func (c Collector) Metrics() MetricsSnapshot
func (Collector) RefreshProjectStatus ¶
func (c Collector) RefreshProjectStatus(ctx context.Context, previous ProjectResult, allRoots []string, panes []Pane) ProjectResult
RefreshProjectStatus reuses an immutable successful project inventory and refreshes only live tmux/provider evidence. It performs no Git or metadata reads, allowing visible polling to stay cheaper than explicit inventory refreshes.
func (Collector) SeedTrackers ¶ added in v0.96.0
func (c Collector) SeedTrackers(seed map[string]agentactivity.Tracker) Collector
SeedTrackers installs persisted activity as the collector's starting state. Entries already observed in this process win: a live reading is always better evidence than a restored one.
func (Collector) TrackerSnapshot ¶ added in v0.96.0
func (c Collector) TrackerSnapshot() map[string]agentactivity.Tracker
TrackerSnapshot copies committed activity for persistence.
func (Collector) ValidateWorkspace ¶
ValidateWorkspace rechecks a card's exact durable identity without creating, migrating, reconciling, or mutating project state.
func (Collector) WithDefaults ¶
func (Collector) WithShellClaims ¶
func (c Collector) WithShellClaims(claims ShellClaims) Collector
type ExecRunner ¶
type ExecRunner struct{}
type Item ¶ added in v0.98.0
type Item struct {
ID string
HostID string
Preview string
ProjectKey, ProjectName string
ProjectRoot string
Kind Kind
Key, Name, Path, Branch string
TaskID string
Provider string
PaneID, TmuxName string
Live, Ambiguous bool
IsMain bool
Agent *agentstatus.Presentation
ObservedAt time.Time
}
Item is the read-only catalog row shared by the Agents board and the global Workspaces browser. Agent is nil for plain shells and worktrees: they are given presentation buckets by the list projection rather than a fabricated semantic state.
func Catalog ¶ added in v0.98.0
func Catalog(result ProjectResult) []Item
Catalog projects a whole project result: every durable shell and Git worktree it holds, agent-backed or not.
type MetricsSnapshot ¶
type MetricsSnapshot struct {
ProjectOps, Captures, MaxCaptures, TrackerCommits int64
}
type Pane ¶
type Pane struct {
ID, Session, Path, Command, Title string
PID int
// ServerPID is the pid of the tmux server that listed this pane, from the
// server-scoped `#{pid}` format. It is the same for every pane in one
// listing and it is here because it is free: the refresh already takes this
// listing, so carrying the server identity on it is what lets shell
// cold-restore eligibility be recorded without a single extra tmux spawn.
//
// Unlike the socket's inode and ctime, a server pid is stable for the
// server's whole lifetime and new after a restart, which is what makes it
// the part of the identity that may be written to disk.
ServerPID int
Dead bool
}
type ProjectResult ¶
type RefreshMetrics ¶
type RefreshMetrics struct {
// contains filtered or unexported fields
}
RefreshMetrics contains privacy-safe operation and concurrency counters for an in-memory refresh. It never includes project paths, pane IDs, or output.
type ShellClaims ¶
ShellClaims records globally reserved agent-shell sessions and their unique owning project. An empty owner marks a collision that no project may claim.
func BuildShellClaims ¶
func BuildShellClaims(results []ProjectResult) ShellClaims
type Workspace ¶
type Workspace struct {
ID, ProjectKey, ProjectName, ProjectRoot string
// HostID names the machine this workspace lives on. Empty means this
// machine, which is what every locally collected workspace is — the field
// exists so a remote row can be an ordinary workspace rather than a
// parallel type with its own rendering. Anything that acts on a workspace
// rather than merely displaying it must check it: an action resolved
// against a local path would operate on the wrong machine's filesystem.
HostID string
// Preview is capture text the collector on the owning machine already
// took. Empty for local workspaces, which read their preview live rather
// than carrying it.
Preview string
Kind Kind
Key, Name, Path, Branch, TaskID string
TmuxName, PaneID, Provider, Namespace string
// Plain marks a workspace collected with no agent evidence at all: a Git
// worktree with no recorded agent. It is the catalog's honest answer to
// "is there an agent here?", and it is what keeps the Agents projection
// identical to what it collected before the catalog carried plain rows.
Plain bool
// IsMain is explicit inventory identity, resolved while collecting Git's
// worktree list. Presentation callers must not guess it from a name.
IsMain bool
// The remaining worktree state git reports. They exist so a presentation
// surface can refuse an action for the same reasons the project surface
// refuses it: a locked worktree cannot be removed, a bare or detached one
// has no branch to act on, and a prunable or missing one is only
// metadata. IsMissing means the directory is gone, whether git has noticed
// (prunable) or not.
IsBare, IsDetached, IsLocked, IsPrunable, IsMissing bool
// Live and Ambiguous describe session health, which is not the same
// question as agent activity: a plain shell or an agentless worktree can
// own a live pane while having no agent semantics at all. Keeping them
// separate is what lets the catalog carry plain workspaces without
// fabricating an agentstatus value for them.
Live, Ambiguous bool
Presentation agentstatus.Presentation
ObservedAt time.Time
// CreatedAt is the shell manifest's record of when this identity was
// written. Empty for worktrees, which have no such record.
CreatedAt time.Time
}
func AgentWorkspaces ¶ added in v0.98.0
AgentWorkspaces is the agent-only projection the Kanban board consumes. It excludes exactly the items with no agent evidence and changes nothing else, so the board keeps the full shared semantic matrix it had before the catalog carried plain workspaces.
func (Workspace) HasAgent ¶ added in v0.98.0
HasAgent reports durable or detected agent evidence. A worktree earns it from its recorded `agent` file; a shell earns it from a configured agent type or from live identification, which is why an unidentified shell can still become an agent on a later status poll. Everything else is plain.
func (Workspace) Item ¶ added in v0.98.0
Item projects one collected workspace into its catalog row.
func (Workspace) Remote ¶ added in v1.11.0
Remote reports whether this workspace lives on another machine. Every mutating path must refuse a remote workspace until Phase C gives the host protocol a request channel; until then an action resolved here would run against a local path that either does not exist or, worse, does.