workspacecreate

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 11 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 workspacecreate owns the shared Create Workspace form: presentation and in-memory state. It does not talk to git or tmux. Hosts bind it and submit through workspaceops.

Index

Constants

View Source
const (
	FieldKind    = "create-kind"
	FieldProject = "create-project"
	FieldName    = "create-name"
	FieldBase    = "create-base"
	FieldAgent   = "create-agent"
	FieldSkip    = "create-skip-permissions"
	ActionCreate = "create-submit"
	ActionCancel = "create-cancel"
)

Stable field IDs shared by both hosts.

View Source
const (
	ActionPlaceAuto  = "create-place-auto"
	ActionPlaceRight = "create-place-right"
	ActionPlaceBelow = "create-place-below"
)

Placement button IDs. Each is a create action: clicking one creates immediately with that placement, with no second confirmation.

Variables

This section is empty.

Functions

func IsPlacementAction added in v1.3.0

func IsPlacementAction(action string) bool

IsPlacementAction reports that an action came from the placement row, which means "create now with this placement".

func PlacementSplit added in v1.3.0

func PlacementSplit(placement Placement) string

PlacementSplit is the `--split` value for a placement.

Types

type Form

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

Form is the Create Workspace chooser: inputs, indexes, skip, error, and modal cache.

func Open

func Open(opts OpenOpts) *Form

Open builds form state and loads last-used agent and that agent's auto-approve. It does not persist last agent.

func (*Form) Agent

func (f *Form) Agent() string

func (*Form) AgentItems

func (f *Form) AgentItems() []modal.DropdownItem

AgentItems is this kind's picker (None first for shells, last for worktrees).

func (*Form) ApplyPlacementAction added in v1.3.0

func (f *Form) ApplyPlacementAction(action string) bool

ApplyPlacementAction records a placement button click and reports that the form should now be submitted. One click is the whole gesture.

func (*Form) BaseBranch

func (f *Form) BaseBranch() string

func (*Form) Build

func (f *Form) Build(width int) *modal.Modal

Build returns the cached modal, rebuilding when width or kind/branch-list visibility change.

func (*Form) Error

func (f *Form) Error() string

func (*Form) InitialFocusID

func (f *Form) InitialFocusID() string

InitialFocusID is Name, or the kind toggle when Open was given FocusKind.

func (*Form) Kind

func (f *Form) Kind() Kind

func (*Form) KindDisabledReason added in v1.3.0

func (f *Form) KindDisabledReason() string

KindDisabledReason is why the selected row cannot be created right now, or empty when it can. It is the one gate every create path asks — keyboard, click, and placement button alike — so a disabled row cannot be created through a path that forgot to check.

func (*Form) Modal

func (f *Form) Modal() *modal.Modal

func (*Form) Name

func (f *Form) Name() string

func (*Form) PersistLastAgent

func (f *Form) PersistLastAgent()

PersistLastAgent writes the current agent after a successful modal create.

func (*Form) Placement added in v1.3.0

func (f *Form) Placement() Placement

Placement is the segmented row's current value; Auto until a placement button is clicked.

func (*Form) PlacementSplit added in v1.3.0

func (f *Form) PlacementSplit() string

PlacementSplit is the `--split` value for the current placement.

func (*Form) ProjectIndex

func (f *Form) ProjectIndex() int

func (*Form) ProjectKey

func (f *Form) ProjectKey() string

func (*Form) RestoreFocus

func (f *Form) RestoreFocus()

RestoreFocus applies the pending focus after the modal has been rendered. No-op if focus is already managed by the modal.

func (*Form) SetBranches

func (f *Form) SetBranches(branches []string, current string)

SetBranches replaces the worktree base-branch list. Prefills current as the value unless the typed value is still a branch in the new list.

func (*Form) SetError

func (f *Form) SetError(msg string)

func (*Form) SetKind

func (f *Form) SetKind(k Kind)

func (*Form) SetKindFromClickX

func (f *Form) SetKindFromClickX(x, regionX, regionW int)

SetKindFromClickX picks the row under a click on the kind toggle.

func (*Form) SetPlacement added in v1.3.0

func (f *Form) SetPlacement(placement Placement)

SetPlacement records the placement a button click asked for.

func (*Form) ShowPlacement added in v1.3.0

func (f *Form) ShowPlacement() bool

ShowPlacement reports that the placement row belongs on screen: only a pane this modal places has somewhere to put it.

func (*Form) ShowSkip

func (f *Form) ShowSkip() bool

func (*Form) SkipPerms

func (f *Form) SkipPerms() bool

func (*Form) SyncAfterInput

func (f *Form) SyncAfterInput()

SyncAfterInput rematches combo indexes, reloads auto-approve when the agent changes, and persists skip immediately on toggle.

func (*Form) TerminalName added in v1.3.0

func (f *Form) TerminalName() string

TerminalName is the name a created terminal split takes: what was typed, or the auto-name.

func (*Form) Validate

func (f *Form) Validate() string

Validate reports why Create cannot proceed. Worktree name is required; shell name is optional. Empty return means the form is submittable.

type Kind

type Kind int

Kind is the workspace type the form will create.

const (
	KindShell Kind = iota
	KindWorktree
	// KindTerminalSplit creates a live terminal beside the workspace's own
	// terminal. It owns no branch and no agent, so it needs at most a name.
	KindTerminalSplit
)

func KindFromClickX

func KindFromClickX(x, regionX, regionW int) Kind

KindFromClickX maps a click on the two-row kind toggle to Shell (left) or Worktree (right). It is the host-independent form kept for callers without a form in hand; hosts should use Form.SetKindFromClickX, which knows which rows the form actually offers.

type OpenOpts

type OpenOpts struct {
	Kind      Kind
	FocusKind bool
	// UseLastKind starts the list on the row it was last left on, when that
	// row is one this host offers.
	UseLastKind bool
	// AllowTerminalSplit offers the Terminal split row. A host without a pane
	// tree to place one in leaves it off.
	AllowTerminalSplit bool
	// TerminalSplitDisabled is why a terminal split cannot be created right
	// now — the on-screen live-terminal cap being the one reason today. When
	// it is set the row and its form render disabled with this one line, and
	// the create paths refuse: the modal states the rule instead of offering a
	// creation that would be refused after the fact.
	TerminalSplitDisabled string
	// TerminalName is the auto-name a terminal split takes when the name field
	// is left empty.
	TerminalName   string
	ShowProject    bool
	ProjectKey     string
	Name           string
	Projects       []ProjectItem
	Agents         []string
	Branches       []string
	NextShell      string
	PreferredAgent string
	DefaultAgent   string
}

OpenOpts configures a new form. PreferredAgent and DefaultAgent are the already-resolved fallbacks from the host (.sidecar-agent / defaultAgentType); this package does not load them from disk.

type Placement added in v1.3.0

type Placement int

Placement is where a created pane lands. It is the modal's face of the same vocabulary `sidecar open --split` uses, so the CLI and the modal share one placement model rather than two that agree by hand.

const (
	PlacementAuto Placement = iota
	PlacementRight
	PlacementBelow
)

func PlacementFromAction added in v1.3.0

func PlacementFromAction(action string) (Placement, bool)

PlacementFromAction maps a placement button's action to its placement.

type ProjectItem

type ProjectItem struct {
	Key   string
	Label string
}

ProjectItem is one row in the global project combo.

Jump to

Keyboard shortcuts

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