From 3e7499f71afdfaf12a9258f29e1293548b9e1e7b Mon Sep 17 00:00:00 2001 From: "Grail Finder (aider)" Date: Sun, 23 Mar 2025 13:03:15 +0300 Subject: feat: add new_chat_from_card option to reload card and start fresh chat --- tables.go | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'tables.go') diff --git a/tables.go b/tables.go index 16b90ee..f3e5b34 100644 --- a/tables.go +++ b/tables.go @@ -16,7 +16,7 @@ import ( ) func makeChatTable(chatMap map[string]models.Chat) *tview.Table { - actions := []string{"load", "rename", "delete", "update card", "move sysprompt onto 1st msg"} + actions := []string{"load", "rename", "delete", "update card", "move sysprompt onto 1st msg", "new_chat_from_card"} chatList := make([]string, len(chatMap)) i := 0 for name := range chatMap { @@ -131,6 +131,33 @@ func makeChatTable(chatMap map[string]models.Chat) *tview.Table { activeChatName = selectedChat pages.RemovePage(historyPage) return + case "new_chat_from_card": + // Reread card from file and start fresh chat + fi := strings.Index(selectedChat, "_") + agentName := selectedChat[fi+1:] + cc, ok := sysMap[agentName] + if !ok { + logger.Warn("no such card", "agent", agentName) + if err := notifyUser("error", "no such card: "+agentName); err != nil { + logger.Warn("failed to notify", "error", err) + } + return + } + // Reload card from disk + newCard, err := pngmeta.ReadCardFromFile(cc.FilePath, cfg.UserRole) + if err != nil { + logger.Error("failed to reload charcard", "path", cc.FilePath, "error", err) + if err := notifyUser("error", "failed to reload card: "+cc.FilePath); err != nil { + logger.Warn("failed to notify", "error", err) + } + return + } + // Update sysMap with fresh card data + sysMap[agentName] = newCard + applyCharCard(newCard) + startNewChat() + pages.RemovePage(historyPage) + return default: return } -- cgit v1.2.3