mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-01 22:10:23 +00:00
wip: refactoring tui
This commit is contained in:
parent
e8e03c895a
commit
5706c6ad3a
4 changed files with 147 additions and 82 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue