Repository navigation
fix(insights): open a model's whole family from a one-slug link, on Insights and Citations - #1824
Conversation
…bility and Citations
Both pages' model filter offers one entry per name, and its value is the
family's slugs ("chatgpt-web,gpt-5-chat-latest"). A link with one slug,
such as Chat's open_page (model=chatgpt-web, platform=chatgpt-web), read
only that slug. Brand Visibility counted fewer answers than picking ChatGPT
in the dropdown, and Citations dropped the filter: its dropdown clears a
value it doesn't list.
- lib/model-families.ts holds the grouping both pages used inline
(modelLabel, modelFamilies) and modelFamilyValue: one slug of a family
reads as the family.
- Before its first read, each page asks the brand's models once
(getBrandFilterOptions) for a single slug, and moves the filter and the
address to the family. The numbers are read once, for the family.
- Citations always lists the platform asked for among its choices. They
come from the rows read, so a family partly answered in the window was
dropped too.
- Tests: the helpers, and Citations from a link (one slug, a family, a
family of one).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ChatGPT's web answers store the model Cloro names (gpt-5-...), not chatgpt-web, so a link's model=chatgpt-web matched no family and opened an empty page under a ChatGPT chip. A known platform id with no stored answers now reads as the family of the same name. An unknown slug is kept, since its fallback name would be ChatGPT's.
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good with 2718c5b (one commit on this branch). Sharing the grouping between the two pages is a good cleanup, and the Citations Select fix is a real bug fixed. The commit covers the one open case below.
Fixed: a platform id, not a stored slug
modelFamilyValue finds the family that contains the slug. That works when answers were stored under chatgpt-web. But ChatGPT's web answers store the model Cloro returns (cloro-scraper.js: model = result.model || scraperId, so gpt-5-3-mini, gpt-5-5, …). The page's own comment names that family "gpt-5-3-mini" + "gpt-5-5". For such a brand, ?model=chatgpt-web (Insights) or ?platform=chatgpt-web (Citations, which #1807 builds) matches no family and stays as is. The page shows a "ChatGPT" chip over an empty page. The tests use chatgpt-web,gpt-5-chat-latest, so they don't hit this.
The commit: when no family contains it, a known slug (one in MODEL_PROVIDER_LABELS / PLATFORM_LABELS) reads as the family shown by the same name, the way the dropdown groups it. An unknown slug is kept, because resolveAIProvider falls back to OpenAI, so ?model=anything would otherwise open ChatGPT's numbers. Both pages call the same function, so both get the fix. A new test case fails without it (chatgpt-web → gpt-5-3-mini,gpt-5-5, perplexity-web → sonar-pro, an unknown slug and a two-slug value kept).
With this, #1807's open_page could pass the platform to Insights again (as model=). Follow-up there.
Checked, fine
- URL values. An unknown slug costs one
getBrandFilterOptionscall, then the read uses it as is (empty result). A comma list isn't single, so no extra read, and it goes to.in()as before. Values reach PostgREST only through.eq/.inor the RPCs'text[]args. Nothing is interpolated. - Scope. Families come from the brand's own stored answers (
insights_filter_options, the caller's client). A slug outside the plan's engines only narrows the brand's own rows. No other brand's data is reached. - One read. The family lookup happens once per slug (
familyRead), before the first data read. On Citations the load returns and the filter change starts the read. On Insights the read continues with the family. A failed lookup keeps the slug. - Both pages now label models with
modelLabel, and the Citations picker keeps a value it doesn't list (platformChoices). - Build.
model-families.tsimports onlyai-provider-avatarandplatform-labels, no server modules.plan-row.test.tspasses.
Non-blocking
- Insights: a brand switch during the family lookup could put brand A's family back after the switch cleared the model. Citations has
stale()there, but Insights has no equivalent. It's rare, and the next pick fixes it. - An unknown slug still shows "ChatGPT" in both pickers, because of the same
resolveAIProviderfallback. This was already the case before. gemini-webis labelled "Google Gemini", butgemini-*model slugs show as "Gemini" or "Gemini 2.5 Flash". So agemini-weblink maps only if Gemini answers were stored undergemini-web. The labels already don't match today; aligning them would fix the link too.
Merge
- Based on current main and merges clean. No migrations.
- Conflicts with #1843 (and #1844, stacked on it) in
insights/page.tsx. #1843 adds its ownmodelName()with the same three-way lookup. Resolve by keeping #1843'smodelNameas a call tomodelLabel(value.split(',')[0]), and drop the old imports. - Clean with #1807.
Tests
model-families.test.ts(5, incl. the new case), Citationspage.test.tsx,src/app,src/lib/guards(incl.plan-row.test.ts),src/config: 189 files, 1765 tests pass with the fix.tscis clean. eslint has no errors (only existing warnings), and prettier is clean on the changed files.
gkhngyk
left a comment
There was a problem hiding this comment.
Merging in order with the other approved PRs. This head merges current main; its tree is what main will be after this squash, checked with the full server and web suites, tsc, lint, format and next build.
Summary
Found in the W1-28 review (#1807). Insights' and Citations' AI Model filter holds a family of slugs, such as
chatgpt-web,gpt-5-chat-latest. A link with one slug (?model=chatgpt-web, as Chat'sopen_pagebuilds) showed "ChatGPT" in the picker but counted only the web scraper's rows. So opening a page from Chat could give different numbers than picking ChatGPT by hand.What changes
web/src/lib/model-families.ts: the grouping that each page had written on its own (modelLabel,modelFamilies) moves here, plusmodelFamilyValue, which turns one slug into its family's value. Citations'getPlatformDisplayLabelusesmodelLabeltoo, so both pages name models the same way.getBrandFilterOptions, once per slug, before the first data read). The filter and the URL move to the family. The data is read once, so no narrower numbers flash first.onValueChange(null)). The options come from that window's rows, soplatform=chatgpt-webfrom a link was silently dropped, and so was a family only partly answered in that window. The chosen platform is now always among the options (platformChoices, labelled bygetGroupedPlatformLabel).Related issue
Follow-up to #1807.
Type of change
fix— Bug fixHow to test
/dashboard/insights?model=chatgpt-web: the picker shows ChatGPT, and the URL becomes the family./dashboard/citations?platform=chatgpt-web&preset=24h: the filter stays, the URL holds the family, and the picker shows "ChatGPT".Tests:
model-families.test.ts(3), and two new scenarios in Citations'page.test.tsx:11/11.
Checklist
🤖 Generated with Claude Code