Skip to content

Commit 8224f92

Browse files
committed
refactor: rename commandbar to inputbar
1 parent 57a1891 commit 8224f92

3 files changed

Lines changed: 34 additions & 34 deletions

File tree

‎internal/app/chat/chat.go‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
tea "charm.land/bubbletea/v2"
88
"charm.land/lipgloss/v2"
99

10-
"github.com/usetero/cli/internal/app/chat/commandbar"
10+
"github.com/usetero/cli/internal/app/chat/inputbar"
1111
"github.com/usetero/cli/internal/app/chat/messagelist"
1212
"github.com/usetero/cli/internal/app/chat/msgs"
1313
appmsg "github.com/usetero/cli/internal/app/msgs"
@@ -26,9 +26,9 @@ var (
2626
key.WithKeys("up"),
2727
key.WithHelp("↑↓", "scroll"),
2828
)
29-
focusCommandBar = key.NewBinding(
29+
focusInputBar = key.NewBinding(
3030
key.WithKeys("tab"),
31-
key.WithHelp("tab", "focus command bar"),
31+
key.WithHelp("tab", "focus input"),
3232
)
3333
focusChat = key.NewBinding(
3434
key.WithKeys("tab"),
@@ -50,7 +50,7 @@ type Model struct {
5050
scope log.Scope
5151
focus focus
5252

53-
commandBar *commandbar.Model
53+
inputBar *inputbar.Model
5454
messageList *messagelist.Model
5555

5656
// Conversation is created lazily on first message
@@ -84,7 +84,7 @@ func New(
8484

8585
return &Model{
8686
scope: scope,
87-
commandBar: commandbar.New(theme, scope),
87+
inputBar: inputbar.New(theme, scope),
8888
messageList: messagelist.New(theme, db, chatClient, toolRegistry, scope),
8989
account: account,
9090
workspace: workspace,
@@ -97,7 +97,7 @@ func New(
9797

9898
// Init initializes the model.
9999
func (m *Model) Init() tea.Cmd {
100-
return m.commandBar.Init()
100+
return m.inputBar.Init()
101101
}
102102

103103
// Update handles messages.
@@ -136,19 +136,19 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd {
136136

137137
case tea.MouseClickMsg:
138138
// Click on the message list area focuses it
139-
if m.hasMessages() && msg.Y >= m.originY && msg.Y < m.originY+m.height-m.commandBar.Height() {
139+
if m.hasMessages() && msg.Y >= m.originY && msg.Y < m.originY+m.height-m.inputBar.Height() {
140140
if m.focus != focusMessages {
141141
cmds = append(cmds, m.setFocus(focusMessages))
142142
}
143-
} else if msg.Y >= m.originY+m.height-m.commandBar.Height() {
143+
} else if msg.Y >= m.originY+m.height-m.inputBar.Height() {
144144
if m.focus != focusEditor {
145145
cmds = append(cmds, m.setFocus(focusEditor))
146146
}
147147
}
148148
}
149149

150150
// Forward to children
151-
cmds = append(cmds, m.commandBar.Update(msg))
151+
cmds = append(cmds, m.inputBar.Update(msg))
152152
cmds = append(cmds, m.messageList.Update(msg))
153153

154154
return tea.Batch(cmds...)
@@ -173,9 +173,9 @@ func (m *Model) setFocus(f focus) tea.Cmd {
173173
switch f {
174174
case focusEditor:
175175
m.messageList.SetFocused(false)
176-
return m.commandBar.Focus()
176+
return m.inputBar.Focus()
177177
case focusMessages:
178-
m.commandBar.Blur()
178+
m.inputBar.Blur()
179179
m.messageList.SetFocused(true)
180180
return nil
181181
}
@@ -198,12 +198,12 @@ func (m *Model) SetOrigin(x, y int) {
198198

199199
// updateLayout calculates sizes for children based on current dimensions.
200200
func (m *Model) updateLayout() {
201-
// CommandBar is fixed height
202-
m.commandBar.SetWidth(m.width)
203-
commandBarHeight := m.commandBar.Height()
201+
// Input bar is fixed height
202+
m.inputBar.SetWidth(m.width)
203+
inputBarHeight := m.inputBar.Height()
204204

205205
// MessageList is flexible - gets remaining space
206-
messageListHeight := m.height - commandBarHeight
206+
messageListHeight := m.height - inputBarHeight
207207
if messageListHeight < 0 {
208208
messageListHeight = 0
209209
}
@@ -214,12 +214,12 @@ func (m *Model) updateLayout() {
214214
// ShortHelp returns the key bindings for the short help view.
215215
func (m *Model) ShortHelp() []key.Binding {
216216
if m.focus == focusMessages {
217-
return []key.Binding{scrollUp, focusCommandBar}
217+
return []key.Binding{scrollUp, focusInputBar}
218218
}
219219
if m.hasMessages() {
220-
return append(m.commandBar.ShortHelp(), focusChat)
220+
return append(m.inputBar.ShortHelp(), focusChat)
221221
}
222-
return m.commandBar.ShortHelp()
222+
return m.inputBar.ShortHelp()
223223
}
224224

225225
// ConversationID returns the current conversation ID.
@@ -364,19 +364,19 @@ func (m *Model) View() string {
364364

365365
colors := m.theme.Colors
366366

367-
// Empty state: centered prompt + command bar
367+
// Empty state: centered prompt + input bar
368368
if !m.hasMessages() {
369-
emptyHeight := m.height - m.commandBar.Height()
369+
emptyHeight := m.height - m.inputBar.Height()
370370
emptyView := lipgloss.NewStyle().
371371
Foreground(colors.Page.TextMuted).
372372
Width(m.width).
373373
Height(emptyHeight).
374374
Align(lipgloss.Center, lipgloss.Center).
375375
Render("Start a conversation...")
376376

377-
return lipgloss.JoinVertical(lipgloss.Left, emptyView, m.commandBar.View())
377+
return lipgloss.JoinVertical(lipgloss.Left, emptyView, m.inputBar.View())
378378
}
379379

380-
// Normal state: message list + command bar
381-
return lipgloss.JoinVertical(lipgloss.Left, m.messageList.View(), m.commandBar.View())
380+
// Normal state: message list + input bar
381+
return lipgloss.JoinVertical(lipgloss.Left, m.messageList.View(), m.inputBar.View())
382382
}

internal/app/chat/commandbar/commandbar.go renamed to internal/app/chat/inputbar/inputbar.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package commandbar
1+
package inputbar
22

33
import (
44
"strings"
@@ -16,9 +16,9 @@ import (
1616
)
1717

1818
const (
19-
textareaHeight = 3 // visible input lines
20-
verticalPadding = 2 // 1 top + 1 bottom
21-
commandBarHeight = textareaHeight + verticalPadding // total height
19+
textareaHeight = 3 // visible input lines
20+
verticalPadding = 2 // 1 top + 1 bottom
21+
inputBarHeight = textareaHeight + verticalPadding // total height
2222
)
2323

2424
// Model handles user input via a textarea.
@@ -29,9 +29,9 @@ type Model struct {
2929
scope log.Scope
3030
}
3131

32-
// New creates a new command bar.
32+
// New creates a new input bar.
3333
func New(theme *styles.Theme, scope log.Scope) *Model {
34-
scope = scope.Child("commandbar")
34+
scope = scope.Child("inputbar")
3535
colors := theme.Colors
3636

3737
ta := textarea.New()
@@ -83,7 +83,7 @@ func New(theme *styles.Theme, scope log.Scope) *Model {
8383
}
8484
}
8585

86-
// Init initializes the command bar.
86+
// Init initializes the input bar.
8787
func (m *Model) Init() tea.Cmd {
8888
return tea.Batch(
8989
m.textarea.Focus(),
@@ -120,7 +120,7 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd {
120120
return cmd
121121
}
122122

123-
// View renders the command bar.
123+
// View renders the input bar.
124124
func (m *Model) View() string {
125125
if m.width == 0 {
126126
return ""
@@ -153,9 +153,9 @@ func (m *Model) SetWidth(width int) {
153153
m.textarea.SetWidth(width)
154154
}
155155

156-
// Height returns the height of the command bar.
156+
// Height returns the height of the input bar.
157157
func (m *Model) Height() int {
158-
return commandBarHeight
158+
return inputBarHeight
159159
}
160160

161161
// Focus returns a command to focus the textarea.

‎internal/app/chat/msgs/input.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package msgs
22

33
import domaintools "github.com/usetero/cli/internal/domain/tools"
44

5-
// UserSubmittedInput is fired when user input is ready (text from command bar or tool results).
5+
// UserSubmittedInput is fired when user input is ready (text from input bar or tool results).
66
type UserSubmittedInput struct {
77
Text string
88
ToolResults []domaintools.Result

0 commit comments

Comments
 (0)