Help us shape the future of Go! Take the 2026 Go Developer Survey

core

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinMasterRatio = 10
	MaxMasterRatio = 90
	MinMasterCount = 1
	MaxMasterCount = 9
	MinColumnWidth = 10
	MaxColumnWidth = 100
	// MinDiffLimit is the lowest [diff] max_files, max_bytes and max_lines;
	// they have no upper bound.
	MinDiffLimit           = 1
	MinReviewRequestedDays = 0
	// MaxReviewRequestedDays is ten years; the bound also keeps the cutoff's
	// duration far from overflowing.
	MaxReviewRequestedDays = 3650
)

Bounds of the numeric config keys.

View Source
const (
	// KeyNone, as a command, unbinds the key.
	KeyNone = "none"
	// DefaultLeaderKey is the leader when the file sets none.
	DefaultLeaderKey = "ctrl+space"
	// DefaultWhichKeyDelay is the which-key delay in milliseconds.
	DefaultWhichKeyDelay = 300
)

Defaults and sentinels of the [keys] section.

View Source
const (
	MinWhichKeyDelay = 0
	MaxWhichKeyDelay = 5000
)

Bounds of keys.which_key_delay in milliseconds.

View Source
const DefaultTheme = "catppuccin-mocha"

DefaultTheme is the theme used when config.toml does not set one.

View Source
const MaxEdits = 32

MaxEdits is the most places a pane keeps; past it the lowest Seq goes.

View Source
const MaxPanes = 64

MaxPanes is the most panes a state may hold across all tabs; the saved layout file is rejected above it.

Variables

View Source
var (
	ErrNeedsBSP        = errors.New("core: needs a BSP layout")
	ErrNeedsMaster     = errors.New("core: needs a master-stack layout")
	ErrNothingToRotate = errors.New("core: nothing to rotate")
)

Errors the layout actions return when the tab's mode or shape does not fit.

View Source
var (
	ErrSameTab = errors.New("core: the pane is already in that tab")
	ErrNoTab   = errors.New("core: there is no such tab")
	ErrAlone   = errors.New("core: the pane is alone in its tab")
)

Errors MovePane and BreakPane return for a move that cannot or need not happen; the state is unchanged.

View Source
var ErrTooManyPanes = errors.New("core: too many panes")

ErrTooManyPanes is returned by OpenPane and NewTab at MaxPanes panes.

View Source
var ErrUnknownMode = errors.New("core: unknown layout mode")

ErrUnknownMode is returned by SetLayoutMode for a mode that does not exist.

Functions

func AutoSchemes

func AutoSchemes() []string

AutoSchemes lists the allowed layout.auto_scheme values.

func ConfigPath

func ConfigPath(env Env) string

ConfigPath returns the default config file path, the same on Linux and macOS.

func DiffLayouts

func DiffLayouts() []string

DiffLayouts lists the allowed diff.layout values.

func KeyContexts

func KeyContexts() []string

KeyContexts lists the [keys.<context>] tables.

func StateDir

func StateDir(env Env) string

StateDir returns the platform state dir that holds the log and persisted state.

func WorktreeRoots

func WorktreeRoots() []string

WorktreeRoots lists the allowed worktrees.root values.

Types

type Action

type Action interface {
	// contains filtered or unexported methods
}

Action is a state change applied through Store.Dispatch.

type AgentState

type AgentState int

AgentState is what an agent pane is doing, as its harness reports it.

const (
	AgentUnknown AgentState = iota
	AgentIdle
	AgentWorking
	AgentBlocked
)

Agent states, in increasing urgency; AgentUnknown shows no badge.

func (AgentState) String

func (s AgentState) String() string

type Arrangement

type Arrangement struct {
	Rects                   map[PaneID]Rect // drawn panes, each including its frame
	Sizes                   map[PaneID]Rect // every placed pane of the tab, hidden columns included: rects whose content is the PTY size
	HiddenLeft, HiddenRight int             // scrolling columns hidden on each side
}

Arrangement is a tab laid out in a body rect.

func Arrange

func Arrange(t Tab, body Rect, lc LayoutConfig) Arrangement

Arrange lays t out in body. Tiles fill the body edge to edge and each is a pane's rect, framed by its outline; the content is the rect inset by one cell. A pane is drawn only when its rect is at least minPane square, inside body and disjoint from the panes kept before it in pane order; others are in neither map. A body under minPane square stays blank. Zoom is the caller's.

