Stabilize feed order with a deterministic signal-score tiebreaker

Equal-score stories reshuffled on every pull-to-refresh because the sort
was unstable. Add StorySummary.feedOrder (signalScore desc, then id desc,
mirroring the backend's signal_score DESC, id DESC) and use it for the feed,
the WebSocket re-sort, and the Saved/Search tabs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Robin Kutesa
2026-06-18 23:33:22 +03:00
parent 1e582f5120
commit 9662c2abf6
4 changed files with 16 additions and 5 deletions

View File

@@ -88,7 +88,7 @@ struct SavedView: View {
@Query private var readStories: [ReadStory]
private var stories: [StorySummary] {
cachedStories.map(StorySummary.init(cached:)).sorted { $0.signalScore > $1.signalScore }
cachedStories.map(StorySummary.init(cached:)).sorted(by: StorySummary.feedOrder)
}
var body: some View {
@@ -133,7 +133,7 @@ struct SearchView: View {
return store.stories
.filter { $0.headline.localizedCaseInsensitiveContains(query)
|| $0.summary.localizedCaseInsensitiveContains(query) }
.sorted { $0.signalScore > $1.signalScore }
.sorted(by: StorySummary.feedOrder)
}
var body: some View {