workspacecreate

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 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.

Variables

This section is empty.

Functions

This section is empty.

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) 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) 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) 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 (SetFocus needs the focus ID list Render builds).

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 Shell or Worktree from a click on the kind toggle.

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) 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
)

func KindFromClickX

func KindFromClickX(x, regionX, regionW int) Kind

KindFromClickX maps a click on the kind toggle to Shell (left half) or Worktree (right half). regionX/regionW are the toggle's hit-region bounds.

type OpenOpts

type OpenOpts struct {
	Kind           Kind
	FocusKind      bool
	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 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