Skip to content

Commit 98c91af

Browse files
scalvertclaude
andcommitted
fix(tui): use LineInfo().Height for textarea growth; add version to header
- Fix textarea auto-grow: was using LineCount() which returns logical lines (always 1 with InsertNewline disabled). Now uses LineInfo().Height which returns the visual wrapped row count — the correct bubbles API for this purpose. - Add version to TUI header: "Glean CLI v0.6.1" (omitted for dev builds) Pass version through New() constructor rather than a separate setter. Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
1 parent 2635701 commit 98c91af

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func NewCmdRoot() *cobra.Command {
9090
}
9191
}
9292

93-
model, err := tui.New(cfg, session, identity, cmd.Context())
93+
model, err := tui.New(cfg, session, identity, cliVersion, cmd.Context())
9494
if err != nil {
9595
return fmt.Errorf("failed to create TUI: %w", err)
9696
}

internal/tui/model.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type Model struct {
6868
session *Session
6969
ctx context.Context
7070
identity string // "email · host" shown in header + status
71+
version string // build-time version shown in header
7172
conversationMsgs []components.ChatMessage // full history sent on each turn (multi-turn context)
7273
chatID *string // Glean chatId — server manages conversation context
7374
startTime time.Time // session start, for stats on quit
@@ -101,7 +102,7 @@ type Model struct {
101102
}
102103

103104
// New creates a fully-initialized TUI model.
104-
func New(cfg *config.Config, session *Session, identity string, ctx context.Context) (*Model, error) {
105+
func New(cfg *config.Config, session *Session, identity, version string, ctx context.Context) (*Model, error) {
105106
ta := textarea.New()
106107
ta.Placeholder = "Message Glean…"
107108
ta.Focus()
@@ -137,6 +138,7 @@ func New(cfg *config.Config, session *Session, identity string, ctx context.Cont
137138
cfg: cfg,
138139
session: session,
139140
identity: identity,
141+
version: version,
140142
ctx: ctx,
141143
startTime: time.Now(),
142144
historyIdx: -1,
@@ -448,11 +450,13 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
448450

449451
m.textarea, taCmd = m.textarea.Update(msg)
450452

451-
// Grow the textarea vertically as content wraps, up to 6 lines.
452-
// Shrink it back when the user deletes content.
453+
// Grow the textarea vertically as content wraps, up to 6 visual rows.
454+
// LineInfo().Height is the wrapped visual row count for the current line —
455+
// correct even with InsertNewline disabled (unlike LineCount which counts
456+
// logical lines and is always 1 when newlines are disabled).
453457
if _, isKey := msg.(tea.KeyMsg); isKey {
454458
const maxInputLines = 6
455-
desired := m.textarea.LineCount()
459+
desired := m.textarea.LineInfo().Height
456460
if desired < 1 {
457461
desired = 1
458462
} else if desired > maxInputLines {

internal/tui/tui_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
func newTestModel(t *testing.T) *Model {
2020
t.Helper()
2121
cfg := &config.Config{GleanHost: "test-be.glean.com", GleanToken: "tok"}
22-
m, err := New(cfg, &Session{}, "[email protected] · test", context.Background())
22+
m, err := New(cfg, &Session{}, "[email protected] · test", "dev", context.Background())
2323
require.NoError(t, err)
2424
// Simulate a terminal size so layout calculations are predictable.
2525
m.width = 120

internal/tui/view.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ func (m *Model) headerView() string {
8787

8888
var sb strings.Builder
8989
sb.WriteString("\n")
90-
sb.WriteString(" " + styleStatusAccent.Render("Glean CLI") + "\n")
90+
title := "Glean CLI"
91+
if m.version != "" && m.version != "dev" {
92+
title += " " + styleTagline.Render(m.version)
93+
}
94+
sb.WriteString(" " + styleStatusAccent.Render(title) + "\n")
9195
if email != "" {
9296
sb.WriteString(" " + styleTagline.Render("Logged in as "+email) + "\n")
9397
}

0 commit comments

Comments
 (0)