Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions pkg/tui/components/messages/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Model interface {
layout.Sizeable
layout.Focusable
layout.Help
layout.Positionable

AddUserMessage(content string) tea.Cmd
AddErrorMessage(content string) tea.Cmd
Expand Down Expand Up @@ -111,6 +112,8 @@ type model struct {
selection selectionState

splitDiffView bool

xPos, yPos int
}

// New creates a new message list component
Expand Down Expand Up @@ -330,6 +333,12 @@ func (m *model) SetSize(width, height int) tea.Cmd {
return nil
}

func (m *model) SetPosition(x, y int) tea.Cmd {
m.xPos = x
m.yPos = y
return nil
}

// GetSize returns the current dimensions
func (m *model) GetSize() (width, height int) {
return m.width, m.height
Expand Down Expand Up @@ -746,12 +755,11 @@ func (m *model) removePendingToolCallMessages() {

// mouseToLineCol converts mouse position to line/column in rendered content
func (m *model) mouseToLineCol(x, y int) (line, col int) {
// Adjust for header (2 lines: text + bottom padding)
adjustedY := max(0, y-2)
adjustedY := max(0, y-m.yPos)
line = m.scrollOffset + adjustedY

// Adjust for left padding (1 column from AppStyle)
adjustedX := max(0, x-1)
adjustedX := max(0, x-1-m.xPos)
col = adjustedX

return line, col
Expand Down
4 changes: 4 additions & 0 deletions pkg/tui/core/layout/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ type Focusable interface {
Blur() tea.Cmd
}

type Positionable interface {
SetPosition(x, y int) tea.Cmd
}

// Help represents components that provide help information
type Help interface {
Bindings() []key.Binding
Expand Down
4 changes: 2 additions & 2 deletions pkg/tui/page/chat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,13 @@ func (p *chatPage) SetSize(width, height int) tea.Cmd {
mainWidth = innerWidth - sidebarWidth
p.chatHeight = height - p.inputHeight
p.sidebar.SetMode(sidebar.ModeVertical)
cmds = append(cmds, p.sidebar.SetSize(sidebarWidth, p.chatHeight))
cmds = append(cmds, p.sidebar.SetSize(sidebarWidth, p.chatHeight), p.messages.SetPosition(0, 0))
} else {
const horizontalSidebarHeight = 3
mainWidth = innerWidth
p.chatHeight = height - p.inputHeight - horizontalSidebarHeight
p.sidebar.SetMode(sidebar.ModeHorizontal)
cmds = append(cmds, p.sidebar.SetSize(width, horizontalSidebarHeight))
cmds = append(cmds, p.sidebar.SetSize(width, horizontalSidebarHeight), p.messages.SetPosition(0, horizontalSidebarHeight))
}

// Set component sizes
Expand Down
Loading