type BreakPane

type BreakPane struct {
	ID   PaneID
	Area Rect
}

BreakPane moves a pane into a new tab of its own and activates it.

type CheckInfo

type CheckInfo struct {
	Name, URL, State       string
	StartedAt, CompletedAt time.Time
	// ID and App are the run's id and the app that made it ("github-actions" for
	// an Actions job); a commit status has ID 0.
	ID  int64
	App string
}

CheckInfo is one check of a pull request. State is pending, success, failure or skipped.

type ClearPreselect

type ClearPreselect struct{}

ClearPreselect drops the active BSP tab's preselection, set or not.

type Clipboard

type Clipboard struct {
	OSC52  *bool `toml:"osc52"`
	Native *bool `toml:"native"`
}

Clipboard is the [clipboard] section. The pointers let an absent key (nil) mean true.

func (Clipboard) NativeOn

func (c Clipboard) NativeOn() bool

NativeOn reports whether copies also go to native clipboard tools on a local session; the default is on.

func (Clipboard) OSC52On

func (c Clipboard) OSC52On() bool

OSC52On reports whether copies are sent as OSC 52; the default is on.

type ClosePane

type ClosePane struct {
	ID PaneID
}

ClosePane removes a pane from its own tab, giving its space to the rest. Closing the focused pane focuses the pane that took its place. The last pane of a tab removes the tab unless it is the only one.

type CloseReview

type CloseReview struct{}

CloseReview closes the active tab's drawer, keeping its pin; with none open it does nothing.

type CloseTab

type CloseTab struct {
	ID TabID
}

CloseTab removes a tab and its panes' metadata. Closing the active tab activates the tab to its left, or the new first tab. The only tab stays, emptied.

type Column

type Column struct {
	Panes []PaneID
	Width float64 // share of the content width, 0.1-1.0
}

Column is one scrolling column.

type Config

type Config struct {
	Theme string `toml:"theme"`
	// Icons is a pointer so an absent key (nil) can mean true.
	Icons        *bool              `toml:"icons"`
	Mouse        Mouse              `toml:"mouse"`
	Clipboard    Clipboard          `toml:"clipboard"`
	Layout       LayoutConfig       `toml:"layout"`
	Diff         DiffConfig         `toml:"diff"`
	Worktrees    WorktreesConfig    `toml:"worktrees"`
	Plans        PlansConfig        `toml:"plans"`
	PullRequests PullRequestsConfig `toml:"pull_requests"`
	Keys         KeysConfig         `toml:"keys"`
}

Config is the user's config.toml.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the config used for keys the file does not set.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig reads the config file at path over the defaults. A missing file gives the defaults; unknown keys are errors, so a typo never goes unnoticed. Values such as theme names are not validated here.

func (Config) IconsOn

func (c Config) IconsOn() bool

IconsOn reports whether Nerd Font glyphs are drawn; the default is on.

type CycleLayoutMode

type CycleLayoutMode struct {
	Area Rect
}

CycleLayoutMode switches the active tab to the next mode: bsp, master-stack, scrolling, bsp.

type CycleTab

type CycleTab struct {
	Delta int
}

CycleTab activates the next (+1) or previous (-1) tab, wrapping.

type DiffConfig

type DiffConfig struct {
	Layout   string `toml:"layout"`    // unified | split: the layout a drawer starts in
	Mode     string `toml:"mode"`      // turn | branch: what a new drawer opens in
	MaxFiles int    `toml:"max_files"` // the engine's limits
	MaxBytes int    `toml:"max_bytes"`
	MaxLines int    `toml:"max_lines"`
}

DiffConfig is the [diff] section. Validate rejects an unknown name or a non-positive limit from a file; the accessors read a zero field as its default so a hand-built DiffConfig behaves as the defaults.

func (DiffConfig) BranchFirst

func (c DiffConfig) BranchFirst() bool

BranchFirst reports whether a new drawer opens in branch mode even when the pane has turns.

func (DiffConfig) Split

func (c DiffConfig) Split() bool

Split reports whether a new drawer starts side by side.

func (DiffConfig) Validate

func (c DiffConfig) Validate() error

Validate names the first key that is unknown or not positive.

type Dir

type Dir int

Dir is a direction for focus, resize and preselection. The zero value is NoDir, so a Tab literal has no preselection.

