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
- func IsPlacementAction(action string) bool
- func PlacementSplit(placement Placement) string
- type Form
- func (f *Form) Agent() string
- func (f *Form) AgentItems() []modal.DropdownItem
- func (f *Form) ApplyPlacementAction(action string) bool
- func (f *Form) BaseBranch() string
- func (f *Form) Build(width int) *modal.Modal
- func (f *Form) Error() string
- func (f *Form) InitialFocusID() string
- func (f *Form) Kind() Kind
- func (f *Form) KindDisabledReason() string
- func (f *Form) Modal() *modal.Modal
- func (f *Form) Name() string
- func (f *Form) PersistLastAgent()
- func (f *Form) Placement() Placement
- func (f *Form) PlacementSplit() string
- func (f *Form) ProjectIndex() int
- func (f *Form) ProjectKey() string
- func (f *Form) RestoreFocus()
- func (f *Form) SetBranches(branches []string, current string)
- func (f *Form) SetError(msg string)
- func (f *Form) SetKind(k Kind)
- func (f *Form) SetKindFromClickX(x, regionX, regionW int)
- func (f *Form) SetPlacement(placement Placement)
- func (f *Form) ShowPlacement() bool
- func (f *Form) ShowSkip() bool
- func (f *Form) SkipPerms() bool
- func (f *Form) SyncAfterInput()
- func (f *Form) TerminalName() string
- func (f *Form) Validate() string
- type Kind
- type OpenOpts
- type Placement
- type ProjectItem
Constants ¶
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.
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
IsPlacementAction reports that an action came from the placement row, which means "create now with this placement".
func PlacementSplit ¶ added in v1.3.0
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 ¶
Open builds form state and loads last-used agent and that agent's auto-approve. It does not persist last agent.
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
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 (*Form) Build ¶
Build returns the cached modal, rebuilding when width or kind/branch-list visibility change.
func (*Form) InitialFocusID ¶
InitialFocusID is Name, or the kind toggle when Open was given FocusKind.
func (*Form) KindDisabledReason ¶ added in v1.3.0
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) PersistLastAgent ¶
func (f *Form) PersistLastAgent()
PersistLastAgent writes the current agent after a successful modal create.
func (*Form) Placement ¶ added in v1.3.0
Placement is the segmented row's current value; Auto until a placement button is clicked.
func (*Form) PlacementSplit ¶ added in v1.3.0
PlacementSplit is the `--split` value for the current placement.
func (*Form) ProjectIndex ¶
func (*Form) ProjectKey ¶
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 ¶
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) SetKindFromClickX ¶
SetKindFromClickX picks the row under a click on the kind toggle.
func (*Form) SetPlacement ¶ added in v1.3.0
SetPlacement records the placement a button click asked for.
func (*Form) ShowPlacement ¶ added in v1.3.0
ShowPlacement reports that the placement row belongs on screen: only a pane this modal places has somewhere to put it.
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
TerminalName is the name a created terminal split takes: what was typed, or the auto-name.
type Kind ¶
type Kind int
Kind is the workspace type the form will create.
func KindFromClickX ¶
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.
func PlacementFromAction ¶ added in v1.3.0
PlacementFromAction maps a placement button's action to its placement.
type ProjectItem ¶
ProjectItem is one row in the global project combo.