Skip to content

feat(action-center): list every action a signal was used by - #1093

Merged
gkhngyk merged 64 commits into
ansvisor:mainfrom
cihan-gyk:feature/signal-used-by-actions
Oct 17, 2026
Merged

gkhngyk merged 64 commits into
ansvisor:mainfrom
cihan-gyk:feature/signal-used-by-actions

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

A signal's "Used by actions" now lists every action the signal was used by, closed ones included, not just its current one.

Two places list the actions behind a signal:

  • the signal drawer's Used by actions (AC-001);
  • list_signals' used_by_actions in MCP and GET /api/mcp/signals.

Both read signals.action_id, which names only the signal's current action. Since #1074, a signal that outlives its action supports the next cycle's, so the earlier action dropped out of both lists. #1074 keeps every link in action_signals, and the action drawer already lists signals from it. This PR does the same in the other direction.

Before Now
Which actions The current one Every action in action_signals for the signal
Order — The current action first, then the rest by their latest link
Drawer row AC-52 · title AC-52 · title and the action's status badge (New, Completed, Dismissed…)

How

  • getSignalActions(brandId, signalId) (lib/actions/signals.ts) reads action_signals with actions!inner, newest link first. It used to take action ids.
  • currentActionFirst (lib/signals/detail.ts) puts signals.action_id first. Ordering by linked_at alone can put an older action first: a signal that rejoins a reopened action keeps that link's first date, because the generator upserts links with ignoreDuplicates.
  • The drawer (SignalEvidenceBlock) caches its answer per signal and current action, so it loads again when the signal moves to another action. A signal with no action_id is still not asked about. It can have no links: a link is only made with action_id, and deleting an action drops both.
  • list_signals reads the links of the listed signals in chunks of 100 ids, keeping a full page of 200 within the request line, as fanout.ts does. A failed read still costs used_by_actions only, not the signals. The shape of used_by_actions is unchanged.
  • The list_signals tool description now says the list includes closed actions and starts with the latest.

Stacked on #1060 and #1074

The branch starts from #1074 and merges in #1060. Please review only these two commits:

The merge commit resolves updateSignalStatus, the MCP docs table and schema.sql as #1076's merge does; schema.sql is rebuilt from the migrations.

Related issue

None. A follow-up to #1074 (AC-007), on the signal side.

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. Link one signal to two or three actions with action_signals, e.g. a completed one and a new one, and point its action_id at the new one.
  2. Open Action Center → Signals and open that signal. Under Evidence and links → Used by actions:
    • every action is listed, the current one first, each with its status badge;
    • a closed action's link opens its drawer.
  3. Point the signal's action_id at an action with an older link. It moves to the top.
  4. Call list_signals (or GET /api/mcp/signals). The signal's used_by_actions lists the same actions in the same order.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/): no errors; the 7 warnings are in files this PR does not touch
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run:

  • web: yarn test passes (822 on this branch), and yarn build passes. New or changed tests:

    • lib/actions/action-signals.test.ts: getSignalActions reads through action_signals, newest link first.
    • components/action-center/signal-detail-blocks.test.tsx:
      • every action with its status;
      • the current action first;
      • loading again when the signal moves to another action;
      • the failed-load message.
    • lib/mcp/signals.test.ts:
      • used_by_actions with every linked action, current first;
      • links read in chunks of 100;
      • a failed read.
    • lib/signals/detail.test.ts: currentActionFirst.
  • Root: npm run version:check passes. bash supabase/build-schema.sh leaves schema.sql unchanged.

  • Dev database: I linked one demo signal to a dismissed, a completed and a new action, and removed them afterwards.

    • The drawer listed all three in order, with their badges. The completed action's link opened its drawer.
    • Pointing the signal at the completed action moved it to the top.
    • I checked at 1440px and 1024px, in the light and dark themes.
    • list_signals' query ran against the same data and returned the three actions in order. A brand id that doesn't own them returned none.
  • Review: a code review found that ordering by linked_at alone could put an older action first, and that reloading on a new action had no test. Both are fixed above.

    It also raised two cases I left as they are:

🤖 Generated with Claude Code

cihan-gyk and others added 30 commits October 15, 2026 14:20
…ls by platform

