From 5706c6ad3add2ad4eb6c3d152f0fa72b701027c4 Mon Sep 17 00:00:00 2001 From: adamdottv <2363879+adamdottv@users.noreply.github.com> Date: Fri, 13 Jun 2025 09:57:54 -0500 Subject: wip: refactoring tui --- packages/tui/internal/components/chat/editor.go | 10 +++++++++- packages/tui/internal/components/chat/message.go | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'packages/tui/internal/components') diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.go index 24cb588ed..7ba961577 100644 --- a/packages/tui/internal/components/chat/editor.go +++ b/packages/tui/internal/components/chat/editor.go @@ -13,6 +13,7 @@ import ( tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/lipgloss/v2" "github.com/sst/opencode/internal/app" + "github.com/sst/opencode/internal/commands" "github.com/sst/opencode/internal/components/dialog" "github.com/sst/opencode/internal/image" "github.com/sst/opencode/internal/layout" @@ -365,7 +366,7 @@ func (m *editorComponent) openEditor(value string) tea.Cmd { } func (m *editorComponent) send() tea.Cmd { - value := m.textarea.Value() + value := strings.TrimSpace(m.textarea.Value()) m.textarea.Reset() attachments := m.attachments @@ -382,6 +383,13 @@ func (m *editorComponent) send() tea.Cmd { if value == "" { return nil } + + // Check for slash command + if strings.HasPrefix(value, "/") { + commandName := strings.TrimPrefix(value, "/") + return util.CmdHandler(commands.ExecuteCommandMsg{Name: commandName}) + } + return tea.Batch( util.CmdHandler(SendMsg{ Text: value, diff --git a/packages/tui/internal/components/chat/message.go b/packages/tui/internal/components/chat/message.go index 068fca1d6..44aceea93 100644 --- a/packages/tui/internal/components/chat/message.go +++ b/packages/tui/internal/components/chat/message.go @@ -230,7 +230,7 @@ func renderText(message client.MessageInfo, text string, author string) string { case client.Assistant: return renderContentBlock(content, WithAlign(lipgloss.Left), - WithBorderColor(t.Primary()), + WithBorderColor(t.Accent()), ) } return "" @@ -250,8 +250,12 @@ func renderToolInvocation( outerWidth := layout.Current.Container.Width innerWidth := outerWidth - 6 paddingTop := 0 + paddingBottom := 0 if showResult { paddingTop = 1 + if result == nil || *result == "" { + paddingBottom = 1 + } } t := theme.CurrentTheme() @@ -259,6 +263,7 @@ func renderToolInvocation( Width(outerWidth). Background(t.BackgroundSubtle()). PaddingTop(paddingTop). + PaddingBottom(paddingBottom). PaddingLeft(2). PaddingRight(2). BorderLeft(true). @@ -301,10 +306,17 @@ func renderToolInvocation( if e, ok := metadata.Get("error"); ok && e.(bool) == true { if m, ok := metadata.Get("message"); ok { body = "" // don't show the body if there's an error + style = style.BorderLeftForeground(t.Error()) error = styles.BaseStyle(). + Background(t.BackgroundSubtle()). Foreground(t.Error()). Render(m.(string)) - error = renderContentBlock(error, WithBorderColor(t.Error()), WithFullWidth(), WithMarginBottom(1)) + error = renderContentBlock( + error, + WithFullWidth(), + WithBorderColor(t.Error()), + WithMarginBottom(1), + ) } } -- cgit v1.2.3