summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYihui Khuu <[email protected]>2025-07-20 02:43:04 +1000
committerGitHub <[email protected]>2025-07-19 11:43:04 -0500
commit50c453e57706e3192198eb8f96b73a7f63f79e0b (patch)
tree143d07e6ce4453b4be136444c1189f4d364e4dbb
parent86d5b25d1831d378f358b46598d4de06b9eaa8f9 (diff)
downloadopencode-50c453e57706e3192198eb8f96b73a7f63f79e0b.tar.gz
opencode-50c453e57706e3192198eb8f96b73a7f63f79e0b.zip
feat(tui): collapse session header into single line when sharing is disabled (#1145)
-rw-r--r--packages/tui/internal/components/chat/messages.go40
1 files changed, 18 insertions, 22 deletions
diff --git a/packages/tui/internal/components/chat/messages.go b/packages/tui/internal/components/chat/messages.go
index acc7b8879..11a3bcd9f 100644
--- a/packages/tui/internal/components/chat/messages.go
+++ b/packages/tui/internal/components/chat/messages.go
@@ -414,18 +414,6 @@ func (m *messagesComponent) renderHeader() string {
t := theme.CurrentTheme()
base := styles.NewStyle().Foreground(t.Text()).Background(t.Background()).Render
muted := styles.NewStyle().Foreground(t.TextMuted()).Background(t.Background()).Render
- headerLines := []string{}
- headerLines = append(
- headerLines,
- util.ToMarkdown("# "+m.app.Session.Title, headerWidth-6, t.Background()),
- )
-
- share := ""
- if m.app.Session.Share.URL != "" {
- share = muted(m.app.Session.Share.URL + " /unshare")
- } else {
- share = base("/share") + muted(" to create a shareable link")
- }
sessionInfo := ""
tokens := float64(0)
@@ -459,30 +447,38 @@ func (m *messagesComponent) renderHeader() string {
Background(t.Background()).
Render(formatTokensAndCost(tokens, contextWindow, cost, isSubscriptionModel))
- background := t.Background()
+ shareEnabled := m.app.Config.Share != opencode.ConfigShareDisabled
+ headerText := util.ToMarkdown("# "+m.app.Session.Title, headerWidth-len(sessionInfo), t.Background())
var items []layout.FlexItem
- justify := layout.JustifyEnd
-
- if m.app.Config.Share != opencode.ConfigShareDisabled {
- items = append(items, layout.FlexItem{View: share})
- justify = layout.JustifySpaceBetween
+ if shareEnabled {
+ share := base("/share") + muted(" to create a shareable link")
+ if m.app.Session.Share.URL != "" {
+ share = muted(m.app.Session.Share.URL + " /unshare")
+ }
+ items = []layout.FlexItem{{View: share}, {View: sessionInfo}}
+ } else {
+ items = []layout.FlexItem{{View: headerText}, {View: sessionInfo}}
}
- items = append(items, layout.FlexItem{View: sessionInfo})
-
+ background := t.Background()
headerRow := layout.Render(
layout.FlexOptions{
Background: &background,
Direction: layout.Row,
- Justify: justify,
+ Justify: layout.JustifySpaceBetween,
Align: layout.AlignStretch,
Width: headerWidth - 6,
},
items...,
)
- headerLines = append(headerLines, headerRow)
+ var headerLines []string
+ if shareEnabled {
+ headerLines = []string{headerText, headerRow}
+ } else {
+ headerLines = []string{headerRow}
+ }
header := strings.Join(headerLines, "\n")
header = styles.NewStyle().