const (
	NoDir Dir = iota
	Left
	Down
	Up
	Right
)

Directions, in the order of the h j k l keys.

type Edit

type Edit struct {
	Root, Common, Repo string    // as git.Place
	Seq                uint64    // the order the edit hooks arrived in; the highest is the latest
	At                 time.Time // when the latest edit's hook arrived
}

Edit is a worktree an agent made a counted edit in.

type Env

type Env struct {
	GOOS   string
	Home   string
	Getenv func(string) string
}

Env is the part of the process environment that decides AIM's paths.

func DefaultEnv

func DefaultEnv() (Env, error)

DefaultEnv returns the environment of the running process.

type Equalize

type Equalize struct{}

Equalize evens out the active tab's layout: BSP panes become equal along each axis, master-stack goes back to master_ratio and every scrolling column to column_width. It changes nothing for fewer than two panes.

type FocusDir

type FocusDir struct {
	Dir  Dir
	Area Rect
}

FocusDir focuses the pane Neighbour picks on the tiles Arrange lays out in Area; a zero Area uses a fixed large rect. It does nothing at an edge.

type FocusPane

type FocusPane struct {
	ID PaneID
}

FocusPane focuses a pane.

type ForgetEdit

type ForgetEdit struct {
	ID   PaneID
	Root string
}

ForgetEdit drops the entry for Root from an agent's edited places; it changes nothing when the pane has none.

type KeyBind

type KeyBind struct{ Key, Command string }

KeyBind is one entry of a [keys] context.

type KeysConfig

type KeysConfig struct {
	LeaderKey     string `toml:"leader_key"`
	WhichKeyDelay *int   `toml:"which_key_delay"` // milliseconds; nil means the default

	Leader  map[string]string `toml:"leader"`
	Drawer  map[string]string `toml:"drawer"`
	Rail    map[string]string `toml:"rail"`
	PRList  map[string]string `toml:"pr_list"`
	Checks  map[string]string `toml:"checks"`
	Reader  map[string]string `toml:"reader"`
	Merge   map[string]string `toml:"merge"`
	Compose map[string]string `toml:"compose"`

	Order map[string][]string `toml:"-"`
}

KeysConfig is the [keys] section. Validate checks the syntax of the key names; which commands a context takes is the UI's to check. Order keeps each context's keys in file order, since a map does not.

func (KeysConfig) Binds

func (c KeysConfig) Binds(context string) []KeyBind

Binds lists a context's entries in file order. Keys Order lacks (a hand-built config) follow, sorted.

func (KeysConfig) Delay

func (c KeysConfig) Delay() time.Duration

Delay is how long the leader waits before which-key opens.

func (KeysConfig) LeaderName

func (c KeysConfig) LeaderName() string

LeaderName is the leader key, read as the default when unset.

func (KeysConfig) Validate

func (c KeysConfig) Validate() error

Validate names the first key that is malformed.

type LayoutConfig

type LayoutConfig struct {
	DefaultMode    string `toml:"default_mode"`    // bsp | master-stack | scrolling
	AutoScheme     string `toml:"auto_scheme"`     // spiral | longest_side | alternate | smart_split
	MasterRatio    int    `toml:"master_ratio"`    // percent, 10-90
	MasterPosition string `toml:"master_position"` // left | right | top | bottom | center
	MasterCount    int    `toml:"master_count"`    // 1-9
	MasterGrid     *bool  `toml:"master_grid"`     // nil means true
	ColumnWidth    int    `toml:"column_width"`    // percent, 10-100
}

LayoutConfig is the [layout] section. Validate rejects an out-of-range value from a file; the accessors read a zero field as its default so a hand-built LayoutConfig behaves as the defaults.

func (LayoutConfig) Mode

func (c LayoutConfig) Mode() LayoutMode

Mode is the mode new tabs start in.

func (LayoutConfig) Scheme

func (c LayoutConfig) Scheme() tiling.AutoScheme

Scheme is the auto split scheme for BSP.

func (LayoutConfig) Validate

func (c LayoutConfig) Validate() error

Validate names the first key that is out of range or unknown.

type LayoutMode

type LayoutMode string

LayoutMode is how a tab arranges its panes.

const (
	ModeBSP       LayoutMode = "bsp"
	ModeMaster    LayoutMode = "master-stack"
	ModeScrolling LayoutMode = "scrolling"
)

