Skip to content

feat(prompts): show a prompt's real demand on its page (PROMPT-014, part 2) - #1651

Merged
gkhngyk merged 8 commits into
ansvisor:mainfrom
cihan-gyk:feature/prompt-demand-ui
Oct 28, 2026
Merged

gkhngyk merged 8 commits into
ansvisor:mainfrom
cihan-gyk:feature/prompt-demand-ui

Conversation

@cihan-gyk

@cihan-gyk cihan-gyk commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

PROMPT-014, part 2 of 3: show a prompt's real demand on its page. It follows the roadmap mockup's screen 2.

Stacked on #1650 (part 1). This PR's own change is its commits after part 1's: 3f27a6f and b1103f3 (the pre-push review's fixes). Merge it together with part 3 (#1652).

KPI row

  • A new tile, "Demand · 3 of 4 signals", with the level (High, Medium, Low) and a Measured badge.
  • Measured numbers never carry the Estimate badge (PROMPT-013).

"Demand · is this asked for real?" A 2×2 grid. Each card names its source and the day it was read.

  • Search Console: impressions and clicks over 28 days, the number of matching queries, and an example query.
  • Google Trends: a 12-month line with rising / steady / falling.
    • Only a rising line says "from no search interest a year ago". A steady line with no change to give shows its label alone.
  • People Also Ask: the questions, each with + Track, which adds it to the prompt's topic.
    • The API marks each question the brand already tracks (case, accents, punctuation and spacing aside), so it shows Tracked, also after a reload.
    • trackDemandQuestion adds nothing for a text the brand already has.
    • Each button names its question for screen readers.
  • YouTube: views across the top videos, the top video, and the result count.

A missing signal says why and what to do

  • connect Search Console (in place, as on AI Traffic), pick its property, or wait for the first sync;
  • analyze the prompt's volume first;
  • being read, or not read yet;
  • not read on this server (DEMAND_SIGNALS off).

A note under the grid says the level raises the Priority Score of Action Center actions about this prompt (part 3).

Where people see it: Prompts › a prompt's page, under the KPI row.

Related issue

PROMPT-014 of the roadmap (Drive › ROADMAP-plan.md). No GitHub issue.

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. Apply part 1's migration. Insert a prompt_demand row for a demo prompt with gsc, trends, paa and youtube data. One People Also Ask question should have the same text as a prompt the brand already tracks.
  2. Open that prompt's page. You should see:
    • the KPI row with "Demand · 4 of 4 signals" and High · Measured;
    • the four cards with their sources and dates;
    • Tracked on the question the brand already has, and + Track on the others.
  3. Open a prompt with no row. Each card should say why it is empty and what to do.
  4. Check dark mode and 1024 px.
  5. Tests: cd web && npx vitest run src/components/prompts/demand-card.test.tsx src/lib/prompt-demand.test.ts src/lib/actions/prompt-demand-signals.test.ts

Checked in the browser (local, 1024 px, light and dark) with a temporary row on a demo prompt: KPI tile, the four cards, Tracked and + Track, Trends "Rising · +186%", and the note. The temporary row was deleted afterwards.

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

Full checks were run at the top of the stack (part 3): server 3,404 tests, web 4,362 tests, typecheck, lint and build all pass.

Follow-up: the read-only gate (#1599) on + Track and on Connect Search Console, once the read-only chain merges.

🤖 Generated with Claude Code

cihan-gyk and others added 5 commits October 28, 2026 04:19
…OMPT-014, part 1)

A prompt's AI search volume is an estimate. This reads what shows people
really ask it, for the Demand card on the prompt's page (part 2):

- prompt_demand (00370): per prompt, Search Console, Google Trends, People
  Also Ask and YouTube, each with the day it was read, the level they come
  to (high / medium / low) and how many of the four were read. Members
  read their brands' rows; the server writes them.
