feat: add header with version and fix layout calculations

This commit is contained in:
大森 2026-05-10 14:47:53 +08:00
parent 8d543a7020
commit 6cd0a8d021

View File

@ -212,7 +212,13 @@ func (m *Model) updateLayout() {
rightWidth := 42
leftWidth := m.width - rightWidth - 3
chatHeight := m.height - 5
headerHeight := 3
mainHeight := m.height - headerHeight - 1
inputHeight := 5
chatHeight := mainHeight - inputHeight
if chatHeight < 10 {
chatHeight = 10
}
m.textarea.SetWidth(leftWidth)
m.viewport.Width = leftWidth
@ -261,7 +267,15 @@ func (m Model) View() string {
rightWidth := 42
leftWidth := m.width - rightWidth - 3
chatHeight := m.height - 5
headerHeight := 3
mainHeight := m.height - headerHeight - 1
inputHeight := 5
chatHeight := mainHeight - inputHeight
if chatHeight < 10 {
chatHeight = 10
}
header := m.renderHeader()
chatBox := boxStyle.Width(leftWidth).Height(chatHeight).Render(m.viewport.View())
inputBox := boxStyle.Width(leftWidth).Render(m.textarea.View())
@ -272,7 +286,7 @@ func (m Model) View() string {
statsHeight := lipgloss.Height(stats)
agentsHeight := lipgloss.Height(agents)
remainingHeight := m.height - statsHeight - agentsHeight - 2
remainingHeight := mainHeight - statsHeight - agentsHeight - 2
if remainingHeight < 3 {
remainingHeight = 3
}
@ -284,7 +298,19 @@ func (m Model) View() string {
leftPanel = lipgloss.JoinVertical(lipgloss.Left, leftPanel, processingStyle.Render("Processing..."))
}
return lipgloss.JoinHorizontal(lipgloss.Top, leftPanel, rightPanel)
body := lipgloss.JoinHorizontal(lipgloss.Top, leftPanel, rightPanel)
return lipgloss.JoinVertical(lipgloss.Left, header, body)
}
func (m Model) renderHeader() string {
version := "v0.1.0"
title := titleStyle.Render("orca.agent ") + mutedStyle.Render(version)
return lipgloss.NewStyle().
Width(m.width).
Height(1).
Padding(0, 1).
Background(lipgloss.Color(colors.bg)).
Render(title)
}
func (m Model) renderStats() string {