Documentation
¶
Overview ¶
Package chat is the chat area of the native desktop: the sessions list, session history and streaming runs (P0 MVP; P1 brings parity with the Web UI: tool cards, diffs, questions, plan/goal, model picker, slash and @).
Index ¶
- type Block
- type Category
- type Chat
- func (ch *Chat) Build(c *ui.Context, r *ui.Route)
- func (ch *Chat) Close()
- func (ch *Chat) HeaderActions(c *ui.Context)
- func (ch *Chat) Open(id string)
- func (ch *Chat) Send(prompt string)
- func (ch *Chat) SidebarPanel(c *ui.Context, collapsed bool)
- func (ch *Chat) Stop()
- func (ch *Chat) Title() string
- type Class
- type Conversation
- func (cv *Conversation) AddPermission(p client.PermissionRequest)
- func (cv *Conversation) AddQuestion(q client.QuestionRequest)
- func (cv *Conversation) Apply(ev client.StreamEvent) (reload bool)
- func (cv *Conversation) BeginAttach()
- func (cv *Conversation) BeginRun(prompt string)
- func (cv *Conversation) FileList() []*FileChange
- func (cv *Conversation) Finish() (reload bool)
- func (cv *Conversation) MergePending(p client.Pending)
- func (cv *Conversation) MergeVCS(entries []client.VCSDiffEntry)
- func (cv *Conversation) Resolve(id string)
- func (cv *Conversation) SetHistory(msgs []client.Message)
- func (cv *Conversation) TrimToLastPrompt()
- type Edit
- type FileChange
- type Item
- type ItemKind
- type Part
- type PartKind
- type Tool
- type ToolMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct {
// Text is set for a text block.
Text *Part
// Events are the thinking/tool parts of an activity group.
Events []*Part
}
Block is a run of consecutive tool calls and thinking parts folded into one activity row, or a text part.
type Category ¶
type Category int
Category is the coarse class of a tool call, used to build the "ran 3 commands · read 2 files" summary of a folded run of calls (web MessageBubble ActivityCategory).
type Chat ¶
type Chat struct {
// contains filtered or unexported fields
}
Chat is the chat area's state. All fields are owned by the UI thread.
func NewSimple ¶
NewSimple returns the simple chat view: the conversation alone, with the sessions panel collapsible and no goal/plan banners.
func (*Chat) HeaderActions ¶
HeaderActions adds the context badge, panel toggles and new-session button.
func (*Chat) SidebarPanel ¶ added in v1.5.1
SidebarPanel implements app.SidebarPanel: the sessions toggle under the navigation and, in the expanded sidebar, the sessions themselves (below the services entries). On the icon rail the toggle shows or hides the sessions column beside the chat.
type Conversation ¶
type Conversation struct {
// ID is empty until the server assigns the session (new chat).
ID string
Items []*Item
// List is the transcript list state (follows the end).
List ui.ListState
// Loaded reports the history was fetched; Loading while it is.
Loaded, Loading bool
LoadErr string
// Running: a run is active server side (own, or followed).
Running bool
// Streaming: this client has a stream open for the run.
Streaming bool
// RunSeq is the last run sequence seen.
RunSeq int64
Usage *client.TokenUsage
// ContextWindow is the context size of the session's model (0 unknown).
ContextWindow int64
// BusyElsewhere: another process (a subagent) runs the session.
BusyElsewhere bool
Plan []client.PlanEntry
Goal *client.GoalStatus
// Files are the modified files of the session by path.
Files map[string]*FileChange
// AutoApprove mirrors the session's auto-approve state.
AutoApprove bool
// Permissions and Questions wait for an answer, oldest first.
Permissions []client.PermissionRequest
Questions []client.QuestionRequest
// Queued is feedback sent while the run goes on, not yet injected.
Queued []string
// contains filtered or unexported fields
}
Conversation is the transcript and run state of one session.
func SpikeConversation ¶
func SpikeConversation(n int) *Conversation
SpikeConversation builds n alternating rows of realistic markdown.
func (*Conversation) AddPermission ¶
func (cv *Conversation) AddPermission(p client.PermissionRequest)
AddPermission queues a permission request unless already seen.
func (*Conversation) AddQuestion ¶
func (cv *Conversation) AddQuestion(q client.QuestionRequest)
AddQuestion queues a question request unless already seen.
func (*Conversation) Apply ¶
func (cv *Conversation) Apply(ev client.StreamEvent) (reload bool)
Apply folds a stream event into the transcript. It reports whether the history should be reloaded (a finished run whose replay brought nothing).
func (*Conversation) BeginAttach ¶
func (cv *Conversation) BeginAttach()
BeginAttach marks the conversation as following a run it did not start.
func (*Conversation) BeginRun ¶
func (cv *Conversation) BeginRun(prompt string)
BeginRun adds the user's prompt and marks a run as started by this client.
func (*Conversation) FileList ¶
func (cv *Conversation) FileList() []*FileChange
FileList returns the modified files, most recently updated first.
func (*Conversation) Finish ¶
func (cv *Conversation) Finish() (reload bool)
Finish ends the run: every row is done. It reports whether the run delivered no content (a replay of a run already over), in which case the history holds the result and should be reloaded.
func (*Conversation) MergePending ¶
func (cv *Conversation) MergePending(p client.Pending)
MergePending adopts the requests of GET /pending (the poll that catches prompts a dropped stream never delivered) and forgets queued ones the server no longer lists.
func (*Conversation) MergeVCS ¶
func (cv *Conversation) MergeVCS(entries []client.VCSDiffEntry)
MergeVCS adds the paths agent-vcs knows the session touched that the history did not name.
func (*Conversation) Resolve ¶
func (cv *Conversation) Resolve(id string)
Resolve removes an answered request from the queues.
func (*Conversation) SetHistory ¶
func (cv *Conversation) SetHistory(msgs []client.Message)
SetHistory replaces the transcript with folded history.
func (*Conversation) TrimToLastPrompt ¶
func (cv *Conversation) TrimToLastPrompt()
TrimToLastPrompt drops the rows after the last user prompt: a run being attached replays them.
type FileChange ¶
type FileChange struct {
Path string
Name string
Additions int
Removals int
// FromVCS: the entry came from agent-vcs only (no inline edits).
FromVCS bool
Edits []Edit
Updated int
}
FileChange is a file the session modified (the modified-files panel).
type Item ¶
type Item struct {
// Key is stable for the life of the row (list identity).
Key int
Kind ItemKind
// Text is the text of user/notice/error/persona rows.
Text string
// Images are data URLs attached to a user message.
Images []string
// Parts is the assistant turn: text, thinking and tool calls in order.
Parts []*Part
// Done is false while an assistant row is still streaming.
Done bool
Model string
Time time.Time
Routing *client.RoutingInfo
ContextFilter *client.ContextFilterInfo
// Open: a collapsible row (persona, context filter) is expanded.
Open bool
// Group expansion state, keyed by the part key that starts the group.
GroupOpen map[int]bool
}
Item is a row of the transcript.
func FoldHistory ¶
FoldHistory turns stored messages into transcript rows: tool messages are folded into the call they answer (as the Web UI does), finish and empty parts dropped, and consecutive assistant messages (one per agent step) merged into a single turn.
type Part ¶
type Part struct {
Key int
Kind PartKind
Text string
Tool *Tool
// Open: a thinking part is expanded.
Open bool
}
Part is one piece of an assistant turn.
type Tool ¶
type Tool struct {
ID string
Name string
Title string
Kind string
Status string
Input string
Output string
IsError bool
Open bool
Locations []client.Location
Diff *client.ToolDiff
Terminal *client.ToolTerminal
// Images are data URLs of image results (screenshots).
Images []string
// contains filtered or unexported fields
}
Tool is a tool call shown in an assistant turn, with its result once it arrives.
func GroupSummary ¶
func GroupSummary(events []*Part, T func(string, ...any) string) (summary string, failures int, live *Tool)
GroupSummary builds "ran 3 commands · read 2 files" for a group, in the Web UI's category order, with the failure count.
type ToolMeta ¶
ToolMeta describes how a call is shown.
func MetaOf ¶
MetaOf classifies a call by its name and input, then lets the server's kind and title win (they mirror ACP), as the Web UI does.
func (ToolMeta) ProgressLabel ¶
ProgressLabel is "bash $ command" style text for the live call of a group.