Private
Public Access
1
0

Chat view cleanup

Replace `waitingForReply` and the `status` string with the `state`
variable.
This commit is contained in:
2024-06-08 21:58:39 +00:00
parent 45df957a06
commit c9e92e186e
5 changed files with 48 additions and 43 deletions

View File

@@ -13,20 +13,6 @@ import (
"github.com/charmbracelet/lipgloss"
)
type focusState int
const (
focusInput focusState = iota
focusMessages
)
type editorTarget int
const (
input editorTarget = iota
selectedMessage
)
// custom tea.Msg types
type (
// sent on each chunk received from LLM
@@ -61,16 +47,38 @@ type (
msgMessageCloned *models.Message
)
type focusState int
const (
focusInput focusState = iota
focusMessages
)
type editorTarget int
const (
input editorTarget = iota
selectedMessage
)
type state int
const (
idle state = iota
loading
pendingResponse
)
type Model struct {
shared.State
shared.Sections
// app state
state state // current overall status of the view
conversation *models.Conversation
rootMessages []models.Message
messages []models.Message
selectedMessage int
waitingForReply bool
editorTarget editorTarget
stopSignal chan struct{}
replyChan chan models.Message
@@ -80,7 +88,6 @@ type Model struct {
// ui state
focus focusState
wrap bool // whether message content is wrapped to viewport width
status string // a general status message
showToolResults bool // whether tool calls and results are shown
messageCache []string // cache of syntax highlighted and wrapped message content
messageOffsets []int
@@ -101,6 +108,7 @@ func Chat(state shared.State) Model {
m := Model{
State: state,
state: idle,
conversation: &models.Conversation{},
persistence: true,
@@ -150,8 +158,6 @@ func Chat(state shared.State) Model {
m.input.FocusedStyle.Base = inputFocusedStyle
m.input.BlurredStyle.Base = inputBlurredStyle
m.waitingForReply = false
m.status = "Press ctrl+s to send"
return m
}