Repository navigation
fix(action-center): list an action's Affected rows from what it kept, as its count does (AC-009) - #1409
Conversation
…nce, as its count One action showed 13 prompts in its title, 12 in its detail and 13 in a task: the title and tasks read the count saved at creation, the detail and exports re-counted signals the nightly pass rewrites, and deleting or pausing a prompt changed nothing. Migration 00244 keeps each action's targets in action_entities when it is created (a trigger, so every way an action is made keeps them alike), marks a prompt deleted or paused and a competitor deleted as removed, and reads the counts per action (action_entity_counts). Group signals now list every target's id beyond the 50 they name, so an action counts and keeps the whole group, and Site Audit's low pages count by their addresses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t each count counts Review fixes on the action list (00244): a prompt kept by its text no longer fails the uuid cast (which would have refused the action), the insert trigger never refuses an action, and moves the target keys out of the payload once kept. Each action sent by a person keeps the keys of what its count counts (an opportunity's prompts, a topic opportunity's suggestions, traffic pages by path); empty lists fall through. Nothing is marked removed when a new action is made; only the backfill marks prompts already gone. The counts RPC returns `total`; the limit is one constant; priority still reads the first 50 prompts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ounts action_entity_counts also returns the removed targets' keys, so a list of an action's prompts or pages can leave them out by id rather than by name (two prompts can share a text, and only 20 names come back). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ce, everywhere Every place now reads an action as action_entity_counts leaves it: the count it was created with less the prompts deleted or paused and the competitors deleted since. The list, the drawer, task titles, the priority reason, History, the signal drawer's actions, the Affected list and its story, Copy all, the exports, the list CSV and MCP agree, and say "(1 prompt removed since this action was created)" with the names on hover or focus. Removed items leave the Affected list by id; text targets are listed; a count is never shown with nothing behind it; a big group's target ids stay out of signal reads. Co-Authored-By: Claude Opus 5.5 <[email protected]>
action_entities.kept_at says when a list was written: as its action was created, or by the backfill for one made before. The nightly count check (AC-009 part 3) judges only lists kept at creation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fixes for AC-009 part 1: - targetKeys gives the keys an action keeps as 00244 keeps them (trimmed, once, in order, at most 1,000, no empty key, object or list); every path that sets a counted list takes targetCount from it: targetPayload, an opportunity's prompts, a topic opportunity's suggestions (refused when none has words), g02, F01 (no longer the signal's raw count) and a topic gap's prompts. - The backfill reads a topic opportunity's suggestions, not the tracked prompts it measures. - The audit signal lists targetIds only past the 10 pages it shows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…splay # Conflicts: # supabase/schema.sql
…does A topic gap, mention review or content opportunity keeps its prompts by id but lists them as texts, so a removed one stayed in the Affected list while the count dropped: such a row is now matched by its text against removedLabels (the first 20 the RPC names). A mention review no longer lists its first prompt twice, and is no longer named after that prompt once it is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ction Co-Authored-By: Claude Opus 5.5 <[email protected]>
… as its count does The Affected list is built from action_entities (what the action kept when it was created and still has): each kept prompt or page with what the signals say of it, one the signals no longer name as a plain row, and none the action never had. The heading and the rows agree; an action made before 00244 keeps its count for the rest. Used by the drawer (and Copy/Markdown from it) and the MCP export; without the list the rows come from the signals as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk #1389's item 3, as promised: the drawer's Affected rows (and MCP get_action's export) are built from |
gkhngyk
left a comment
There was a problem hiding this comment.
One fix before merge. Item 2 answers your question in the body.
-
The Why's demand now leaves out prompts the Why names but the list doesn't.
- The drawer reads demand for the Affected rows' ids (
use-action-story.ts:59-62), and those rows are now the kept list. - The Why is still told from the signals (
story.ts:235). It sums the demand of its own prompts from that map (story.ts:269-273) and silently skips a prompt with no entry. - So when the signals name prompts the action didn't keep, the "(12–18k AI searches a month, estimated)" range shrinks. When none of them is kept, it disappears.
- Before this PR, demand was read for the signals' prompts, so the Why's range was whole.
- On prod there are 178 open prompt actions whose signals name prompts by id:
- 120 name some the action never kept (median 3, up to 40);
- in 31, none of the prompts the signals name is still in the list.
- The MCP export has the same gap (
action-export.ts:296-300). The History drawer is fine because it passes no kept list. - Fix, in both places: read demand for the ids of
affected.promptsplus those ofaffectedOf(evidence, payload)withoutkept. - Add a test where a signal's prompt outside the kept list still gets its demand in the Why.
- The drawer reads demand for the Affected rows' ids (
-
The list's Export CSV: yes, please take it in this PR.
getActionsAffected(action-center.ts:635) still lists the signals' prompts under the count of the kept list.- So the CSV's count and names disagree in the same actions where the drawer used to, e.g. "5" over 8 names.
- Fix: read
action_entitiesonce per chunk with.in('action_id', chunk)and pass each action's rows toaffectedOf. - Page that read as
readSignalsdoes, because a chunk can hold more rows than one response returns. - It's cheap. The brand with the most actions (50 actions, 700 kept rows) reads all of its rows in 6.4 ms as a member.
- The History drawer can stay on the signals. It shows no rows, only the Why, and its demand is right.
Checked and fine
- Rows and count agree.
- On prod, 362 of the 363 live prompt, page and competitor actions with a kept list now list as many rows as their count.
- The other one is the content opportunity that counts 20 and keeps 18 (two duplicate texts), as before.
- The 24 actions with no list (15 page and 9 prompt actions) read the signals as before.
- The 7 that lost all their prompts list none, under a count of 0.
- Matching, on prod data:
- Prompts: 1,514 of the 1,907 live kept prompts in actions with signals get the signals' details. The other 393 show as plain rows, because their signals have moved on.
- Text-target actions: every kept label equals the payload's text. Topic gap and mention review rows match by label and gain their prompt's id, so they get a link and a volume.
- Pages: 386 of 558 kept pages match a signal row by address. None match only by path (an absolute URL against a path), so no row is dropped over its format.
- Labels: no live kept prompt or competitor has a null label, so no id shows as a name.
- Fallbacks:
- A database without 00244 (
PGRST205/42P01) falls back to the signals quietly. Any other error is logged, then falls back. - An action with no rows of its kind also reads the signals, as in #1389.
- A database without 00244 (
- Auth:
- The drawer reads through the member's client, under the table's member policy. A member of another organization reads none of an action's rows.
- The MCP export uses the admin client, but only after checking the action belongs to the key's organization.
- Cost:
- Each drawer open adds one query on the primary key.
- As a member, on the brand with the most actions, its biggest list (50 rows) reads in 0.6 ms (6 ms with planning).
- Merge and deploy:
- One commit on top of #1389. It merges cleanly on main (
76c87361). - Web only (7 files), no migration. 00244 is on prod, so it can deploy on merge.
- One commit on top of #1389. It merges cleanly on main (
- CI and tests:
- CI is green.
- CI doesn't run the web tests. The PR reports them passing.
… and the list's CSV the kept rows The drawer and the MCP export read demand for the Affected rows' prompts and for those the signals name (affectedOf without the kept list): the Why is told from the signals, which can name prompts the action didn't keep, so its range no longer shrinks or disappears for them. The actions list's Export CSV reads action_entities once per chunk of actions, page by page, and builds each action's names from its kept list, as the drawer does: the count and the names agree. A database without 00244 falls back to the signals quietly; any other failure is logged and falls back too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-entities Main squash-merged ansvisor#1389 (this branch's parent): this is main with this branch's own two commits on top.
|
@gkhngyk Fixed, and main merged (main with this branch's two commits on top; #1389 is squash-merged below it).
|
gkhngyk
left a comment
There was a problem hiding this comment.
All items done. Looks good.
- The Why's demand: done.
demandPromptIdsreads the Affected rows' prompts plus the ones the signals name, each once. The drawer (use-action-story.ts) and the MCP export (action-export.ts) both use it now.- The Why tells its prompts from
affectedOf(mine, removedOnly(payload)).mineis a subset of the signals, and the removed keys are the same, so every prompt the Why sums is in the read. - Tests cover it in all three places.
- The Why tells its prompts from
- The list's Export CSV: done.
readKeptEntityListsreads each chunk of 100 actions once, a page of 1,000 rows at a time.- Its sort ends on the primary key, so pages never overlap or skip rows.
- An action with no list, or a chunk that fails to read, falls back to the signals. The fallback is quiet without 00244 and logged on any other error.
- Tests check that the count and names agree, one read per chunk, paging past 1,001 rows, and both fallbacks.
Checked
- Merge of main (04125b2): the PR's diff on main is identical to its own two commits on top of #1389, blob for blob, so resolving the conflicts with #1389's squash hid nothing.
- Merge state: merges cleanly on main (8cde68c).
- Deploy: web only, no migration. 00244 is on prod, so this can deploy on merge.
- CI: green. CI doesn't run the web tests; the PR reports them passing.
Summary
AC-009 follow-up (#1389's known limit): an action's Affected rows come from what it kept when it was created (
action_entities), so the rows always agree with the count in the heading.On prod (gkhngyk's check of the 182 open prompt actions with signals), the drawer's rows came from the signals the nightly pass rewrites: 74 listed more prompts than their count and 47 fewer.
How the rows are built now (
affected.ts,entity-counts.ts)readKeptEntities(actionId): the action'saction_entitiesrows, removed ones marked (one query on the primary key, members' RLS,limit 1000, ordered by label).affectedOf(signals, payload, kept): with kept rows of the action'stargetEntity:Where
getActionDetail→useActionStory): the Affected tab, and Copy/Markdown/CSV from it.get_action's export.After review (2026-10-23):
Related issue
AC-009 "Single count source" (ROADMAP, Drive › Diğer); gkhngyk's review of #1389, item 3. No GitHub issue.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
Not browser-checked locally: the dev DB has a kept list for only 2 actions (3 rows), so the drawer reads the signals there; prod has the lists (00244's backfill).
Tests (
affected.test.ts):Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/) (0 errors; the 6 warnings are in untouched files, as on main)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run: web
yarn testandyarn build.🤖 Generated with Claude Code