diff options
| author | Grail Finder <wohilas@gmail.com> | 2026-03-01 13:33:25 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2026-03-01 13:33:25 +0300 |
| commit | e36bade353f04ab614a45ffb11e1610565234100 (patch) | |
| tree | 01b9f38888fd9106b229035330cdf3c652dc17a2 /tui.go | |
| parent | 01d8bcdbf58aee18643645ac292e26904551776e (diff) | |
Fix: escape with empty textarea not generating response
Diffstat (limited to 'tui.go')
| -rw-r--r-- | tui.go | 60 |
1 files changed, 29 insertions, 31 deletions
@@ -997,42 +997,40 @@ func init() { return nil } msgText := textArea.GetText() + nl := "\n\n" // keep empty lines between messages + prevText := textView.GetText(true) + persona := cfg.UserRole + // strings.LastIndex() + // newline is not needed is prev msg ends with one + if strings.HasSuffix(prevText, nl) { + nl = "" + } else if strings.HasSuffix(prevText, "\n") { + nl = "\n" // only one newline, add another + } if msgText != "" { - nl := "\n\n" // keep empty lines between messages - prevText := textView.GetText(true) - persona := cfg.UserRole - // strings.LastIndex() - // newline is not needed is prev msg ends with one - if strings.HasSuffix(prevText, nl) { - nl = "" - } else if strings.HasSuffix(prevText, "\n") { - nl = "\n" // only one newline, add another + // as what char user sends msg? + if cfg.WriteNextMsgAs != "" { + persona = cfg.WriteNextMsgAs } - if msgText != "" { - // as what char user sends msg? - if cfg.WriteNextMsgAs != "" { - persona = cfg.WriteNextMsgAs - } - // check if plain text - if !injectRole { - 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) - textArea.SetText("", true) - if scrollToEndEnabled { - textView.ScrollToEnd() + // check if plain text + if !injectRole { + matches := roleRE.FindStringSubmatch(msgText) + if len(matches) > 1 { + persona = matches[1] + msgText = strings.TrimLeft(msgText[len(matches[0]):], " ") } - colorText() } - // go chatRound(msgText, persona, textView, false, false) - chatRoundChan <- &models.ChatRoundReq{Role: persona, UserMsg: msgText} + // add user icon before user msg + fmt.Fprintf(textView, "%s[-:-:b](%d) <%s>: [-:-:-]\n%s\n", + nl, len(chatBody.Messages), persona, msgText) + textArea.SetText("", true) + if scrollToEndEnabled { + textView.ScrollToEnd() + } + colorText() } + // go chatRound(msgText, persona, textView, false, false) + chatRoundChan <- &models.ChatRoundReq{Role: persona, UserMsg: msgText} return nil } if event.Key() == tcell.KeyPgUp || event.Key() == tcell.KeyPgDn { |
