app

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Package app is the Bubble Tea application layer: the controller that owns the home model, routes keyboard input, and composes the ui view components.

Keyboard dispatch is two-staged: handleKeyPress in app.go selects a per-state handler in state_*.go, and within the default state keys flow through the Lua script engine via app_scripts.go's scriptHost adapter. The canonical keymap is script/defaults.lua, which users can extend or override from ~/.loom/scripts/*.lua.

Concurrency: the Lua script.Engine is not goroutine-safe, so every dispatch runs under the engine's mutex via a tea.Cmd goroutine; the goroutine emits a scriptDoneMsg that the main loop consumes in handleScriptDone. Never touch Bubble Tea state from inside the Lua engine — queue it on scriptHost and finalize on the main goroutine.

Index

Constants

View Source
const GlobalInstanceLimit = 10

GlobalInstanceLimit caps the number of simultaneously-tracked instances per workspace slot. Once reached, New/Prompt flows short- circuit with an error-bar message instead of allocating another worktree. The cap is a soft guardrail — tmux server memory and git worktree overhead are the real upper bound; raise deliberately.

Variables

This section is empty.

Functions

func ParseLaunchOptions added in v0.6.0

func ParseLaunchOptions(program string) (opts overlay.LaunchOptions, baseProgram string)

ParseLaunchOptions decodes a composed Program string back into the overlay.LaunchOptions that produced it, plus the underlying bare program (binary path/name and any *other* flags) applyLaunchOptions would need to recompose it from scratch. It is the symmetric decode of applyLaunchOptions: 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 — applyLaunchOptions'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/apply them from Instance.HeadroomProxy/CacheTTL1h directly instead.

func Run

func Run(ctx context.Context, wsCtx *config.WorkspaceContext, registry *config.WorkspaceRegistry, appConfig *config.Config, program string, pendingDir string, noScripts bool) error

Run starts the Bubble Tea program and blocks until the user quits or ctx is cancelled. It wires the home model, installs a shutdown hook that drains suspended Lua coroutines, and swallows no errors — a non-nil return means tea.Program.Run failed.

Parameters:

  • wsCtx is the resolved workspace context; nil falls back to the global config directory.
  • registry is the workspace registry for the startup workspace picker.
  • appConfig is the pre-loaded config from the resolved workspace dir.
  • program overrides the default agent command for new instances (empty string uses appConfig.GetProgram()).
  • pendingDir is an optional directory to seed the new-instance overlay with (used by `loom` invoked from a non-workspace dir).
  • noScripts disables loading user scripts from ~/.loom/scripts; embedded defaults still load so core keybindings work.

Types

This section is empty.

Jump to

Keyboard shortcuts

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