Private
Public Access
1
0

tui: renamed stateConversation -> stateChat

stateConversationList -> stateConversations
This commit is contained in:
2024-03-31 02:29:35 +00:00
parent 811ec4b251
commit 020db40401
3 changed files with 47 additions and 46 deletions

View File

@@ -24,28 +24,15 @@ import (
type appState int
const (
stateConversation = iota
stateConversationList
stateChat = iota
stateConversations
//stateModelSelect // stateOptions?
//stateHelp
)
type focusState int
const (
focusInput focusState = iota
focusMessages
)
type editorTarget int
const (
input editorTarget = iota
selectedMessage
)
// we populate these fields as part of Update(), and let View() be
// responsible for returning the final composition of elements
// this struct holds the final rendered content of various UI components, and
// gets populated in the application's Update() method. View() simply composes
// these elements into the final view
type views struct {
header string
content string
@@ -113,7 +100,7 @@ func initialModel(ctx *lmcli.Context, convShortname string) model {
views: &views{},
}
m.state = stateConversation
m.state = stateChat
m.content = viewport.New(0, 0)
@@ -155,11 +142,11 @@ func (m model) Init() tea.Cmd {
m.waitForReply(),
}
switch m.state {
case stateConversation:
case stateChat:
if m.convShortname != "" {
cmds = append(cmds, m.loadConversation(m.convShortname))
}
case stateConversationList:
case stateConversations:
cmds = append(cmds, m.loadConversations())
}
return tea.Batch(cmds...)
@@ -180,10 +167,10 @@ func (m *model) handleGlobalInput(msg tea.KeyMsg) tea.Cmd {
}
default:
switch m.state {
case stateConversation:
return m.handleConversationInput(msg)
case stateConversationList:
return m.handleConversationListInput(msg)
case stateChat:
return m.handleChatInput(msg)
case stateConversations:
return m.handleConversationsInput(msg)
}
}
return nil
@@ -210,10 +197,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
switch m.state {
case stateConversationList:
cmds = append(cmds, m.handleConversationListUpdate(msg)...)
case stateConversation:
cmds = append(cmds, m.handleConversationUpdate(msg)...)
case stateConversations:
cmds = append(cmds, m.handleConversationsUpdate(msg)...)
case stateChat:
cmds = append(cmds, m.handleChatUpdate(msg)...)
}
return m, tea.Batch(cmds...)
@@ -233,12 +220,12 @@ func (m model) View() string {
}
switch m.state {
case stateConversationList:
case stateConversations:
sections = append(sections, m.views.content)
if m.views.error != "" {
sections = append(sections, m.views.error)
}
case stateConversation:
case stateChat:
sections = append(sections, m.views.content)
if m.views.error != "" {
sections = append(sections, m.views.error)
@@ -257,7 +244,7 @@ func (m *model) headerView() string {
titleStyle := lipgloss.NewStyle().Bold(true)
var header string
switch m.state {
case stateConversation:
case stateChat:
var title string
if m.conversation != nil && m.conversation.Title != "" {
title = m.conversation.Title
@@ -266,7 +253,7 @@ func (m *model) headerView() string {
}
title = truncateToCellWidth(title, m.width-headerStyle.GetHorizontalPadding(), "...")
header = titleStyle.Render(title)
case stateConversationList:
case stateConversations:
header = titleStyle.Render("Conversations")
}
return headerStyle.Width(m.width).Render(header)