diff options
| author | adamdottv <[email protected]> | 2025-04-29 14:46:12 -0500 |
|---|---|---|
| committer | adamdottv <[email protected]> | 2025-04-30 07:47:10 -0500 |
| commit | 8497145db277fa849195150043a0ffa19da99403 (patch) | |
| tree | 04b38169e163aa904731f9593ffde9a97718dca1 /internal | |
| parent | 89544fad61396ef3502afc2d5f5c9ae6780389de (diff) | |
| download | opencode-8497145db277fa849195150043a0ffa19da99403.tar.gz opencode-8497145db277fa849195150043a0ffa19da99403.zip | |
fix: status sizing
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/tui/components/core/status.go | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/internal/tui/components/core/status.go b/internal/tui/components/core/status.go index 75fafff05..312570610 100644 --- a/internal/tui/components/core/status.go +++ b/internal/tui/components/core/status.go @@ -132,11 +132,20 @@ func (m statusCmp) View() string { Background(t.BackgroundDarker()). Render(m.projectDiagnostics()) + model := m.model() + + statusWidth := max( + 0, + m.width- + lipgloss.Width(status)- + lipgloss.Width(model)- + lipgloss.Width(diagnostics), + ) + if m.info.Msg != "" { infoStyle := styles.Padded(). Foreground(t.Background()). - Width(m.availableFooterMsgWidth(diagnostics)) - + Width(statusWidth) switch m.info.Type { case util.InfoTypeInfo: infoStyle = infoStyle.Background(t.Info()) @@ -148,7 +157,7 @@ func (m statusCmp) View() string { // Truncate message if it's longer than available width msg := m.info.Msg - availWidth := m.availableFooterMsgWidth(diagnostics) - 10 + availWidth := statusWidth - 10 if len(msg) > availWidth && availWidth > 0 { msg = msg[:availWidth] + "..." } @@ -157,12 +166,12 @@ func (m statusCmp) View() string { status += styles.Padded(). Foreground(t.Text()). Background(t.BackgroundSecondary()). - Width(m.availableFooterMsgWidth(diagnostics)). + Width(statusWidth). Render("") } status += diagnostics - status += m.model() + status += model return status } @@ -245,16 +254,6 @@ func (m *statusCmp) projectDiagnostics() string { return strings.Join(diagnostics, " ") } -func (m statusCmp) availableFooterMsgWidth(diagnostics string) int { - tokens := "" - tokensWidth := 0 - if m.session.ID != "" { - tokens = formatTokensAndCost(m.session.PromptTokens+m.session.CompletionTokens, m.session.Cost) - tokensWidth = lipgloss.Width(tokens) + 2 - } - return max(0, m.width-lipgloss.Width(helpWidget)-lipgloss.Width(m.model())-lipgloss.Width(diagnostics)-tokensWidth) -} - func (m statusCmp) model() string { t := theme.CurrentTheme() |
