Documentation
¶
Overview ¶
Package chat is the terminal side of the interactive mode: the slash-command table and its menu, a small line editor with key decoding, and a console that keeps the input line intact while session events print above it. It knows nothing about the API.
Index ¶
Constants ¶
const MaxMenu = 6
MaxMenu is how many commands the menu shows at once.
Variables ¶
var Commands = []Command{ {Name: "new", Args: "[prompt]", Desc: "Start a new session from this repo"}, {Name: "sessions", Desc: "List recent sessions and pick one by number"}, {Name: "switch", Args: "<id>", Desc: "Follow another session"}, {Name: "status", Desc: "Run, queue, last outcome, pull request"}, {Name: "stop", Desc: "Stop the running work (changes are kept)"}, {Name: "steer", Args: "<text>", Desc: "Redirect the run that is going"}, {Name: "queue", Desc: "Show the prompts waiting behind the run"}, {Name: "logs", Args: "[N]", Desc: "Show the last N events (default 30)"}, {Name: "diff", Desc: "What the session changed, per repo"}, {Name: "pr", Desc: "Show and open the pull request"}, {Name: "preview", Desc: "Print preview links (one-time, 60 seconds)"}, {Name: "open", Desc: "Open the session in the browser"}, {Name: "share", Args: "[viewer|collaborator]", Desc: "Turn on a share link and print it"}, {Name: "export", Args: "[csv|xlsx]", Desc: "Save this session's summary row to a file"}, {Name: "mode", Args: "auto|build|plan|ask", Desc: "How the next prompts run"}, {Name: "model", Args: "<id>", Desc: "Model for the next prompts"}, {Name: "attach", Args: "<file>", Desc: "Attach a file to the next prompt"}, {Name: "whoami", Desc: "Who you are and where"}, {Name: "workspace", Args: "[name]", Desc: "List workspaces, or switch for this chat"}, {Name: "login", Desc: "Sign in"}, {Name: "logout", Desc: "Sign out and leave"}, {Name: "clear", Desc: "Clear the screen (the session keeps going)"}, {Name: "help", Aliases: []string{"?"}, Desc: "List every command"}, {Name: "quit", Aliases: []string{"exit"}, Desc: "Leave; the session keeps running"}, }
Commands are all the slash commands, in the order the menu shows them.
var SpinnerFrames = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
SpinnerFrames are the braille frames of the spinner, drawn about ten times a second.
var Words = []string{
"Thinking",
"Looking closer",
"Connecting the dots",
"Weighing options",
"Checking twice",
"Turning it over",
"Following the thread",
"Sorting it out",
"Gathering my thoughts",
"Piecing it together",
"Reading between the lines",
"Taking a careful look",
}
Words are what the status line says between real updates: Waniis's own gentle words.
Functions ¶
func Complete ¶
Complete is the text Tab puts in the input for a command: "/name", plus a space when it takes arguments.
func Describe ¶ added in v0.1.1
Describe says what a real event means for what Waniis is doing, "" when it says nothing new.
Types ¶
type Activity ¶ added in v0.1.1
type Activity struct {
// contains filtered or unexported fields
}
Activity is the live status of a working session: what Waniis is doing now, from the events, and for how long. It is pure and driven by an injected clock, so it can be tested.
func NewActivity ¶ added in v0.1.1
NewActivity returns an idle status.
func (*Activity) Line ¶ added in v0.1.1
Line is the status line: a spinner frame (a static dot without a spinner) and the text.
func (*Activity) Observe ¶ added in v0.1.1
Observe takes one event: a real update replaces what the line says.
type Command ¶
Command is a slash command: its name, the argument hint and a one-line description.
type Console ¶
type Console struct {
Out io.Writer
Raw bool
Width func() int
Prompt func() string // the prompt text, plain
Ed *Editor
Bold func(string) string // styling for the selected menu item; nil: none
Dim func(string) string
// contains filtered or unexported fields
}
Console is the chat's output. In Raw mode (a terminal in raw input mode) it keeps a footer at the bottom: the half-written line of a streaming answer, the live status line, the input line and the command menu. Text written to it scrolls above the footer, which is drawn again after, so the input line stays usable while Waniis streams. Otherwise it is a plain writer.
func (*Console) Edit ¶ added in v0.1.1
func (c *Console) Edit(fn func())
Edit runs fn while holding the console's lock: the input line (Ed) is read when the footer is drawn, which can happen from the stream's goroutine at any time, so every change to it from the key-reading goroutine goes through here.
func (*Console) Hide ¶
func (c *Console) Hide()
Hide removes the footer, finishing any half-written line, and leaves the cursor at the start of an empty line.
func (*Console) Redraw ¶
func (c *Console) Redraw()
Redraw draws the footer again (after a key press).
func (*Console) SetStatus ¶ added in v0.1.1
SetStatus sets the live status line (already styled, no newline); "" removes it.
type Editor ¶
type Editor struct {
Buf []rune
Pos int
Sel int // selected menu item
Dismissed bool // Esc closed the menu until the text changes
Line string
// contains filtered or unexported fields
}
Editor is a one-line editor with history and the slash-command menu. It is pure: it takes keys and changes its state; the Console draws it.