From 6a8e854ef6dd9a3f00027cf46f6b673c6cf13ab0 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Tue, 21 Oct 2025 10:35:37 +0300 Subject: Feat: parse role from raw msg --- tui.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'tui.go') diff --git a/tui.go b/tui.go index dc8a17a..4938a01 100644 --- a/tui.go +++ b/tui.go @@ -229,8 +229,9 @@ func makeStatusLine() string { if cfg.WriteNextMsgAsCompletionAgent != "" { botPersona = cfg.WriteNextMsgAsCompletionAgent } - statusLine := fmt.Sprintf(indexLineCompletion, botRespMode, cfg.AssistantRole, activeChatName, cfg.ToolUse, chatBody.Model, - cfg.SkipLLMResp, cfg.CurrentAPI, cfg.ThinkUse, logLevel.Level(), isRecording, persona, botPersona) + statusLine := fmt.Sprintf(indexLineCompletion, botRespMode, cfg.AssistantRole, activeChatName, + cfg.ToolUse, chatBody.Model, cfg.SkipLLMResp, cfg.CurrentAPI, cfg.ThinkUse, logLevel.Level(), + isRecording, persona, botPersona, injectRole) return statusLine } @@ -333,6 +334,8 @@ func makePropsForm(props map[string]float32) *tview.Form { cfg.ThinkUse = checked }).AddCheckbox("RAG use", cfg.RAGEnabled, func(checked bool) { cfg.RAGEnabled = checked + }).AddCheckbox("Inject role", injectRole, func(checked bool) { + injectRole = checked }).AddDropDown("Set log level (Enter): ", []string{"Debug", "Info", "Warn"}, 1, func(option string, optionIndex int) { setLogLevel(option) @@ -946,6 +949,14 @@ func init() { if cfg.WriteNextMsgAs != "" { persona = cfg.WriteNextMsgAs } + // check if plain text + if injectRole == false { + matches := roleRE.FindStringSubmatch(msgText) + if len(matches) > 1 { + persona = matches[1] + msgText = strings.TrimLeft(msgText[len(matches[0]):], " ") + } + } // add user icon before user msg fmt.Fprintf(textView, "%s[-:-:b](%d) <%s>: [-:-:-]\n%s\n", nl, len(chatBody.Messages), persona, msgText) -- cgit v1.2.3