Repository navigation
feat(action-center): measure the position outcome of sent Improve actions - #1018
Conversation
The Positions panel was fixed to the table's range, so checking a prompt over another period meant changing the whole table. The panel now has its own 24h / 7d / 30d / 90d / Custom control. It opens on the table's range, and changing it reloads only the panel. The open prompt and the panel's range are mirrored to the URL (?positions=<id>&positionsRange=7d) so the view can be shared. A custom range no longer spells its dates twice in the header. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gestions For one prompt and the panel's range, the Positions panel gets an Improve tab: per AI platform where the brand is not mentioned, mentioned late, or mentioned early but not cited, AI-generated suggestions grounded in that platform's own evidence (fan-out sub-queries, cited domains, competitor URLs, the answer text). The server checks every source against that evidence and drops invented ones, so each card names something real. Suggestions are editable drafts: check, edit, remove (undoable) or add your own. Generation is always the user's click and is metered: each call's real token cost is charged against a monthly budget of 1% of the plan price (Growth $2.49, Enterprise $4.99 or 1% of plan_overrides.contractMonthlyUsd), so the share holds whichever model IMPROVE_SUGGESTION_MODEL points at. Sets are cached per prompt, range and location; newer runs show a "Regenerate" notice instead of rebuilding automatically. Growth+ only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Improve tab's footer gets Send Actions: the checked suggestions, exactly as edited, become one Action Center action (kind prompt_improve, category compete). Each suggestion is a task with its body, platform and evidence in the new action_tasks.details column. The action's why and goal are written from the platform states at send time, its impact from the prompt's demand and the size of the gap, and its baseline keeps the positions per platform for PROMPT-008. Validation measures it on its own prompt. After a send the button turns into Open in Actions, the footer shows the action id, and the sent suggestions are marked. The send is recorded on the cached set, so this survives a reload, and is dropped once the action is dismissed. An idempotency key per send makes a double click create one action. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ions An Improve action now keeps the prompt's last 7 days per platform at send time as a fixed baseline (a trigger stops it being edited). A daily sweep re-reads the same 7 days with the Positions panel's rule while the action is open and for 30 days after completion, storing the comparison on actions.position_outcome. The action's Overview shows an Outcome card (baseline → last 7 days per platform, "Not enough data" where a side had no runs), the Positions panel shows "Improving · AC-n" with the delta, and the read at day 30 is final: it is recorded in History and shown in its Result column. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk PROMPT-008 is ready for review: Improve actions now keep a fixed 7-day baseline, a daily sweep compares the latest 7 days per platform (Outcome card on the action's Overview, "Improving · AC-n" in the Positions panel), and the read 30 days after completion is recorded in History. It's stacked on #1012, so only the last commit is new here. Migration |
gkhngyk
left a comment
There was a problem hiding this comment.
Thanks, this closes the loop nicely, and the baseline trigger is safe: nothing updates actions.baseline after insert. Three things before merge:
- Use the Improve tab's mention rule in the verdict. #1011 now marks a platform
not_mentionedwhen the brand appears in fewer than half its runs (MIN_MENTION_RATE).platformVerdictinstead treats any mention as mentioned, so going from 0 to 1 mention in 10 runs counts as "improved" while the panel still says not mentioned. Decide mentioned or not from the snapshot'sstate, whichclassifyPlatformalready sets. - Filter finished actions in the sweep's query.
sweepImproveOutcomesloads up to 1,000 Improve actions in open or completed states, then skips the final ones in code. Final reads accumulate, so they will eventually fill the 1,000 and newer actions stop being refreshed. Exclude them in the query, e.g. open statuses, orcompleted_atwithin the last 31 days. - Merge
mainin. The branch still carries the pre-review #1010–#1012 commits. Your own commit conflicts only infrom-prompt-improve.js; keep both sides:improvePagesandimproveKpiKeysfrom #1012, plus your 7-day baseline and first outcome read.
…rove-outcome ansvisor#1010, ansvisor#1011 and ansvisor#1012, which this branch was stacked on, are now in main in their final, reviewed form. The merge keeps main's versions of their files and this branch's own change (measuring the position outcome of sent Improve actions) on top: sendImproveToActionCenter keeps main's KPI keys from the action's pages and adds the 7-day baseline and position_outcome.
…and skip final reads in the sweep Decide mentioned or not from the snapshot's state, so a platform under MIN_MENTION_RATE (e.g. 1 mention in 10 runs) stays not mentioned in the verdict, the panel's position delta and the Outcome card's label. Leave final reads out of the sweep's query so they can't fill its limit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk Thanks, all three are addressed:
|
…iew-b8de67 # Conflicts: # supabase/schema.sql
gkhngyk
left a comment
There was a problem hiding this comment.
Thanks, all three addressed. Migration 00124 is applied to production.
Summary
PROMPT-008. Sending Improve suggestions to Action Center (#1012) was half the loop. This PR closes it by showing whether the prompt's positions actually moved after the work.
classifyPlatform, the same rule the Positions panel and Improve tab use.actions.baseline.actions_keep_improve_baseline) rejects any later change to an Improve action's baseline.sweepImproveOutcomesruns in the daily job next tosweepActionValidation.actions.position_outcome.ChatGPT #3.4 → #2.0 ✓.position_outcome_recordedevent is written to the action's History;#3.4 → #2.0); clicking it opens the action.Verdict per platform (threshold confirmed with product: 0.5):
Data
00124_prompt_improve_outcome.sql:actions.position_outcome jsonb(shape documented in the column comment) plus the baseline trigger.supabase/schema.sqlis regenerated.Code
lib/action-center/improve-outcome.js:readPlatformStates,platformVerdict,compareOutcome,refreshImproveOutcome,sweepImproveOutcomes, with tests;from-prompt-improve.js: the 7-day baseline at send and the first read;server.js: the daily hook.lib/improve-outcome.ts: parsing, labels and the panel's tracked-action pick, with tests;improve-outcome-card.tsx;en.jsonstrings.Related issue
PROMPT-008 (internal product task)
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
00124.baselineholds the last 7 days per covered platform.mention_position; set a few to see positions.completedwithcompleted_atmore than 30 days ago and run the sweep. Then:I ran steps 3–7 locally on the dev database and reverted the test data afterwards.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/): 0 errors; the 7 warnings are in files this PR doesn't touchyarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run:
yarn testyarn buildserver: npm run format && npm run lint && npm testnpm run version:checkbash supabase/build-schema.sh🤖 Generated with Claude Code