summaryrefslogtreecommitdiff
path: root/tui.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2024-12-07 12:53:35 +0300
committerGrail Finder <wohilas@gmail.com>2024-12-07 12:53:35 +0300
commit7c4d0579943365dd363b659135e7db8c9fca474e (patch)
tree4a073dd1f512c4205477ac317d144a0c1004ce8b /tui.go
parente811bc51d401ecde194df562034ae529943546d0 (diff)
Fix: resolve points on the fixlist
Diffstat (limited to 'tui.go')
-rw-r--r--tui.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/tui.go b/tui.go
index 28d1c44..afb8cc6 100644
--- a/tui.go
+++ b/tui.go
@@ -5,6 +5,7 @@ import (
"elefant/pngmeta"
"fmt"
"strconv"
+ "strings"
"time"
"github.com/gdamore/tcell/v2"
@@ -48,6 +49,10 @@ func colorText() {
textView.SetText(starRE.ReplaceAllString(cq, `[turquoise::i]$1[-:-:-]`))
}
+func updateStatusLine() {
+ position.SetText(fmt.Sprintf(indexLine, botRespMode, cfg.AssistantRole, activeChatName))
+}
+
func init() {
theme := tview.Theme{
PrimitiveBackgroundColor: tcell.ColorDefault,
@@ -84,9 +89,6 @@ func init() {
AddItem(textView, 0, 40, false).
AddItem(textArea, 0, 10, true).
AddItem(position, 0, 1, false)
- updateStatusLine := func() {
- position.SetText(fmt.Sprintf(indexLine, botRespMode, cfg.AssistantRole, activeChatName))
- }
chatOpts := []string{"cancel", "new", "rename current"}
chatList, err := loadHistoryChats()
if err != nil {
@@ -149,6 +151,7 @@ func init() {
switch buttonLabel {
case "cancel":
pages.RemovePage("sys")
+ sysModal.ClearButtons()
return
default:
cc, ok := sysMap[buttonLabel]
@@ -295,6 +298,13 @@ func init() {
}
if event.Key() == tcell.KeyF3 && !botRespMode {
// delete last msg
+ // check textarea text; if it ends with bot icon delete only icon:
+ text := textView.GetText(true)
+ if strings.HasSuffix(text, cfg.AssistantIcon) {
+ logger.Info("deleting assistant icon", "icon", cfg.AssistantIcon)
+ textView.SetText(strings.TrimSuffix(text, cfg.AssistantIcon))
+ return nil
+ }
chatBody.Messages = chatBody.Messages[:len(chatBody.Messages)-1]
textView.SetText(chatToText(cfg.ShowSys))
return nil
@@ -374,6 +384,8 @@ func init() {
position.SetText(fmt.Sprintf(indexLine, botRespMode, cfg.AssistantRole, activeChatName))
// read all text into buffer
msgText := textArea.GetText()
+ // TODO: check whose message was latest (user icon / assistant)
+ // in order to decide if assistant new icon is needed
if msgText != "" {
fmt.Fprintf(textView, "\n(%d) <user>: \n%s\n", len(chatBody.Messages), msgText)
textArea.SetText("", true)