Repository navigation
fix(chat): read over the page's dates and filters in the side panel - #2459
Merged
Merged
Conversation
Chat beside a page now reads what the page shows (the owner's rule, 2026-11-16; step 5 of the page-data plan, gaps G1 and G2). - Period: a period the message names wins, then the page's date chip, then the person's default. A page on All time reads all time. On a page with its own dates the range card isn't shown and nothing is kept as the default; the composer hides the person's range chip beside the page's. A read with a period input (Ads) takes the range when it is one of its periods. - Filters (lib/chat/page-scope.ts, from scopeRead): platform, region and topic fill the reads of the page's brand that take them; a list's own filters (status, category, impact, type, Sources, prompt) only the read of that page's list. Values are checked against each input's schema; a chip no read takes the same way stays text. The model's own input wins, "" reads all, and a question that asks for all of a filter drops that chip. A page of another brand than the run's keeps its filters as words only. - Rules: the reader is told the page's dates and filters apply; each read's scope has from_page, and the writer says once what the answer covers, as on the page, never row counts. - Help: Chat answers for the page's dates and filters unless you ask otherwise. - Eval: citations-page-scope (24 hours, ChatGPT, Brand sources). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
The owner's decisions on ansvisor#2459 (16 Nov): - Citations: the domain and page lists follow the page's Sources, as its table does, and the citations and their average per answer count every source, as its cards do. When list_citations took Sources from the page, the engine runs the same read over every source beside it (one row, same filters and window) and puts its totals next to the filtered lists as all_sources_totals (lib/chat/citation-totals.ts). The person's own Sources read once, as before. The writer says counts are for all sources and lists for the chosen Sources. No change to lib/mcp or the read's registry row. - Ads: get_ads_opportunities takes the page's period only on Ads, and a period the message names anywhere; elsewhere it reads its own 30 days, never the person's default or another page's range (ScopeFacts.rangeFrom: message, page or default). - Lookups by domains or urls take no page filter, as codes and ids. - Help: Ads' Chat line says the period it reads. - Eval: the Citations scenario checks the answer says its scope. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
cihan-gyk
marked this pull request as ready for review
November 16, 2026 19:14
gkhngyk
requested changes
Nov 16, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
runRead runs list_citations twice in parallel when Sources come from the page (allSourcesInput, limit 1), but limit 1 doesn't shrink the work: readCitationAggregates still scans every prompt_results row of the window. Count the all-source totals in the same pass. Also on its own this reads Citations' 24h as a rolling now−24h while the page uses the latest run's days (#2462 fixes that), so it should ship with that fix.
cihan-gyk
pushed a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Nov 16, 2026
The page's search (from its view) now fills `search` on the reads of the page's own list that take one, as ansvisor#2459 fills its list filters: as ansvisor#2460's capped lookup words, never over the model's own search, ids or codes, not for another brand's page, and dropped when the question asks for all. The read's scope names it (from_page.search) and the writer says it. In the models' page_view block every row and ref stay, each label cut to 80 characters; the stored view's cap is now a safety net that every 100-row view fits under. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
When Sources came from the Citations page, the engine ran list_citations twice in parallel: the filtered read and the same read over every source (limit 1) for the cards' totals. Limit 1 didn't shrink the work, so every such question scanned the window's answers twice. The read now counts every source's citations in the same pass that builds the Sources-filtered domain and page lists, and returns them as all_sources_totals when the engine asks (ChatToolContext.allSourcesTotals): one read, one scan. The writer's rule and the result's shape stay as they were. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
This was referenced Nov 17, 2026
gkhngyk
previously approved these changes
Nov 17, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
LGTM, thanks for the fix.
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
This was referenced Nov 17, 2026
gkhngyk
previously approved these changes
Nov 17, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Re-approving after the main merge: the PR's own changes are unchanged (numstat matches; the tools.test.ts resolution keeps both sides).
The page's own-list filters (and, above, its search) reach a read only when the read's route is the page's. The Prompts area's base path opens on Tracked Prompts (next.config.ts redirects it there), but it never matched list_prompts' /dashboard/prompts/tracked. One alias map in page-route.ts (pageRoute, samePage) now decides it for the page's filters (page-scope.ts) and its period (scope.ts). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
help/chat/chat.md keeps both sides' keywords; approved-articles.json regenerated from the help files. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
gkhngyk
pushed a commit
that referenced
this pull request
Nov 18, 2026
Stacks step 7 on both open Chat PRs (#2459 page period and filters, #2460 lookups by name). Their eval scenarios, eval data, eval tests and Chat help keywords are kept as a union; approved-articles.json is regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Step 5 of the "Chat must read everything a page shows" plan (owner, 16 Nov).
Chat beside a page now reads over the page's dates and with the page's filters, unless the question asks for something else. Before, it ignored both:
Now the server applies both, and the answer says once what it covers: "Last 24 hours, ChatGPT, as on the page: citation counts for all sources, lists for Brand sources".
The second commit applies the owner's two decisions from this PR's review: Citations' counts over every source beside its Sources-filtered lists, and Ads' period only on Ads.
Changes
engine.tsrunRange,range.tspageDatesOf).scope.ts,ScopeFacts.rangeFrom: message, page or default).get_ads_opportunitiestakes the page's period (7d, 30d or 90d).lib/chat/page-scope.ts, called fromscopeRead).routemust be the page's route. Actions' "In progress" is not Content's "In progress".model). Mentions sends a platform id (platform). AI Traffic sends the visit's source, which no read takes. A platform chip on any other page is not mapped.owned, competitors →competitor, third_party →external.lib/chat/citation-totals.ts, called from the engine's read).list_citationstook Sources from the page, the engine setsallSourcesTotalson the read's context. The read counts every source's citations in the same pass that builds the filtered lists, and puts them next to those lists asall_sources_totals(citations,avg_citations_per_result). One read, one scan.totalsstay as they were, so the domain and page counts match the table.all_sources_totals, as before.listCitationsForaddsall_sources_totalsonly when its caller asks (allSourcesTotals), and the MCP tool never does.""for platform, model or region means all of them.codes,ids,domains,urls) takes no page filter.brand_idis the page's brand (the brand chip, which the server already sets to the run's brand).messageScopeOf), so no read gets another brand's topic.brandAllowed, as before.scopehasfrom_page(period,platform,sources…). The writer says once what the answer covers, as the page names it. It also names any page filter no read took ("all regions"), and never mentions row counts.all_sources_totals, citation counts and the average per answer come from it, lists from the filtered read, and the line says so ("citation counts for all sources, lists for Brand sources").<page_context>line now says the app reads over its date range and applies its filters.approved-articles.jsonis regenerated. Ads › "Ask Chat about Ads" (119 words): Chat reads the page's period there, and 30 days elsewhere unless you name another period. That article is not approved yet, so the JSON doesn't change for it.citations-page-scope: on Citations (24 hours, ChatGPT, Brand), "What are my top cited domains?".list_citationsover the last 24 hours withmodel: chatgpt-webandsource_filter: owned.Page by page
list_action_center_taskslist_content_opportunitiesregionon every read that takes itplatform; region; topic →topic_idmodel; region; topic →topic_id; Sources →source_filteronlist_citationslists, withall_sources_totalsbeside themmodel; region; topic →topic_idperiod, on Ads only (elsewhere 30d)A read that doesn't take an input keeps the chip as text. For example,
get_overview_summaryhas no region, so on Overview the answer says "all regions".How to test
ADS_ENABLED=true), set your Chat range to Last 7 days. On Ads with the period on 90 days, ask "Which prompts should we pay for?": the read covers 90 days. Ask the same from Chat's own page or beside Citations: it covers 30 days. Ask "… in the last 90 days?" anywhere: 90 days.cd web && SKILL_EVAL=citations-page-scope yarn vitest run src/lib/chat/agent-eval.test.tsChecks
npx tsc --noEmit -p .: passes.src/lib/chat(all),src/lib/mcp,src/components/chat,src/app/api/chat,src/app/api/mcp,src/lib/help,src/i18n,use-server-exportsandsubscription-guard-coverage: 355 files, 4,679 tests, all pass (1 skipped: the real-model eval).page-scope.test.ts);""for all, and "all platforms" or "tüm konular" dropping a chip;period: the page's on Ads, a period the message names anywhere, and 30 days elsewhere even with a 7d or 90d default or another page's range;getCitationsOverview): one read and one scan of the answers; the lists equal the table's Brand rows,totals.domainsequals Unique Domains, andall_sources_totalsequals Total Citations and the average per answer (6 and 1.5, while the Brand-only total is 3); noall_sources_totalswhen nobody asked or the read is over every source;list_citationsand asking it for every source's totals, not when the person named Sources, and the writer gettingall_sources_totalsand the scope-line rule;from_pagein each read's scope, and the reader, writer and<page_context>texts;git merge-tree --write-tree HEAD upstream/main: clean.NAMED_ROWSis untouched.read-tools.tsandlib/mcp/data.tschange only for the opt-inall_sources_totals.Known differences (fixed in #2462, which ships with this PR)
list_citationsaggregates the window's answers in one query, which returns at most 1,000 rows (the database API's row limit), so on a busy brand Chat's citation counts can be lower than the page's cards. fix(chat): rank and count as the pages do #2462 reads the domains and totals from the page's daily rollups instead.Owner decisions (approved 16 Nov)
get_ads_opportunitiestakes the page's period. Elsewhere it reads Ads' own 30 days, never the person's default range.🤖 Generated with Claude Code
https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9