on main help sign in
fix: sidebar files jumping
commitcb6642b5fb1a67cfe5feb8052df36c7aa55f1c40 authorKujtim Hoxha <kujtimii.h@gmail.com> dateSun 3 Aug 2025, 22:56 (1 year ago) parent35fc31b
1 file changed+7−1
internal/tui/components/chat/sidebar/sidebar.go+7−1
internal/tui/components/chat/sidebar/sidebar.go+7−1
@@ -400,6 +400,9 @@ func (m *sidebarCmp) filesBlockCompact(maxWidth int) string {
400400
401401 fileList := []string{section, ""}
402402 sort.Slice(files, func(i, j int) bool {
403+ if files[i].History.latestVersion.CreatedAt == files[j].History.latestVersion.CreatedAt {
404+ return files[i].FilePath < files[j].FilePath
405+ }
403406 return files[i].History.latestVersion.CreatedAt > files[j].History.latestVersion.CreatedAt
404407 })
405408
@@ -626,8 +629,11 @@ func (m *sidebarCmp) filesBlock() string {
626629 }
627630
628631 fileList := []string{section, ""}
629− // order files by the latest version's created time
632+ // order files by the latest version's created time, then by path for stability
630633 sort.Slice(files, func(i, j int) bool {
634+ if files[i].History.latestVersion.CreatedAt == files[j].History.latestVersion.CreatedAt {
635+ return files[i].FilePath < files[j].FilePath
636+ }
631637 return files[i].History.latestVersion.CreatedAt > files[j].History.latestVersion.CreatedAt
632638 })
633639