Layout modes.

func LayoutModes

func LayoutModes() []LayoutMode

LayoutModes lists the layout modes in cycle order. Each call returns a fresh slice.

type MarkHunks

type MarkHunks struct {
	Repo     string
	IDs      []string
	Reviewed bool
	Day      string
}

MarkHunks marks the hunk ids reviewed on Day, or unmarks them.

type Mouse

type Mouse struct {
	FocusFollowsMouse bool `toml:"focus_follows_mouse"`
	CopyOnSelect      bool `toml:"copy_on_select"`
}

Mouse is the [mouse] section; both switches are off by default.

type MovePane

type MovePane struct {
	ID     PaneID
	Tab    int
	Follow bool
	Area   Rect
}

MovePane moves a pane to the tab at a 0-based index, or to a new tab at the end when Tab is the tab count. It lands per the target's mode (BSP: at the preselection, else beside the focused pane; master-stack: appended; scrolling: a new column after the focused one) and becomes the target's focused pane. The source loses it as ClosePane would, and an emptied source tab is removed. Follow makes the target active; otherwise the previously active tab stays active, unless it was the removed source tab.

type NewTab

type NewTab struct {
	Kind PaneKind
	Cwd  string
}

NewTab appends a tab whose first pane is a new pane and activates it. An empty active tab (only possible as the only tab) is filled instead, keeping its ID and name.

type Node

type Node struct {
	Pane  PaneID
	Split Split
	Ratio float64
	A, B  *Node
}

Node is a layout tree node: a leaf when Pane is set, otherwise a split with children A (left or top) and B (right or bottom), A taking Ratio of the space.

type NoteEdit

type NoteEdit struct {
	ID      PaneID
	Session SessionID
	Edit    Edit
}

NoteEdit records a worktree Session's agent edited. It changes nothing, and is no error, for a pane that is closed, a shell, or in another session. An entry for the same Root keeps the higher Seq and the later At; past MaxEdits the entry with the lowest Seq goes.

type NotePlan

type NotePlan struct {
	ID   PaneID
	Plan Plan
}

NotePlan replaces an agent's latest plan. It changes nothing, and is no error, for a pane that is closed or a shell; an invalid Plan is an error.

type OpenPane

type OpenPane struct {
	Kind    PaneKind
	Cwd     string
	Split   Split
	Harness string
	Area    Rect
	// Beside, when it names a pane of the tab, places the pane beside that one in
	// place of the focused one. The new pane takes the focus either way.
	Beside PaneID
}

OpenPane puts a new pane beside the active tab's focused pane and focuses it; in BSP a split divides the focused pane with the new pane as child B. The first pane of a tab ignores Split. Area is the body rect the UI lays out in; a zero Area decides auto splits as on a wide screen. Harness is kept only for an agent.

type OpenReview

type OpenReview struct {
	Pane PaneID
	Mode ReviewMode
}

OpenReview opens the active tab's drawer on a pane of that tab, replacing any open one. A pin on another pane ends.

type PRChecks

type PRChecks struct {
	Number  int
	HeadOID string
	Checks  []CheckInfo
}

PRChecks is the checks of one pull request at one head commit.

type PRInfo

type PRInfo struct {
	Number                          int
	Title, URL, Author              string
	State                           string // OPEN, MERGED or CLOSED
	HeadBranch, HeadOID, BaseBranch string
	ReviewDecision, MergeState      string // GitHub's enums as given; "" when null
	Draft, CrossRepo                bool
	ViewerAuthored                  bool // the signed-in user opened it
	ChecksTotal, ChecksDone         int
	ChecksFailed                    int
	UpdatedAt                       time.Time
}

PRInfo is a pull request as the poll sees it. It mirrors the GitHub client's type so that core needs no import of it.

type Pane

type Pane struct {
	Kind       PaneKind
	Cwd        string
	Harness    string     // "claude-code" for agents; "" for shells
	Session    SessionID  // the latest session the agent reported; "" for none
	Transcript string     // that session's transcript file, as the harness reported it
	State      AgentState // not persisted
	Action     string     // the agent's current action from its hooks; not persisted
	AgentCwd   string     // the directory the agent last reported in a hook; not persisted

	Model         string    // the model the agent's status line reported; not persisted
	Context       int       // that status line's context percentage, floored and clamped to 0-100; meaningful with ContextKnown; not persisted
	ContextKnown  bool      // the status line reported a percentage; not persisted
	StatusSession SessionID // the session the status above belongs to; not persisted

	Edits []Edit // the places of this session's counted edits; not persisted

	Plan Plan // the agent's latest plan; a zero Path means none
}

