Private
Public Access
1
0

Add LastMessageAt field to conversation

Replaced `LatestConversationMessages` with `LoadConversationList`, which
utilizes `LastMessageAt` for much faster conversation loading in the
conversation listing TUI and `lmcli list` command.
This commit is contained in:
2024-10-21 15:33:20 +00:00
parent 0384c7cb66
commit 07c96082e7
5 changed files with 88 additions and 78 deletions

View File

@@ -13,14 +13,9 @@ import (
"github.com/charmbracelet/lipgloss"
)
type LoadedConversation struct {
Conv conversation.Conversation
LastReply conversation.Message
}
type AppModel struct {
Ctx *lmcli.Context
Conversations []LoadedConversation
Conversations conversation.ConversationList
Conversation *conversation.Conversation
Messages []conversation.Message
Model string
@@ -89,22 +84,6 @@ func (m *AppModel) NewConversation() {
m.ApplySystemPrompt()
}
func (m *AppModel) LoadConversations() (error, []LoadedConversation) {
messages, err := m.Ctx.Conversations.LatestConversationMessages()
if err != nil {
return fmt.Errorf("Could not load conversations: %v", err), nil
}
conversations := make([]LoadedConversation, len(messages))
for i, msg := range messages {
conversations[i] = LoadedConversation{
Conv: *msg.Conversation,
LastReply: msg,
}
}
return nil, conversations
}
func (a *AppModel) LoadConversationMessages() ([]conversation.Message, error) {
messages, err := a.Ctx.Conversations.PathToLeaf(a.Conversation.SelectedRoot)
if err != nil {