- Search Console, every night and free: the brand's queries over 28 days
  (prompt_demand_gsc_queries), each matched to the closest prompt with
  the Action Center's rule (classify.js matchPrompt), summed per prompt.
- Trends, PAA and YouTube: DataForSEO Standard tasks for the prompt's
  top volume keyword and its location and language, once a week, at most
  500 prompts a night. Set at night, read an hour later or the next night
  (tasks_ready, task_get). Off unless DEMAND_SIGNALS=true.
- The level is the share of points the read signals give (demandLevel):
  high at 60% with two signals or more, medium at 30%, low below.
- Workspaces whose plan has ended are skipped. Runs after the nightly
  Search Console sync.
- GET /api/prompts/:promptId/demand answers the card.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…art 2)

The prompt's page shows what the nightly sweep (part 1) read, as in the
roadmap mockup's screen 2:

- The KPI row gets "Demand · 3 of 4 signals" with the level (High,
  Medium, Low) and a Measured badge: measured numbers never carry the
  Estimate badge (PROMPT-013).
- "Demand · is this asked for real?": a 2x2 grid of Search Console,
  Google Trends (a 12-month line, rising / steady / falling and the
  change on a year ago), People Also Ask and YouTube, each with its
  source and the day it was read.
- A People Also Ask question is tracked in one click (+ Track), in the
  prompt's topic, with trackPagePrompts.
- A missing signal says why and what to do: connect Search Console (in
  place, as on AI Traffic), pick its property, wait for the first sync,
  analyze the prompt's volume first, being read, or not read yet.
- A note under the grid says what the level does to the Priority Score.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tasks (PROMPT-014, part 1)

Review fixes for the nightly demand sweep:

- postTasks catches each 100-task request's failure on its own and hands
  every request's ids to the caller as soon as they're in; the sweep
  writes them at once, so a later failure loses none that were paid for.
- A write that hits a prompt deleted meanwhile (foreign key) is written
  again without it, instead of dropping the whole chunk.
- Done tasks whose ids were never written are read back by their tag
  (the prompt's id) from tasks_ready.
- The sweep claims the prompts it is about to set (prompt_demand_claim,
  claimed_at) and sets only those, so two sweeps at once never set the
  same prompt twice; a claim older than two hours may be taken again.
- Brands go never-written first, then longest since their last write
  (prompt_demand_brand_updates); the ones a sweep runs out of time for
  are counted (unfinished) and logged. The due count is logged too.
- 00370: drop the unused prompt_demand_posted_idx, fix the header.
- DEMAND_SIGNALS documented in env-variables.mdx (paid, off by default).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ds wording (PROMPT-014, part 2)

Review fixes for the Demand card:

- Google Trends says "from no search interest a year ago" only for a
  rising line; a steady one with no change to give shows its label alone.
- GET /api/prompts/:id/demand marks each People Also Ask question the
  brand already tracks (case, accents, punctuation and spacing aside), so
  it shows "Tracked" after a reload; +Track goes through a new
  trackDemandQuestion action that adds nothing for a text the brand
  already has. Each button names its question for screen readers.
- The note under the cards says the level feeds the Priority Score of
  Action Center actions about the prompt.
- "about once a week" instead of "once a week".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 28, 2026
…d route, and link only http(s) pages (PROMPT-014, part 2)

A 404 without our error body means the API doesn't have the route yet: the
prompt page then shows no Demand section instead of "Couldn't load". The
route's own 404 and other failures still show the error.

The People Also Ask and YouTube signals keep a provider link only when it is
an http(s) URL, and the card links the top video only then.
@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 28, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with ca949fe: while the API has no demand route yet (a 404 with no body of ours), the prompt page hides the demand section instead of showing an error; the route's own errors still show. Provider links are kept only when they're http(s), on the server and in the YouTube card. 00370 is applied to production. The remaining follow-ups (the #1599 read-only gate on + Track and Connect) stay open.

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.

2 participants