mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-05 00:44:54 +01:00
fix: header width to display header in one line when sharing disabled (#1310)
This commit is contained in:
@@ -670,15 +670,21 @@ func (m *messagesComponent) renderHeader() string {
|
|||||||
isSubscriptionModel := m.app.Model != nil &&
|
isSubscriptionModel := m.app.Model != nil &&
|
||||||
m.app.Model.Cost.Input == 0 && m.app.Model.Cost.Output == 0
|
m.app.Model.Cost.Input == 0 && m.app.Model.Cost.Output == 0
|
||||||
|
|
||||||
|
sessionInfoText := formatTokensAndCost(tokens, contextWindow, cost, isSubscriptionModel)
|
||||||
sessionInfo = styles.NewStyle().
|
sessionInfo = styles.NewStyle().
|
||||||
Foreground(t.TextMuted()).
|
Foreground(t.TextMuted()).
|
||||||
Background(t.Background()).
|
Background(t.Background()).
|
||||||
Render(formatTokensAndCost(tokens, contextWindow, cost, isSubscriptionModel))
|
Render(sessionInfoText)
|
||||||
|
|
||||||
shareEnabled := m.app.Config.Share != opencode.ConfigShareDisabled
|
shareEnabled := m.app.Config.Share != opencode.ConfigShareDisabled
|
||||||
|
headerTextWidth := headerWidth
|
||||||
|
if !shareEnabled {
|
||||||
|
// +1 is to ensure there is always at least one space between header and session info
|
||||||
|
headerTextWidth -= len(sessionInfoText) + 1
|
||||||
|
}
|
||||||
headerText := util.ToMarkdown(
|
headerText := util.ToMarkdown(
|
||||||
"# "+m.app.Session.Title,
|
"# "+m.app.Session.Title,
|
||||||
headerWidth,
|
headerTextWidth,
|
||||||
t.Background(),
|
t.Background(),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -705,11 +711,9 @@ func (m *messagesComponent) renderHeader() string {
|
|||||||
items...,
|
items...,
|
||||||
)
|
)
|
||||||
|
|
||||||
var headerLines []string
|
headerLines := []string{headerRow}
|
||||||
if shareEnabled {
|
if shareEnabled {
|
||||||
headerLines = []string{headerText, headerRow}
|
headerLines = []string{headerText, headerRow}
|
||||||
} else {
|
|
||||||
headerLines = []string{headerRow}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
header := strings.Join(headerLines, "\n")
|
header := strings.Join(headerLines, "\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user