app

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResumeExact       = adapter.ResumeExact
	ResumeHeuristic   = adapter.ResumeHeuristic
	ResumeUnsupported = adapter.ResumeUnsupported
)
View Source
const (
	DiagnosticProfileFallback = "profile_fallback"
)
View Source
const ProbeGlyph = "●"

ProbeGlyph is the character the cli-side CPR measurement prints: it must be East-Asian-Ambiguous (the class that misrenders) and part of our vocabulary.

Variables

View Source
var ErrAmbiguousResume = errors.New("ambiguous heuristic resume")

Functions

func ApplyMouseReporting

func ApplyMouseReporting(enabled bool) bool

func MouseReportingEnabled

func MouseReportingEnabled() bool

func RecordFromSession

func RecordFromSession(sess adapter.Session, mode store.Mode) store.SessionRecord

func SortSessions

func SortSessions(sessions []adapter.Session)

Types

type AttachmentPolicySnapshot

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

func (AttachmentPolicySnapshot) BackDetach

func (p AttachmentPolicySnapshot) BackDetach() bool

func (AttachmentPolicySnapshot) Capabilities

func (AttachmentPolicySnapshot) ControlPrefix

func (p AttachmentPolicySnapshot) ControlPrefix() string

func (AttachmentPolicySnapshot) Mouse

func (AttachmentPolicySnapshot) MouseFiltered

func (p AttachmentPolicySnapshot) MouseFiltered() bool

func (AttachmentPolicySnapshot) OwnsOuterScreen

func (p AttachmentPolicySnapshot) OwnsOuterScreen() bool

type ClientCapabilities

type ClientCapabilities struct {
	FramedOutput     bool `json:"-"`
	RoleEvents       bool `json:"-"`
	LocalMouseFilter bool `json:"-"`
	OwnedScreen      bool `json:"-"`
}

type ClientTemporaryOverride

type ClientTemporaryOverride struct {
	Mouse         *store.MousePolicy `json:"-"`
	ControlPrefix *string            `json:"-"`
	BackDetach    *bool              `json:"-"`
}

type DashboardMode

type DashboardMode uint8

DashboardMode is the primary dashboard surface. Like LayoutClass it is derived from the existing interaction state.

const (
	ModeOperations DashboardMode = iota
	ModeNew
)

type DoctorCheck

type DoctorCheck struct {
	Status  string `json:"status"`
	Count   int    `json:"count,omitempty"`
	Version int    `json:"version,omitempty"`
}

type EffectivePolicy

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

func ResolveProfilePolicy

func ResolveProfilePolicy(input ResolutionInput) (EffectivePolicy, error)

func (EffectivePolicy) Diagnostics

func (p EffectivePolicy) Diagnostics() []PolicyDiagnostic

func (EffectivePolicy) LaunchSnapshot

func (p EffectivePolicy) LaunchSnapshot() LaunchPolicySnapshot

func (EffectivePolicy) NewAttachment

func (p EffectivePolicy) NewAttachment(temporary ClientTemporaryOverride, capabilities ClientCapabilities) (AttachmentPolicySnapshot, error)

func (EffectivePolicy) SelectedProfile

func (p EffectivePolicy) SelectedProfile() string

type EffectiveProfileView

type EffectiveProfileView struct {
	SessionID        string            `json:"session_id"`
	Provider         string            `json:"provider"`
	SelectedProfile  string            `json:"selected_profile"`
	EffectiveProfile string            `json:"effective_profile"`
	Mode             store.Mode        `json:"mode"`
	CommandAlias     string            `json:"command_alias"`
	Mouse            store.MousePolicy `json:"mouse"`
	ControlPrefix    string            `json:"control_prefix"`
	BackDetach       bool              `json:"back_detach"`
	ScrollbackLines  int               `json:"scrollback_lines"`
}

type GlobalDoctorReport

type GlobalDoctorReport struct {
	Store     DoctorCheck      `json:"store"`
	Runtime   DoctorCheck      `json:"runtime"`
	Providers []ProviderDoctor `json:"providers"`
	Profiles  []ProfileDoctor  `json:"profiles"`
}

type GlyphSet

type GlyphSet uint8

GlyphSet selects the vocabulary the tone table renders with.

