Skip to content

feat(chat): show what an agent's runs took live, and what they did, on its page - #2148

Merged
gkhngyk merged 7 commits into
ansvisor:mainfrom
cihan-gyk:feature/agent-impact-card
Nov 5, 2026
Merged

gkhngyk merged 7 commits into
ansvisor:mainfrom
cihan-gyk:feature/agent-impact-card

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

This PR adds the "What this agent did" card to the agent page, between Triggers and Run history (AGENTS-plan §2 rule 1, §7 step 2). The owner approved the card's mockup and decided its open questions:

  • One period, the last 30 days. There is no period picker; the header says "Last 30 days", like the agent list's "Outcomes · 30 days".
  • Show the line about drafts that aren't live yet.

The card has three states

  • With results: three numbers, then the changes, newest first (5 shown, then Show all N).
    • Changes shipped: pages that went live from its runs.
    • Improved X of Y: the same headline rule as Reports, so only Medium and High confidence verdicts count.
    • Pending: changes still waiting for their first verdict.
  • The first week: only pending changes. Improved reads "—", "no verdict yet".
  • Nothing live yet: "Nothing from this agent has gone live yet." plus when its first verdict will come.

Each row shows

  • Title.
  • Where it went and who sent it, e.g. "Published to your CMS · run chore: remove font customization settings #31, you approved · Shipped Oct 28 · 6 prompts".
    • The credit reads on its own, you approved or by {name} (by a teammate once that person has left).
    • run #N opens the run's chat for people allowed to open it.
  • Outcome pill, in Reports' wording ("Pending · early signal" after day 7).
  • Result numbers: the lift, the confidence and the next checkpoint, e.g. "+6.4 pts · High · Day 30, due Nov 13". A Not measurable change shows its reason instead.

Below the rows

  • "N drafts from this agent aren't live yet. Drafts aren't measured until they go live."
  • The method line from reports.impact.method.*: "Baseline: 14 days before ship · Control: untouched similar prompts · Min. change: 3 pts · Correlation, not causation".
  • Open in Reports →. Reports has no link to a single change (its evidence opens in a sheet driven by page state), so the card has this one link instead of one per row.

Data

  • A new route, GET /api/chat/agents/{id}/impact, sits next to /runs and is called the same way (chatActor, agentContextFor). It returns 404 unless the person can see the agent.
  • lib/chat/agent-impact.ts reads the agent's ship_events (agent_id, ship_events_agent_idx) from the last 30 days, with their impact_measurements.
  • Only events in the person's workspace and on brands they may see count: brand_id in their brand access. This is the same rule as the ledger's policy (00424, user_brand_ids()).
  • Each row goes through Reports' own impactRow, and the headline through impactSummary. Nothing about outcome or confidence is decided again here.

Run numbers: a run's number is its place among the agent's runs the person can see, oldest first, so it matches what Run history shows them.

Drafts that aren't live

  • These are the drafts made in the agent's runs of the last 30 days, found through their chat: content_drafts.conversation_id → chat_conversations.agent_run_id → chat_agent_runs.agent_id.
  • Going through the chat also counts a draft a person approved in the run's chat, which origin = 'agent' would miss.
  • Archived drafts, and drafts on brands the person can't see, aren't counted.
  • A draft counts as live once any ship event names it.

"You approved" comes from #2137, now merged

Reuse, no second copy

One known gap, on the demo brand only: its sample agents have no ship events, because the demo never publishes (coverage.js). So their card shows "Nothing from this agent has gone live yet", while one sample run in Run history shows Improved · Medium. This PR doesn't change demo data.

Help: help/chat/agents.md

Related issue

None. AGENTS-plan §7 step 2. The owner approved this card's mockup. The "you approved" rows come from #2137 (merged).

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. With Chat's agents on (CHAT_AGENTIC), open an agent's page in Agent Center. What this agent did sits between Triggers and Run history, with "Last 30 days" and no period picker.
  2. Take an agent that published a page on its own in the last 30 days.
    • Its row says "Published to your CMS · run #N, on its own", and run #N opens the run's chat.
    • The outcome pill and the next checkpoint match the page's row in Reports › What Ansvisor did for you.
  3. In an agent run's chat, send or publish a page from its card. Once it's live:
    • its row says "run #N, you approved" to you, and "run #N, by {your name}" to a teammate;
    • a page sent later from the Content Editor or the Library doesn't show on the card.
  4. The Improved number counts only Medium and High confidence verdicts. It shows "—" until there is one.
  5. A run that made drafts that didn't go live shows "N drafts from this agent aren't live yet." An agent with nothing live shows the empty state.
  6. As a member with Selected brands, you don't see changes, run numbers or drafts on brands that aren't shared with you.
  7. Tests: cd web && npx vitest run src/lib/chat/agent-impact.test.ts src/components/chat/agents src/components/reports src/lib/help.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change) — see help/README.md

