Skip to content

fix(chat): every list read pages, with totals, so Chat reads all a page shows - #2448

Merged
gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:fix/chat-list-paging
Nov 16, 2026
Merged

gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:fix/chat-list-paging

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Stacked on #2420 (fix/chat-reads-all-actions). Until it lands, this diff also shows its commits.

Summary

Chat read only part of a list. It saw 10 of 451 signals, 25 prompts and 20 of every 100 mentions. It got no total and had no way to read on. A result cut for size came back as {list}_more, and the model turned that into "38 actions are missing".

Every list read now pages the way Actions does since #2420. Each page:

  • holds 50 items by default;
  • says how many match in all;
  • says where the next page starts.

A page cut for size stays a page, so the rest reads as "the next page" and never as missing.

Changes

  • One page shape for every list read:

    • inputs: limit (50 by default and at most) and offset;
    • outputs: total, offset, next_offset (null on the last page) and a note, e.g. "Showing 1–50 of 451 signals, newest first. Read the next page with offset 50, or say how many you judged."
    • Helpers: lib/mcp/list-page.ts and chat/registry/list-paging.ts.
  • Reads, with their old and new defaults:

    Read Before Now
    list_signals 10, max 50, no window, no total 50 a page, paged, the Signals page's window
    get_action_history 10, max 50 50 a page, paged
    list_content_opportunities 10, max 50 50 a page, paged
    list_prompts 25, max 50 50 a page, paged
    get_prompt_performance 10, max 50 50 a page, paged
    get_prompt_volumes 25, max 50 50 a page, paged
    list_citations 20, max 50 50 a page; one offset pages domains and pages
    list_mentions 20 of each 100 50 a page, any answer by offset
    get_reports 5, max 20 50 a page, paged
    list_drafts, list_topics, list_competitors, list_prompt_suggestions, get_site_audit_summary, list_brands, get_ads_opportunities cut at 50 50 a page, paged
  • Descriptions state the real default. The wrong ones said "default 50" or "default 100" for reads that took 5, 10, 20 or 25.

  • Filters stay. Each read keeps its filters. list_signals also takes the run's period, read the way the Signals page reads its window: detected by its end, and open or resolved after its start.

  • Signals rows are compact. Each has a title and description in the page's words, kind, status, impact, the day it was detected, where it happened, and its actions. So a page of 50 fits one read.

  • Counted on the server. Database lists count every match and read a range. New …PageFor reads sit beside the MCP functions, which keep their shape. The MCP changes are additive: an optional offset, and a total on prompt performance. An offset past the end is an empty page with the total.

  • Mentions: list_mentions pages over mentions_list's own offset, so answers 21–100 of each 100 can be read.

  • scope.ts: any read with an offset input is paged. It reads no extra probe row and takes 50 a page.

  • Data share: each page gets a 20,000-character share (PAGE_CHARS), as fix(chat): read every open action by priority, say how many, and name actions by title #2420 gave actions.

  • fitResult: a page over its share comes back as a shorter page. Its next_offset and note say where to read on. No more {list}_more or {list}_rest on a page.

  • Scope: every read stays limited to the caller's organization and brand access. The brand-scope test covers each new page read.

Size: about 750 lines added and 215 removed outside tests. That is over the ~800 aim because it covers 16 reads in one shape. About 200 of those lines move existing queries into counted closures without changing them.

Not paged, and why:

  • list_members, list_connections: short lists for the whole workspace.
  • list_ready_agents: 3–5 picks by design.
  • get_whats_new: 3 updates by design.
  • list_ai_answers: one prompt's full answers, up to 9.
  • get_gsc_queries, get_prompt_insights, get_fanout_gaps: top-N summary reads.
  • get_visibility_trend, get_ai_traffic_summary: summary reads. These are for later PRs in the audit plan.

How to test

  1. On a brand with more than 50 signals, open Chat on Signals and ask "What changed this month?"
  2. Open the read's Data (debug). It shows 50 signals, total, next_offset: 50 and the note.
  3. Ask "And the next ones?" Chat reads with offset: 50.
  4. Ask about mentions on a brand with over 100 answers. Ask for answers past the 20th. They come back.
  5. Run cd web && yarn vitest run src/lib/mcp/list-page.test.ts src/lib/mcp/signal-page.test.ts src/lib/chat/fit.test.ts src/lib/chat/scope.test.ts src/lib/chat/registry.

Checks

  • npx tsc --noEmit -p .: clean.
  • vitest: 345 files, 4934 tests passed, after merging upstream/main. The run covered src/lib/chat, src/lib/mcp (brand-scope included), src/components/chat, src/lib/action-center, src/lib/help, src/i18n, src/lib/agent, use-server-exports and subscription-guard-coverage.
  • ESLint and Prettier: clean on changed files.
  • Merge check:
  • No migration, no new dependency, no 'use server' file touched.

Generated by Claude Code

…ge shows

Chat read 10 of 451 signals, 25 prompts, 20 of each 100 mentions and 5
reports, with no total and no way to read on, and a result cut for size
came back as "{list}_more", which the model turned into "38 actions are
missing". Every list read now pages the way list_action_center_tasks
does since ansvisor#2420:

- Each list read takes limit (50 by default and at most) and offset, and
  returns total (every match), offset, next_offset (null on the last
  page) and a note ("Showing 1–50 of 451 signals, newest first. Read the
  next page with offset 50, or say how many you judged."). Shared helpers
  in lib/mcp/list-page.ts and chat/registry/list-paging.ts.
- Reads: list_brands, list_prompts, get_prompt_performance,
  list_prompt_suggestions, get_prompt_volumes, list_topics, list_mentions,
  list_citations (one offset pages domains and pages), list_competitors,
  get_site_audit_summary, list_signals, get_action_history,
  list_content_opportunities, list_drafts, get_reports and
  get_ads_opportunities. Each keeps its filters; descriptions state the
  real default.
- Database lists count on the server and read a range (new …PageFor
  reads beside the MCP functions, which keep their shape); an offset past
  the end is an empty page with the total. list_mentions reads any answer
  by offset over mentions_list's own paging, not 20 of each 100.
- list_signals reads the Signals page's window (detected by its end, open
  or resolved after its start) over the run's period, in compact rows:
  title and description in the page's words, where, and the actions
  built on it (lib/mcp/signal-page.ts).
- scope.ts treats any read with an offset as paged: no probe row, 50 a
  page. Each page gets a 20,000-character share (PAGE_CHARS).
- fitResult cuts a page over its share into a shorter page whose
  next_offset and note say where to read on: never "{list}_more".
- Every read stays limited to the caller's organization and brand access
  (brand-scope test covers each new page read).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
# Conflicts:
#	web/src/lib/help/approved-articles.json
gkhngyk
gkhngyk previously approved these changes Nov 16, 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.

LGTM.

@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.

LGTM.

@gkhngyk
gkhngyk merged commit 90cec29 into ansvisor:main Nov 16, 2026
11 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