diff options
author | Grail Finder (aider) <wohilas@gmail.com> | 2025-03-23 13:03:15 +0300 |
---|---|---|
committer | Grail Finder (aider) <wohilas@gmail.com> | 2025-03-23 13:03:15 +0300 |
commit | 3e7499f71afdfaf12a9258f29e1293548b9e1e7b (patch) | |
tree | 9baad02a561a95dee88ec1b224983a6657bf4e18 | |
parent | 98d48228d872ea4910247fd32d537dcfad149309 (diff) |
feat: add new_chat_from_card option to reload card and start fresh chat
-rw-r--r-- | tables.go | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -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 } |