on main help sign in
fix(tui): cursor position in the textarea

Hide the cursor when it's misaligned with the textarea.

commit8f39595eaa57692aa7bcac19425bdea4ab4a3875 authorAyman Bagabas <ayman.bagabas@gmail.com> dateMon 21 Jul 2025, 16:04 (1 year ago) parent0e4f332
1 file changed+6
internal/tui/tui.go+6
internal/tui/tui.go+6
@@ -3,6 +3,7 @@ package tui
33import (
44 "context"
55 "fmt"
6+ "strings"
67
78 "github.com/charmbracelet/bubbles/v2/key"
89 tea "github.com/charmbracelet/bubbletea/v2"
@@ -453,6 +454,11 @@ func (a *appModel) View() tea.View {
453454 var cursor *tea.Cursor
454455 if v, ok := page.(util.Cursor); ok {
455456 cursor = v.Cursor()
457+ // Hide the cursor if it's positioned outside the textarea
458+ statusHeight := a.height - strings.Count(pageView, "\n") + 1
459+ if cursor != nil && cursor.Y+statusHeight+chat.EditorHeight-2 <= a.height { // 2 for the top and bottom app padding
460+ cursor = nil
461+ }
456462 }
457463 activeView := a.dialog.ActiveModel()
458464 if activeView != nil {