Repository navigation
Description
Problem
On /dashboard/insights, the Prompt Results by Topic section groups each prompt's results by platform. When an AI provider changes the model slug it returns for a given platform (e.g. ChatGPT's web surface reporting gpt-5-5 and later gpt-5-3-mini), the same logical platform shows up as two separate groups for that prompt — e.g. two "ChatGPT" rows under one prompt.
This is not data corruption — the underlying prompt_results rows are correct. It's purely a grouping/display issue, and it recurs every time a provider rolls its model slug.
Root cause
In web/src/app/[locale]/(dashboard)/dashboard/insights/page.tsx, groupResultsByPlatform() keys groups by platform + model:
const key = `${r.platform}|${r.modelUsed ?? ''}`;model_used stores whatever slug the provider/scraper returned for that run. When the slug changes over time for the same platform, the composite key produces a second group, so the history splits into a "phantom" duplicate platform.
Why it keeps happening
Providers periodically rename the model behind a surface. A platform is never tracked with two models concurrently — each platform runs exactly one model at a time, and the slug simply drifts. Observed cases (last 30 days, sequential — not concurrent):
chatgpt-web:chatgpt-web→gpt-5-5→gpt-5-3-minichatgpt-shopping:gpt-5-5→gpt-5-3-minigrok-web:grok-web→grok-3
Platforms whose slug has been stable (claude = claude-sonnet-4-6, copilot-web, gemini-web, google-aimode, google-aio, perplexity-web) each show a single group, confirming the duplicate only appears on slug change.
Proposed fix
Group by platform only, and keep the model as display metadata (the latest run's model still drives the badge, e.g. "ChatGPT · gpt-5-3-mini"). The per-run history inside the group then spans the slug change instead of fragmenting into two groups.
- In
groupResultsByPlatform(), change the key tor.platform. - The group's
modelUsedshould remain the latest run's model (already the case — it reads from the most recent result), so the badge keeps showing the current model. - Distinct platforms that are genuinely separate surfaces (e.g.
chatgpt-webvschatgpt-shopping) must stay separate — they already have distinctplatformvalues, so platform-only keying preserves that.
Acceptance criteria
- A prompt whose platform model slug changed over time shows one group per platform (no duplicate "ChatGPT"/"Grok" rows)
- The platform group's model badge reflects the most recent run's model
- The previous-runs history inside a group includes runs from before and after the slug change
- Genuinely distinct platforms (web vs shopping surfaces) remain separate groups
- No change to stored data or RPCs — display layer only
Pointer
groupResultsByPlatform() in web/src/app/[locale]/(dashboard)/dashboard/insights/page.tsx (around the const key = ... line).
Activity