Repository navigation
feat(prompts): analyze a prompt the moment it is added - #754
Merged
Merged
Conversation
A prompt added from the Prompts page was written to the database and then left idle until the next daily tracking run, so a user could add a prompt and see nothing for up to a day. The toast said as much, which made the delay honest but no less useless. Submit the prompt for analysis as soon as it is saved. The request names the single prompt id that was just created rather than asking for the brand's unanalyzed set. Results arrive asynchronously, so a prompt that is still in flight has no result rows yet and would be picked up — and paid for — a second time by the very next add. Naming the id keeps each prompt to exactly one submission. A refusal is not an error. The daily cap, the cooldown, a paused brand, an inactive subscription and an unreachable server all leave the prompt saved and the scheduled run to collect it, so they change the confirmation message and nothing else. Scoped to the Prompts page in the sidebar; the brand-level page keeps its existing Analyze Prompts button.
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
A prompt added from the sidebar's Prompts page was written to the database and then left idle until the next daily tracking run. The confirmation toast said as much — "it will be picked up by the next tracking run" — which made the delay honest but no less useless: add a prompt at noon, see nothing until tomorrow morning's scheduled run.
This submits the prompt for analysis as soon as it is saved.
The request names one prompt id, not the brand's unanalyzed set.
POST /api/tracking/analyze-newbuilds its candidate list from active prompts that have no rows inprompt_results. Results arrive asynchronously, so a prompt that is still in flight has no result rows yet and would be swept back into the candidate list — and paid for a second time — by the very next add:Passing only the id that was just created keeps each prompt to exactly one submission, with no new state to track. The route already accepts
promptIdsand validates them against the brand, so nothing changes server-side.A refusal is not an error. The daily on-demand cap, the cooldown, a paused brand, an inactive subscription and an unreachable server all leave the prompt saved and the scheduled run to collect it. They change the confirmation message and nothing else — no error toast, no failed-looking state on a write that succeeded. Only unexpected statuses reach the server log.
Scoped to the Prompts page in the sidebar. The brand-level prompts page keeps its existing Analyze Prompts button and is untouched.
No server changes, so no redeploy is needed.
Related issue
None — reported directly.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
Four tests cover the action, the important one asserting the exact request body so a future change back to "the brand's unanalyzed prompts" fails loudly.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)