Fix (f1): load from the card

This commit is contained in:
Grail Finder
2026-02-09 11:29:47 +03:00
parent c04e120ddb
commit 3f4d8a9467
4 changed files with 9 additions and 9 deletions

6
bot.go
View File

@@ -1165,12 +1165,12 @@ func applyCharCard(cc *models.CharCard, loadHistory bool) {
chatBody.Messages = history chatBody.Messages = history
} }
func charToStart(agentName string) bool { func charToStart(agentName string, keepSysP bool) bool {
cc, ok := sysMap[agentName] cc, ok := sysMap[agentName]
if !ok { if !ok {
return false return false
} }
applyCharCard(cc, true) applyCharCard(cc, keepSysP)
return true return true
} }
@@ -1223,7 +1223,7 @@ func summarizeAndStartNewChat() {
return return
} }
// Start a new chat // Start a new chat
startNewChat() startNewChat(true)
// Inject summary as a tool call response // Inject summary as a tool call response
toolMsg := models.RoleMsg{ toolMsg := models.RoleMsg{
Role: cfg.ToolRole, Role: cfg.ToolRole,

View File

@@ -121,12 +121,12 @@ func initSysCards() ([]string, error) {
return labels, nil return labels, nil
} }
func startNewChat() { func startNewChat(keepSysP bool) {
id, err := store.ChatGetMaxID() id, err := store.ChatGetMaxID()
if err != nil { if err != nil {
logger.Error("failed to get chat id", "error", err) logger.Error("failed to get chat id", "error", err)
} }
if ok := charToStart(cfg.AssistantRole); !ok { if ok := charToStart(cfg.AssistantRole, keepSysP); !ok {
logger.Warn("no such sys msg", "name", cfg.AssistantRole) logger.Warn("no such sys msg", "name", cfg.AssistantRole)
} }
// set chat body // set chat body

View File

@@ -206,8 +206,8 @@ func makeChatTable(chatMap map[string]models.Chat) *tview.Table {
} }
// Update sysMap with fresh card data // Update sysMap with fresh card data
sysMap[agentName] = newCard sysMap[agentName] = newCard
applyCharCard(newCard, false) // fetching sysprompt and first message anew from the card
startNewChat() startNewChat(false)
pages.RemovePage(historyPage) pages.RemovePage(historyPage)
return return
default: default:
@@ -543,7 +543,7 @@ func makeAgentTable(agentList []string) *tview.Table {
// notification := fmt.Sprintf("chat: %s; action: %s", selectedChat, tc.Text) // notification := fmt.Sprintf("chat: %s; action: %s", selectedChat, tc.Text)
switch tc.Text { switch tc.Text {
case "load": case "load":
if ok := charToStart(selected); !ok { if ok := charToStart(selected, true); !ok {
logger.Warn("no such sys msg", "name", selected) logger.Warn("no such sys msg", "name", selected)
pages.RemovePage(agentPage) pages.RemovePage(agentPage)
return return

2
tui.go
View File

@@ -1016,7 +1016,7 @@ func init() {
return nil return nil
} }
if event.Key() == tcell.KeyCtrlN { if event.Key() == tcell.KeyCtrlN {
startNewChat() startNewChat(true)
return nil return nil
} }
if event.Key() == tcell.KeyCtrlO { if event.Key() == tcell.KeyCtrlO {