Skip to content

fix(content): ask for one opportunity for a prompt, and offer the one it already has - #1797

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/new-opportunity-prompt-focus
Oct 29, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/new-opportunity-prompt-focus

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Content › Opportunities › New, with a prompt as the focus, let you pick 3 and said "Uses 3 of your N remaining", but a prompt belongs to one prompt group and a group gets one opportunity, so at most one could come. When the prompt's group already had an open opportunity, the result was "No new opportunities: every matching need already has one", with no way to find that one. Reported while testing on 2026-10-29: Let Ansvisor choose (3) gave 2 + 1 duplicate, a topic (3) gave 1, then a prompt (3) gave none.

What changes (web only)

  • new-opportunities-dialog.tsx: with the Prompt focus the count is 1 and More is off. The note beside it reads "One per prompt. For a different take, use Another angle on its opportunity.", and the usage line and Generate say 1.
    • The chosen count is kept, so going back to Let Ansvisor choose or Topic brings it back.
  • Content page: when a "+ New" run writes nothing and the server returns existingId (already in the job result since PROMPT-006), the toast says "This prompt already has an opportunity" with Open existing, which opens that opportunity's panel (and ?opportunity= in the URL, like a row click).
  • en.json: content.newExisting, content.openExisting, content.newDialog.promptOne.

The server already claims only the slots it writes, so no quota was ever lost; only the dialog's numbers and the dead end change.

Related issue

None. Reported by the product owner while testing Content Opportunities.

Type of change

  • fix — Bug fix

How to test

  1. Content › Opportunities › New → Prompt: the count shows 1, More is off, the note says "One per prompt…", the usage line says "Uses 1 of your…", the button says Generate 1.
  2. Switch back to Let Ansvisor choose: the count is 3 again.
  3. Pick a prompt whose group already has an open opportunity and generate: the toast says "This prompt already has an opportunity". Open existing opens it.
  4. Unit tests:
    • new-opportunities-dialog.test.tsx (new): the prompt focus sends count: 1, and the count comes back.
    • content/page.test.tsx: a finished run with existingId shows the toast, and its action opens the panel and sets ?opportunity=.

Checklist

Checks on this branch (5276032): web lint 0 errors (7 warnings, none in these files), typecheck OK, 631 test files / 6,249 tests passed. yarn build fails on main's own break, unrelated to this change; #1796 fixes it.

🤖 Generated with Claude Code

cihan-gyk and others added 2 commits October 29, 2026 20:46
… it already has

A prompt belongs to one prompt group, which gets one opportunity, so New with
a prompt as its focus could never write more than one, while the dialog let
you pick 3 and said it would use 3. With a prompt the count is now 1, with a
note to use Another angle for a different take. When the run writes nothing
because the prompt already has an open opportunity, the toast says so with
Open existing, from the existingId the job already returned.

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

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

What I checked

  • With the Prompt focus the dialog caps the count at 1 (cap = min(1, max)), More is off, and the submit check uses the same cap, so it can't send more than 1. The chosen count is kept in state, so leaving the Prompt focus brings it back. With max 0 nothing can be sent, as before.
  • The server already treats a prompt request as targeted (open.slice(0, count ?? 1)), and only a prompt request (or a page's, which "+ New" doesn't send) returns existingId with nothing written, so "This prompt already has an opportunity" can't show for a topic or Let Ansvisor choose run. existingId was already in the job result type.
  • Open existing calls selectOpportunity, the same path as a row click, so the panel and ?opportunity= match. selectOpportunity is defined above pollJob and added to its dependencies.
  • The order of toasts keeps "limit reached" first; newNothing and newDone are unchanged for the other cases.
  • Three new en.json keys, all used; only en.json exists.
  • Web only: no migration, no new route or server action, no embeds. plan-row.test.ts (client imports never reach the server Supabase client) passes on the PR merged with main.
  • Merges cleanly with main.

Follow-ups (not blocking)

  1. The PR says the "+ New" section of help/content/content-opportunities.md is added on #1792, but #1792's article has no "+ New" section yet. Once both are in, add it there, including that a prompt asks for one.

Tests (PR merged with main): web vitest new-opportunities-dialog.test.tsx, content/page.test.tsx, plan-row.test.ts, subscription-guard-coverage.test.ts: 20 passed. tsc --noEmit clean; eslint and prettier clean on the touched files.

@gkhngyk
gkhngyk merged commit e4cbcec into ansvisor:main Oct 29, 2026
4 of 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.

2 participants