accessmodal

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package accessmodal is the TUI's approval surface for browsers asking to sign in to this machine's Sidecar UI API. It is a projection of the API's access-request routes over the Local socket: it lists pending requests for context and approves by the code the person types. Selecting a row never approves, and every rule (code matching, limits, who may approve) stays in internal/uiapi.

Index

Constants

View Source
const (
	// ActionApprove submits the typed code; ActionCancel closes the modal.
	ActionApprove = "approve"
	ActionCancel  = "cancel"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApprovedMsg

type ApprovedMsg struct {
	Host     *Host
	Approval uiapi.AccessApproval
	Err      error
}

ApprovedMsg carries the outcome of an approval.

type Client

type Client interface {
	ListAccessRequests(ctx context.Context) (uiapi.AccessRequestList, error)
	ApproveAccess(ctx context.Context, code, surface string) (uiapi.AccessApproval, error)
}

Client is the slice of the Local-socket API the modal uses.

type Host

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

Host is one open approval modal.

func New

func New(stateDir string, client Client) *Host

New opens a modal for the API server whose state lives in stateDir. A nil client discovers the running server through its endpoint file on each call.

func (*Host) ApplyApproved

func (h *Host) ApplyApproved(msg ApprovedMsg) (done bool, flash string, cmd tea.Cmd)

ApplyApproved records an approval result. It reports whether the modal is done (the browser was let in) and the line to flash; on a refusal it keeps the modal open with the server's reason and reloads the list.

func (*Host) ApplyLoaded

func (h *Host) ApplyLoaded(msg LoadedMsg)

ApplyLoaded records a list result addressed to this modal.

func (*Host) Ensure

func (h *Host) Ensure(termWidth int)

Ensure builds the modal for the terminal width.

func (*Host) HandleKey

func (h *Host) HandleKey(msg tea.KeyPressMsg, termWidth int) (string, tea.Cmd)

HandleKey routes a key and returns an action, if one was chosen.

func (*Host) HandleMouse

func (h *Host) HandleMouse(msg tea.MouseMsg, termWidth int) string

HandleMouse routes a mouse event and returns an action, if one was chosen.

func (*Host) Load

func (h *Host) Load() tea.Cmd

Load fetches the pending requests.

func (*Host) MouseHandler

func (h *Host) MouseHandler() *mouse.Handler

MouseHandler is the hit map the last Render built.

func (*Host) Paste

func (h *Host) Paste(msg tea.PasteMsg) tea.Cmd

Paste routes a bracketed paste into the code field.

func (*Host) Render

func (h *Host) Render(width, height int) string

Render draws the modal.

func (*Host) Submit

func (h *Host) Submit() tea.Cmd

Submit approves the typed code. A code that cannot be one is refused here with the same rule the server applies, without a round trip.

func (*Host) WheelAtBoundary

func (h *Host) WheelAtBoundary(msg tea.MouseWheelMsg) bool

WheelAtBoundary reports whether a wheel event would not scroll the modal.

type LoadedMsg

type LoadedMsg struct {
	Host     *Host
	Requests []uiapi.AccessRequestInfo
	Err      error
}

LoadedMsg carries the pending requests for the modal that asked.

Jump to

Keyboard shortcuts

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