Skip to content

fix(chat): read the page's view: tab, sort, search and the rows on screen - #2463

Merged
gkhngyk merged 32 commits into
ansvisor:mainfrom
cihan-gyk:fix/chat-page-view
Nov 18, 2026
Merged

gkhngyk merged 32 commits into
ansvisor:mainfrom
cihan-gyk:fix/chat-page-view

Conversation

@cihan-gyk

@cihan-gyk cihan-gyk commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Merged with main (17 Nov): merged #2462 (with main at 3b4d242). page-scope.ts keeps both imports, the help keywords keep both sides, and approved-articles.json is regenerated. git merge-tree against main is clean.

Review fixes (17 Nov)

1. The page's search now reads the page's rows (review of 17 Nov: with the page's search, list_prompts and list_content_opportunities used their lookup path. That path dropped the page's status, archived, topic, is_active, impact and type filters and its sort, while scopeForModel still said those were taken.)

  • web/src/lib/chat/page-scope.ts pageFilterInputs:
    • When the app fills a read's search from the page's search, it also sets the new as_listed input (AS_LISTED) on reads whose search is otherwise a lookup.
    • The model's own search on such a read stays a lookup by name in every status. Like ids and codes, it now takes none of the page's filters, so none is reported as taken. Before, a status chip was reported but ignored.
    • Reads whose search is an ordinary filter (Mentions, History, Agents) work as before.
  • web/src/lib/chat/registry/read-tools.ts, list_prompts and list_content_opportunities:
    • New as_listed input. With it, the search reads the list rather than the lookup. list_prompts applies topic_id and is_active and lists newest first. list_content_opportunities applies status, impact and type, sets archived aside unless asked by status, and keeps the read's sort.
    • Both page and count like the list ("All 3 opportunities whose title holds every word of the search, newest first").
    • Their descriptions say so.
  • web/src/lib/chat/scope.ts namesRows: a search with as_listed no longer counts as naming rows, so it keeps the list's page and the model's limit. Ids still name rows.
  • web/src/lib/mcp/data.ts: promptsPageFor and contentOpportunitiesPageFor take asListed. It applies the list's filters and sort and matches each search word as an escaped ilike, the same way the lookup does. The MCP tools are unchanged.
  • Checked every read the page search can reach. Only these two have a lookup search. list_mentions, get_action_history and list_my_agents already apply their search as a filter. list_drafts and list_reports get no page search.

