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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user