Repository navigation
feat(content): start from the prompts AI doesn't name or cite the brand for yet - #1323
Conversation
…nd for yet New content › Prompt lists only the tracked prompts where no answer of the last 30 days named the brand or cited its pages: a prompt it already shows for needs no new page. A note says how many are left out, and the empty list says when the brand shows for every prompt. Add source in the editor still offers every prompt. Migration 00230 adds content_start_prompts (insights_prompt_daily; not seen first, with the seen count; security definer, members only). Before it is applied, every prompt is listed as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk This is item E of the Plan feedback. New content → Prompt now lists only the prompts where AI hasn't named or cited the brand in the last 30 days.
Checks: web 281 files / 2,486 tests, lint, typecheck and build. Checked on the dev DB as a member (8 → 3 unseen) and as an outsider (null). |
gkhngyk
left a comment
There was a problem hiding this comment.
A couple of small fixes before merge:
-
Wrong empty-state message on a search miss.
ComboboxEmptyalso renders when the search box filters the list down to nothing. WithpromptsSeen > 0, typing a query that matches no unseen prompt shows "AI already names or cites you for every tracked prompt in the last 30 days", even when unseen prompts exist (web/src/components/content/new-content-dialog.tsx:763-767).
Fix: showallSeenonly when the unfiltered list is empty, e.g.kind === 'prompt' && items.length === 0 && options?.promptsSeen ? allSeen : empty. Add a test that types a non-matching query and expects the generic empty text. -
A malformed RPC payload reads as "no prompts".
readStartPromptsmaps everysafeParsefailure to{ prompts: [], seen: 0 }(web/src/lib/actions/content-drafts.ts:268-272). Onlynullmeans "not the member's brand". Any shape drift between the function and the schema would silently empty the picker.
Fix:if (read.data === null) return { prompts: [], seen: 0 }; return startPromptsSchema.parse(read.data);so drift throws, and New content then shows its load error.
Migration 00230 looks right. It's security definer with search_path set and the membership check (null for an outsider). Execute is revoked from public/anon and granted to authenticated/service_role, and create or replace keeps it idempotent. I timed a copy as an authenticated member on the largest brand (about 78k rollup rows in 30 days, 226 active prompts): about 110 ms cold, 23 ms warm. A member of another org gets null as expected. No brand has more than 500 active prompts today, so the cap doesn't change what Add source lists. This merges cleanly with #1333.
…n-prompts # Conflicts: # supabase/schema.sql
…own start-prompts payload - New content's prompt picker says every prompt is seen only when nothing is left to list; a search that matches nothing reads the generic empty text. - readStartPrompts treats only null as "not the member's brand"; any other payload goes through the schema's parse, so drift throws and New content shows its load error instead of an empty picker. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk Thanks, both are in |
gkhngyk
left a comment
There was a problem hiding this comment.
Both items are fixed:
- A search miss now shows the generic empty text.
- Only
nullreads as "not the member's brand"; any other payload is parsed, and drift throws.
00230 on production. For the largest brand, a member gets 226 prompts (208 seen) in 0.16 s, and an outsider gets null.
Tests. Run on top of main together with #1345: web and server tests, tsc, lint and Prettier pass, and schema.sql matches a rebuild.
Summary
From the user's review of New content: Start from Prompt should only suggest prompts where AI neither names nor cites the brand. If the brand is already cited or mentioned for a prompt, it needs no new page.
Migration
00230_content_start_prompts.sqlNew function
content_start_prompts(brand, days = 30, limit = 500). It returns:seenwhen an answer in the last 30 UTC days (today included) named the brand or cited its pages;How it reads and orders:
insights_prompt_daily, by its(brand_id, day)index), not the answers.It is built like the content reads in 00226: plpgsql,
force_custom_plan, security definer with the organization check made explicit, and null for a caller outside the organization. It's applied on the dev DB and checked as a member (8 prompts → 3 unseen, 5 seen; the limit holds) and as an outsider (null).schema.sqlis rebuilt.Web
getContentStartOptionsreads the prompts through it.DraftStartOptions.promptsgainsseen, plus a newpromptsSeencount.Opportunities and Topics are unchanged.
Related issue
None. Product feedback from the user.
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
Apply
00230first.Checked in light and dark, at 1024 px and wider.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)yarn testpasses: 281 files, 2,486 tests.yarn buildpasses with CI's placeholders.bash supabase/build-schema.shwas run.🤖 Generated with Claude Code