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

@@ -33,7 +33,7 @@ func (m *Model) HandleInput(msg tea.KeyMsg) (bool, tea.Cmd) {
switch msg.String() {
case "esc":
if m.waitingForReply {
if m.state == pendingResponse {
m.stopSignal <- struct{}{}
return true, nil
}
@@ -41,7 +41,7 @@ func (m *Model) HandleInput(msg tea.KeyMsg) (bool, tea.Cmd) {
return shared.MsgViewChange(shared.StateConversations)
}
case "ctrl+c":
if m.waitingForReply {
if m.state == pendingResponse {
m.stopSignal <- struct{}{}
return true, nil
}
@@ -112,15 +112,14 @@ func (m *Model) handleMessagesKey(msg tea.KeyMsg) (bool, tea.Cmd) {
return cmd != nil, cmd
case "ctrl+r":
// resubmit the conversation with all messages up until and including the selected message
if m.waitingForReply || len(m.messages) == 0 {
return true, nil
if m.state == idle && m.selectedMessage < len(m.messages) {
m.messages = m.messages[:m.selectedMessage+1]
m.messageCache = m.messageCache[:m.selectedMessage+1]
cmd := m.promptLLM()
m.updateContent()
m.content.GotoBottom()
return true, cmd
}
m.messages = m.messages[:m.selectedMessage+1]
m.messageCache = m.messageCache[:m.selectedMessage+1]
cmd := m.promptLLM()
m.updateContent()
m.content.GotoBottom()
return true, cmd
}
return false, nil
}
@@ -141,8 +140,8 @@ func (m *Model) handleInputKey(msg tea.KeyMsg) (bool, tea.Cmd) {
m.input.Blur()
return true, nil
case "ctrl+s":
// TODO: call a "handleSend" function with returns a tea.Cmd
if m.waitingForReply {
// TODO: call a "handleSend" function which returns a tea.Cmd
if m.state != idle {
return false, nil
}