Files
coder/coderd/database
Marcin Tojek 2b488cd5ae fix: order session providers by usage frequency instead of alphabetically
The AI Sessions page Provider column displayed the wrong provider when a
session contained interceptions from multiple providers. This happened
because providers were aggregated with ARRAY_AGG(DISTINCT ... ORDER BY
provider), which sorts alphabetically. Since 'anthropic' < 'openai', a
single Anthropic Haiku title-generation interception would push
Anthropic to index 0, even when the session was primarily an OpenAI
chat.

Replace the alphabetical ARRAY_AGG with a subquery that groups providers
by count and orders them most-frequent-first (with alphabetical as
tiebreaker). The frontend already displays providers[0], so the primary
chat provider now appears correctly.

Fixes: AIGOV-403
2026-05-28 12:01:54 +00:00
..