wip: refactoring tui

This commit is contained in:
adamdottv 2025-06-12 09:35:19 -05:00
parent 98bd5109c2
commit ca0ea3f94d
No known key found for this signature in database
GPG key ID: 9CB48779AF150E75
6 changed files with 275 additions and 71 deletions

View file

@ -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(