a98160f0b963
keep saves made within one second newest first in the all list, breaking the tie by write order instead of by hash (3.0.64)
- time
- 2026-09-26 13:07 UTC · 2 weeks ago
- machine
- Junes-MacBook-Pro.local
- agent
- claude-opus-5-5
- session
- history view
- parent
- 55e1a2cc5c00
↓ koh-a98160f0.tar.gzatlas at this save
files changed4 files
VERSION+1 −1src/history/history.v+3 −1src/history/history_test.v+20 −0v.mod+1 −1src/history/history.v+3 −1
@@ -87,7 +87,9 @@8787 // all_saves returns every save Koh knows, newest first. This is the "all" tab:8888 // it includes saves that were replayed away and are no longer on the line.8989 pub fn all_saves(store &storage.Store) ![]Save {90- mut stmt := store.db.prepare('${select_save} ORDER BY created_at DESC, id DESC')!90+ // Saves made within one second share a time; the order they were written91+ // in breaks the tie, as in Koh 2. An ID is a hash and would shuffle them.92+ mut stmt := store.db.prepare('${select_save} ORDER BY created_at DESC, rowid DESC')!9193 defer {9294 stmt.finalize()9395 }src/history/history_test.v+20 −0
@@ -288,3 +288,23 @@288288 store.commit()!289289 assert !files_of(store, saved.id)!.any(it.path == 'secret.env')290290 }291+292+// Saves made within one second share a time; the all list must still show the293+// newest first rather than ordering them by their hash.294+fn test_all_saves_keeps_same_second_saves_newest_first() {295+ mut store, dir := temp_repo('same_second')!296+ defer {297+ store.close()298+ os.rmdir_all(dir) or {}299+ }300+ mut made := []string{}301+ for i in 0 .. 6 {302+ write_file(dir, 'a.txt', 'version ${i}\n')!303+ made << save_worktree(store, dir, snapshot.Ignore{}, SaveInput{304+ message: 'save ${i}'305+ created_at: 1790000000306+ })!.id307+ }308+ made.reverse_in_place()309+ assert all_saves(store)!.map(it.id) == made310+}v.mod+1 −1
@@ -1,6 +1,6 @@11 Module {22 name: 'koh3'3- version: '3.0.63'3+ version: '3.0.64'44 description: 'One SQLite file per repo, one line of history.'55 license: 'MIT'66 }