const (
	// GlyphsUnicode is the full set: ● ○ ✕ ▲ ▸ ▌ ⇄ and hairline rules.
	GlyphsUnicode GlyphSet = iota
	// GlyphsASCII is the degraded set for terminals without UTF-8 or whose
	// fonts draw East-Asian-Ambiguous glyphs two cells wide. Substitution is
	// wholesale rather than per-glyph: a mixed vocabulary is harder to read
	// than a plain one, and the failure is per-terminal, not per-glyph.
	GlyphsASCII
)

type LaunchPolicySnapshot

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

func (LaunchPolicySnapshot) CommandAlias

func (p LaunchPolicySnapshot) CommandAlias() string

func (LaunchPolicySnapshot) Mode

func (p LaunchPolicySnapshot) Mode() store.Mode

func (LaunchPolicySnapshot) Provider

func (p LaunchPolicySnapshot) Provider() string

func (LaunchPolicySnapshot) ProviderPolicy

func (LaunchPolicySnapshot) ScrollbackLines

func (p LaunchPolicySnapshot) ScrollbackLines() int

func (LaunchPolicySnapshot) TERM

func (p LaunchPolicySnapshot) TERM() string

type LayoutClass

type LayoutClass uint8

LayoutClass names the three responsive dashboard geometries. It is derived from the current terminal dimensions; Model deliberately stores no parallel layout booleans that could become contradictory after a resize.

const (
	LayoutCompact LayoutClass = iota
	LayoutStandard
	LayoutWide
)

type Model

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

func New

func New() Model

func NewWithDeps

func NewWithDeps(st *store.Store, reg *adapter.Registry) Model

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() tea.View

type NamedProfile

type NamedProfile struct {
	Name    string        `json:"name"`
	Default bool          `json:"default"`
	Profile store.Profile `json:"profile"`
}

type PolicyDiagnostic

type PolicyDiagnostic struct {
	Code    string
	Profile string
	Scope   string
}

type ProfileDoctor

type ProfileDoctor struct {
	Name   string `json:"name"`
	Status string `json:"status"`
}

type ProfileList

type ProfileList struct {
	DefaultProfile string         `json:"default_profile"`
	Profiles       []NamedProfile `json:"profiles"`
}

type ProfileReferencedError

type ProfileReferencedError struct {
	Name       string
	Default    bool
	SessionIDs []string
}

func (*ProfileReferencedError) Error

func (e *ProfileReferencedError) Error() string

type ProviderDoctor

type ProviderDoctor struct {
	Name        string `json:"name"`
	Status      string `json:"status"`
	OuterScreen string `json:"outer_screen,omitempty"`
	KeyProtocol string `json:"key_protocol,omitempty"`
}

type ProviderPolicyDoctor

type ProviderPolicyDoctor struct {
	OuterScreen string `json:"outer_screen"`
	KeyProtocol string `json:"key_protocol"`
}

type ResolutionInput

type ResolutionInput struct {
	Config         store.Config
	Session        store.SessionRecord
	ProviderPolicy adapter.ProviderTerminalPolicy
}

type ResumeKind

type ResumeKind = adapter.ResumeKind

type ResumeOptions

type ResumeOptions struct {
	AllowLatest bool
}

type Service

type Service struct {
	Store              *store.Store
	Registry           *adapter.Registry
	SessionDiagnostics SessionDiagnosticSource
	// contains filtered or unexported fields
}

func NewService

func NewService(st *store.Store, reg *adapter.Registry) *Service

func (*Service) AssignProfileExact

func (s *Service) AssignProfileExact(id, name string) error

func (*Service) AttachSpec

func (s *Service) AttachSpec(ctx context.Context, id string) (adapter.AttachSpec, error)

func (*Service) AttachSpecExact

func (s *Service) AttachSpecExact(ctx context.Context, agentName, id string) (adapter.AttachSpec, error)

func (*Service) AttachSpecExactWithOptions

func (s *Service) AttachSpecExactWithOptions(ctx context.Context, agentName, id string, opts ResumeOptions) (adapter.AttachSpec, error)

func (*Service) AttachSpecWithOptions

func (s *Service) AttachSpecWithOptions(ctx context.Context, id string, opts ResumeOptions) (adapter.AttachSpec, error)

func (*Service) DispatchNamed

