diff options
Diffstat (limited to 'packages/tui/internal')
| -rw-r--r-- | packages/tui/internal/app/constants.go | 4 | ||||
| -rw-r--r-- | packages/tui/internal/components/chat/editor.go | 23 | ||||
| -rw-r--r-- | packages/tui/internal/components/chat/messages.go | 17 | ||||
| -rw-r--r-- | packages/tui/internal/tui/tui.go | 2 |
4 files changed, 18 insertions, 28 deletions
diff --git a/packages/tui/internal/app/constants.go b/packages/tui/internal/app/constants.go deleted file mode 100644 index 0d37833f5..000000000 --- a/packages/tui/internal/app/constants.go +++ /dev/null @@ -1,4 +0,0 @@ -package app - -const MAX_CONTAINER_WIDTH = 86 -const EDIT_DIFF_MAX_WIDTH = 180 diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.go index 687553342..ef129765f 100644 --- a/packages/tui/internal/components/chat/editor.go +++ b/packages/tui/internal/components/chat/editor.go @@ -64,10 +64,7 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.WindowSizeMsg: - m.width = min(msg.Width-4, app.MAX_CONTAINER_WIDTH) - if m.app.Config.Layout == opencode.LayoutConfigStretch { - m.width = msg.Width - 4 - } + m.width = msg.Width - 4 return m, nil case spinner.TickMsg: m.spinner, cmd = m.spinner.Update(msg) @@ -180,6 +177,11 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m *editorComponent) Content() string { + width := m.width + if m.app.Session.ID == "" { + width = min(width, 80) + } + t := theme.CurrentTheme() base := styles.NewStyle().Foreground(t.Text()).Background(t.Background()).Render muted := styles.NewStyle().Foreground(t.TextMuted()).Background(t.Background()).Render @@ -188,7 +190,7 @@ func (m *editorComponent) Content() string { Bold(true) prompt := promptStyle.Render(">") - m.textarea.SetWidth(m.width - 6) + m.textarea.SetWidth(width - 6) textarea := lipgloss.JoinHorizontal( lipgloss.Top, prompt, @@ -200,7 +202,7 @@ func (m *editorComponent) Content() string { } textarea = styles.NewStyle(). Background(t.BackgroundElement()). - Width(m.width). + Width(width). PaddingTop(1). PaddingBottom(1). BorderStyle(lipgloss.ThickBorder()). @@ -236,7 +238,7 @@ func (m *editorComponent) Content() string { model = muted(m.app.Provider.Name) + base(" "+m.app.Model.Name) } - space := m.width - 2 - lipgloss.Width(model) - lipgloss.Width(hint) + space := width - 2 - lipgloss.Width(model) - lipgloss.Width(hint) spacer := styles.NewStyle().Background(t.Background()).Width(space).Render("") info := hint + spacer + model @@ -247,9 +249,14 @@ func (m *editorComponent) Content() string { } func (m *editorComponent) View() string { + width := m.width + if m.app.Session.ID == "" { + width = min(width, 80) + } + if m.Lines() > 1 { return lipgloss.Place( - m.width, + width, 5, lipgloss.Center, lipgloss.Center, diff --git a/packages/tui/internal/components/chat/messages.go b/packages/tui/internal/components/chat/messages.go index bf0c4d8f6..acc7b8879 100644 --- a/packages/tui/internal/components/chat/messages.go +++ b/packages/tui/internal/components/chat/messages.go @@ -146,10 +146,7 @@ func (m *messagesComponent) renderView() tea.Cmd { orphanedToolCalls := make([]opencode.ToolPart, 0) - width := min(m.width, app.MAX_CONTAINER_WIDTH) - if m.app.Config.Layout == opencode.LayoutConfigStretch { - width = m.width - } + width := m.width // always use full width for _, message := range m.app.Messages { var content string @@ -320,13 +317,6 @@ func (m *messagesComponent) renderView() tea.Cmd { continue } - width := width - if m.app.Config.Layout == opencode.LayoutConfigAuto && - part.Tool == "edit" && - part.State.Error == "" { - width = min(m.width, app.EDIT_DIFF_MAX_WIDTH) - } - if part.State.Status == opencode.ToolPartStateStatusCompleted || part.State.Status == opencode.ToolPartStateStatusError { key := m.cache.GenerateKey(casted.ID, part.ID, @@ -419,10 +409,7 @@ func (m *messagesComponent) renderHeader() string { return "" } - headerWidth := min(m.width, app.MAX_CONTAINER_WIDTH) - if m.app.Config.Layout == opencode.LayoutConfigStretch { - headerWidth = m.width - } + headerWidth := m.width t := theme.CurrentTheme() base := styles.NewStyle().Foreground(t.Text()).Background(t.Background()).Render diff --git a/packages/tui/internal/tui/tui.go b/packages/tui/internal/tui/tui.go index b201a9086..a81c1a6ba 100644 --- a/packages/tui/internal/tui/tui.go +++ b/packages/tui/internal/tui/tui.go @@ -439,7 +439,7 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.WindowSizeMsg: msg.Height -= 2 // Make space for the status bar a.width, a.height = msg.Width, msg.Height - container := min(a.width, app.MAX_CONTAINER_WIDTH) + container := min(a.width, 86) layout.Current = &layout.LayoutInfo{ Viewport: layout.Dimensions{ Width: a.width, |