Pane is the metadata of one pane.

func (Pane) FollowDir

func (p Pane) FollowDir() string

FollowDir is the worktree of the latest edit, else WorkDir.

func (Pane) Followed

func (p Pane) Followed() (Edit, bool)

Followed is the edit with the highest Seq, if the pane has any.

func (Pane) WorkDir

func (p Pane) WorkDir() string

WorkDir is the directory the pane works in: the one its agent last reported, else the one it was opened in.

type PaneID

type PaneID string

PaneID names a pane for the session: "p1", "p2", ... and never reused.

func NeighbourSkipping

func NeighbourSkipping(t Tab, d Dir, area Rect, lc LayoutConfig, skip func(PaneID, Rect) bool) (PaneID, bool)

NeighbourSkipping is the pane a focus move reaches from the tab's focused pane in direction d, as FocusDir finds it, but passing over every pane skip reports as out of reach; a nil skip passes over none. skip gets the pane and the rect it is drawn at, which in scrolling is the rect after the focus has moved to it, since that scrolls the columns. A pane that is not drawn is never skipped. It reads the tab and changes nothing.

type PaneKind

type PaneKind string

PaneKind is what a pane runs.

const (
	KindShell PaneKind = "shell"
	KindAgent PaneKind = "agent"
)

Pane kinds.

type Pin

type Pin struct {
	Pane PaneID
	Root string
}

Pin holds a tab's drawer on one worktree while it reviews Pane; not persisted.

type PinReview

type PinReview struct{ Root string }

PinReview holds the open drawer on the worktree at Root, or releases it when Root is empty.

type Plan

type Plan struct {
	Path   string // the plan's markdown file; empty for none
	Root   string // for a plan file, the folder its [plans] path sits under; empty for a plan-mode plan
	Kind   PlanKind
	At     time.Time // when the plan arrived or was last rewritten
	Unread bool
}

Plan is an agent's latest plan: a markdown file, not its text.

func (Plan) Valid

func (p Plan) Valid() bool

Valid reports whether p can be kept: an absolute, clean Path and a known Kind, where a plan file has an absolute, clean Root that strictly holds Path and a plan-mode plan has none.

type PlanKind

type PlanKind uint8

PlanKind says where a plan came from.

const (
	PlanMode PlanKind = iota + 1 // the file ExitPlanMode names
	PlanFile                     // a markdown file under a [plans] paths folder
)

Plan kinds; the zero value is no kind.

type PlansConfig

type PlansConfig struct {
	Paths []string `toml:"paths"`
}

PlansConfig is the [plans] section: the folders, relative to a worktree root, whose markdown files count as plans.

func (PlansConfig) Validate

func (c PlansConfig) Validate() error

Validate names the first entry that is not a relative path inside a worktree.

type Preselect

type Preselect struct {
	Dir Dir
}

Preselect makes the next pane opened in the active BSP tab go to the given side of the focused pane at ratio 0.5. Focus moves keep it; a mode switch and the pane it places clear it.

type Promote

type Promote struct{}

Promote swaps the focused pane with the first pane of a master-stack tab, or with the second when it is first, and focuses the pane now first.

type PullRequestsConfig

type PullRequestsConfig struct {
	ReviewRequestedDays int `toml:"review_requested_days"`
}

PullRequestsConfig is the [pull_requests] section. ReviewRequestedDays limits the Review requested tab to pull requests updated in that many days; 0, the zero value, is no limit.

func (PullRequestsConfig) RequestedSince

func (c PullRequestsConfig) RequestedSince(now time.Time) time.Time

RequestedSince is the oldest update a review request may have at now, or the zero time for no limit. Whole days of 24 hours keep a DST change from moving the cutoff.

func (PullRequestsConfig) Validate

func (c PullRequestsConfig) Validate() error

Validate names the key when the days are out of range.

type ReadPlan

type ReadPlan struct {
	ID PaneID
}

ReadPlan clears the unread flag of a pane's plan; it changes nothing when the pane has none.

type Rect

type Rect struct {
	X, Y, W, H int
}

