fix(tui): track selection by site ID + q means back everywhere
Cursor tracked by site ID instead of positional index. When the list re-sorts every tick (sites change status), the selection stays on the same monitor instead of silently jumping to whatever now occupies that index position. q now means "back" in detail, history, SLA, and alert-detail views — consistent with muscle memory from navigating deeper views. Only the dashboard q quits the app. ctrl+c always quits from anywhere.
This commit was merged in pull request #113.
This commit is contained in:
@@ -105,9 +105,24 @@ func (m *Model) refreshLive() {
|
||||
}
|
||||
m.sites = ordered
|
||||
m.logViewport.SetContent(strings.Join(m.engine.GetLogs(), "\n"))
|
||||
|
||||
if m.currentTab == 0 && m.selectedID != 0 {
|
||||
for i, s := range m.sites {
|
||||
if s.ID == m.selectedID {
|
||||
m.cursor = i
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
m.clampCursor()
|
||||
}
|
||||
|
||||
func (m *Model) syncSelectedID() {
|
||||
if m.currentTab == 0 && m.cursor < len(m.sites) {
|
||||
m.selectedID = m.sites[m.cursor].ID
|
||||
}
|
||||
}
|
||||
|
||||
// clampCursor keeps the cursor and scroll offset within the current tab's list.
|
||||
func (m *Model) clampCursor() {
|
||||
listLen := m.currentListLen()
|
||||
|
||||
Reference in New Issue
Block a user