fix: make resolving less jumpy

This commit is contained in:
2026-08-03 08:41:58 +02:00
parent e36b00f741
commit 4f2b508154
4 changed files with 49 additions and 1 deletions

View File

@@ -1470,6 +1470,45 @@ func TestResolveToggleConfirmsAndUsesCurrentThreadState(t *testing.T) {
}
}
func TestResolvingSelectedThreadKeepsSelectionNearItsPreviousPosition(t *testing.T) {
tests := []struct {
name string
selected int
wantID string
}{
{name: "next thread", selected: 1, wantID: "c"},
{name: "previous thread at end", selected: 2, wantID: "b"},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
m := NewApp(nil, "o", "r", false, 50, time.Second)
m.screen, m.loading, m.focus = threadScreen, false, threadDetailPane
m.details.Threads = []ReviewThread{
{ID: "a", Path: "a.go"},
{ID: "b", Path: "b.go"},
{ID: "c", Path: "c.go"},
}
m.threadIndex = test.selected
resolvedID := m.details.Threads[test.selected].ID
updated, _ := m.Update(threadResolvedMsg{
threadID: resolvedID,
thread: ReviewThread{
ID: resolvedID, IsResolved: true, ViewerCanUnresolve: true,
},
})
m = updated.(App)
if got := m.details.Threads[m.threadIndex].ID; got != test.wantID {
t.Fatalf("selected thread = %q, want nearest thread %q", got, test.wantID)
}
if m.focus != threadDetailPane {
t.Fatalf("focus = %d, want detail pane", m.focus)
}
})
}
}
func TestPollingMarksNewThreadCommentsUnread(t *testing.T) {
m := NewApp(nil, "o", "r", false, 50, 10*time.Second)
m.screen, m.width, m.height = threadScreen, 80, 8