Rect is a cell rectangle.

type RenameTab

type RenameTab struct {
	ID   TabID
	Name string
}

RenameTab sets a tab's name; "" restores the automatic name.

type RepoMarks

type RepoMarks struct {
	Days map[string]string
	Rev  uint64
}

RepoMarks holds a repository's reviewed-hunk marks: hunk id to the UTC day (2006-01-02) it was last set or shown. Rev changes with every change, so views rebuild on it. Copies of the state share Days, so actions build a new map and never edit one in place.

type RepoPRs

type RepoPRs struct {
	DefaultBranch string
	Open          []PRInfo // the last successful poll, newest update first
	Err           string   // the last poll's failure; "" after a success
	// Methods are the merge methods the repository allows, in the order merge,
	// squash, rebase.
	Methods             []string
	DeleteBranchOnMerge bool
	Focused             *PRChecks         // the focused pull request with its checks, when there is one
	Branch              map[string]PRInfo // per branch, the pull request a lookup found
}

RepoPRs is what is known of one repository's pull requests. State copies share it, so an action replaces a RepoPRs and never edits one in place.

type ResizeDir

type ResizeDir struct {
	Dir Dir
}

ResizeDir moves the nearest BSP divider on the direction's axis by one step: Right and Down grow the first child, Left and Up shrink it. It does nothing when the focused pane has no split on that axis. Master-stack moves the master ratio and scrolling the focused column's width.

type Review

type Review struct {
	Pane PaneID
	Mode ReviewMode
	Tree bool
	PR   *ReviewPR // the pull request the drawer shows instead of a diff; never saved
}

Review is a tab's open review drawer: the pane it reviews, its mode and whether its file tree is open.

type ReviewMode

type ReviewMode string

ReviewMode is what a tab's review drawer shows.

const (
	ReviewTurn   ReviewMode = "turn"
	ReviewBranch ReviewMode = "branch"
)

Review modes.

func ReviewModes

func ReviewModes() []ReviewMode

ReviewModes lists the review modes.

func (ReviewMode) Valid

func (m ReviewMode) Valid() bool

Valid reports whether m is a known mode.

type ReviewPR

type ReviewPR struct {
	Repo   string
	Number int
	Root   string
}

ReviewPR is the pull request a drawer in PR mode shows: its repository keyed "host/owner/name", its number and the worktree root it was opened from.

type RotateSplit

type RotateSplit struct{}

RotateSplit flips the axis of the focused pane's parent split in BSP and keeps its ratio. A lone pane has nothing to rotate.

type SelectTab

type SelectTab struct {
	Index int
}

SelectTab activates the tab at a 0-based index; out of range does nothing.

type SessionID

type SessionID string

SessionID names a harness session, e.g. a Claude Code session UUID.

type SetAgentAction

type SetAgentAction struct {
	ID     PaneID
	Action string
}

SetAgentAction records what an agent is doing right now; empty clears it.

type SetAgentCwd

type SetAgentCwd struct {
	ID  PaneID
	Cwd string
}

SetAgentCwd records the directory an agent reported in a hook; empty clears it.

type SetAgentSession

type SetAgentSession struct {
	ID         PaneID
	Session    SessionID
	Transcript string
	// NewConversation drops the plan: the session does not go on with the old
	// conversation.
	NewConversation bool
}

SetAgentSession records the session an agent reported and its transcript file. An empty Session clears both. An end or a change of session also clears the edited places, and the reported status unless that status already belongs to the new session: a status line can report before its SessionStart hook.

type SetAgentState

type SetAgentState struct {
	ID    PaneID
	State AgentState
}

SetAgentState records what an agent is doing; AgentUnknown clears the badge.

type SetAgentStatus

type SetAgentStatus struct {
	ID           PaneID
	Session      SessionID
	Model        string
	Context      float64
	ContextKnown bool
}

SetAgentStatus records the model and context an agent's status line reported for Session. A false ContextKnown clears the meter and keeps the model; Context is floored and clamped to 0-100.

func (SetAgentStatus) Matches

func (a SetAgentStatus) Matches(p Pane) bool

Matches reports whether p already holds the status a would record.

type SetBranchPR

type SetBranchPR struct {
	Repo, Branch string
	PR           PRInfo
	Found        bool
}

SetBranchPR records the pull request a lookup found for a branch of the repository keyed "host/owner/name"; without Found it forgets the branch's.

