Skip to content

feat(prompts): add a Positions column with a per-platform positions panel - #1003

Merged
gkhngyk merged 1 commit into
mainfrom
feature/prompt-positions
Oct 11, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feature/prompt-positions

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a Positions column to Prompts → Tracked Prompts. A See button opens a right-side panel that shows, per AI platform, where the brand was mentioned and cited for that prompt.

The column

  • "See" appears when the brand has at least one mention or citation for the prompt in the selected window and location. Otherwise the cell shows "—".
  • The table query already returns mention_answers and citation_answers per prompt, so the column needs no extra query.
  • The panel opens over the table. Closing it with ×, Esc or "Back to prompts" leaves search, sort, page and scroll as they were.

The panel uses the table's own window and location. It loads lazily through a new server action, getPromptPositions.

  • 24h: each platform's latest answer, with its run time.
  • 7d / 30d / 90d / custom:
    • Summary cards: runs; tracked, mentioned and cited days; average position.
    • Per platform: mentioned and cited days, best, worst and average mention position, and one block per UTC day. Hovering a block shows that day's positions.
    • Opening a platform lists every run day by day, with the sentiment split.
    • A "Daily history" tab lists all platforms by day.

Counting rules

  • A day without an answer is "not tracked", never "not mentioned" or "not cited".
  • Several answers on one day count that day once, and every answer is still listed.
  • Answers carry no run id. The summary therefore counts runs by splitting answers on gaps of more than 6 hours: one per day for the nightly run. A platform's run count is its number of answers.
  • Mention position: the stored mention_position out of mentioned_entity_count, i.e. the brand's rank among tracked brands.
  • Citation position: the brand's first source among the answer's sources that have a URL. It uses the same own-domain rule as citation_count. Over 3,000 recent cited answers, every one had a matching source.
  • Missing values read "Position unavailable" or "Sentiment unavailable". Nothing is made up.
  • Days are UTC, and the panel says so.

Plans

  • Platform access comes from the org's effective plan (getOrgPlan), so Enterprise overrides apply.
  • A platform the plan doesn't include shows "Available on Growth" with Upgrade (to billing), or Contact us. Its rows are never queried.
  • Claude needs the Enterprise per-customer model override.
  • Grok is offered through sales on every cloud plan. It is paused for everyone (UNAVAILABLE_PLATFORMS in the tracking worker), so an included but empty card would look broken. The plan lists keep Grok, because removing it there would strip it from stored prompts. Self-hosted keeps it.

Also

  • The Early/Mid/Late rule (lib/position-tone.ts) and label (components/position-label.tsx) are shared now. The Citation URL page uses them and renders the same as before.
  • The contact-sales URL becomes CONTACT_SALES_URL, which the plan switcher shares.
  • The Perplexity logo is centred in its viewBox. It sat to the left on every page that shows it.
  • AIProviderAvatar gets a plain variant for the panel. It drops the round badge and shows the ChatGPT mark black on light backgrounds.

No migration: everything comes from prompt_results, brand_domains and the plan.

Related issue

None. This implements the team's Positions spec and mockup.

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. On Prompts → Tracked Prompts, pick 30d and click See on a prompt the brand appears in. Check:
    • the summary cards;
    • a block per day, including untracked days;
    • that opening a platform lists every run with its mention and citation positions.
  2. Switch to 24h and open the same prompt. Each platform shows its latest run and time.
  3. A prompt with no mention or citation in the window shows "—" instead of See.
  4. Change the location filter, then reopen the panel. The numbers follow the filter.
  5. On a Starter workspace:
    • AI Overviews, AI Mode, Gemini and Copilot show Upgrade;
    • Grok and Claude show Contact us;
    • no data is shown for any of them.
  6. The Citation URL page's Position column looks as before.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

yarn test (466) and yarn build also pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A

…anel

The Tracked Prompts table gets a Positions column. When the brand was
mentioned or cited for a prompt in the selected window and location, a
"See" button opens a right-side panel with that prompt's results per AI
platform. Otherwise the cell shows "—".

The panel reads the table's own window and location:
- 24h shows each platform's latest answer: mention (position, sentiment) and
  citation (position), with "Detected earlier in this period" when an earlier
  answer in the window had what the latest one lacks.
- 7d/30d/90d/custom show runs, tracked/mentioned/cited days, best/worst/avg
  mention position and a block per UTC day; opening a platform lists every
  run by day. A "Daily history" tab lists all platforms by day.
- A day without an answer is "not tracked", never "not mentioned"; several
  answers on one day count that day once.
- Mention position is the brand's rank among tracked brands
  (mention_position of mentioned_entity_count). Citation position is the
  brand's first source among the answer's sources, matched on the same
  own-domain rule as citation_count. Missing values read "Position
  unavailable", never a made-up number.

Platforms the org's plan doesn't include show "Available on Growth" with
Upgrade, or Contact us. They are never queried. Grok is offered through
sales on every cloud plan: it is paused for everyone, and an included but
empty card would look broken.

Also:
- The Early/Mid/Late rule and label move to shared modules; the Citation
  URL page uses them, unchanged.
- The contact-sales URL becomes a constant shared with the plan switcher.
- The Perplexity logo is centred in its viewBox (it sat to the left
  everywhere). The avatar gets a plain variant, used in the panel, that
  shows the ChatGPT mark black on light backgrounds.

Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
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.

1 participant