The Signals list never said which AI platform or location a signal was
about, and named platforms by their raw ids ("Visibility dropped on
gemini-web", "Weak in JP"). Part one of AC-002:

- Each row's Affected cell gets a line with the engines and locations the
  signal is about: from the payload for platform and country signals, and
  from the prompts' tracked platforms and locations for prompt and topic
  signals. A line rather than a column keeps the table within the page
  beside a pinned sidebar.
- Platforms and locations read as people know them ("Gemini", "Japan").
- Descriptions carry the measured fact instead of a generic sentence, e.g.
  "Your mention rate fell from 34% to 18% against the week before."
- A Platform filter, search over platform and location names, and
  platforms and locations columns in the CSV export.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A brand can track the same prompt text as several prompts, and the
detectors write one signal per prompt: on production one pass wrote ten
identical "Citations lost for '…'" rows, which read as duplicates and
inflated every count. Part two of AC-002:

- Signals of one kind, about one prompt text (case, spacing and the
  closing "?" ignored), found in one pass are one row with a "×N grouped"
  toggle. Opened, it lists each copy with its topic, place and status; each
  copy keeps its own drawer and menu, and the group's menu acts on the
  copies it applies to.
- The category tabs, the tab badge and the summary cards count groups.
  Migration 00141 adds signal_group_key (the same rule as
  lib/signals/group.ts), counts signals_summary over groups, where a group
  is resolved only once every copy is, and adds signals_new_count for the
  badge.
- A drawer opened from a link to a copy opens its group.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hat it rests on

The signal drawer showed bare numbers ("0 → 251 +167") and no platform,
location, page or action. Part one of AC-001: the drawer has three blocks.

- Where: the fields the spec asks per category (prompt, topic, platforms,
  locations, domain, competitor, pages, queries, and for a lost citation
  the page cited before and who is cited now). A field no detector records
  yet says "Not available"; platforms read from a signal's prompts say
  "Tracked on".
- What changed: every figure with its metric, whose or which window, and
  unit, over its period: "Mention rate · previous 7 days 34% → last 7 days
  18%, −16 pts". A source domain's three counts are named instead of read
  as a before and after. A fall in the brand's own numbers is red, a
  competitor's rise too (the old colouring showed drops as good news).
- Evidence and links: the page behind the signal (the prompt's answers, the
  topic, Citations…), first and last detection, and the actions using it.

MCP list_signals returns the same detail per signal (where, change,
evidence, used_by_actions) beside the raw row, from lib/signals/detail.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every action's drawer gets Copy Data, Export CSV and Export Excel
(AC-005). Copy Data opens the whole action as Markdown, every tab of the
drawer, to copy a part or all of it with one click; the copy falls back
to the browser's copy command where the clipboard API is blocked. The
CSV (action-AC-52.csv, UTF-8 with a BOM) has a row per task and per
signal marked by a section column; the Excel workbook has a sheet each
for the action, its tasks, its signals and its history. Adds the
write-excel-file package, loaded only when a workbook is asked for.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each action gets a priority score from 0 to 100 with a level (critical,
high, medium, low), and the facts behind it for "Why this priority?"
(AC-006). The score weighs impact, the demand of the most searched
prompts, queries or pages, how severe the change is, commercial intent,
independent kinds and sources of evidence, whether the ground was held
before, and how recent it is, never how many signals repeat. It is
worked out when an action is created and again every night, stored in
new columns (migration 00144), and orders the queue of waiting findings
too, with a little added for each day waited.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The actions list sorts by the server's priority score by default, shows the
score beside Impact, and the Top Actions card counts the five highest-priority
open actions. The drawer explains the score in "Why this priority?", and Copy
Data and the exports carry it. MCP list_actions and get_action return the
priority, and list_actions can sort by it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mpact

The score already weighs impact in, so showing both read as two answers to
one question. The Actions and History lists drop their Impact column for a
Priority Score column (score and level), filter and sort by priority, and the
Potential Impact card becomes Highest Priority. The drawers' headers, Copy
Data and Excel show the priority instead of impact, and MCP list_actions now
lists the highest priority first by default (sort "updated" for the old
order). Signals keep their own impact.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rity-score

# Conflicts:
#	supabase/schema.sql
…rity current

AC-007. Every signal an action takes as evidence is now kept in a new
action_signals table (00145), so an action lists its signals after they move
on to a later cycle and a signal can be used by more than one action.

- The nightly generator writes the link, treats a signal as taken only while
  an active action holds it (a still-open signal whose action closed can
  start the next cycle), and keeps newcomers queued on the nights after they
  were linked, not only the first.
- Resolving, dismissing or reopening a signal scores its active actions again
  at once, through POST /api/action-center/signals/:id/rescore.
- "Why this action?" says how many open signals support the action and lists
  them by type, platform and subject. The list counts only those, and the
  drawer, History and MCP get_action read through the new table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	web/src/components/action-center/action-drawer.tsx
# Conflicts:
#	server/src/lib/action-center/from-prompt-improve.js
#	supabase/schema.sql
#	web/src/types/supabase.ts
…rity-ui

# Conflicts:
#	web/src/lib/actions/action-center.ts
#	web/src/lib/actions/action-history.ts
…traceability

# Conflicts:
#	web/src/components/action-center/action-drawer.tsx
…traceability

# Conflicts:
#	supabase/schema.sql
cihan-gyk and others added 17 commits October 16, 2026 12:31
…ure/signals-grouping

# Conflicts:
#	supabase/schema.sql
…ure/action-priority-score

# Conflicts:
#	supabase/schema.sql
…ure/signals-grouping

# Conflicts:
#	supabase/schema.sql
…ure/action-priority-score

# Conflicts:
#	supabase/schema.sql
…o feature/signal-used-by-actions

# Conflicts:
#	docs/guides/mcp-server.mdx
#	supabase/schema.sql
#	web/src/lib/actions/signals.ts
…ests

ansvisor#1060 moves updateSignalStatus to a list of signal ids (a group's copies
move together) and gives SignalWhere its topics; ansvisor#1074's tests still called
it with one id and built where without topics. They now do as ansvisor#1076's merge
of the same two stacks does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A signal drawer's "Used by actions" and list_signals' used_by_actions read
the signal's action_id, its current action only. Once a signal outlived its
action and supported the next cycle's, the earlier action dropped out.

Both now read the signal's links in action_signals (AC-007): every action it
was used by, closed ones included. The current action leads, then the rest
by their latest link, and the drawer shows each action's status. list_signals
reads the links in chunks of 100 signals, so a full page stays within the
request line, and a failed read still costs used_by_actions only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk could you review this when you have a moment? A signal's "Used by actions" (drawer and list_signals) now lists every action linked through action_signals, not only its current action_id. It is stacked on #1060 and #1074, so only the last two commits are new.

@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 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.

Reviewed. Merged main into the branch: list_signals keeps the per-figure period wording, the MCP data module imports both the signal detail helpers and the task details parser, and updateSignalStatus keeps the one-rescore-per-action change for copies of a finding. Tested on the full Action Center chain.

@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 17, 2026
@gkhngyk
gkhngyk merged commit 3d39346 into ansvisor:main Oct 17, 2026
4 of 5 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.

2 participants