type SetLayoutMode

type SetLayoutMode struct {
	Mode LayoutMode
	Area Rect
}

SetLayoutMode rebuilds the active tab in a mode from its pane order: BSP inserts the panes one by one with the auto scheme, master-stack keeps the order with the configured ratio, scrolling makes one column per pane. Split ratios and column widths reset; focus stays, zoom and preselection clear. An empty tab only gets its mode, and the current mode changes nothing. Area is the body rect the UI lays out in.

type SetMarks

type SetMarks struct {
	Repo string
	Days map[string]string
}

SetMarks replaces a repository's marks, as loaded from its file. The first SetMarks for a repository always creates its entry: that records the marks as loaded.

type SetPaneCwd

type SetPaneCwd struct {
	ID  PaneID
	Cwd string
}

SetPaneCwd records a pane's working directory.

type SetPaneKind

type SetPaneKind struct {
	ID      PaneID
	Kind    PaneKind
	Harness string
}

SetPaneKind changes what a pane is. An agent names its harness; becoming a shell clears Harness, Session, Transcript, State, Action, AgentCwd, the reported status and the edited places.

type SetRail

type SetRail struct {
	Open bool
}

SetRail opens or closes the agents rail.

type SetRepoPRs

type SetRepoPRs struct {
	Repo          string
	DefaultBranch string
	Open          []PRInfo
	Err           string

	Methods             []string
	DeleteBranchOnMerge bool
	Focused             *PRChecks
}

SetRepoPRs records a poll of the repository keyed "host/owner/name": its default branch, its open pull requests, merge methods, delete-branch setting, focused pull request's checks and the poll's error, replacing all of them. The branch lookups stay.

type SetReviewMode

type SetReviewMode struct {
	Mode ReviewMode
}

SetReviewMode changes the open drawer's mode.

type SetReviewTree

type SetReviewTree struct {
	Open bool
}

SetReviewTree opens or closes the open drawer's file tree.

type SetTheme

type SetTheme struct {
	Name string
}

SetTheme switches the theme by name. Whether the name is a known theme is the caller's check, since core cannot import the theme package.

type ShowReviewPR

type ShowReviewPR struct {
	Repo   string
	Number int
	Root   string
}

ShowReviewPR puts the open drawer in PR mode on a pull request.

type Split

type Split string

Split is the orientation of a split node.

const (
	SplitVertical   Split = "vertical"
	SplitHorizontal Split = "horizontal"
)

Split orientations: vertical puts the children side by side, horizontal stacks them.

type State

type State struct {
	Theme     string
	Tabs      []Tab // at least one once an action has run
	Active    int   // index into Tabs
	Panes     map[PaneID]Pane
	NextID    int          // last pane number handed out
	NextTabID int          // last tab number handed out
	Layout    LayoutConfig // settings Arrange and the placement helpers read
	Rail      bool         // the agents rail is open; it narrows every pane's body

	// PRs holds each GitHub repository's pull requests, keyed "host/owner/name".
	// It is not saved. Copies of the state share it, so actions replace the map
	// and its values and never edit them in place.
	PRs map[string]RepoPRs

	// Marks holds each repository's reviewed-hunk marks, keyed by its common
	// dir. It is not saved in state.json (the marks have their own files) and
	// copies share it, so actions replace the map and its values.
	Marks map[string]RepoMarks
}

State is the application state; only a Store changes it. A State with no tabs behaves as one empty tab.

func InitialState

func InitialState(cfg Config) State

InitialState returns the state of a fresh session: one empty tab.

func (State) AgentPanes

func (s State) AgentPanes() []PaneID

AgentPanes lists the agent panes by tab, then layout order.

func (State) NewPaneID

func (s State) NewPaneID() PaneID

NewPaneID returns the ID the next OpenPane or NewTab will use.

func (State) OpenPRFor

func (s State) OpenPRFor(repo, branch string) (PRInfo, bool)

OpenPRFor returns the newest same-repository open pull request of a branch in the repository keyed "host/owner/name", from the last poll alone. Newest is the highest number, which is the order of creation.

func (State) PRFor

func (s State) PRFor(repo, branch string) (PRInfo, bool)

PRFor returns the pull request of a branch of the repository keyed "host/owner/name": the open one the last poll lists (see OpenPRFor), else the one a lookup found. A merged lookup record of the same number outranks the poll's entry.

