Documentation
¶
Overview ¶
Package chatthread renders a vertically-stacked conversation of role-aware chat bubbles with viewport-style scrolling. It composes chat-bubble and expects the consumer to drive Append/Scroll via their own tea.Model.
Scroll is measured in lines from the bottom. offset == 0 means the latest message is visible at the bottom of the viewport. Increase offset to look back in history.
Index ¶
- type Message
- type Thread
- func (th Thread) Append(m Message) Thread
- func (th Thread) Init() tea.Cmd
- func (th Thread) Messages() []Message
- func (th Thread) ScrollDown(n int) Thread
- func (th Thread) ScrollToBottom() Thread
- func (th Thread) ScrollToTop() Thread
- func (th Thread) ScrollUp(n int) Thread
- func (th Thread) Update(msg tea.Msg) (Thread, tea.Cmd)
- func (th Thread) View() string
- func (th Thread) WithMessages(msgs []Message) Thread
- func (th Thread) WithSize(w, h int) Thread
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct {
Role chatbubble.Role
Label string
Text string
}
Message is one row in the thread.
type Thread ¶
type Thread struct {
// contains filtered or unexported fields
}
Thread holds an ordered list of messages and a line-based scroll offset.
func (Thread) Append ¶
Append adds a message to the bottom of the thread. Snaps to the bottom unless the user has scrolled up — preserve their position in that case.
func (Thread) ScrollDown ¶
ScrollDown moves the viewport down by n lines.
func (Thread) ScrollToBottom ¶
ScrollToBottom snaps to the latest line.
func (Thread) ScrollToTop ¶
ScrollToTop scrolls all the way up.
func (Thread) WithMessages ¶
WithMessages replaces the entire message list and snaps to the bottom.
