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
}
func charToStart(agentName string) bool {
func charToStart(agentName string, keepSysP bool) bool {
cc, ok := sysMap[agentName]
if !ok {
return false
}
applyCharCard(cc, true)
applyCharCard(cc, keepSysP)
return true
}
@@ -1223,7 +1223,7 @@ func summarizeAndStartNewChat() {
return
}
// Start a new chat
startNewChat()
startNewChat(true)
// Inject summary as a tool call response
toolMsg := models.RoleMsg{
Role: cfg.ToolRole,

View File

@@ -121,12 +121,12 @@ func initSysCards() ([]string, error) {
return labels, nil
}
func startNewChat() {
func startNewChat(keepSysP bool) {
id, err := store.ChatGetMaxID()
if err != nil {
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)
}
// set chat body

View File

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

2
tui.go
View File

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