Repository navigation
feat(prompts): show average position and trend in the Positions column - #1017
Conversation
…Positions column Adds a prompt_position_summaries RPC (per-prompt, per-platform position sums) and uses it for the current and previous period. The Positions column now shows the average mention position (matching the Positions panel), its change against the previous period of the same length, and one dot per plan-included platform. The column is sortable and a "Late or missing" quick filter narrows the table to prompts that need work. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the per-platform dots in favour of a hover breakdown on the value, turn See into a compact chart icon button, and give the value a fixed width so the trend never pushes the button and the cell sits under its header. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk PROMPT-007 is ready for review: the Positions column now shows the average position (same number as the Positions panel) with a trend arrow against the previous period of the same length, is sortable, and has a "Late or missing" quick filter. Hover the value for a per-platform breakdown. Note: the demo seed has no |
gkhngyk
left a comment
There was a problem hiding this comment.
Thanks, the column is useful, and the query holds up. On our largest brand (about 218k results in 180 days), the function took about 2.7 s for a 90-day window as an authenticated user, under the 8 s limit. Three things before merge:
- A failure here takes down the whole Prompts page.
getPositionRowsis awaited insidegetPromptsPageData'sPromise.allwithout a catch. A timeout, or the web deploying before 00123 is applied, fails the whole table. Degrade like volumes and the location quota do: catch and return empty positions, so the column shows—. - "Missing" should match the Improve tab. #1011 now treats a platform where the brand appears in fewer than half the runs as not mentioned (
MIN_MENTION_RATE). Heremissingmeans never mentioned, so a platform at #1 in 8 of 120 answers reads as early. The "Late or missing" filter then skips a prompt that the Improve tab calls not mentioned on the same platform. Please apply the same rule indotState. - Merge
mainin. The chart button callssetPositionsFor, which #1010 replaced withopenPositionsPanel(p.id).getPromptsPageDatanow also loads the location quota (#1009). Then re-runbuild-schema.sh.
Smaller: for the current window, this scans the same rows as prompt_visibility_summaries. Folding the position sums into that function later would save one scan.
…ition-trend # Conflicts: # supabase/schema.sql # web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx # web/src/lib/actions/prompt.ts
…entioned platforms as missing - getPromptsPageData catches a failed position query like volumes and the location quota: the Positions column shows — instead of failing the table. - A platform where the brand appears in fewer than half the runs is missing, as on the Improve tab (MIN_MENTION_RATE, mirrored from the server), so "Late or missing" includes it. Its hover shows the mention rate instead of its average position. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the review! All three points are addressed:
On the smaller note: agreed. Folding the position sums into FYI, unrelated to this PR: |
gkhngyk
left a comment
There was a problem hiding this comment.
Thanks, all three addressed. Migration 00123 is applied to production.
… behind first (#1098) Clicking "Late or missing" on Tracked Prompts seemed to do nothing. It filtered, but nearly every prompt with answers is late or missing on at least one platform (on production, 202 of the 202 answered in 24h), and the list kept its order, so the first page stayed the same and only the row count at the bottom changed. The definition stays (#1017). The button now says how many prompts it leaves ("Late or missing · 202", after search and work status), and while it is on the list starts with the prompts furthest behind: - late or missing on the most platforms; - then missing on more of them; - then the worse average position, a prompt never ranked counting as furthest back; - then the more visible. A column picked before is set aside and comes back when the filter is turned off, unless a header is clicked in between; a header click starts at its usual direction. The order is announced in a screen-reader caption, and the button's text moves to en.json. Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
PROMPT-007. The Tracked Prompts table's Positions column now tells you where the brand stands without opening the panel:
Average position (e.g.
#2.9): the mean mention position over answers that mention the brand, on the platforms the plan includes. It is the same number the Positions panel shows; checked in the browser.Trend arrow: the change against the previous period of the same length, ending where the selected range starts.
The panel has no period comparison, so this is the only place the trend shows.
Hover breakdown: hovering the value lists each platform's state and average, e.g. "ChatGPT: named further down (chore(seo): block search indexing on the app subdomain #3.0)".
Detail button: the See button is now a compact chart icon ("See positions" on hover) right next to the value, so the cell fits under its header. It opens the same panel.
Sortable: the first click sorts ascending, so fix(tracking): keep job active until webhook results drain #1 is on top. Prompts without a position go last.
"Late or missing" quick filter: shows only prompts named late, or not mentioned, on at least one platform.
Empty states:
#3.7+ arrow (if changed) + chart button—+ chart button (the panel shows citation ranks)—Long values (e.g.
#28.5 ↑12.5) fit the fixed-width slot without touching the button; checked at 1024px.Data
New migration
00123_prompt_position_summaries.sqladds the RPCprompt_position_summaries(brand, from, to, region):GROUP BYreturning per-prompt, per-platform sums and counts, not averages, so platforms combine exactly.SECURITY INVOKER, so RLS applies.chatgpt-shoppingand respects the location filter.getPromptsPageDatacalls it for the current and previous windows inside its existingPromise.all, so the page still loads in one round trip. The cell is computed by the pure helperweb/src/lib/prompt-position-summary.ts, which has tests.supabase/schema.sqlis regenerated.Related issue
PROMPT-007 (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
mention_position, so to see values, temporarily setmention_positionandmentioned_entity_counton some demoprompt_results.#x.x, plus a trend arrow when the previous period differs. Hover the value for the per-platform breakdown.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 test: 473/473 passedyarn build: passednpm run version:check: passedbash supabase/build-schema.sh: run, and the regeneratedschema.sqlis included🤖 Generated with Claude Code