Update tui error handling
- Allow each view to position error banners where they choose - Add global 'esc' key handler to dismiss errors
This commit is contained in:
@@ -83,6 +83,7 @@ type Model struct {
|
||||
stopSignal chan struct{}
|
||||
chatReplyChunks chan provider.Chunk
|
||||
persistence bool // whether we will save new messages in the conversation
|
||||
promptCaching bool // whether prompt caching is enabled
|
||||
|
||||
// UI state
|
||||
focus focusState
|
||||
|
||||
@@ -245,7 +245,7 @@ func (m *Model) conversationMessagesView() string {
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
func (m *Model) Content(width, height int) string {
|
||||
func (m *Model) Content(width, height int, errors string) string {
|
||||
// calculate clamped input height to accomodate input text
|
||||
// minimum 4 lines, maximum half of content area
|
||||
inputHeight := max(4, min(height/2, m.input.LineCount()))
|
||||
@@ -255,7 +255,15 @@ func (m *Model) Content(width, height int) string {
|
||||
// remaining height towards content
|
||||
m.content.Width, m.content.Height = width, height-tuiutil.Height(input)
|
||||
content := m.content.View()
|
||||
return lipgloss.JoinVertical(lipgloss.Left, content, input)
|
||||
|
||||
var sections []string
|
||||
if errors != "" {
|
||||
sections = []string{content, errors, input}
|
||||
} else {
|
||||
sections = []string{content, input}
|
||||
}
|
||||
|
||||
return lipgloss.JoinVertical(lipgloss.Left, sections...)
|
||||
}
|
||||
|
||||
func (m *Model) Header(width int) string {
|
||||
|
||||
Reference in New Issue
Block a user