edit

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package edit implements Cmd-K-style inline AI edits. The pane wraps a short prompt for the model and streams the result back as a diff preview. One pane edits one line at a time; selection ranges are a follow-up.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AcceptMsg

type AcceptMsg struct {
	Path    string
	Line    int    // 0-based line number to replace
	NewText string // proposed replacement line
}

AcceptMsg is emitted when the user accepts the proposed edit. Host inserts NewText at the original line.

type CancelMsg

type CancelMsg struct{}

CancelMsg means the user dismissed the pane without applying.

type Pane

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

Pane is the immutable model for the inline edit overlay.

func NewPane

func NewPane(t theme.Theme, client *ai.Client) Pane

NewPane constructs an empty pane. The client may be nil; in that case the pane shows a status message instead of streaming.

func (Pane) Open

func (p Pane) Open(path string, line int, original string) Pane

Open targets a (path, line) pair. The pane resets prompt+proposed and returns to StateComposing.

func (Pane) Proposed

func (p Pane) Proposed() string

Proposed returns the current proposed text (may be partial during streaming).

func (Pane) State

func (p Pane) State() State

State reports the current state. Useful in tests.

func (Pane) Update

func (p Pane) Update(msg tea.Msg) (Pane, tea.Cmd)

Update handles keystrokes and stream messages.

func (Pane) View

func (p Pane) View() string

View renders the floating overlay.

func (Pane) WithSize

func (p Pane) WithSize(w, h int) Pane

WithSize updates layout dimensions.

type State

type State int

State enumerates the four shapes the pane can take.

const (
	StateComposing State = iota // user is typing an instruction
	StateStreaming              // model is streaming back
	StateReview                 // accept/reject the proposed edit
	StateError                  // surface an error and let user retry/cancel
)

type SubmittedMsg

type SubmittedMsg struct{}

SubmittedMsg is fired internally when the user presses Enter from StateComposing. The host doesn't need to react to this.

Jump to

Keyboard shortcuts

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