Large refactor - it compiles!
This refactor splits out all conversation concerns into a new `conversation` package. There is now a split between `conversation` and `api`s representation of `Message`, the latter storing the minimum information required for interaction with LLM providers. There is necessary conversation between the two when making LLM calls.
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.mlow.ca/mlow/lmcli/pkg/api"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/conversation"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/tui/bubbles"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/tui/model"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/tui/shared"
|
||||
@@ -21,7 +21,7 @@ type (
|
||||
// sent when conversation list is loaded
|
||||
msgConversationsLoaded ([]model.LoadedConversation)
|
||||
// sent when a conversation is selected
|
||||
msgConversationSelected api.Conversation
|
||||
msgConversationSelected conversation.Conversation
|
||||
// sent when a conversation is deleted
|
||||
msgConversationDeleted struct{}
|
||||
)
|
||||
@@ -154,7 +154,7 @@ func (m *Model) Update(msg tea.Msg) (shared.ViewModel, tea.Cmd) {
|
||||
case bubbles.MsgConfirmPromptAnswered:
|
||||
m.confirmPrompt.Blur()
|
||||
if msg.Value {
|
||||
conv, ok := msg.Payload.(api.Conversation)
|
||||
conv, ok := msg.Payload.(conversation.Conversation)
|
||||
if ok {
|
||||
cmds = append(cmds, m.deleteConversation(conv))
|
||||
}
|
||||
@@ -188,9 +188,9 @@ func (m *Model) loadConversations() tea.Cmd {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Model) deleteConversation(conv api.Conversation) tea.Cmd {
|
||||
func (m *Model) deleteConversation(conv conversation.Conversation) tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
err := m.App.Ctx.Store.DeleteConversation(&conv)
|
||||
err := m.App.Ctx.Conversations.DeleteConversation(&conv)
|
||||
if err != nil {
|
||||
return shared.AsMsgError(fmt.Errorf("Could not delete conversation: %v", err))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user