func (s *Service) DispatchNamed(ctx context.Context, agentName, name, prompt, cwd, mode string) (adapter.Session, error)

func (*Service) DispatchNamedWithAlias

func (s *Service) DispatchNamedWithAlias(ctx context.Context, agentName, commandAlias, name, prompt, cwd, mode string) (adapter.Session, error)

func (*Service) DispatchNamedWithAliasProfile

func (s *Service) DispatchNamedWithAliasProfile(ctx context.Context, agentName, commandAlias, name, prompt, cwd, mode, profileName string) (adapter.Session, error)

func (*Service) DoctorGlobal

func (s *Service) DoctorGlobal(ctx context.Context) GlobalDoctorReport

func (*Service) DoctorSession

func (s *Service) DoctorSession(ctx context.Context, id string) (SessionDoctorReport, error)

func (*Service) EffectiveProfileExact

func (s *Service) EffectiveProfileExact(ctx context.Context, id string) (EffectiveProfileView, error)

func (*Service) Find

func (s *Service) Find(ctx context.Context, id string) (adapter.Session, store.Config, error)

func (*Service) FindExact

func (s *Service) FindExact(ctx context.Context, agentName, id string) (adapter.Session, store.Config, error)

FindExact resolves the unique provider/session pair used by the TUI. Unlike Find it deliberately performs no prefix or cross-provider matching.

func (*Service) ListProfiles

func (s *Service) ListProfiles() (ProfileList, error)

func (*Service) LoadSessions

func (s *Service) LoadSessions(ctx context.Context) ([]adapter.Session, store.Config, error)

func (*Service) NotifyClosed

func (s *Service) NotifyClosed(sessionName string) error

NotifyClosed flags the record whose backend session name matches as user-closed. It backs the `uam notify-closed` CLI subcommand. Session hosts normally mark records closed in-process when their agent exits (store.MarkSessionClosed); this stays as the scriptable entry point.

Idempotent: a no-op if the record is already StatusClosedByUser or if no record matches (e.g., uam already deleted it via Ctrl+X / `uam rm`).

func (*Service) PrintList

func (s *Service) PrintList(ctx context.Context, asJSON bool) error

func (*Service) Profile

func (s *Service) Profile(name string) (NamedProfile, error)

func (*Service) PruneStartup

func (s *Service) PruneStartup(ctx context.Context) error

PruneStartup removes long-stale, dead records from the store so sessions.json does not grow unbounded. It is outage-safe: pruning only runs when at least one live session is visible, so a transient failure to scan the session runtime directory (which looks exactly like "no sessions") can never wipe every record. PruneOld then drops records whose process is gone and that have not been seen within pruneMaxAge (F20 Stage 2).

func (*Service) RefreshPRStatuses

func (s *Service) RefreshPRStatuses(ctx context.Context) error

RefreshPRStatuses enriches stale discovered PRs outside the session-discovery path. Only PR-owned fields are persisted, and overlapping passes coalesce.

func (*Service) RemoveProfile

func (s *Service) RemoveProfile(name string) error

func (*Service) Rename

func (s *Service) Rename(ctx context.Context, id, name string) error

func (*Service) RenameExact

func (s *Service) RenameExact(ctx context.Context, agentName, id, name string) error

func (*Service) Restart

func (s *Service) Restart(ctx context.Context, id string) error

Restart replaces a session's agent process while keeping its identity: a running backend session is stopped (soft close, record kept), then resumed under the same name with the provider's resume args so the agent picks its conversation back up. A session that is already stopped simply resumes.

func (*Service) RestartExact

func (s *Service) RestartExact(ctx context.Context, agentName, id string) error

func (*Service) RestartExactWithOptions

func (s *Service) RestartExactWithOptions(ctx context.Context, agentName, id string, opts ResumeOptions) error

func (*Service) RestartWithOptions

func (s *Service) RestartWithOptions(ctx context.Context, id string, opts ResumeOptions) error

func (*Service) ResumeBackground

func (s *Service) ResumeBackground(ctx context.Context, id string) error

ResumeBackground restarts a stopped session's backend session without attaching to it. It is a no-op when the session is already running.

func (*Service) ResumeBackgroundExact

func (s *Service) ResumeBackgroundExact(ctx context.Context, agentName, id string) error

func (*Service) ResumeBackgroundExactWithOptions

