Repository navigation
fix(action-center): show an action's count, less what was removed since, everywhere (AC-009, 2/3) - #1389
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]>
|
@gkhngyk AC-009 part 2/3 (web), stacked on #1388: one count everywhere, '(1 prompt removed since this action was created)' with the names on hover/focus. #1388 also gained removed_keys in action_entity_counts (44ec1e5) so the Affected list leaves removed prompts out by id. A follow-up idea in the body: build the Affected list from action_entities. |
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]>
|
@gkhngyk Merged #1388's review fixes forward (1f06172). bbfb70a adds |
gkhngyk
left a comment
There was a problem hiding this comment.
A few fixes before merge. Both are in the new text-target branch of affectedOf, and both show on prod as soon as 00244 runs.
-
A removed prompt stays in the Affected list when the action's targets are texts.
- Topic gaps, mention reviews and content opportunities keep their prompts by id (
promptIds), but theirtargetsare texts.affectedFromPayloadnow lists those as rows withid: null. affected.ts:100matchesrow.id ?? row.textagainstremovedKeys, so it compares a text with prompt ids and never matches. Nothing is left out.- The count still drops, so the heading and the CSV disagree with the rows.
- On prod today, the open topic gap action has 9 prompts and 6 of them are paused. The backfill marks those 6 removed. It would then read "3 prompts (6 prompts removed since this action was created)" over all 9 rows, and the list CSV would say 3 with 9 names.
- Fix: for a row without an id, also match its text against
removedLabels. 00244 stores the prompt's text as the label for these (coalesce(n.label, pr.text)).- The RPC caps labels at 20. Either accept that, or return every removed label and keep the 20 slice for the hover only (00244 isn't on prod yet).
- Add a test with text targets plus
removedKeys/removedLabels.
- Topic gaps, mention reviews and content opportunities keep their prompts by id (
-
Mention reviews now list their first prompt twice.
affected.ts:298adds thepromptTextrow (nopromptIdin this payload, soid: null).- Then
:311adds every text intargets, and that list starts with the same prompt. - A review of 3 prompts shows 4 rows under "3 prompts".
affected-tab.tsx:114keys rows byrow.id ?? row.text, so two rows get the same key. - Before this PR, text targets were skipped, so this is new. There are no mention reviews on prod yet, but every new send from Mentions hits it.
- Fix: in
affectedFromPayload, skip a target whoseid ?? textis already listed.
-
The known limit is common. Decide whether it ships as is.
affected.ts:103sets the prompt total to the action's count whenever any row is listed. The rows still come from the signals.- I compared them on prod for the 182 open prompt actions that have signals. I took the prompt ids from their supporting signals, falling back to all linked signals, as the drawer does. This only approximates what the tab lists.
- 74 list more prompts than their count (median 3 more, at most 30). The heading says "5 prompts" over 8 rows.
- 47 list fewer, so the heading counts prompts the tab can't show.
- Before this PR, the tab agreed with itself and disagreed with the title. Now it agrees with the title and disagrees with its own rows in about two of every five open actions.
- Building the rows from
action_entities(the follow-up you propose) fixes both. Members can already read that table under its policy. - If that waits, say so in the body with these numbers, so it's taken next and not left open.
-
Low: a mention review left with 1 prompt can be named after the removed one.
display.ts:136namespromptText, which is the first prompt.- If that prompt is the one paused and one other is left, the title names the paused prompt.
- Fix: use
promptTextonly whenpromptIds[0]isn't inremovedKeys. Otherwise usetitleMany.
-
Low, fine as a follow-up: MCP
list_actionsstill gives the created count inpriority.reason.data.ts:2934doesn't adjust it, whileget_actiondoes (currentPriorityReason).- One
readEntityCountscall for the up-to-200 ids would make the two agree.
Checked and fine:
-
Every place that shows the count reads it the same way:
- the list (
getActions); - the drawer's header, chips, tasks and Affected tab;
- History;
- the signal drawer's "Used by";
- the list CSV;
- Copy Data, Markdown and CSV;
- MCP
get_actionand the MCP export.
Nothing else in the web or the server renders an action's count, and there are no emails or digests with one.
- the list (
-
One batched call per page, never one per row:
getActions(at most 1,000 actions, so at most 2 calls of 500) runs it in parallel with its other reads;- the CSV export, History, the drawer and MCP make one call each.
-
Arithmetic:
- The count left is the saved
targetCountless what was removed, clamped at 0.totalisn't read. - An action with no rows, like the 19 from the earlier review, keeps its saved count, as asked.
- With none left, tasks fall back to their plain title, the priority reason drops its count, and generic titles read
titleGeneric.
- The count left is the saved
-
Without 00244: a missing function (
PGRST202) or any read error leaves the payloads as stored, and the page still renders.- The web can deploy before 00244 is applied. Only items 1–3 change what it shows then, through the payload count.
-
web/src/types/supabase.tsmatches 00244: the columns, nullability, insert defaults, FK name, RPC args and return columns. -
RemovedNote: a button with a tooltip. It stops the row click and has a focus ring. -
i18n: all copy is in
en.json, the only locale. -
Merges:
66b4c4ec,96e386d0and1f06172fre-merge to identical trees, so they carry no hidden changes.- It contains #1388 and merges cleanly on current main (
c4568814). - It adds no migration or server change of its own.
- It contains #1388 and merges cleanly on current main (
…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]>
|
@gkhngyk Fixed, after merging main (only
Web 2,919 tests + build, lint, typecheck, format pass. |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good. All five items from the last review are done or answered.
Earlier items
- A removed text-named prompt stayed listed: done.
affected.ts:106now also matches a row without an id by its text againstremovedLabels.- On prod the labels line up. All 9 kept labels of the open topic gap (6 removed) equal its payload texts exactly. It now lists 3 rows under "3 prompts".
- The 20-label cap doesn't matter today. That topic gap is the only text-target action with removed prompts.
- Tests are in
affected.test.tsandentity-counts.test.ts.
- A mention review listed its first prompt twice: done.
affected.ts:319and:330skip a target whoseid ?? textis already listed.- There's a test.
- The known limit: answered.
- The body states it with the numbers.
- #1409 builds the rows from
action_entities.
- Low: a mention review named after a removed prompt: done.
display.ts:136readstitleManyoncepromptIds[0]is inremovedKeys.- The test covers both the first prompt and another one removed.
- Low: MCP
list_actionspriority reason: done.data.ts:2922makes onereadEntityCountscall for the listed ids. There are at most 200, so it's one call.:2943applies the samecurrentPriorityReasonasget_action.- There's a test.
Checked
- Merge
dc17bcc9(main into the branch):- Re-merging its parents conflicts only in
schema.sql. - The commit's
schema.sqlis main's atf7c42fe0. - It carries no hidden changes.
- Re-merging its parents conflicts only in
- Merge state:
- It merges cleanly on current main (
76c87361). - On top of main it changes only web files (25 files). It adds no migration and no server change.
- The #1388 commits it still carries are on main as the squash, so they drop out of the diff.
- It merges cleanly on current main (
- Auth and cost, as a member, on the brand with the most actions (50):
action_entity_countsfor all 50 ids takes 7.8 ms.- A member of another organization reads none of that brand's
action_entitiesrows.
- Deploy:
- Web only, so it deploys on merge.
- 00244 is on prod, so there's no ordering issue.
- CI and tests:
- CI is green: format, lint and typecheck.
- CI doesn't run the web tests. The PR reports 2,919 passing.
…t-steps-server Main squash-merged ansvisor#1389 and ansvisor#1393–ansvisor#1399; its tree is ansvisor#1399's last head (b84e724), so this is that merge: this branch's changes on top of it.
…-entities Main squash-merged ansvisor#1389 (this branch's parent): this is main with this branch's own two commits on top.
Summary
AC-009, part 2 of 3: every place shows one count for an action, the count it was created with less what was removed since, and says "(1 prompt removed since this action was created)". Hover or focus names the removed items.
One source.
lib/action-center/entity-counts.ts:readEntityCounts(client, ids)calls the RPC in batches of 500. A database without 00244, or a failed read, leaves the actions as they were.withEntityCounts(payload, rows)rewrites the payload as the action reads now:targetCount(and apromptCount/pageCountthat counted the same list) becomes the count left;createdTargetCount,removedCount,removedLabels(up to 20, for the hover) andremovedKeys.Because every surface already reads the payload, they all follow.
currentTaskParams: a planned task that named the action's count ("across 13 prompts") names the count left. With none left it names no count, so it reads as its plain title.currentPriorityReason: "Why this priority?" ("Lost ground on 13 prompts") names the count left too.Where it's applied
getActions,getActionDetail(task titles), viaactionItemFromRow.getActionHistory.getSignalActions.getActionsAffected.get_action: payload, tasktitle_params, priority reason.The Affected list agrees with the count (
affectedOf):UI
RemovedNotesits beside the count in the list row and the drawer header. It's a button with a tooltip, so focus shows the names as hover does; clicking it doesn't open the drawer. Copy: "(1 prompt removed since this action was created)".Also
get_action/list_signalsand the drawer's signal reads drop a big group'stargetIds(up to 1,000 ids), which no reader needs.mention_reviewwith every prompt removed reads its generic title, not "0 prompts".removedLabelstoo (the RPC names the first 20); a mention review lists its first prompt once; a review whose first prompt was removed readstitleMany; MCPlist_actionsgives the current count inpriority.reason, asget_actiondoes.Known limits
action_entities(members can already read it). It is taken next, as its own PR right after this one, not left open.Related issue
AC-009 "Single count source" (ROADMAP, Drive › Diğer). 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
I checked step 1 in the browser on the dev DB with a temporary action (deleted afterwards, and the prompt resumed), at 1024 px and phone width, in light and dark themes.
Tests:
entity-counts.test.ts: the count left, nothing below 0, task titles (including none left), priority reason, removed rows left out by id, text targets, no count without rows, reads in batches of 500, a missing RPC,withoutTargetIds;action-table.test.tsx: the note, and that its click doesn't open the drawer;actions-affected.test.ts: the list CSV count;display.test.ts:mention_reviewwith none left;action-signals,action-exportandaction-priority.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:
yarn testandyarn build.🤖 Generated with Claude Code