summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/internal/components
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-06-13 09:57:54 -0500
committeradamdottv <[email protected]>2025-06-13 09:57:54 -0500
commit5706c6ad3add2ad4eb6c3d152f0fa72b701027c4 (patch)
treeaaa8b3c9f7ae66588a258d3c517b331c980a4d4d /packages/tui/internal/components
parente8e03c895aa5fb215302ece625e9569397c9064c (diff)
downloadopencode-5706c6ad3add2ad4eb6c3d152f0fa72b701027c4.tar.gz
opencode-5706c6ad3add2ad4eb6c3d152f0fa72b701027c4.zip
wip: refactoring tui
Diffstat (limited to 'packages/tui/internal/components')
-rw-r--r--packages/tui/internal/components/chat/editor.go10
-rw-r--r--packages/tui/internal/components/chat/message.go16
2 files changed, 23 insertions, 3 deletions
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),
+ )
}
}