mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-07 18:04:54 +01:00
wip: refactoring tui
This commit is contained in:
@@ -258,16 +258,18 @@ func renderToolInvocation(
|
||||
}
|
||||
|
||||
body := ""
|
||||
error := ""
|
||||
finished := result != nil && *result != ""
|
||||
if finished {
|
||||
body = *result
|
||||
}
|
||||
|
||||
if metadata["error"] != nil && metadata["message"] != nil {
|
||||
body = styles.BaseStyle().
|
||||
Width(outerWidth).
|
||||
body = ""
|
||||
error = styles.BaseStyle().
|
||||
Foreground(t.Error()).
|
||||
Render(metadata["message"].(string))
|
||||
error = renderContentBlock(error, WithBorderColor(t.Error()), WithFullWidth(), WithPaddingTop(1), WithPaddingBottom(1))
|
||||
}
|
||||
|
||||
elapsed := ""
|
||||
@@ -364,10 +366,12 @@ func renderToolInvocation(
|
||||
|
||||
content := style.Render(title)
|
||||
content = lipgloss.PlaceHorizontal(layout.Current.Viewport.Width, lipgloss.Center, content)
|
||||
// content = styles.ForceReplaceBackgroundWithLipgloss(content, t.Background())
|
||||
if showResult && body != "" {
|
||||
if showResult && body != "" && error == "" {
|
||||
content += "\n" + body
|
||||
}
|
||||
if showResult && error != "" {
|
||||
content += "\n" + error
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ const (
|
||||
userTextBlock
|
||||
assistantTextBlock
|
||||
toolInvocationBlock
|
||||
errorBlock
|
||||
)
|
||||
|
||||
func (m *messagesComponent) renderView() {
|
||||
@@ -129,6 +130,7 @@ func (m *messagesComponent) renderView() {
|
||||
return
|
||||
}
|
||||
|
||||
t := theme.CurrentTheme()
|
||||
blocks := make([]string, 0)
|
||||
previousBlockType := none
|
||||
for _, message := range m.app.Messages {
|
||||
@@ -211,9 +213,19 @@ func (m *messagesComponent) renderView() {
|
||||
previousBlockType = toolInvocationBlock
|
||||
}
|
||||
}
|
||||
|
||||
error := ""
|
||||
errorValue, _ := message.Metadata.Error.ValueByDiscriminator()
|
||||
switch errorValue.(type) {
|
||||
case client.UnknownError:
|
||||
clientError := errorValue.(client.UnknownError)
|
||||
error = clientError.Data.Message
|
||||
error = renderContentBlock(error, WithBorderColor(t.Error()), WithFullWidth(), WithPaddingTop(1), WithPaddingBottom(1))
|
||||
blocks = append(blocks, error)
|
||||
previousBlockType = errorBlock
|
||||
}
|
||||
}
|
||||
|
||||
t := theme.CurrentTheme()
|
||||
centered := []string{}
|
||||
for _, block := range blocks {
|
||||
centered = append(centered, lipgloss.PlaceHorizontal(
|
||||
|
||||
Reference in New Issue
Block a user