Skip to content

feat(action-center): raise an action's Priority Score with its prompts' measured demand (PROMPT-014, part 3) - #1652

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

gkhngyk merged 14 commits into
ansvisor:mainfrom
cihan-gyk:feature/prompt-demand-priority

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

PROMPT-014, part 3 of 3: a prompt's measured demand raises the Priority Score of actions about it.

Stacked on #1651 (part 2, itself on #1650). This PR's own change is its commits after part 2's: ca7eb28, 6364c71 and 44c2887. Merge it together with part 2.

How the score changes

  • loadPromptDemand reads each prompt's level from prompt_demand beside its volume. It's best effort: the volumes still count without it.
  • An action about the prompt gets a demand factor of at least:
    • High: 0.85, as for about 2,500 monthly AI searches;
    • Medium: 0.55, as for about 160.
  • Low leaves the factor as it is, and it is never named as a reason.
  • The seven weights don't change. The level is better evidence of the same thing the demand factor measures, so it raises that factor instead of adding an eighth.

"Why this priority?"

  • It names the level ("measured demand High"), stored as priority_reason.realDemand.
  • Only High and Medium are stored, and Low is never shown, also for a reason stored before.

Rescoring

  • When a prompt's level changes in the nightly sweep, the brand's open actions are scored again the same night.
  • rescoreBrandActions leaves an action alone when its score, level and reason come out as stored. A brand is often scored twice a night (the signal pass, then the demand sweep), and the second pass has nothing new to write.

Docs

  • prompts.mdx: Real demand, the level's rule, "about once a week", the weekly reads off by default (DEMAND_SIGNALS), and Tracked on questions the brand already has.
  • action-center.mdx: the Priority Score's demand line.

Where people see it: the Action Center's priority order, and the action drawer's "Why this priority?".

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. cd server && npx vitest run src/lib/action-center/priority.test.js src/lib/action-center/priority-data.test.js
    • Covers: High and Medium floors, Low unchanged and not a reason, an unchanged rescore that writes nothing.
  2. cd web && npx vitest run src/lib/action-center/priority.test.ts
    • "Why this priority?" names High and Medium, never Low.
  3. With a prompt_demand row at high for a prompt with open actions, run the rescore (or wait for the nightly sweep). The action's score goes up, and its drawer says "measured demand High".

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 at this branch (44c2887):

  • server format, lint and npm test: 249 files, 3,404 tests passed;
  • web format, lint (0 errors), typecheck and vitest: 446 files, 4,362 tests passed;
  • web build: OK.

🤖 Generated with Claude Code

cihan-gyk and others added 9 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]>
…s' measured demand (PROMPT-014, part 3)

A prompt's demand level (part 1) now feeds the Priority Score (AC-006):

- loadPromptDemand reads each prompt's level from prompt_demand beside
  its volume; best effort, so the volumes still count without it.
- The demand factor of an action about the prompt is at least High's
  0.85 (as about 2,500 monthly AI searches) or Medium's 0.55 (about
  160); Low leaves it. The seven weights are unchanged: the level is
  better evidence of the same thing the demand factor measures, so it
  raises that factor instead of adding an eighth.
- "Why this priority?" names the level ("measured demand High"), stored
  as priority_reason.realDemand.
- When a prompt's level changes in the nightly sweep, the brand's open
  actions are scored again the same night.
- Docs: Real demand, the level's rule and its effect in prompts.mdx;
  the Priority Score's demand line in action-center.mdx.

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]>
…iority

# Conflicts:
#	server/src/lib/prompt-demand.js
#	server/src/lib/prompt-demand.test.js
…nd skip unchanged rescores (PROMPT-014, part 3)

Review fixes for the demand level in the Priority Score:

- Low raises nothing, so it is no reason: the stored reason keeps the
  level only for High and Medium, and "Why this priority?" never names
  Low (also for a reason stored before).
- rescoreBrandActions leaves an action whose score, level and reason
  come out as stored: a brand is often scored twice a night (signal
  pass, then demand sweep), and the second has nothing new to write.
- Docs: "about once a week", the weekly reads are off by default
  (DEMAND_SIGNALS), and +Track shows Tracked for a question the brand
  already has.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mintlify

mintlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit c516540.

Approve preview

…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. Merged with main after #1696: the score keeps both factors (the measured demand level and the kind's past success), with tests that both add up and that the web's "Why this priority?" reads both. The follow-ups from the review stay open.

@gkhngyk
gkhngyk merged commit 2a7be7e into ansvisor:main Oct 28, 2026
6 checks passed
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