Skip to content

feat(prompts): show a prompt's content opportunities on its detail page - #994

Merged
gkhngyk merged 4 commits into
ansvisor:mainfrom
Nandinikumari02:feature/prompt-content-opportunities
Oct 13, 2026
Merged

gkhngyk merged 4 commits into
ansvisor:mainfrom
Nandinikumari02:feature/prompt-content-opportunities

Conversation

@Nandinikumari02

Copy link
Copy Markdown
Contributor

Summary

Adds a Content opportunities card to the prompt detail page, in the Workflow section below the Notes and Target URLs cards.

  • Lists up to 5 open opportunities for the prompt, each with title, impact, type (owned / earned) and a "Brief ready" marker when a brief exists. Each row links to /dashboard/content/<id>.
  • Shows "View all N" linking to /dashboard/content?prompt=<promptId> when there are more than 5.
  • Shows an empty state when the prompt has no open opportunities.
  • Loaded once per prompt in its own effect (deps: brand and prompt only), so changing the date range does not reload it. Uses getOpportunities(brandId, { promptId, status: 'new', limit: 5 }); the prompt_id filter from feat(content): filter opportunities by prompt #836 is already merged, so this is frontend-only.
  • Notes and Target URLs keep their two-column row; the new card sits full-width underneath.

Closes #838

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

Local data comes from supabase/seed.sql (npx supabase db reset), signed in as [email protected].

  1. Open a prompt with more than 5 open opportunities (I added extra new rows to one prompt in my local DB, one with a brief): the card lists 5, shows the count badge, "Brief ready" on the one with a brief, and "View all N".
  2. Click "View all N": the Content page opens filtered to that prompt.
  3. Click a row: it opens that opportunity.
  4. Open a prompt with none: the empty state shows.
  5. Change the date range: no new opportunities request is made.

Notes

  • yarn build compiles and passes TypeScript, but fails at page-data collection for an unrelated route (/api/agent/conversations/[id]) because a Supabase key is not set in my local env.
  • yarn lint reports 0 errors (the same 8 warnings that already exist in unrelated files).
  • yarn format:check flags many files repo-wide on my Windows machine (CRLF line endings); the two files I changed pass prettier --check --end-of-line auto.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/)
  • 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

@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.

Thanks for this. Two things need fixing before merge, plus a few smaller ones.

Required

  1. "View all N" opens a different list (_workflow-cards.tsx, the "View all" link). N counts only new opportunities, but the link doesn't carry the status, so the Content page shows every non-archived status for the prompt. Use /dashboard/content?prompt=${encodeURIComponent(promptId)}&status=new.
  2. The card loads the active brand's opportunities, not the prompt's (page.tsx, the getOpportunities effect). The rest of the page loads the prompt regardless of the active brand. When the active brand is a different one (a shared link, or switching brand on the page), the card shows "No open opportunities" for a prompt that has some. Use data.prompt.brandId instead of activeBrandId, and load once the prompt has loaded.

Please also

  1. Show a failed load as unavailable, not as "no opportunities." OpportunityContext does this with a failed state, and the card can do the same.
  2. Clear the previous results when a new load starts or fails. Otherwise a failed reload keeps showing the old rows.
  3. Reuse the Content page's labels for impact and type. That means IMPACT_COLORS, t('content.impact.*') and t('content.type.*') instead of the raw HIGH / OWNED values, so both pages look the same.

Nits

  • Keep the preview size in one constant (5 appears in three places), and drop the slice(0, 5), since the request already limits to 5.
  • Remove the unused group and flex justify-between classes, and add title={opp.title} to the truncated title.
  • Update the module comment in _workflow-cards.tsx: the section now has three cards, not two.
  • Rename the PR to Conventional Commits form, e.g. feat(prompts): show a prompt's content opportunities on its detail page. It becomes the squash commit message.

@Nandinikumari02 Nandinikumari02 changed the title Feature/prompt content opportunities feat(prompts): show a prompt's content opportunities on its detail page Oct 11, 2026
@Nandinikumari02

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review, @gkhngyk. I've addressed everything:

  • "View all N" now links to ...&status=new with encodeURIComponent(promptId), so the Content page shows the same N rows.
  • The card now loads with data.prompt.brandId once the prompt has loaded, instead of the active brand. The effect depends only on the brand id and prompt id, so a date-range refetch doesn't re-trigger it.
  • A failed load shows an "unavailable" message instead of the empty state, and previous results are cleared when a load starts or fails.
  • Impact and type now reuse the Content page's colors and the content.impact.* / content.type.* labels (including the type hint tooltip).
  • Nits: a single OPPORTUNITY_PREVIEW_LIMIT constant (dropped the slice), removed the unused classes, title on the truncated title (it truncates with an ellipsis again), updated the module comment, and renamed the PR.

One note: IMPACT_COLORS was duplicated in content/page.tsx and opportunity-detail.tsx, and a page file can't export it, so I exported the one in opportunity-detail.tsx and reused it. Happy to move it into a shared file if you prefer.

Tested locally: the labels and colors, long titles truncating, "View all" landing on the Content page with the New status filter and the same count, and the empty state.

@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.

Thanks, all addressed. Moving IMPACT_COLORS into a shared file can wait for a follow-up.

@gkhngyk
gkhngyk merged commit 6337f90 into ansvisor:main Oct 13, 2026
5 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.

feat(prompts): show a prompt's content opportunities on its detail page

2 participants