Repository navigation
fix(content): keep open opportunities when Generate is pressed - #870
Merged
Merged
Conversation
The Generate button deleted every open opportunity a brand had before inserting three new ones, so pressing it threw away the list someone was working through. #63 moved the nightly generator from delete-and- replace to keep-and-append, but the button path was never updated. The button now adds to the open list and follows the same rules as the nightly run: prompts at the per-prompt cap are skipped, the rest list their open titles as "Already suggested", and exact repeats are dropped. Both generators share the open-opportunity read (lib/open-opportunities) and the prompt-data helpers and rule (opportunity-limits), so the two paths cannot drift apart again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pressing Generate Opportunities on the Content page deleted every open (
new) opportunity the brand had, then inserted three new ones. Anyone working through the list lost it the moment they pressed the button.This is a leftover of #63. That change moved the nightly generator (
lib/opportunity-generator.js) from delete-and-replace to keep-and-append, but the queued generator behind the button (workers/content-worker.js) was never updated.Change
MAX_OPEN_PER_PROMPTare skipped before the top-25 cut;lib/open-opportunities.js→loadOpenOpportunities(), the paged read of a brand's open opportunities;opportunity-limits.js:ALREADY_SUGGESTED_RULE,openTitlesByPrompt(),alreadySuggested()andopportunityKey().If every candidate prompt is at the cap, the button generates nothing and the existing toast reports 0. On the largest brand only 58 of 709 prompts are at the cap today.
Related issue
None. This was found while reviewing #837 / #869.
Type of change
How to test
Source tests check that both generators use the shared read, cap, rule and duplicate key, and that the worker contains no
.delete(). Unit tests cover the new helpers.Checklist
yarn lint,yarn format:checkandyarn test(887 passed) pass fromserver/🤖 Generated with Claude Code