@@ -61,6 +61,16 @@ func (a *App) createEntriesView(projectID string) tview.Primitive {
6161
6262 // Load and display entries
6363 loadEntries := func () {
64+ // Remember currently selected entry ID before clearing
65+ var selectedEntryID string
66+ row , _ := table .GetSelection ()
67+ if row > 0 {
68+ cell := table .GetCell (row , 0 )
69+ if entry , ok := cell .Reference .(* models.Entry ); ok {
70+ selectedEntryID = entry .ID
71+ }
72+ }
73+
6474 table .Clear ()
6575
6676 entries , err := a .store .ListEntriesFiltered (
@@ -102,6 +112,9 @@ func (a *App) createEntriesView(projectID string) tview.Primitive {
102112 var invoicedMinutes int64
103113 var uninvoicedMinutes int64
104114
115+ // Track which row contains the previously selected entry
116+ rowToSelect := 1
117+
105118 // Add entry rows
106119 for i , entry := range entries {
107120 row := i + 1
@@ -114,6 +127,11 @@ func (a *App) createEntriesView(projectID string) tview.Primitive {
114127 uninvoicedMinutes += entry .Duration
115128 }
116129
130+ // Check if this is the previously selected entry
131+ if selectedEntryID != "" && entry .ID == selectedEntryID {
132+ rowToSelect = row
133+ }
134+
117135 // Format invoiced status
118136 invoicedText := "✗"
119137 invoicedColor := ColorUninvoiced
@@ -150,9 +168,9 @@ func (a *App) createEntriesView(projectID string) tview.Primitive {
150168 SetAlign (tview .AlignCenter ))
151169 }
152170
153- // Select first data row
171+ // Select appropriate row (previously selected entry or first row)
154172 if len (entries ) > 0 {
155- table .Select (1 , 0 )
173+ table .Select (rowToSelect , 0 )
156174 }
157175 }
158176
0 commit comments