func (s *Service) ResumeBackgroundExactWithOptions(ctx context.Context, agentName, id string, opts ResumeOptions) error

func (*Service) ResumeBackgroundWithOptions

func (s *Service) ResumeBackgroundWithOptions(ctx context.Context, id string, opts ResumeOptions) error

func (*Service) SetDefaultAgent

func (s *Service) SetDefaultAgent(agent string) error

func (*Service) SetDefaultProfile

func (s *Service) SetDefaultProfile(name string) error

func (*Service) SetUI

func (s *Service) SetUI(mut func(*store.UISettings)) error

func (*Service) Stop

func (s *Service) Stop(ctx context.Context, id string, remove bool) error

func (*Service) StopExact

func (s *Service) StopExact(ctx context.Context, agentName, id string, remove bool) error

StopExact is the provider-aware TUI variant of Stop. The ID-only method is retained for CLI prefix lookup compatibility.

func (*Service) TogglePin

func (s *Service) TogglePin(ctx context.Context, id string) error

func (*Service) TogglePinExact

func (s *Service) TogglePinExact(ctx context.Context, agentName, id string) error

func (*Service) UpdateProfile

func (s *Service) UpdateProfile(name string, mutate func(*store.Profile) error) error

func (*Service) UpdateProfileOverridesExact

func (s *Service) UpdateProfileOverridesExact(id, provider string, mutate func(*store.SessionProfileOverrides) error) error

func (*Service) UpdateSortIndices

func (s *Service) UpdateSortIndices(sessions []adapter.Session) error

UpdateSortIndices persists the explicit canonical positions carried by each session. Grouped presentation order is not itself a global sort order: only the pair moved inside a workspace has its positions exchanged.

func (*Service) UpdateSortOrder

func (s *Service) UpdateSortOrder(sessions []adapter.Session) error

type SessionDiagnosticSource

type SessionDiagnosticSource interface {
	Doctor(context.Context, string) (session.RuntimeDiagnostic, error)
}

type SessionDoctorReport

type SessionDoctorReport struct {
	SessionID        string                    `json:"session_id"`
	SessionName      string                    `json:"session_name"`
	Provider         string                    `json:"provider"`
	RuntimeStatus    string                    `json:"runtime_status"`
	Runtime          session.RuntimeDiagnostic `json:"runtime"`
	SelectedProfile  string                    `json:"selected_profile"`
	EffectiveProfile string                    `json:"effective_profile"`
	ProviderPolicy   ProviderPolicyDoctor      `json:"provider_policy"`
	FallbackReasons  []string                  `json:"fallback_reasons"`
}

type TermCaps

type TermCaps struct {
	Glyphs GlyphSet
	// AmbiguousWide records the measured width of an East-Asian-Ambiguous
	// glyph when the probe ran (0 = not probed, 1 = narrow, 2 = wide). It is
	// diagnostic — doctor reports it — while Glyphs carries the decision.
	AmbiguousWide int
	// UTF8 records whether the locale advertises UTF-8.
	UTF8 bool
	// Probed reports whether the CPR measurement actually ran (false when
	// stdout is not a TTY, the terminal never answered, or an override
	// short-circuited it).
	Probed bool
}

TermCaps is the result of the startup probe. The zero value is the full Unicode experience, which keeps every existing test rendering exactly what it rendered before.

func ApplyTermCaps

func ApplyTermCaps(caps TermCaps) TermCaps

ApplyTermCaps installs the probe result. It returns the previous value so tests can restore it with defer.

func CapsFromEnvironment

func CapsFromEnvironment(getenv func(string) string, measuredWidth int, probed bool) TermCaps

CapsFromEnvironment resolves the non-probe inputs: locale and overrides. The CPR measurement lives in the cli package (it needs the real TTY before Bubble Tea starts); this half is pure and unit-testable.

Precedence: UAM_ASCII forces ASCII; UAM_WIDE=0 forces Unicode (trust the terminal); a non-UTF-8 locale forces ASCII; otherwise the measured width decides (2 → ASCII), defaulting to Unicode when unmeasured.

func CurrentTermCaps

func CurrentTermCaps() TermCaps

CurrentTermCaps exposes the active capabilities (doctor reports them).

Jump to

Keyboard shortcuts

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