From cb6642b5fb1a67cfe5feb8052df36c7aa55f1c40 Mon Sep 17 00:00:00 2001 From: Kujtim Hoxha Date: Sun, 3 Aug 2025 22:56:26 +0200 Subject: [PATCH] fix: sidebar files jumping --- internal/tui/components/chat/sidebar/sidebar.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/tui/components/chat/sidebar/sidebar.go b/internal/tui/components/chat/sidebar/sidebar.go index 1f5fd2a672e3d643efbed4ca35b08ed88c55d2eb..ccbc9330f979acd0750279a278ebb8748e5a32cf 100644 --- a/internal/tui/components/chat/sidebar/sidebar.go +++ b/internal/tui/components/chat/sidebar/sidebar.go @@ -400,6 +400,9 @@ func (m *sidebarCmp) filesBlockCompact(maxWidth int) string { fileList := []string{section, ""} sort.Slice(files, func(i, j int) bool { + if files[i].History.latestVersion.CreatedAt == files[j].History.latestVersion.CreatedAt { + return files[i].FilePath < files[j].FilePath + } return files[i].History.latestVersion.CreatedAt > files[j].History.latestVersion.CreatedAt }) @@ -626,8 +629,11 @@ func (m *sidebarCmp) filesBlock() string { } fileList := []string{section, ""} - // order files by the latest version's created time + // order files by the latest version's created time, then by path for stability sort.Slice(files, func(i, j int) bool { + if files[i].History.latestVersion.CreatedAt == files[j].History.latestVersion.CreatedAt { + return files[i].FilePath < files[j].FilePath + } return files[i].History.latestVersion.CreatedAt > files[j].History.latestVersion.CreatedAt })