Documentation
¶
Index ¶
- Constants
- func FloatingEdgeBar(cx *core.Scope, scroll *core.Ref) core.Node
- func FloatingMargin(cx *core.Scope, footer core.Points) core.Points
- type Actions
- type Activity
- type ActivityRow
- type Attachment
- type AttachmentPreview
- type Bubble
- type Chip
- type ChipPopover
- type Composer
- type ContextMeter
- type Conversation
- type ConversationState
- type EffortPicker
- type FloatingConversation
- type GlassPanel
- type IconAction
- type Message
- type Option
- type Picker
- type Quota
- type QuotaRow
- type QuotaSummary
- type Reasoning
- type ResultSummary
- type Shimmer
- type Status
- type Step
- type Suggestion
- type SummaryItem
- type Turn
- type View
Constants ¶
FooterHeight is the height of a composer's Footer.
Variables ¶
This section is empty.
Functions ¶
func FloatingEdgeBar ¶
FloatingEdgeBar blurs scroll, a view that scrolls under a resting floating composer with a footer, as FloatingConversation blurs its transcript.
Types ¶
type Actions ¶
type Actions struct {
// Text is what Copy copies.
Text func() string
// OnCopy replaces copying Text, for a message that is not all prose; the
// receipt shows either way.
OnCopy func()
// OnRetry shows a retry, which CanRetry keeps from a reply the app may
// not ask for again; nil CanRetry leaves it always available.
OnRetry func()
CanRetry func() bool
// OnEdit shows an edit, which CanEdit keeps from a message something has
// superseded; nil CanEdit leaves it always available.
OnEdit func()
CanEdit func() bool
// Receipt is how long the copied receipt shows, 1600 ms when 0; pressing
// copy again restarts it.
Receipt time.Duration
// Children are the app's own actions, after these.
Children []core.Node
TestID string
}
Actions are what a message offers a reader: copy with a receipt, retry a reply, and edit a message the user sent. The app says where each applies and its own actions may follow; the words are ui/chat's, through its catalog.
type Activity ¶
type Activity struct {
ID, Action, Detail string
// Icon leads the row, lucide.Wrench when empty.
Icon func() *core.SVG
Status Status
// Content is the expanded detail; nil keeps the activity a single row.
Content View
// Mono presents Content as monospace output rather than prose.
Mono bool
// MaxHeight bounds the expanded detail, which then scrolls; 0 is 400.
MaxHeight core.Points
}
Activity is one step of work inside a Step, such as reading a file, running a command or thinking. ID is stable within its turn, so a tool's result updates its activity however results are ordered. Action is a short verb ("Read") and Detail its target.
type ActivityRow ¶
type ActivityRow struct {
Activity func() Activity
Conversation *ConversationState
}
ActivityRow is one activity as a compact card that can expand to its bounded detail. What the detail costs and how far it is cut is the app's.
type Attachment ¶
type Attachment struct {
Label, Detail, RemoveLabel string
Image core.ImageSource
Icon func() *core.SVG
OnRemove func()
}
Attachment is a compact file chip with an optional remove action, for the composer's Attachments or a prompt. Detail is short trailing text, such as a size. Image is a thumbnail the app prepared; without one, Icon replaces the file icon, such as lucide.Image for an image still on its way. An empty RemoveLabel makes it read-only. It reads no files.
type AttachmentPreview ¶
type AttachmentPreview struct {
Label, RemoveLabel string
Image core.ImageSource
OnRemove func()
}
AttachmentPreview is a 64-point image tile with an optional remove action, for rows of images alone; Attachment keeps mixed rows at one height. Label names the image for assistive technology and its tooltip, and an empty RemoveLabel makes it read-only. Without Image it shows a placeholder: loading and decoding are the app's.
type Chip ¶
type Chip struct {
Text string
// TextFunc replaces Text and may change.
TextFunc func() string
Icon func() *core.SVG
Image core.ImageSource
// Leading replaces Image, which replaces Icon: content at the size
// it is given, such as a product mark in its own colors.
Leading func(cx *core.Scope, size core.Points) core.Node
// Caret marks a chip that opens a choice.
Caret bool
// Yield gives up the row's room before the chips beside it, cutting the
// start of its label, for a name its end tells apart, such as a model's.
Yield bool
// Active keeps the chip lit while what it opens shows.
Active func() bool
OnPress func()
TestID string
}
Chip is a compact composer or footer control for a setting such as a model, reasoning level, project or branch. Its label shortens as the row tightens. A chip with OnPress is a button; without one it is a fixed value, a label rather than a disabled action.
type ChipPopover ¶
type ChipPopover struct {
Chip Chip
Open func() bool
OnOpenChange func(open bool)
Children []core.Node
// Width is the popover's, 260 when 0.
Width core.Points
Label string
TestID string
}
ChipPopover is a Chip that opens the app's Children in a popover, for a choice a Picker's options cannot say: Open is the app's, as OnOpenChange reports it.
type Composer ¶
type Composer struct {
Draft func() string
OnDraftChange func(string)
Label string
Placeholder, SendLabel, StopLabel string
// PlaceholderFunc replaces Placeholder and may change.
PlaceholderFunc func() string
Running func() bool
OnSend, OnStop func()
// Suggest offers rows for the query typed after "@" at the caret. Choosing a row replaces the "@" and the query with its Insert, or its Label when Insert is empty.
Suggest func(query string) []Suggestion
// SuggestLabel names Suggest's list for screen readers, such as "Mentions", apart from the editor's Label.
SuggestLabel string
// Accessory holds controls in the card's bottom row, such as chips, and
// shrinks; Trailing compact ones just before Send or Stop, which do not.
Accessory, Trailing View
// Attachments shows above the editor while HasAttachments is true.
Attachments View
HasAttachments func() bool
Footer View
// OnDropFiles makes the card take files dropped from other apps. It gets their URLs, which core.FileFromURL opens; reading them is the app's.
OnDropFiles func(uris []string)
// OnPaste hears what the user pastes, images and files included.
OnPaste func(core.PasteEvent)
// AutoFocus focuses the editor as the composer mounts, as core.Input's.
AutoFocus bool
// SendDisabled holds Send while attachments are prepared, and
// StopDisabled keeps Stop shown but inactive. Editing stays on.
SendDisabled, StopDisabled func() bool
// Glass puts the card on glass, for a FloatingConversation; its
// State measures it, for the edge's blur. The footer stays off the glass
// so the card stays light.
Glass bool
State *ConversationState
TestID string
}
Composer is a multiline editor card with send and stop and a row of the app's controls. Return sends on desktops and Shift+Return inserts a line; phones keep Return for lines. While Running, Stop shows, and a nonempty draft shows Send instead so the app can interrupt the run with the new message. Labels are the app's; it clears the draft in OnSend and owns cancelling in OnStop.
type ContextMeter ¶
type ContextMeter struct {
Label, Title string
Tooltip, Value func() string
Fraction func() float64
TestID string
}
ContextMeter is a small ring gauge for the composer's Trailing, that opens a panel with the value and a bar. It fills with the accent, warns from 80% and alerts from 95%; the app measures use. Fraction is 0 to 1, or negative with nothing measured. Label is its name and Tooltip its hover text; Title and Value head the panel, such as "Context window" and "61k / 272k (22%)".
type Conversation ¶
type Conversation struct {
State *ConversationState
JumpLabel string
ContentWidth core.Points
Children []core.Node
TestID string
}
Conversation is a bounded scroll viewport with a jump button, which floats over it so showing it never changes the viewport's height. Give its parent a bounded height. Label its button with JumpLabel. It follows the end, and yields as the user scrolls up. ContentWidth caps the transcript's reading width, centered; zero fills the conversation.
type ConversationState ¶
type ConversationState struct {
// contains filtered or unexported fields
}
ConversationState is a transcript's scrolling and its composer's measurements. Keep one per transcript, and share it with the turns and the glass composer in it. The transcript scrolls without virtualizing, which keeps selection across turns, so the app bounds its history.
func NewConversationState ¶
func NewConversationState(cx *core.Scope) *ConversationState
NewConversationState makes a state at the latest turn.
func (*ConversationState) AtLatest ¶
func (s *ConversationState) AtLatest() bool
AtLatest reports whether the transcript follows its end.
func (*ConversationState) ComposerHeight ¶
func (s *ConversationState) ComposerHeight() core.Points
ComposerHeight is the room the floating composer takes at the bottom, for what the app overlays on an empty conversation.
func (*ConversationState) JumpToLatest ¶
func (s *ConversationState) JumpToLatest()
JumpToLatest returns to the end and follows it again.
func (*ConversationState) Scroll ¶
func (s *ConversationState) Scroll() *core.Ref
Scroll is the transcript's scroll view, for a bar over it (View.EdgeBar).
func (*ConversationState) Search ¶
func (s *ConversationState) Search() *textview.Search
Search returns the transcript's search, which Conversation and FloatingConversation provide to every TextView in their children and open with Mod+F in a find bar.
func (*ConversationState) SearchOpen ¶
func (s *ConversationState) SearchOpen() bool
SearchOpen reports whether the transcript's find bar is open.
type EffortPicker ¶
type EffortPicker struct {
// Label names the trigger and the bar, and heads the panel; Tooltip is
// the trigger's hover text, Label when nil.
Label string
Tooltip func() string
Icon func() *core.SVG
// Levels run from the weakest to the strongest; only their ID and
// Label are used.
Levels []Option
Selected func() string
OnChange func(id string)
// Off makes the first level turn reasoning off: the bar empties and
// the icon dims.
Off bool
// Width is the panel's, 260 when 0.
Width core.Points
TestID string
}
EffortPicker is a chip with an icon, the selected level's name and a caret, for the composer's Accessory, that opens a panel with the name and a bar above the levels' names, spread from edge to edge; each level fills the bar to the end of its name. Pressing or dragging across the bar or the names, or the arrows, Home and End, choose a level and keep the panel open. The panel widens to fit the names.
The stronger the level, the livelier all three: the icon turns violet and gains a breathing halo, then streams blocks of data outward; the bar's violet fill gains a glint, then streaming blocks, a glow, flowing colors, sparkles and rising sparks; the panel gains a violet wash, then drifting aurora, floating motes and a turning border. They are shaders on the platform's clock, each fading in or out as the level changes. Reduced motion keeps them still.
type FloatingConversation ¶
type FloatingConversation struct {
State *ConversationState
JumpLabel string
ContentWidth core.Points
Children []core.Node
Composer []core.Node
TopInset core.Points
TestID string
}
FloatingConversation lets the transcript scroll behind the composer, leaving trailing room so the latest turn stays clear of it. The transcript blurs progressively from the bottom edge up to the middle of the composer card at rest, or the whole card on iOS, where nothing else covers the transcript behind it, without following the card as it grows. Give its parent a bounded height; Composer typically builds a Composer with Glass set. It manages no title bar: TopInset clears a bar the host overlays, which the transcript scrolls under. ContentWidth caps the reading width of the transcript and the composer, centered; zero fills the conversation.
type GlassPanel ¶
type GlassPanel struct {
Children []core.Node
Flush bool
StyleFunc func() core.Style
TestID string
}
GlassPanel is a compact card on the composer's glass, for status the host floats over a conversation, such as command output or errors. Its height follows its content. Flush lays the children edge to edge, clipped to its inner corners, and StyleFunc merges over the surface's.
type IconAction ¶
type IconAction struct {
Label string
LabelFunc func() string
Icon func() *core.SVG
IconFunc func() *core.SVG
Active func() bool
Tint func() core.Color
Disabled func() bool
OnPress func()
TestID string
}
IconAction is a named icon button with a tooltip, for a turn's actions or the composer's slots. Active marks a choice in Tint, such as a rating; Label and Icon may follow it through LabelFunc and IconFunc.
type Message ¶
Message lays out a message apart from its surface: an Outgoing one at the trailing edge, an incoming one across the width.
type Option ¶
type Option struct {
ID, Label, Detail, Description, Group string
Icon func() *core.SVG
Image core.ImageSource
Leading func(cx *core.Scope, size core.Points) core.Node
}
Option is one choice of a Picker. ID is stable and nonempty. Group gathers consecutive options under a heading; Detail is trailing text such as a context size, and Description a muted second line. Leading replaces Image, which replaces Icon, and when any option has one the others keep its room.
type Picker ¶
type Picker struct {
// Label is the chip's text and name.
Label func() string
Icon func() *core.SVG
Image core.ImageSource
// Leading leads the chip as Chip's does.
Leading func(cx *core.Scope, size core.Points) core.Node
Options []Option
Selected func() string
OnChange func(id string)
// SearchLabel lets the user filter once there are more than Searchable
// options, 8 when 0; EmptyText shows when nothing matches.
SearchLabel, EmptyText string
Searchable int
// Width is the popover's, 260 when 0.
Width core.Points
TestID string
}
Picker is a chip that opens a popover of grouped, optionally searchable options, with a check on the selection. Choosing closes it and calls OnChange, for the app to apply.
type Quota ¶
type Quota struct {
ID, Title, Note string
Countdown func() string
RefreshLabel, OpenLabel string
Refreshing, Loading func() bool
Leading func(cx *core.Scope, size core.Points) core.Node
Trailing View
Rows func() []QuotaRow
OnRefresh, OnOpen func()
}
Quota lists an account's limits with accent bars of what remains, warning from 20% left and alerting from 5%. The header ends in Countdown, such as the time to the next read ("04:59"), a refresh action when RefreshLabel is set, which Refreshing disables, and an open action when OnOpen's OpenLabel is. Note explains missing or stale rows, and Loading shows placeholders until rows are read. Reading usage is the app's.
type QuotaRow ¶
QuotaRow is one account limit, such as Label "5-hour limit", Detail "Resets in 2h" and Value "63% left". Fraction is the share that remains, 0 to 1; a negative one omits the bar, as for a balance. Pace marks on the bar the share that would remain had the limit been used evenly so far, usually the time left as a share of its window, so a fill short of the mark runs out before it resets; zero omits the mark.
type QuotaSummary ¶
type QuotaSummary struct {
Label string
Tooltip func() string
Row func() QuotaRow
Quotas []Quota
TestID string
}
QuotaSummary is a compact footer control showing Row's Detail, such as the time to reset, and a small bar of what remains, or Value for a balance. Pressing it opens a panel with every Quota. The app chooses the row, usually the limit that applies to the chosen model. Label names it and Tooltip is its hover text.
type Reasoning ¶
type Reasoning struct {
// Text is the reasoning, which the app streams; the block builds
// nothing while it is empty.
Text func() string
// Status reports where the reasoning is: Completed folds the block and
// stops its duration.
Status func() Status
// Elapsed is what the reasoning has cost so far. A running block reads
// it again once a second; without it, ui/chat's labels give no time.
Elapsed func() time.Duration
// Label says the row while it runs ("Thinking for 12s") and Summary
// once it ends ("Thought for 12s"): the app's words, through its
// catalog. A nil Label or Summary reads ui/chat's own.
Label, Summary func() string
// Content replaces the default body, the Text as selectable prose.
Content View
// HoldOpen keeps the block open while the user reads older content, as
// Turn's does.
HoldOpen func() bool
Conversation *ConversationState
TestID string
}
Reasoning is a model's reasoning before its answer. While it streams it stays open with what it has cost so far; once it ends it folds itself, unless the user opened it or is reading older content. A Turn shows it as its Reasoning, after the prompt and apart from the steps, so its text stays where the reader left it however the turn's work is folded.
type ResultSummary ¶
type ResultSummary struct {
Title, Description, ActionLabel, MoreLabel, LessLabel string
Items []SummaryItem
Metadata View
OnAction func()
OnSelect func(id string)
Conversation *ConversationState
}
ResultSummary is a bounded list of artifacts outside the execution fold: three, or up to 100 expanded. MoreLabel and LessLabel say the limits of the app's collection, and Action opens all of it in a view of the app's. Metadata replaces Description. It reads no files.
type Shimmer ¶
type Shimmer struct {
Text func() string
Size core.Points
// Color is the text's, the muted text's when nil, and Highlight the
// band's, the text's when nil.
Color, Highlight func() core.Color
Style core.Style
}
Shimmer is a single line of text of Size in Color with a Highlight sweeping across it, marking ongoing work. It keeps its natural width unless its parent shrinks it, when it ends in an ellipsis. The sweep is a mask the platform moves, so it costs no commits. Reduced motion shows plain text.
type Status ¶
type Status uint8
Status is a turn or activity's lifecycle, as the app reports it. A tool finishing does not finish its turn; only Completed folds it.
type Step ¶
Step is intermediate prose (Message) or a group of activities under a Title the app summarizes, such as "Ran 2 commands".
type Suggestion ¶
type Suggestion struct {
base.SuggestItem
Icon func() *core.SVG
}
Suggestion is a Composer's row: a SuggestItem and the icon drawn before it.
type SummaryItem ¶
SummaryItem is an artifact or result. Its ID is nonempty and unique within the summary; Metadata replaces Detail with badges or metrics the app builds.
type Turn ¶
type Turn struct {
Status func() Status
// Summary labels the completed turn's fold row ("Worked for 2m") and
// Working the live indicator ("Working for 12s").
Summary, Working func() string
Prompt View
// Reasoning shows after the prompt and does not fold with the steps,
// usually a Reasoning.
Reasoning View
Steps func() []Step
// Final is the response, shown once HasFinal is true: the last step
// is never taken for the answer.
Final View
HasFinal func() bool
// Footer holds results or errors and Actions response actions such
// as copy, while ShowActions is true or nil. Neither folds with the
// steps.
Turn is one request and its response: the prompt, the steps and the final response. A completed turn with a final response folds its steps behind a centered summary row and builds nothing hidden; a running turn ends with a pulsing working row. A choice the user makes survives updates. The expansion lives as long as the view does, so key turns by a stable ID.