Feat: scroll to end toggle
This commit is contained in:
8
bot.go
8
bot.go
@@ -674,7 +674,9 @@ out:
|
||||
case chunk := <-chunkChan:
|
||||
fmt.Fprint(tv, chunk)
|
||||
respText.WriteString(chunk)
|
||||
if scrollToEndEnabled {
|
||||
tv.ScrollToEnd()
|
||||
}
|
||||
// Send chunk to audio stream handler
|
||||
if cfg.TTS_ENABLED {
|
||||
extra.TTSTextChan <- chunk
|
||||
@@ -682,14 +684,18 @@ out:
|
||||
case toolChunk := <-openAIToolChan:
|
||||
fmt.Fprint(tv, toolChunk)
|
||||
toolResp.WriteString(toolChunk)
|
||||
if scrollToEndEnabled {
|
||||
tv.ScrollToEnd()
|
||||
}
|
||||
case <-streamDone:
|
||||
// drain any remaining chunks from chunkChan before exiting
|
||||
for len(chunkChan) > 0 {
|
||||
chunk := <-chunkChan
|
||||
fmt.Fprint(tv, chunk)
|
||||
respText.WriteString(chunk)
|
||||
if scrollToEndEnabled {
|
||||
tv.ScrollToEnd()
|
||||
}
|
||||
// Send chunk to audio stream handler
|
||||
if cfg.TTS_ENABLED {
|
||||
extra.TTSTextChan <- chunk
|
||||
@@ -1130,5 +1136,7 @@ func init() {
|
||||
if cfg.STT_ENABLED {
|
||||
asr = extra.NewSTT(logger, cfg)
|
||||
}
|
||||
// Initialize scrollToEndEnabled based on config
|
||||
scrollToEndEnabled = cfg.AutoScrollEnabled
|
||||
go updateModelLists()
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ ToolRole = "tool"
|
||||
AssistantRole = "assistant"
|
||||
SysDir = "sysprompts"
|
||||
ChunkLimit = 100000
|
||||
AutoScrollEnabled = true
|
||||
# AutoCleanToolCallsFromCtx = false
|
||||
# rag settings
|
||||
RAGBatchSize = 1
|
||||
|
||||
@@ -28,6 +28,7 @@ type Config struct {
|
||||
AssistantRole string `toml:"AssistantRole"`
|
||||
SysDir string `toml:"SysDir"`
|
||||
ChunkLimit uint32 `toml:"ChunkLimit"`
|
||||
AutoScrollEnabled bool `toml:"AutoScrollEnabled"`
|
||||
WriteNextMsgAs string
|
||||
WriteNextMsgAsCompletionAgent string
|
||||
SkipLLMResp bool
|
||||
|
||||
22
tui.go
22
tui.go
@@ -36,6 +36,7 @@ var (
|
||||
roleEditWindow *tview.InputField
|
||||
fullscreenMode bool
|
||||
positionVisible bool = true
|
||||
scrollToEndEnabled bool = true
|
||||
// pages
|
||||
historyPage = "historyPage"
|
||||
agentPage = "agentPage"
|
||||
@@ -88,6 +89,7 @@ var (
|
||||
[yellow]Ctrl+q[white]: cycle through mentioned chars in chat, to pick persona to send next msg as
|
||||
[yellow]Ctrl+x[white]: cycle through mentioned chars in chat, to pick persona to send next msg as (for llm)
|
||||
[yellow]Alt+1[white]: toggle shell mode (execute commands locally)
|
||||
[yellow]Alt+2[white]: toggle auto-scrolling (for reading while LLM types)
|
||||
[yellow]Alt+3[white]: summarize chat history and start new chat with summary as tool response
|
||||
[yellow]Alt+4[white]: edit msg role
|
||||
[yellow]Alt+5[white]: toggle system and tool messages display
|
||||
@@ -203,7 +205,9 @@ func executeCommandAndDisplay(cmdText string) {
|
||||
cmdParts := parseCommand(cmdText)
|
||||
if len(cmdParts) == 0 {
|
||||
fmt.Fprintf(textView, "\n[red]Error: No command provided[-:-:-]\n")
|
||||
if scrollToEndEnabled {
|
||||
textView.ScrollToEnd()
|
||||
}
|
||||
colorText()
|
||||
return
|
||||
}
|
||||
@@ -233,7 +237,9 @@ func executeCommandAndDisplay(cmdText string) {
|
||||
}
|
||||
}
|
||||
// Scroll to end and update colors
|
||||
if scrollToEndEnabled {
|
||||
textView.ScrollToEnd()
|
||||
}
|
||||
colorText()
|
||||
}
|
||||
|
||||
@@ -767,7 +773,9 @@ func init() {
|
||||
updateStatusLine()
|
||||
textView.SetText(chatToText(cfg.ShowSys))
|
||||
colorText()
|
||||
if scrollToEndEnabled {
|
||||
textView.ScrollToEnd()
|
||||
}
|
||||
// init sysmap
|
||||
_, err := initSysCards()
|
||||
if err != nil {
|
||||
@@ -792,6 +800,18 @@ func init() {
|
||||
positionVisible = !positionVisible
|
||||
updateFlexLayout()
|
||||
}
|
||||
if event.Key() == tcell.KeyRune && event.Rune() == '2' && event.Modifiers()&tcell.ModAlt != 0 {
|
||||
// toggle auto-scrolling
|
||||
scrollToEndEnabled = !scrollToEndEnabled
|
||||
status := "disabled"
|
||||
if scrollToEndEnabled {
|
||||
status = "enabled"
|
||||
}
|
||||
if err := notifyUser("autoscroll", "Auto-scrolling "+status); err != nil {
|
||||
logger.Error("failed to send notification", "error", err)
|
||||
}
|
||||
updateStatusLine()
|
||||
}
|
||||
if event.Key() == tcell.KeyF1 {
|
||||
// chatList, err := loadHistoryChats()
|
||||
chatList, err := store.GetChatByChar(cfg.AssistantRole)
|
||||
@@ -1292,7 +1312,9 @@ func init() {
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user