Documentation
¶
Overview ¶
Package launch is a Claude session's launch options and their composition into (and decoding from) the agent command line: remote control, permission mode, model, effort, plus the options that never reach the command line (Headroom proxy, the 1h cache TTL, the branch prefix, the account). The TUI's Session Launch Options modal edits an Options value; the model composes one from config for the workspace terminal it creates.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compose ¶
func Compose(opts Options, auth session.RemoteControlAuth, program, title string) string
Compose composes program in order: remote-control, permission-mode, model, then effort. Headroom Proxy is intentionally absent from composition — it never touches program (see session.HeadroomProxyEnv, applied separately to the tmux session's environment via Instance.HeadroomProxy) — but it still affects composition indirectly: remoteControlProgram receives EffectiveRemoteControl(opts), not raw opts.RemoteControl, so Headroom Proxy being on still forces --remote-control off. This is the authoritative enforcement of the RC/HeadroomProxy exclusivity rule — the UI-level auto-disable (Claude Preferences, Session Launch Options) is the good-UX layer on top, not the only guarantee.
func EffectiveRemoteControl ¶
EffectiveRemoteControl reports whether opts should actually apply the --remote-control flag once Headroom Proxy's exclusivity is accounted for. Compose and every RemoteControlBlocked call site must agree on this value — otherwise a config.json hand-edited to set both ClaudeRemoteControl and HeadroomProxy true (or a Session Launch Options selection reaching that state) would make RemoteControlBlocked report a conflict the composed command doesn't actually have.
func RemoteControlBlocked ¶
func RemoteControlBlocked(auth session.RemoteControlAuth, rcEnabled bool, program string) bool
RemoteControlBlocked reports whether a launch of program should be interrupted to tell the user remote control can't work: the toggle is on (rcEnabled, after EffectiveRemoteControl), the program is Claude, and the launching account's auth was clearly determined incompatible.
Types ¶
type Options ¶
type Options struct {
RemoteControl bool
PermissionMode string
Model string
// Context1M requests Claude's [1m] long-context suffix on Model.
// Applied only when Model accepts it (see
// config.ClaudeModelSupports1M); otherwise silently ignored.
Context1M bool
HeadroomProxy bool
Effort string
CacheTTL1h bool
// BranchPrefix overrides config.BranchPrefix for this one session.
// Unlike the fields above it never reaches the agent command line —
// it is consumed by git worktree setup (see session.Instance.
// SetBranchPrefix), so Parse cannot recover it and the
// restart path seeds it from the instance instead.
BranchPrefix string
// Account is the Claude account to launch under (account.DefaultName
// for the default). Like BranchPrefix it never reaches the command
// line: app records it on the instance (session.Instance.SetAccount),
// and a launch turns it into CLAUDE_CONFIG_DIR.
Account string
}
Options holds the per-session launch overrides. Defined here (rather than in app or ui/overlay) so it's usable both by overlay.SessionLaunchOptions (ephemeral, edited as a plain value) and by the launch-command composition below, without an import cycle back to app or a UI import in core.
func FromConfig ¶
FromConfig snapshots cfg's current global launch-option values into an Options, the same shape edited by the Session Launch Options modal. Returns the zero value (all disabled/default) for a nil cfg — matching the effect the old cfg-nil guards in remoteControlProgram/permissionModeProgram had before this refactor.
func FromSettings ¶
FromSettings is FromConfig over a copy of the settings: what the TUI holds (core.WorkspaceView.Settings).
func Parse ¶
Parse decodes a composed Program string back into the Options that produced it, plus the underlying bare program (binary path/name and any *other* flags) Compose would need to recompose it from scratch. It is the symmetric decode of Compose: scans tokens for --remote-control[=name], --permission-mode <mode>, --model <model>, and --effort <level>, removing each recognized flag (and its value token, where applicable) from the returned base program. Recomposing must start from a bare program — Compose's ApplyXFlag functions insert "right after parts[0]", so calling them again on an already-flagged string would duplicate an existing --permission-mode. A token this doesn't recognize (e.g. a hand-added flag) is left in place in baseProgram and simply doesn't set the corresponding opts field — never an error.
opts.HeadroomProxy and opts.CacheTTL1h are left at their zero value (false) — unlike the other four options, neither is ever baked into Program (see session.HeadroomProxyEnv/CacheTTL1hEnv); callers must seed them from Instance.HeadroomProxy()/CacheTTL1h() and apply them through Instance.SetLaunchOptions instead.