2. /dashboard/prompts counts as the Tracked Prompts page

  • New web/src/lib/chat/page-route.ts (added in fix(chat): read over the page's dates and filters in the side panel #2459, where the route match lives). pageRoute() and samePage() read one alias map, PROMPTS_BASE → PROMPTS_TRACKED from prompts-routes.ts. main's next.config.ts redirects /dashboard/prompts to /dashboard/prompts/tracked, the home page since feat(prompts): simplify the Prompts page header #2472–feat(nav): analytics before execution; everyone lands on Prompts › Tracked Prompts #2475.
  • The page↔tool match (page-scope.ts, tool.route === page.route → samePage) and the page's period (scope.ts) use the helper. So do the view's URL keys (page-view.ts viewRoute), its open item (page-view-scope.ts) and its order (page-order.ts pageOrderOf). The duplicate '/dashboard/prompts' entries are gone.
  • web/src/lib/chat/page-order.ts pageOrderLine takes takes. The engine (engine.ts) builds it from pageFilterInputs, the same function that fills the reads.
    • The line says "the app applies that search to …" only when the app does.
    • When the app doesn't (the question asks for all of them, or the search has no words to search), it says so and points to the rows on screen.
    • It leaves out a filter's "all" only when the app fills that filter.
  • help/chat/chat.md: Chat's lists follow the page's search within the page's filters, and an item named on its own is still found in any status.

Tests

  • web/src/lib/chat/page-search.test.ts (new) runs scopeRead and then the read on a fake database:
    • Content's search with type, impact and status chips returns only the page's rows, newest first (the page's sort). Rows of another status, impact or type, and archived rows, are left out. took is ['type','impact','status','search'].
    • Without chips, archived rows are set aside and the score and oldest sorts are kept. An archived chip reads only archived rows.
    • The model's own search is a lookup (it finds the archived one) and reports nothing taken. With as_listed, the chips apply.
    • "Show all opportunities" drops the search and keeps the filters.
    • Tracked Prompts' search on /dashboard/prompts and on /dashboard/prompts/tracked returns only active prompts of the topic, newest first, and reports ['search']. A named lookup still finds a paused prompt.
    • The order line says the app applies the search on both Prompts routes. It doesn't say so for "all prompts", for a search with no words, or without takes. A filter's "all" follows what the app fills.
  • web/src/lib/chat/page-scope.test.ts: as_listed on both Prompts routes and on Content. The model's lookup takes no page filters. Mentions keeps its filters beside a model search.
  • web/src/lib/chat/scope.test.ts: a search with as_listed doesn't name rows, and one with ids still does.
  • web/src/lib/chat/page-order.test.ts: the claim on /dashboard/prompts and /dashboard/prompts/tracked, and no claim when takes says none.
  • web/src/lib/chat/page-route.test.ts (in fix(chat): read over the page's dates and filters in the side panel #2459): both routes, the other Prompts views, prototype keys.

Merged with main (17 Nov): via the updated #2462; the eval files are a union (pageTop next to scenario checks); only the eval test imports conflicted (union).

Review fixes (16 Nov): No change to this PR's own code. It merges the updated #2462 (which includes the updated #2459) and upstream/main (#2460 and #2461 are merged).

Stacked on #2462 (→ #2459). Until they land, this diff also shows their commits. This PR's own changes are commits ddcc080a8 and cea81aadb, plus the merge 9dc1a518a.

Summary

Step 8 of the "Chat must read everything a page shows" plan (owner, 16 Nov): the page's view reaches Chat (audit gap G7).

Until now the side panel sent the page's path and its chips only. The sort and search the person picked, the open tab, an open drawer (?action=<id>), the address on /citations/url?u=… and the rows on screen never reached Chat. So "what are these?", "the first ones" after a sort, or "how are these doing?" after a search were answered from a list read in the read's own order, which can be other rows.

Now each message from the panel carries the page's view: its tab, sort, search, the rows on screen (by the code the page shows, else the id, domain or address, with their title) and the list's total, plus the page's own URL state, whitelisted per page. The engine checks it again, gives it to both models as untrusted data, and tells the reader to read those rows by their refs before saying anything about them. The page's chosen sort replaces its default in the order line, mapped to the read's sort input where one exists. The page's search is applied by the server to the reads of that page's own list, as #2459 applies its list filters, and the answer says it ("matching "skip a month", as on the page").

This needs one change in chat-thread-view.tsx (send() posts the view), which the owner allowed for this plan ("chat-thread-view izni var"). It is 7 lines, below.

Changes

  • ChatPageContext.view (new plain module lib/chat/page-view.ts): tab, sort ({ key, dir }, the page's own sort name), search, rows ({ ref, label }, at most 100, labels cut to 200 characters on one line), total, query. viewRows() builds the rows from what the page already holds; nothing is read again.
  • The 8 pages pass it through useChatPageContext (table in "Page by page"). Where a table keeps its own state (Prompts › Tracked, the Mentions table, Ads › Opportunities), it hands its part up with an onChatView callback. No rows or total while a list is still loading.
  • URL state. ChatSidePanel adds the page's query to view.query, read as the message goes (so a URL written 300 ms after a change is current). Only the keys each page writes with writeUrlParams or reads as its state (PAGE_QUERY_KEYS), at most 20, each value on one line and cut to 300 characters. Everything else is dropped: token, code, next, utm_*, unknown keys. The query is never appended to the route, so originPage is untouched. No view goes once the person takes the page chip off with ×, or on a Retry from another page.
  • chat-thread-view.tsx (owner's exception for this plan): a pageView prop, and send() posts its result beside route and chips:
    +import type { ChatPageView } from '@/lib/chat/page-view';
    +  pageView,
    +  /** What the page on `route` shows as the message goes (its tab, sort, search, rows, URL state). */
    +  pageView?: (route?: string) => ChatPageView | undefined;
    -        ...(sent.context.length > 0 ? { context: { route, chips: sent.context } } : {}),
    +        ...(sent.context.length > 0
    +          ? { context: { route, chips: sent.context, view: pageView?.(route) } }
    +          : {}),
    Nothing else in the file changed.
  • Server (new plain module lib/chat/page-view-scope.ts):
    • startRunFields takes context.view with zod, field by field. A field that isn't what a page sends is dropped, never refused: a tab or sort key must be a word, dir asc or desc, total a non-negative integer. A row needs a ref that is an app code (AC-12, S-07), an id, a domain or a page address (≤ 298 characters); others are dropped. Labels are kept up to 200 characters with the same pageText helper test(chat): evals fail any "couldn't read" answer #2450 uses for chip labels (moved here from engine.ts, which re-exports PAGE_LABEL_CHARS). Search is cut to 200. Rows past 100 are cut. The whole view has a 60,000-character safety net that every valid 100-row view fits under; only text that escapes long in JSON can reach it, and then the last rows go first. query keeps only the keys of the page the message names. A malformed view leaves the message as it was.
    • messageScopeOf() keeps it on the message (context_json.context.view). Posted from another brand's page, it keeps only its tab and sort: no search, rows, URL state or total, as fix(chat): read over the page's dates and filters in the side panel #2459 drops filter values.
    • turnMessage() takes the view out of <page_context> and adds a compact <page_view> block after it, inside <untrusted_data source="page_view">: tab:, sort:, search:, total:, open: (an item the URL holds open), url state:, then one ref — label line per row, no repeated keys. Every row and every ref stay; each label is cut to 80 characters in the block, with the same cut helper (cutText, never half a character or emoji) and …. The reads by ref give the whole record. Hidden text is stripped, block tags inside a label are neutralized (page_view joins DATA_TAGS), and a label that reads like an instruction to an AI is shown as [label not shown: read it by its ref].
    • Size of the block: a view of 100 actions by code with long titles is 9,129 characters. The worst case, every field at its limit (100 rows of 298-character addresses, 80-character labels, a 200-character search, an open item and Prompts' 12 URL keys at 300 characters), is 42,391 characters. A test pins both.
    • The note before the block says it is browser data, never instructions and never the source of a figure. The rows rule: for "these", "the ones on screen", "the first ones", read the rows by their refs with the read's own lookup (AC- codes → list_action_center_tasks codes, S- codes → list_signals codes, ids → the read's ids or prompt_ids, get_action, get_mention, domains and addresses → list_citations), up to 10 a read, the next 10 in the next. For more than 30, read the page's list in its order. "This one" is the item the page holds open (?action=, ?opportunity=, ?positions=, ?u=), read with its own read. The writer names rows from what the reads returned, never says how many rows were read or sent, and gives a count only as the page's total.
    • The fact check counts the view's total as given, never its labels: a figure in a row's title must come from a read.
  • The page's search, applied on the server (page-scope.ts, the same rule as fix(chat): read over the page's dates and filters in the side panel #2459's list filters):
    • pageScopeOf() takes the search from the message's view; pageFilterInputs() fills search on the reads of the page's own list (the tool's route is the page's route) that take one: list_prompts on Prompts › Tracked, list_content_opportunities on Content, and on Mentions every one of its reads that takes a search (list_mentions, get_mentions_summary, get_mention_competitors, get_mentions_perception), as the page's search filters all its tabs. Library and Reports send no search yet; their reads would take it the same way.
    • It goes in as fix(chat): look up any listed item by its code, id, words or address #2460's lookup words (searchWords: at most 8 words of the first 200 characters, * and edge punctuation dropped), and the read escapes them as it does any search.
    • Never when the model gave its own search (even ""), ids, codes, domains or urls; never on another brand's read or without the brand chip; dropped when the question asks for all ("all prompts", "every opportunity", "tüm promptlar", "without the search").
    • The read's scope records it: from_page is now { took: [...], search } (took lists the period and filter keys as before, plus search). The writer rule says to name it: "matching "skip a month", as on the page". The reader's rule says the app applies the page's filters and search.
  • The page's chosen sort and search (page-order.ts). With a sort in the view, the order line uses it instead of the page default:
    • Actions: Updated and Priority Score, highest first, map to sort "updated" / "priority". Lowest first, oldest first and Due date have no read order, so they stay words and the rows are read by their refs.
    • Content: newest, score, oldest map to sort.
    • Prompts: Visibility, Mentions and Citations map to sort_by and order. Position, volume, runs, added and last run stay words.
    • Mentions (no line before, its read already lists newest first): newest, oldest, co-mentions and negative map to list_mentions' sort.
    • A key no page has stays in page_view and the line only points to it.
    • With a search, the line says the app applies it to list_prompts (then get_prompt_performance with their ids), list_content_opportunities or list_mentions unless the model gives its own. Actions' read has no search, so its rows are read by code. The search text itself stays in the untrusted block.
  • Help. Chat › "Numbers that match the page" gains two sentences (section now 100 words): "Chat also sees the open tab, the sort and search you picked, and the items on screen, and reads those items before it answers: "these" are the rows you see. On Prompts, Content and Mentions, Chat's lists follow the page's search, and the answer says so." Keywords added; approved-articles.json regenerated with yarn vitest run -u src/lib/help.
  • Eval (testing/agent-eval.ts): scenarios can carry the page's view, a pageSearch the list read must take, and pageRows the answer must name. Two new scenarios:
    • actions-page-view: Actions sorted by Priority Score, filtered to New, 3 rows on screen; "What are these?" must read AC-41, AC-42 and AC-44 by their codes, name each by title and code, and name no other action.
    • prompts-page-search: Prompts › Tracked searched for "coffee subscription"; "How are these doing?" must read list_prompts with that search, say the search, and name each prompt it shows. On the scripted model the run calls list_prompts with no search, the server fills it, and the writer sees from_page: { took: ["search"], search: "coffee subscription" }.

Page by page

Page tab sort search (server applies it to) rows on screen (ref — label) total URL keys kept
Action Center › Actions – Updated, Priority Score (either way), Due date the search box (no read takes it: rows by code) AC- code — title, in the list's order the list's count after filters category, priority, status, assignee, sort, q, from, action
Content › Opportunities – newest, score, oldest the search box (list_content_opportunities) id — title (the page of 100) the server's total status, impact, type, source, suggested, from, to, sort, prompt, opportunity
Prompts (all tabs) tracked, suggestions, topics, fanout, insights Tracked: the column picked and its direction (none until one is) Tracked's search (list_prompts) Tracked: id — prompt text (the page on screen) prompts matching range, from, to, region, status, sort, dir, layout, positions, positionsRange, positionsFrom, positionsTo
AI Referral Traffic – – the visit list's search (no read takes it) visit id — landing page · platform visits matching none (its range is kept in the browser)
Visibility › Mentions overview, mentions, perception Mentions tab: newest, oldest, co_mentions, negative the search box (list_mentions, get_mentions_summary, get_mention_competitors, get_mentions_perception) Mentions tab: answer id — prompt · platform (the page of 100) answers matching tab, range, from, to, platform, region, topic, q, sentiment, with, sort, group
Visibility › Citations domains, urls, gaps, types – (most cited first) – domain — domain, or address — page title (the page of 100); Gaps: domain the tab's table count preset, from, to, platform, region, topic, prompt, scope
Citation URL page – (no page context yet) – – – – u, preset, from, to, platform, region, topic, prompt
Visibility › Overview – – – none: no list on the page – range, from, to, region, model, topic
Ads (ADS_ENABLED) overview, opportunities, paid_sov, campaigns, connections – – Opportunities: prompt id — prompt text, under the decision filter rows under the filter none (its tab is in the hash)

Safety

  • The view is client data and is treated as untrusted: it is never used for authorization. It goes to the models only in <untrusted_data source="page_view">. The one input filled from it is the page's search, on the page's own list, the way fix(chat): read over the page's dates and filters in the side panel #2459 fills the page's list filters from its chips: after the read's brand check, as fix(chat): look up any listed item by its code, id, words or address #2460's capped lookup words, escaped by the read, never over the model's own inputs, and not for another brand's page.
  • Refs only reach reads the model calls. Every lookup still checks brandAllowed, filters by brand_id and joins the organization, so a ref from another brand finds nothing.
  • Another brand's view keeps its tab and sort only.
  • URL keys are whitelisted per page twice: in the browser and again on the server, by the route the message names. Tokens, auth codes, next= and unknown keys never leave the browser and are dropped if posted.
  • Labels: hidden characters stripped, block tags neutralized, one line each, at most 200 characters stored and 80 in the models' block, and a label aimed at an AI withheld.
  • No row counts to users: the writer is told never to say how many rows were read or sent, and a count only as the page's total.
  • No migration, no new dependency, no lockfile change. No 'use server' file changed. page-pane.tsx, page-open.ts, the content editor folder and Action Center site-type files are untouched.

How to test

  1. Action Center › Actions, filter Status: New, sort Priority Score. Open Chat and ask "What are these?". The step reads Action Center by the codes on screen. The answer names each action by title and code, highest Priority Score first, and no other action.
  2. Same page: sort by Due date and ask "What are the first 3 on the page?". The rows on screen, in that order.
  3. Open an action's drawer and ask "What is this one about?". Chat reads that action.
  4. Prompts › Tracked: type "coffee" in the search and ask "How are these doing?". The prompts step reads with that search even when the model gives none, and the answer starts "Matching "coffee", as on the page" and names them with their Visibility. Then ask "How are all prompts doing?": no search.
  5. Prompts › Tracked: click the Mentions header and ask "Show the top 5 on the page". Ranked by mentions, as the table.
  6. Content: sort Score and ask "Show me the first 3". Highest score first.
  7. Citations, URLs tab: ask "What are these pages?". Chat reads them by address.
  8. Mentions: search "espresso" and ask "How many mentions?". The count is the page's for that search, and the answer says so.
  9. Take the page chip off with ×, then ask "What are these?". No view is sent (DevTools: the run request's context has no view).
  10. DevTools: add ?token=abc&next=/x to a page's URL and send a message. context.view.query has neither.
  11. Optional, real model: cd web && SKILL_EVAL=actions-page-view yarn vitest run src/lib/chat/agent-eval.test.ts, and SKILL_EVAL=prompts-page-search.

Checks

  • npx tsc --noEmit -p . passes.
  • Vitest on src/lib/chat (all), src/lib/mcp, src/components/chat, src/app/api/chat, src/app/api/mcp, the 8 pages' tests (Actions, Content, Prompts, AI Traffic, Mentions, Citations, Overview, Ads), src/lib/action-center, src/lib/help, src/i18n, use-server-exports and subscription-guard-coverage: 448 files, 5,870 tests, all pass (1 skipped: the real-model eval). Run again after the review merge.
  • New tests:
    • page-view.test.ts: rows capped at 100 and labels cut on one line (no half emoji); the URL whitelist keeps the page's keys only (token, code, next, access_token, utm_source dropped), values cut to 300; the panel puts the URL's state in place of any the page set.
    • page-view-scope.test.ts (through startRunInput): what a page sends is kept; over-limit rows, labels and search are cut and bad tabs, sorts, totals, refs and queries dropped, never refusing the message; the query is whitelisted by the message's route; 100 rows of the longest refs and labels are all kept, and the 60,000-character safety net cuts only text that escapes long, last rows first; ref kinds; another brand's view keeps its tab and sort only. The block: compact ref — label lines in <untrusted_data source="page_view">, each label cut to 80 (never half an emoji), the 9,129- and 42,391-character sizes pinned, an instruction-like label withheld, tags neutralized, the open item only for its page and ref kind; the reader and writer rules.
    • page-order.test.ts: the chosen sort beats the default and maps to sort / sort_by + order; unmapped and unknown sorts stay words and point to the refs; the line says the app applies the search to list_prompts, list_content_opportunities, list_mentions, and its text stays out of the line.
    • page-scope.test.ts (as fix(chat): read over the page's dates and filters in the side panel #2459's filter tests): the search comes from the view; it fills search on the page's own list only (Prompts' list_prompts, Content's list beside its status filter, all of Mentions' reads), not on another page's list, a read without one, or Actions; fix(chat): look up any listed item by its code, id, words or address #2460's words (8 at most, 200 characters, no wildcard); never over the model's own search (or "") or ids, nor for "all prompts", "Tüm promptlar", "every prompt", "without the search"; none for another brand or without the brand chip.
    • engine.test.ts: from_page as { took: [...] } in fix(chat): read over the page's dates and filters in the side panel #2459's three filter tests.
    • engine.test.ts: the view is kept on the message with its whitelisted query, reaches both models in its untrusted block, is gone from <page_context>, and the chosen sort drives the order line.
    • chat-thread-view.test.tsx: send() posts context.view from the page on route, read only as the message goes. chat-panel.test.tsx: the panel's getter adds the URL's whitelisted keys (current at send time), none on a Retry from another page or with the page chip off.
    • Pages: Actions (default sort, a chosen sort and search, codes in the list's order, none while loading), Content (sort, rows, server total, none while loading), Prompts (tab, column sort, search, the page's rows; another tab sends its name only; no sort until a header is picked), Mentions page and table, Citations (domains then URLs), Overview (no view), Ads view and Opportunities, AI Traffic (trafficChatView).
    • Eval: actions-page-view and prompts-page-search on the scripted model, each with a passing run and a failing one ("these" from a list read; a read without the page's search). In the passing prompts-page-search run the model calls list_prompts with no search: the server applies "coffee subscription", get_prompt_performance by ids takes none, the writer sees from_page: { took: ["search"], search: "coffee subscription" }, and the new must check "says the page's search" passes. The grading helpers.
  • ESLint and Prettier are clean on the changed TypeScript files. The only ESLint output is 3 warnings that were already there: citations/page.tsx:1314 (the export's useCallback deps) and engine.test.ts:255–256.
  • git merge-tree --write-tree upstream/main HEAD (0044e8fea): clean at 9dc1a518a.
  • No migration, new dependency, lockfile change or 'use server' file change. page-pane.tsx, page-open.ts, the content editor folder and Action Center site-type files are untouched.
  • Screenshot (dark, 2×): the panel on Actions after "What are these?", its step "Read Action Center" and the three actions named with their codes. A test harness with the real ChatThreadView and ActionTable; the header is the panel's, drawn by hand.

Not in this PR

  • Pages without a page context (plan item 9): Today, Signals, History, KPIs, Review, Agents, Competitors, Products, Site Audit, Library, Plan, Reports and the Citation URL page. The panel already sends their whitelisted URL keys where listed (e.g. u on /citations/url), and they can pass rows with one useChatPageContext call each.
  • Actions' card focus (Top, At risk, Opportunities, In progress) isn't in the URL or the view. The rows on screen reflect it.
  • Mentions' response drawer isn't in the URL, so "this one" there isn't known.
  • AI Traffic's visits have no Chat read by id (audit section 5). Their refs and labels go, but no lookup takes them.
  • Ads' opportunities have no lookup by id. Their prompt ids work with get_prompt_performance's prompt_ids.

Choices made

Made in review to match the screen and keep the prompt small; the owner can change any of them:

🤖 Generated with Claude Code

https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

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
Stacks step 7 on both open Chat PRs (ansvisor#2459 page period and filters,
ansvisor#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
Step 7 of the "Chat must read everything a page shows" plan: Chat's
numbers and "top" lists equal the screen's.

- Counts past 1,000 answers: the citations scan, the visibility
  summary's raw window and a product's appearances read the window a
  page at a time, newest first, up to 50,000 answers (answer-pages.ts).
  Past that the note says what the counts cover, never a row count.
- Last 24 hours as the page reads it: on Overview and Citations reads,
  the latest completed tracking run's days (the pages' own
  getTrackingWindow, with the service role after brandAllowed); the
  rolling 24 hours before a first run. Prompts and AI Traffic read a
  preset as the last N x 24 hours, as their pages do (page-periods.ts).
- Prompts: get_prompt_performance gives each prompt's AI Visibility
  Score and Coverage, as the Prompts table (the page's own read, or the
  same sums over a platform's answers) and ranks by it by default;
  avg_visibility stays, sorted by "answer_score", and is labelled.
- The page's default order: Actions can read every status, most
  recently updated first (the list's tie-break too); Content
  Opportunities take the page's Sort (newest, score, oldest). The
  models get the page's order beside <page_context>; "what should I do
  first" keeps priority, and the writer says which order a list is in.
- explain_change compares the run's period (the page's, else the
  person's range) with the days before it, as the pages compare a
  change, to yesterday; Last 24 hours keeps its 7 against 7.
- get_visibility_trend returns every day of its period, compact, within
  its share of the run.
- Help: "Numbers that match the page"; "Why a number changed" says its
  new default. approved-articles.json regenerated.
- Eval: prompts-page-top ("What are my top 5 prompts?" on Prompts).

No migration. MCP output is unchanged but for additive fields.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
The side panel now sends what the page shows beyond its chips: the open
tab, the sort and search picked, the rows on screen by the code or id the
page shows, the list's total, and the page's own URL state (whitelisted
per page). The engine checks it again (cut, never refused), keeps it on
the message, and gives it to both models in an untrusted page_view block
with the rule to read those rows by their refs before saying anything.
The page's chosen sort replaces its default in the order line, and a
search goes into the read's search input. send() in chat-thread-view.tsx
posts the view, with the owner's permission for this plan.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
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
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
The maintainer's review: readAnswerPages paged prompt_results by offset,
four pages at once up to 50,000 rows of jsonb, under the visibility
summary (also the external MCP tool), the citations reads, product
visibility and the prompt scores. It is gone.

- Citations (list_citations and the domain/page lookups): over whole UTC
  days the domains, citations and answers come from the Citations page's
  own daily rollups (00118: citations_domains_daily and
  citations_window_stats_daily). They are security invoker over the rollup
  tables, so the service role runs them after the brand check, by brand.
  Every source's totals come from the same rows. The pages and the prompts
  citing them have no aggregate the service role may run
  (citations_urls_daily and citation_url_occurrences refuse it), so they
  come from one bounded request of the newest answers, never paged; the
  result says what that covers when the window holds more.
- Visibility summary inside a day: the raw aggregates the page reads
  (competitor_aggregates, ai_visibility_aggregates, visible_prompt_stats,
  tracked_prompt_count), no answer rows. Whole days keep the rollups. The
  MCP output keeps its shape.
- Product visibility: the Products page reads cards itself, so one bounded
  request with an exact count: every appearance counted, the breakdowns of
  the newest read, said when cut.
- Prompt scores: always the Prompts page's prompt_visibility_summaries. It
  takes no platform, and the page counts every platform's answers, so the
  plan's platforms no longer send Starter to a raw read.
- Visibility order: the Prompts table's own comparator, a prompt with no
  score counted as 0, an unscored one last.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. With the page's search, list_content_opportunities (~read-tools.ts:993) and list_prompts (~331) switch to the lookup path, which drops the page's other filters (status, archived, topic, is_active, impact/type) and its sort, while scopeForModel still reports them as taken, so Chat says 'as on the page' over rows the page doesn't show. Apply the filters and sort in the search branch, or don't report them. 2) On /dashboard/prompts (the default Prompts view) the search is never applied: pageFilterInputs needs tool.route === page.route and list_prompts.route is /dashboard/prompts/tracked, but page-order.ts tells the model the app applied it.

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
…-same-maths-as-pages

list_content_opportunities' description keeps both sides: the Content
page's sorts and main's pointer to get_content_opportunity.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
getVisibilitySummaryFor read the raw competitor_aggregates whenever a
window started or ended inside a day: on the busiest brand 13 s for 7
days and past 120 s for 90, which external MCP calls with timestamps
reach. Now a window of at most about a day (25 hours of answers, up to
now) is still read to the minute from the raw aggregates; a longer one
is read over the whole UTC days it touches from the daily rollups, and
the result says so (roundedToDays and a note). A bound that isn't a day
or a time is refused with a clear message before any read. Chat's
whole-day windows are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
…-page-view

page-scope.ts takes both imports: the lookups' search words and the
page-route helper.

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
get_prompt_locations (from main) is a read of Prompts › Tracked, so the
app gives it a preset as that page reads it: the last N × 24 hours up to
now (page-periods.ts rollingWindow), as every other Prompts read here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
…-same-maths-as-pages

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
With the page's search, list_prompts and list_content_opportunities went
down their lookup path, which reads every status and drops the page's
other filters and the sort, while the scope note said they were taken.
Now the app sets as_listed with the page's search: the search reads the
list as the page lists it (status, impact, type, topic, active state,
archived set aside, the read's sort, paged and counted like the list).
The model's own search on such a read stays a lookup by name in every
status, and then none of the page's filters is filled or said taken.

/dashboard/prompts is Tracked Prompts (page-route.ts), so its search
reaches list_prompts; the view's URL keys, open item and order use the
same helper. The order line says the app applies the page's search, or
leaves out a filter's "all", only where pageFilterInputs does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
…-page-view

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
scope.ts took any search on list_prompts or list_content_opportunities
for named rows and dropped the model's limit. The page's search, as
listed, reads the list, so it keeps them; ids still name rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
@mintlify

mintlify Bot commented Nov 17, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 633f496.

Approve preview

gkhngyk
gkhngyk previously approved these changes Nov 18, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, both fixed: the page search now reads the list with its filters (as_listed), and /dashboard/prompts maps to the tracked route.

@cihan-gyk
cihan-gyk dismissed gkhngyk’s stale review November 18, 2026 11:26

The merge-base changed after approval.

@gkhngyk
gkhngyk merged commit a5be8e5 into ansvisor:main Nov 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants