Skip to content

fix(chat): read Today, your agents and their runs, History over a range, and the Signals summary - #2465

Merged
gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:fix/chat-today-agents-reads
Nov 17, 2026
Merged

gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:fix/chat-today-agents-reads

Conversation

@cihan-gyk

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

Copy link
Copy Markdown
Collaborator

Merged with main (17 Nov): tests keep both sides' mocks and rows; in the model eval, main's competitor-losses keeps row 38 and Today's first action moves to row 39.

Summary

Step 6b of "Chat must read everything a page shows". Chat can now read Action Center's Today, the person's agents and their runs, History over any range with its filters, and the Signals summary cards. Each read calls the page's own functions, so Chat and the page show the same things in the same order. On Today, "what should I do first?" now means the first Focus card.

Changes

Read Page it matches What it returns Paging and gates
get_today (new) Action Center › Today Focus cards in the page's order (code, title, why, first step, effort, who, new), Since yesterday (code, title, up/down/rival), Waiting for you (agent runs waiting for an OK, drafts in review, tasks due, reminders, reviews, waiting prompts, prompt ideas), Where you stand, set-up steps left, Last week on Mondays, the first day's and the ended day's parts Not paged (a few items). Brand check. Needs the person's own session; a run without one gets a note pointing to the Actions list
list_my_agents (new) Action Center › Agents (Your agents) Agents in a tab (Mine, Workspace, Paused, Archived) with search: status, mode, skills, triggers and next run, brands, last run (waits on you?), 30-day outcomes, AI use 50 a page, total, next_offset. Workspace-level; only agents the person may see
list_agent_runs (new) An agent's Runs tab One agent's last 50 runs on this brand, newest first: status, waits on you, trigger, times, stop or skip reason, outcome, AI use, agents it ran, its chat 50 a page. Brand check; another person's private agent is not found
get_action_history (changed) Action Center › History The page's rows over the period: its statuses, its filters (status, category, priority, source, search), its sort (newest by default), and its summary cards 50 a page, total, next_offset. Takes the run's period like other dated reads. Brand check
get_signals_summary (new) Action Center › Signals (summary cards) Active, high impact, new and resolved, each against the period before, and the active ones by category and source Not paged. Takes the run's period (30 days by default, as the page). Brand check

Other changes:

  • History's filter moved into lib/action-center/history.ts (filterHistory). The page and Chat both use it.
  • getActionHistory and getSignalsSummary use dbClient(). The page is unchanged (it still gets the person's client). Chat runs them with the service role after the brand check, as KPIs and Getting started already do.
  • Reader rule: on Today, "the first action" or "what to do first" is the first Focus card. The other priority rules stay.
  • Labels in en.json. Chat Help gets one section on these reads (129 words).
  • Input names match the other reads (brand_id, date_from, date_to, status, category, priority, source, search), so fix(chat): read over the page's dates and filters in the side panel #2459's page-filter mapping applies once it lands.
  • Model eval: new scenario (row 38), "ilk yapmam gereken ne?" asked on Today.

Safety

  • Every read checks the brand first (brandAllowed: the caller's organization and brand access). A brand outside it reads nothing (brand-scope.test.ts rows added).
  • Today is read only with the person's own session, through the page's functions. Reading it keeps the focus the way the page does. It never marks Today as seen.
  • Agents and runs come from the agents API's own functions with the person's context read fresh. Visibility rules are unchanged: a private agent is seen only by its owner and Admins.
  • get_today and get_action_history are untrusted (they carry outside text). list_my_agents and list_agent_runs are workspace reads (scanned, not tainting). get_signals_summary is trusted (counts only).
  • No new server action. No 'use server' export added. No migration, no dependency, no lockfile change.
  • Performance: no new queries on big tables. History re-runs the page's own read (up to 500 actions in the range) for each page Chat reads, as the page does on each load. The Signals summary calls the page's signals_summary function.

How to test

  1. Open Action Center › Today and open Chat beside it. Ask "ilk yapmam gereken ne?". Chat reads Today and names the first Focus card by its title and code (AC-…).
  2. On Today, ask "Bugün beni ne bekliyor?". The answer matches Waiting for you.
  3. On Today, ask "Dünden beri ne değişti?". The answer matches Since yesterday, with S- codes.
  4. Open Action Center › Agents. Ask "Ajanlarımın durumu ne?". Chat lists the agents in your Mine tab with their status and last run.
  5. Ask "Visibility Watch geçen hafta ne yaptı?". Chat reads that agent's runs on this brand.
  6. Sign in as an Analyst. Ask about another person's private agent. Chat doesn't see it.
  7. Open History and set 90 days. Ask "Son 90 günde tamamlanan aksiyonlar neler?". The list matches History with status Completed.
  8. Ask "Geçen ay kapanan büyüme aksiyonlarından hangileri sonuç verdi?". Chat uses the category filter and the period.
  9. Open Signals. Ask "Bu ay kaç sinyal var, kaçı yüksek etkili?". The numbers match the summary cards.

Checks

  • npx tsc --noEmit -p .: clean.
  • Vitest: src/lib/chat, src/lib/mcp, src/components/chat, src/components/action-center, the Action Center and Agents pages' tests, src/lib/action-center, src/lib/help, src/i18n, use-server-exports, subscription-guard-coverage: 378 files, 5309 passed, 1 skipped.
  • New tests: today-reads.test.ts (12), agent-reads.test.ts (6, on the page's own listAgents and runs), today-tools.test.ts (9), today-eval.test.ts (3).
  • ESLint and Prettier: clean on changed files.
  • git merge-tree --write-tree HEAD upstream/main: clean.
  • Help snapshot regenerated with yarn vitest run -u src/lib/help.

Not in this PR

  • Waiting for you's "Fix this" rows (the menu's red dots). They need the menu's own read with its areas, a separate change.
  • Today in an agent's or a schedule's run, with no session. The read says so and points to the Actions list.
  • The MCP list_action_history tool keeps its closed-only list. Range and filters for MCP are a separate change.
  • Scorecard, Review and the other MCP-only reads (fix(chat): read what the MCP Server already reads, and keep the two in step #2464).
  • Sending Today's, History's and Agents' page context from those pages (step 9).

Choices made

  • Today without a session. Today's page functions read as the signed-in person, so an agent's or a schedule's run can't read it. It gets a note pointing to the Actions list instead of an error.
  • History matches the page. get_action_history now includes In progress and On hold by default, as History does. Before, it read only Completed and Dismissed. The MCP tool list_action_history keeps its closed-only list, so Chat and MCP differ here until MCP gets the same range and filters.
  • Reading Today keeps the focus, as the page does. When the 3 focus cards change, reading Today saves them, so "the first Focus card" Chat names is the one the page shows next. It never marks Today as seen.

Generated by Claude Code

…ge, and the Signals summary

Chat now reads what Action Center's Today, Agents, History and Signals
pages show, from the pages' own functions:

- get_today: Today's focus in its cards' order (code, title, why, first
  step), Since yesterday, Waiting for you, Where you stand, set-up steps
  left, and Last week on Mondays, with the person's session.
- list_my_agents and list_agent_runs: Your agents by tab, and one agent's
  runs on the brand, as Agents lists them for the person, paged.
- get_action_history: History's range, filters and sort, with its
  summary cards, paged (History's filter is now shared with the page).
- get_signals_summary: the Signals page's summary cards over its window.

A reader rule says "what to do first" on Today is the first focus card.
Chat Help says what Chat reads on these pages. A model eval scenario
checks "ilk yapmam gereken ne?" on Today.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
gkhngyk
gkhngyk previously approved these changes Nov 17, 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 previously approved these changes Nov 17, 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.

Re-approving after the main merge: the PR's own changes are unchanged (numstat matches; the tools.test.ts resolution keeps both sides).

@gkhngyk

gkhngyk commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Approved, but it now conflicts with main after today's merges. Please merge main in and I'll merge it.

Conflict in web/src/lib/mcp/brand-scope.test.ts: kept both import groups
(this branch's today-reads and agent-reads, main's learning, catalog,
product-visibility and prompt-locations). approved-articles.json taken
from main and regenerated with the help tests.

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.

Re-approving after the main merge: own changes unchanged; the help-file resolution keeps both sides.

@gkhngyk
gkhngyk merged commit 70f1e73 into ansvisor:main Nov 17, 2026
12 checks passed
cihan-gyk pushed a commit to cihan-gyk/ansvisor that referenced this pull request Nov 17, 2026
Main now holds ansvisor#2465 (fix/chat-today-agents-reads), so it comes in with
main rather than on its own.

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