func (State) Reviewed

func (s State) Reviewed(repo, id string) bool

Reviewed reports whether the hunk id is marked in the repository.

func (State) Tab

func (s State) Tab() Tab

Tab returns the active tab.

func (State) TabAgentState

func (s State) TabAgentState(i int) AgentState

TabAgentState is the most urgent state among tab i's agent panes: blocked, working, idle, else AgentUnknown.

func (State) TabHasAgents

func (s State) TabHasAgents(i int) bool

TabHasAgents reports whether tab i holds an agent pane.

func (State) TabOf

func (s State) TabOf(id PaneID) (int, bool)

TabOf returns the index of the tab holding a pane.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store holds the State. It is used only on the Bubble Tea goroutine, so it has no lock.

func NewStore

func NewStore(initial State) *Store

NewStore returns a Store holding initial.

func (*Store) Dispatch

func (s *Store) Dispatch(a Action) error

Dispatch applies a. On error the state is unchanged.

func (*Store) State

func (s *Store) State() State

State returns a copy of the current state; tabs and panes are deep copies, and PRs is shared (see State.PRs).

type SwapDir

type SwapDir struct {
	Dir  Dir
	Area Rect
}

SwapDir exchanges the focused pane with its FocusDir neighbour. In BSP the tree keeps its shape and ratios, so each position keeps its size; focus stays on the moved pane. It does nothing at an edge.

type Tab

type Tab struct {
	ID        TabID
	Name      string     // "" for the automatic name
	Focus     PaneID     // "" when the tab has no pane
	Zoomed    bool       // the focused pane fills the body
	Mode      LayoutMode // never "" once a pane exists
	Panes     []PaneID   // layout order; empty for an empty tab
	Layout    *Node      // the BSP tree; nil outside BSP and for an empty tab
	Master    float64    // master-stack ratio, 0.1-0.9
	Columns   []Column   // scrolling columns, left to right
	First     int        // first visible scrolling column
	Preselect Dir        // NoDir when none; BSP only, not saved
	Review    *Review    // the open review drawer; nil when closed
	Pin       *Pin       // the worktree the drawer is held on; not saved
}

Tab is one workspace: its own layout, focus and zoom, kept as plain values so a state copy is a value copy.

func DefaultLayout

func DefaultLayout(t Tab, lc LayoutConfig) Tab

DefaultLayout returns t with the configured default mode built from t.Panes, for a state file with no usable layout. It needs no screen size: BSP puts the panes side by side in equal columns, master-stack keeps the order at the configured ratio, scrolling makes one column per pane. Focus and zoom stay; preselection clears.

func (Tab) Empty

func (t Tab) Empty() bool

Empty reports whether the tab has no pane.

func (*Tab) KeepVisible

func (t *Tab) KeepVisible()

KeepVisible scrolls a scrolling tab so its focused column is drawn; other modes are unchanged. A restored tab calls it once its focus is set.

type TabID

type TabID string

TabID names a tab for the session: "t1", "t2", ... and never reused.

type ToggleRail

type ToggleRail struct{}

ToggleRail opens the agents rail when it is closed and closes it when open.

type ToggleZoom

type ToggleZoom struct{}

ToggleZoom zooms or unzooms the active tab's focused pane.

type TouchMarks

type TouchMarks struct {
	Repo string
	IDs  []string
	Day  string
}

TouchMarks sets Day on the ids that are already marked with another day.

type WorktreesConfig

type WorktreesConfig struct {
	Root string `toml:"root"` // inside | sibling: where a new worktree goes
}

WorktreesConfig is the [worktrees] section. Validate rejects an unknown root from a file; Sibling reads a zero field as the default, so a hand-built WorktreesConfig behaves as the defaults.

func (WorktreesConfig) Sibling

func (c WorktreesConfig) Sibling() bool

Sibling reports whether a new worktree goes beside the main checkout rather than inside it. internal/git owns the layouts, so the UI maps this to its root style.

func (WorktreesConfig) Validate

func (c WorktreesConfig) Validate() error

Validate names the key when the root is unknown.

Directories

Path Synopsis
Package tiling computes tiled pane layouts: a BSP tree, master-stack and scrolling columns.
Package tiling computes tiled pane layouts: a BSP tree, master-stack and scrolling columns.

Jump to

Keyboard shortcuts

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