Checks were run locally on 57a153b, which merges upstream/main 5a8de56 (#2134, #2135, #2136, #2137). The branch still merges cleanly into the current main.

  • yarn format:check passes, and yarn format changed nothing.
  • yarn lint: 0 errors, and 7 warnings in files this PR doesn't touch.
  • yarn typecheck passes.
  • yarn test: 990 files, 10,620 tests passed, 1 skipped.
  • yarn build passes with CI's placeholder env.

This PR doesn't touch the server, supabase/ or skills/, so those checks weren't run.

Open questions

  1. Drafts window: drafts are counted from runs queued in the last 30 days, to match the card's period. Should the card count all of the agent's drafts that aren't live, whatever their age?
  2. Run numbers: "run #N" is computed for this card only. Should Run history show run numbers too?
  3. Demo brand: should the demo get sample ship events, so its agents' cards aren't empty?
  4. When the clicking person is removed: feat(impact-ledger): credit a page a person approved in an agent run to that run (00480) #2137's ship.js writes automated when delivery.sent_by is null. If the person who clicked a card in the run's chat is removed before the CMS confirms the publish, the change would show "on its own" here. It's rare, and the fix belongs server-side in feat(impact-ledger): credit a page a person approved in an agent run to that run (00480) #2137's code.

Generated by Claude Code

… ship-row read

Reports' outcome pill colors, "Pending · early signal" label and signed
numbers move to components/reports/impact-parts.ts, and the ship_events
embed (action number, measurement) and measurementOf to lib/impact/report.ts,
so the agent page's "What this agent did" shows a change exactly as
Reports does. Reports reads and renders as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
GET /api/chat/agents/{id}/impact answers the agent's ship events of the
last 30 days (agent_id) with their measurements, read by Reports' own
impactRow and impactSummary (Improved counts Medium and High verdicts
only), on the brands the person may see as the ledger's policy (00424)
has it. Each change says how it went live (on its own, the reader
approved it, or a teammate) and its run's number among the agent's runs
the person sees, with the run's chat when they may open it. It also
counts the drafts the agent's runs of the last 30 days made that no ship
event names, found through the draft's chat: content_drafts.conversation_id
-> chat_conversations.agent_run_id -> chat_agent_runs.agent_id.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
Between Triggers and Run history, as the owner approved it: the last 30
days, with no period to pick. Changes shipped, Improved X of Y (Medium
and High verdicts only, "—" before any) and Pending; each change with
how it went live ("run #31, on its own", "you approved", "by Sam Lee"),
its outcome in Reports' words and its next checkpoint; how many drafts
aren't live yet; the method line and Open in Reports, as Reports has no
link to one change. Three states: with results, the first week, and
nothing live yet.

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

Brings in ansvisor#2134, ansvisor#2135, ansvisor#2136 (the Onboarding & Help agent) and ansvisor#2137
(impact-ledger ship credit, 00480).

Conflict in help/chat/agents.md: both sides added a section after "An
agent's page". Kept both, "What this agent did" (this branch) then "What
a run's outcome means" (ansvisor#2137), in the page's order; each stays under 150
words. impact-report.tsx merged cleanly: ansvisor#2137's taken_down reason in
REASONS beside this branch's move of the pills, outcome words and signed
numbers to impact-parts.ts. approved-articles.json regenerated.

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

A person's click on a card in an agent run's chat now ships with the
agent and its run (00480, ship.js agentOrigin), execution_mode assisted
and shipped_by the person; the agent's own send stays automated. The card
already reads automated as "on its own" and the rest by who sent it, so
nothing changes in the read: the tests now use that data. Each change in
the credit test names its run, a page sent later from the Content Editor
or the Library (no agent) isn't listed, and the agent's own change reads
"on its own" to every viewer. The card's fixtures ship "you approved" and
"by {name}" rows as assisted, and a page taken down shows ansvisor#2137's reason.

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

Agent Center's article gets keywords and synonyms for the agent page's
card (what this agent did, agent impact, what did my agent do), now that
ansvisor#2136's Onboarding & Help keywords are on main, and its section says the
three ways a change went live: on its own, you approved on a card in the
run's chat (00480), or by a teammate. Sources name agent-impact.ts.
approved-articles.json follows.

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.

LGTM. Non-blocking: numberedRuns (agent-impact.ts) pages runs oldest-first from the oldest shipped run and stops at RUNS_MAX, so an agent with >10k runs since then drops its newest runs and draftsNotLive under-counts. Reading the 30-day window on its own would avoid it.

@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 fbcca00 into ansvisor:main Nov 5, 2026
13 checks passed
cihan-gyk pushed a commit to cihan-gyk/ansvisor that referenced this pull request Nov 5, 2026
Main brought ansvisor#2146, ansvisor#2148 and ansvisor#2149. help/chat/agents.md's front matter
keeps both keyword and synonym lists; approved-articles.json regenerated;
schema.sql rebuilt.

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