recorder

package
v1.97.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package recorder turns a live `docker-agent run --record` TUI session into a ready-to-edit tuitest e2e test.

It wraps the real top-level TUI model and, for every keystroke and mouse click, records the input together with a snapshot of the frame the user was looking at when they acted. After the session ends, GenerateTest replays those events into the pkg/tui/tuitest DSL: typing bursts become Type(...), special keys become Press(...), clicks become ClickText(...), and the frame snapshots are diffed to synthesize WaitFor(Contains(...)) synchronization points. Combined with the model-traffic cassette recorded by the --record proxy, the output is a complete offline regression test.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestNameFromPath

func TestNameFromPath(path string) string

TestNameFromPath derives a Go test name from a cassette path, e.g. "cagent-recording-17.yaml" becomes "TestRecordedCagentRecording17". Paths with no usable characters fall back to a deterministic hash so distinct recordings never collapse to the same test name.

Types

type GenerateOptions

type GenerateOptions struct {
	// TestName is the Go test function name. Derive it with TestNameFromPath
	// so it stays a valid identifier.
	TestName string
	// AgentFile is the agent YAML the session ran with, referenced (and to be
	// copied) into the test's testdata directory.
	AgentFile string
	// CassettePath is the model-traffic cassette recorded alongside the input.
	CassettePath string
}

GenerateOptions parameterizes the generated test source.

type Recorder

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

Recorder is a tea.Model wrapping the real TUI model. All tea.Model methods run on the Bubble Tea message-loop goroutine; GenerateTest must only be called after Program.Run has returned.

func New

func New(inner tea.Model) *Recorder

New wraps inner so its user input is recorded.

func (*Recorder) GenerateTest

func (r *Recorder) GenerateTest(opts GenerateOptions) string

GenerateTest renders the recorded session as a tuitest e2e test. It is not goroutine-safe with the Bubble Tea message loop: call it only after Program.Run has returned, never while the program is still running.

func (*Recorder) HasInput

func (r *Recorder) HasInput() bool

HasInput reports whether any user input was recorded. When false there is nothing worth generating a test from.

func (*Recorder) Init

func (r *Recorder) Init() tea.Cmd

func (*Recorder) SetProgram

func (r *Recorder) SetProgram(p *tea.Program)

SetProgram forwards the running program to the wrapped model so the session supervisor can route runtime events back through it.

func (*Recorder) Update

func (r *Recorder) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Recorder) View

func (r *Recorder) View() tea.View

Jump to

Keyboard shortcuts

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