Fix: KnowTo is added only if tag present

This commit is contained in:
Grail Finder
2026-01-17 13:03:30 +03:00
parent 0fb5921004
commit 3e2a1b6f99
3 changed files with 26 additions and 12 deletions

5
bot.go
View File

@@ -124,8 +124,8 @@ func processMessageTag(msg models.RoleMsg) models.RoleMsg {
// For simplicity, if knownTo is not nil, replace. // For simplicity, if knownTo is not nil, replace.
if knownTo != nil { if knownTo != nil {
msg.KnownTo = knownTo msg.KnownTo = knownTo
} // Only ensure sender role is in KnownTo if there was a tag
// Ensure sender role is in KnownTo // This means the message is intended for specific characters
if msg.Role != "" { if msg.Role != "" {
senderAdded := false senderAdded := false
for _, k := range msg.KnownTo { for _, k := range msg.KnownTo {
@@ -138,6 +138,7 @@ func processMessageTag(msg models.RoleMsg) models.RoleMsg {
msg.KnownTo = append(msg.KnownTo, msg.Role) msg.KnownTo = append(msg.KnownTo, msg.Role)
} }
} }
}
return msg return msg
} }

View File

@@ -436,7 +436,7 @@ func TestProcessMessageTag(t *testing.T) {
wantMsg: models.RoleMsg{ wantMsg: models.RoleMsg{
Role: "Alice", Role: "Alice",
Content: "Hello everyone", Content: "Hello everyone",
KnownTo: []string{"Alice"}, KnownTo: nil,
}, },
}, },
{ {

13
tui.go
View File

@@ -93,6 +93,7 @@ var (
[yellow]Alt+4[white]: edit msg role [yellow]Alt+4[white]: edit msg role
[yellow]Alt+5[white]: toggle system and tool messages display [yellow]Alt+5[white]: toggle system and tool messages display
[yellow]Alt+6[white]: toggle status line visibility [yellow]Alt+6[white]: toggle status line visibility
[yellow]Alt+7[white]: toggle role injection (inject role in messages)
[yellow]Alt+8[white]: show char img or last picked img [yellow]Alt+8[white]: show char img or last picked img
[yellow]Alt+9[white]: warm up (load) selected llama.cpp model [yellow]Alt+9[white]: warm up (load) selected llama.cpp model
@@ -828,6 +829,18 @@ func init() {
} }
updateStatusLine() updateStatusLine()
} }
// Handle Alt+7 to toggle injectRole
if event.Key() == tcell.KeyRune && event.Rune() == '7' && event.Modifiers()&tcell.ModAlt != 0 {
injectRole = !injectRole
status := "disabled"
if injectRole {
status = "enabled"
}
if err := notifyUser("injectRole", fmt.Sprintf("Role injection %s", status)); err != nil {
logger.Error("failed to send notification", "error", err)
}
updateStatusLine()
}
if event.Key() == tcell.KeyF1 { if event.Key() == tcell.KeyF1 {
// chatList, err := loadHistoryChats() // chatList, err := loadHistoryChats()
chatList, err := store.GetChatByChar(cfg.AssistantRole) chatList, err := store.GetChatByChar(cfg.AssistantRole)