approval

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package approval renders one pending tool-approval request inline and turns keypresses into a ports.Decision.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DecisionMsg

type DecisionMsg struct {
	ToolCallID string
	Decision   ports.Decision
}

DecisionMsg is emitted when the user resolves the active request.

type Model

type Model struct {
	Theme theme.Theme
	Tier  theme.Tier
	// contains filtered or unexported fields
}

Model holds at most one pending request: a new SetRequest replaces whatever was pending. This is the inline prompt the build spec calls for (uikit/config.ApprovalDefaultInline), not a queue-visualising dialog - promotion to a full alt-screen dialog is a later screen, not this component's job.

func New

func New(t theme.Theme, tier theme.Tier) Model

New returns a Model with no request pending.

func (Model) Active

func (m Model) Active() bool

Active reports whether a request is currently awaiting a decision.

func (*Model) Clear

func (m *Model) Clear()

Clear dismisses the prompt without emitting a decision (e.g. tool started out-of-band or turn ended).

func (Model) Height

func (m Model) Height() int

Height is the number of terminal rows View() claims, border included, so the enclosing screen can reserve them without re-rendering. It is 0 when nothing is pending, and CONSTANT while scrolling: the window never grows or shrinks with the offset.

func (Model) ScrollBy

func (m Model) ScrollBy(n int) Model

ScrollBy moves the diff preview window by n lines and returns the model. The offset clamps to [0, total-window], so scrolling past either end is a no-op, never an empty window.

func (*Model) SetRequest

func (m *Model) SetRequest(b uievent.ToolPendingBody)

SetRequest arms the prompt for a new pending tool call. The scroll offset restarts at the top: a new request is a new diff, and a stale offset could land the first view halfway through it.

func (*Model) SetWidth

func (m *Model) SetWidth(w int)

SetWidth records the terminal width so the box renders at a fixed size. Call it on WindowSizeMsg, like the composer.

func (Model) Update

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

Update ignores every Msg except a key press while a request is active.

func (Model) View

func (m Model) View() string

View renders the prompt, or "" when nothing is pending.

The diff preview is a FIXED-height window (ApprovalDiffPreviewLines) into the full diff at the current scroll offset, with a position row ("lines X-Y of Z") when the diff is longer than the window. Fixed height matters: scrolling must never change the rows the prompt claims, or every wrapped line above it reflows on every keystroke (ux-rules.md rule 2.7).

Jump to

Keyboard shortcuts

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