Chore: bool colors for statusline

This commit is contained in:
Grail Finder
2026-01-22 09:29:56 +03:00
parent a28e8ef9e2
commit 9813872854
4 changed files with 27 additions and 34 deletions

6
bot.go
View File

@@ -43,7 +43,6 @@ var (
store storage.FullRepo store storage.FullRepo
defaultFirstMsg = "Hello! What can I do for you?" defaultFirstMsg = "Hello! What can I do for you?"
defaultStarter = []models.RoleMsg{} defaultStarter = []models.RoleMsg{}
defaultStarterBytes = []byte{}
interruptResp = false interruptResp = false
ragger *rag.RAG ragger *rag.RAG
chunkParser ChunkParser chunkParser ChunkParser
@@ -1170,11 +1169,6 @@ func init() {
slog.Error("failed to open log file", "error", err, "filename", cfg.LogFile) slog.Error("failed to open log file", "error", err, "filename", cfg.LogFile)
return return
} }
defaultStarterBytes, err = json.Marshal(defaultStarter)
if err != nil {
slog.Error("failed to marshal defaultStarter", "error", err)
return
}
// load cards // load cards
basicCard.Role = cfg.AssistantRole basicCard.Role = cfg.AssistantRole
// toolCard.Role = cfg.AssistantRole // toolCard.Role = cfg.AssistantRole

View File

@@ -113,7 +113,9 @@ func startNewChat() {
newChat := &models.Chat{ newChat := &models.Chat{
ID: id + 1, ID: id + 1,
Name: fmt.Sprintf("%d_%s", id+1, cfg.AssistantRole), Name: fmt.Sprintf("%d_%s", id+1, cfg.AssistantRole),
Msgs: string(defaultStarterBytes), // chat is written to db when we get first llm response (or any)
// actual chat history (messages) would be parsed then
Msgs: "",
Agent: cfg.AssistantRole, Agent: cfg.AssistantRole,
} }
activeChatName = newChat.Name activeChatName = newChat.Name
@@ -235,9 +237,10 @@ func makeStatusLine() string {
} else { } else {
shellModeInfo = "" shellModeInfo = ""
} }
statusLine := fmt.Sprintf(indexLineCompletion, botRespMode, activeChatName, statusLine := fmt.Sprintf(indexLineCompletion, boolColors[botRespMode], botRespMode, activeChatName,
cfg.ToolUse, chatBody.Model, cfg.SkipLLMResp, cfg.CurrentAPI, boolColors[cfg.ToolUse], cfg.ToolUse, chatBody.Model, boolColors[cfg.SkipLLMResp],
isRecording, persona, botPersona, injectRole) cfg.SkipLLMResp, cfg.CurrentAPI, boolColors[isRecording], isRecording, persona,
botPersona, boolColors[injectRole], injectRole)
return statusLine + imageInfo + shellModeInfo return statusLine + imageInfo + shellModeInfo
} }
@@ -260,6 +263,9 @@ func listChatRoles() []string {
} }
currentCard, ok := sysMap[currentChat.Agent] currentCard, ok := sysMap[currentChat.Agent]
if !ok { if !ok {
// case which won't let to switch roles:
// started new chat (basic_sys or any other), at the start it yet be saved or have chatbody
// if it does not have a card or chars, it'll return an empty slice
// log error // log error
logger.Warn("failed to find current card in sysMap", "agent", currentChat.Agent, "sysMap", sysMap) logger.Warn("failed to find current card in sysMap", "agent", currentChat.Agent, "sysMap", sysMap)
return cbc return cbc

View File

@@ -8,6 +8,7 @@ import (
) )
var ( var (
boolColors = map[bool]string{true: "green", false: "red"}
botRespMode = false botRespMode = false
editMode = false editMode = false
roleEditMode = false roleEditMode = false
@@ -17,8 +18,7 @@ var (
currentORModelIndex = 0 // Index to track current OpenRouter model in ORFreeModels slice currentORModelIndex = 0 // Index to track current OpenRouter model in ORFreeModels slice
currentLocalModelIndex = 0 // Index to track current llama.cpp model currentLocalModelIndex = 0 // Index to track current llama.cpp model
shellMode = false shellMode = false
// indexLine = "F12 to show keys help | bot resp mode: [orange:-:b]%v[-:-:-] (F6) | card's char: [orange:-:b]%s[-:-:-] (ctrl+s) | chat: [orange:-:b]%s[-:-:-] (F1) | toolUseAdviced: [orange:-:b]%v[-:-:-] (ctrl+k) | model: [orange:-:b]%s[-:-:-] (ctrl+l) | skip LLM resp: [orange:-:b]%v[-:-:-] (F10)\nAPI_URL: [orange:-:b]%s[-:-:-] (ctrl+v) | ThinkUse: [orange:-:b]%v[-:-:-] (ctrl+p) | Log Level: [orange:-:b]%v[-:-:-] (ctrl+p) | Recording: [orange:-:b]%v[-:-:-] (ctrl+r) | Writing as: [orange:-:b]%s[-:-:-] (ctrl+q)" indexLineCompletion = "F12 to show keys help | llm turn: [%s:-:b]%v[-:-:-] (F6) | chat: [orange:-:b]%s[-:-:-] (F1) | toolUseAdviced: [%s:-:b]%v[-:-:-] (ctrl+k) | model: [orange:-:b]%s[-:-:-] (ctrl+l) | skip LLM resp: [%s:-:b]%v[-:-:-] (F10)\nAPI: [orange:-:b]%s[-:-:-] (ctrl+v) | recording: [%s:-:b]%v[-:-:-] (ctrl+r) | writing as: [orange:-:b]%s[-:-:-] (ctrl+q) | bot will write as [orange:-:b]%s[-:-:-] (ctrl+x) | role injection (alt+7) [%s:-:b]%v[-:-:-]"
indexLineCompletion = "F12 to show keys help | bot resp mode: [orange:-:b]%v[-:-:-] (F6) | chat: [orange:-:b]%s[-:-:-] (F1) | toolUseAdviced: [orange:-:b]%v[-:-:-] (ctrl+k) | model: [orange:-:b]%s[-:-:-] (ctrl+l) | skip LLM resp: [orange:-:b]%v[-:-:-] (F10)\nAPI: [orange:-:b]%s[-:-:-] (ctrl+v) | Recording: [orange:-:b]%v[-:-:-] (ctrl+r) | Writing as: [orange:-:b]%s[-:-:-] (ctrl+q) | Bot will write as [orange:-:b]%s[-:-:-] (ctrl+x) | role_inject [orange:-:b]%v[-:-:-]"
focusSwitcher = map[tview.Primitive]tview.Primitive{} focusSwitcher = map[tview.Primitive]tview.Primitive{}
) )

7
tui.go
View File

@@ -832,13 +832,6 @@ func init() {
// Handle Alt+7 to toggle injectRole // Handle Alt+7 to toggle injectRole
if event.Key() == tcell.KeyRune && event.Rune() == '7' && event.Modifiers()&tcell.ModAlt != 0 { if event.Key() == tcell.KeyRune && event.Rune() == '7' && event.Modifiers()&tcell.ModAlt != 0 {
injectRole = !injectRole injectRole = !injectRole
status := "disabled"
if injectRole {
status = "enabled"
}
if err := notifyUser("injectRole", "Role injection "+status); err != nil {
logger.Error("failed to send notification", "error", err)
}
updateStatusLine() updateStatusLine()
} }
if event.Key() == tcell.KeyF1 { if event.Key() == tcell.KeyF1 {