Repository navigation
feat(prompts): open the Content Editor from a tracked prompt - #1333
Conversation
From the user's spec, PR A of the Content Editor entry points: - The Tracked Prompts row menu gets "Create content", which opens New content > Start with the prompt picked. When a draft not yet published already covers the prompt (content_drafts.prompt_ids), it shows "Open draft" and goes to the editor instead. - The Positions panel's Improve tab starts with a content step, on the user's thresholds (lib/prompt-content.ts). If no answer in the period mentions or cites the brand, it offers Create content. If the brand is mentioned in under 20% of 5+ answers, or at an average position worse than 3 over 3+ answers, it offers Optimize content on the brand page AI cites most for the prompt (new citedPage in the positions data). Without a cited page, Start's overlap check offers the pages to optimize. - Start takes a "prompt" preset. The cited page's option reads "The page AI engines cite for this prompt". The panel stays open when Escape or a click outside closes Start over it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk PR A of the user's Content Editor entry points: a tracked prompt now leads straight into the Content Editor, from the row menu (Create content / Open draft) and from the Improve tab. The Improve tab offers Create or Optimize using the user's thresholds: under 20% mentions with 5+ answers, or an average position worse than 3 with 3+ answers. It's web only and has no new AI calls; the cited page comes from the source lists the panel already reads. Two things to note:
Tests (2,501) and the build pass. PR B (opportunities) comes next. |
gkhngyk
left a comment
There was a problem hiding this comment.
A few fixes before merge:
-
The Improve tab can still start a second draft for the prompt.
PromptContentStepchecks for a draft once per prompt (web/src/components/prompts/prompt-content-step.tsx:39-49). Start opened from the panel with Agent or Team creates the draft, closes and leaves the user on the Prompts page with the panel still open (sendToAgent/sendToTeamcallchangeOpen(false)and don't navigate). The step still holdsid: null, so Create content stays enabled and a second click starts a duplicate draft, which this PR is meant to prevent. The row menu doesn't have this problem because it checks again on every open.
Fix: passonSentto theNewContentDialogon the Prompts page (web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx:3916-3922) and use it to bump a counter. Thread that counter intoPromptContentStep(through the sheet) and add it to the effect's deps so the check runs again. Add a test: send to Team, then the step shows Open draft. -
Archived drafts (merge order with #1328).
getDraftForPrompt(web/src/lib/actions/content-drafts.ts:311-319) counts every draft indraft/in_review/ready. Oncearchived_atexists, an archived draft would replace Create content with Open draft and open a page the Library hides. Whichever PR lands second should add.is('archived_at', null)and a filter assertion incontent-drafts-start.test.ts.
The rest checks out. getDraftForPrompt goes through the RLS client (content_drafts select is org-scoped) and validates both ids. citedPage is folded from source lists the action already reads, with no extra queries. The tie-break and dedupe in brandCitedPage match their tests. The Escape/outside-click guard on the sheet (page.tsx:3912) works because the closure sees the current contentPreset. New strings are in en.json. This merges cleanly with #1323.
…ent-entry # Conflicts: # web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx # web/src/components/content/new-content-dialog.tsx
…, so Improve offers Open draft Start sent to the Agent or the Team closes over the positions panel, which stays open. The Prompts page now bumps a counter on New content's onSent, passed through the sheet to PromptContentStep, whose draft lookup reruns on it: the step offers Open draft rather than a second draft. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk Thanks. (1) is in
Merge with main. #1320 turned the overlap check into the Overview, which no longer picks for the person. This PR's |
gkhngyk
left a comment
There was a problem hiding this comment.
One fix before merge:
- Optimize content without a cited page now opens Start on a new page. The merge of main took #1320's side in
NewContentDialogand droppedpreferOptimize. Now nothing reads the preset'smethod(web/src/components/content/new-content-dialog.tsx:134). Onlypageis used (:234-240).- The Improve tab's Optimize content with no
citedPagetherefore opens on "Create: ". Open editor then starts a new page. - The PR description still says "The first page to optimize is picked". The step's copy says "pick the one to optimize" (
prompt-content-step.tsx:91). - #1320's rule is that Start "keeps the action the person picked". Here the person picked Optimize.
- Fix: once the Overview read lands for a
method: 'optimize'preset without a page, pick its optimize option one time, like the old ref did. UseoverlapOptions(overlap, null).find((o) => o.choice.kind === 'optimize')withwithChoice, and skip it after a retry or a pick. The test atnew-content-dialog.test.tsx:335should then expect "Optimize: CRM guide" without the click. - If opening on Create is the intended behavior, drop
methodfrom the type and from the step's presets (prompt-content-step.tsx:61-72), then update the doc comment (new-content-dialog.tsx:120-126) and the PR description.
- The Improve tab's Optimize content with no
Earlier items:
- Second draft from the Improve tab: done.
onSentbumpscontentSent, which reachesPromptContentStepasrecheck, and the lookup runs again. The step test covers it. - Archived drafts: still open, waiting on #1328. #1328 isn't on main yet, and the two PRs merge without a textual conflict, so git won't flag this. Whichever lands second must add
.is('archived_at', null)togetDraftForPrompt(web/src/lib/actions/content-drafts.ts:311-322) and the filter to the assertion incontent-drafts-start.test.ts. #1334'sgetOpportunityDraftsneeds the same.
The merge of main changes nothing beyond resolving its two conflicts:
page.tsxkeeps both sides' imports.new-content-dialog.tsxtakes main's side, as described in item 1.
This merges cleanly on main and with #1323 and #1345.
With #1334 it conflicts in three files, and both sides are additive, so keep both in each:
content-drafts.ts: each adds a function aftergetContentStartOptions.content-drafts-start.test.ts: the import list and the newdescribeblocks.new-content-dialog.tsx: theDialogPresetunion versus #1334's& { who?: 'team' }, andgivenPageversusopportunityItem.
The contains line in the mock comes from this PR only, and it merges without conflict.
…ent-entry # Conflicts: # web/src/components/content/new-content-dialog.tsx # web/src/lib/actions/content-drafts-start.test.ts # web/src/lib/actions/content-drafts.ts
… opens Start to optimize The merge of main took ansvisor#1320's side and dropped this PR's preferOptimize, so Optimize content from the Improve tab without a cited page opened Start on a new page. The person picked Optimize: once the Overview's read lands, its first page to optimize is chosen, a single time. A pick of their own, or a retry, leaves the choice to them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk You're right: the person picked Optimize, so Start should keep it. Fixed in
Web: 2,622 tests, lint, tsc, Prettier and the build pass. |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good. The round-6 item is done:
- Optimize without a cited page (a00e589).
- A
method: 'optimize'prompt preset with no page setsoptimizeOnce(web/src/components/content/new-content-dialog.tsx:272). - When the Overview's read lands, Start picks the first optimize option with
withChoice(:304-308).withChoicekeepsstart.source, so the read doesn't run again. - A pick of the person's own and
resetclear the flag. - The test at
new-content-dialog.test.tsx:458expects "Optimize: CRM guide" without a click. It also checks that "Create a new page" stays once the person picks it. - Adding
siteTypeto the read's deps is safe here. The Prompts page passessiteTypeOf(activeBrand), which doesn't change while Start is open.
- A
- The merge of main (70b246d) has three conflicts. Each keeps both sides, and the merge adds nothing else:
getDraftForPromptandgetOpportunityDrafts;- the prompt preset inside
& { who?: 'team' }; givenPagebesideopportunityItem.
Optional: Retry only shows when the read failed (:1166-1169), so no pick has happened yet when it's clicked. Clearing optimizeOnce in onRetry (:672-676) means that after a failed first read, the successful retry doesn't pick the page. To keep the pick in that case, clear the flag only in onChoose and reset.
Still open, waiting on #1328:
- #1328 isn't on main yet, and the two PRs still merge without a textual conflict, so git won't flag it.
- Whichever lands second adds
.is('archived_at', null)togetDraftForPrompt(web/src/lib/actions/content-drafts.ts:348-362), plus the filter to its assertion incontent-drafts-start.test.ts. - #1328 already filters
getOpportunityDrafts.
This merges cleanly on main (12846db) and with #1328.
Tested on top of main together with #1126: web and server tests, tsc, lint and Prettier pass. #1328 will add the archived_at filter to getDraftForPrompt when it merges main.
getDraftForPrompt (ansvisor#1333) skips archived drafts, as getOpportunityDrafts does, so Start opens the work in hand, never one sent to the Archive. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ws (#1328) * feat(content): archive, delete and set a status from the Library's rows Each Library row gets a menu: its status (In progress · In review · Ready · Published; Ready goes through Mark ready, keeping a History version and completing the draft's task) and, for admins and managers, Send to Archive (with Undo) or Restore, and Delete behind a confirmation. An Archived tab holds archived drafts, which keep their status and leave the other tabs, the Plan and the MCP list. Created and Updated replace the AEO score column, and "Draft" reads "In progress". Migration 00233 adds content_drafts.archived_at/archived_by, a trigger letting only admins and managers archive, and a manager delete policy (drafts had none). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): guard archived drafts on insert too, and keep them out of the Action Center - 00233: guard_content_draft_archive runs before insert or update. A member's new draft with archived_at or archived_by set is refused (42501), so archived_by is never the app's word; the server, which bypasses RLS, is unaffected. - readActionDrafts skips archived drafts: the Action Center drawer doesn't list them, and a task's Start writes a new draft instead of reopening one. - Remove aeoScoreText and the list's scoreBefore/scoreAfter, unused since the AEO Score column went. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): let Start write a new draft once its work's draft is archived 00218's content_drafts_action_work_key counted archived drafts too, so a task whose draft was archived could never start again: readActionDrafts skips the archived one, the insert hit the key, and the 23505 retry found no winner. 00233 recreates the key over drafts not archived. Restoring the archived one while a newer draft does the same work is refused (23505), named newer_draft, and the Library says what to do. getOpportunityDrafts (from #1334, now on main) skips archived drafts too. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): don't open an archived draft from a tracked prompt getDraftForPrompt (#1333) skips archived drafts, as getOpportunityDrafts does, so Start opens the work in hand, never one sent to the Archive. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
…reation date (#1354) * fix(content): draw the Plan's mix bars to one scale, and open the page in its final layout - "What AI cites in your topics" drew both shares on one track scaled to AI's largest share, so a type the brand leans on more than AI does (e.g. 35% · 73%) ran its bar past the track onto the shares column. The two shares are now two thin bars on one scale, the larger of the two, never past the track. - The list and the sections above it (AI results, the mix) were read and drawn apart, so the list showed mid-screen first and jumped down when the sections came in. The page now shows one spinner until both reads are in; a list that fails says so at once. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): show the brand's cited pages as an Overview, not an overlap warning More of the brand's pages cited for the same prompts is no loss (AI answers aren't a ranking), so neither Start nor the Plan treats it as a problem any more: - Start's "Overlap check" is an "Overview": a plain box listing the brand's pages AI already cites for these prompts, with no amber warning, no "Safe to create" and no "Recommended". The action the person clicked stays chosen (Create stays Create); the choices are the plan's page when it named one, a new page, and optimizing the page cited most. - The Plan drops the Overlaps card, the ⚠ Overlap tag on rows, and the rows that were listed only because another page of the brand is cited for the same prompts. content_plan_pages (00220/00221) still returns overlaps; the Plan no longer reads it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): assign, mark as a priority or hide a Content plan row Each Priority list row gets a "…" menu: - Assign to… (every member): a row with a draft assigns its Action Center task (sending the draft first when needed); a row without one opens Start on Team, which now has an "Assign to" picker. The Who column shows the assignee. - Mark as priority (admins and managers): the row goes to the top with a Priority tag; a Priority card counts and filters the marked rows. - Hide from the plan (admins and managers): the row leaves the list, with Undo and "N hidden rows · Show"; an opportunity's row also dismisses the opportunity and gets its status back when shown again. Migration 00229 adds content_plan_marks (members read; admins and managers write). Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): archive, delete and set a status from the Library's rows Each Library row gets a menu: its status (In progress · In review · Ready · Published; Ready goes through Mark ready, keeping a History version and completing the draft's task) and, for admins and managers, Send to Archive (with Undo) or Restore, and Delete behind a confirmation. An Archived tab holds archived drafts, which keep their status and leave the other tabs, the Plan and the MCP list. Created and Updated replace the AEO score column, and "Draft" reads "In progress". Migration 00233 adds content_drafts.archived_at/archived_by, a trigger letting only admins and managers archive, and a manager delete policy (drafts had none). Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): suggest opportunity content types by the brand's site type Content Opportunities gave every brand the same ten asset types, so a shop could get a glossary or landing page and a SaaS brand a product or category page. The generator now reads brands.site_type (or the editor's guess from Shopping mode and industry), lists that site's page types with their formats in the prompt, and limits assetType and the supporting types to them, plus the earned third_party_article and backlink. No calculation changes. Older opportunities keep their stored types and are read as the brand's page types (pillar_guide -> guide / buying_guide, landing_page -> solution_page / collection_page / destination_page, and so on). The opportunities list, the drawer, the assets card and Copy All Data name them with the editor's labels. Start preselects an opportunity's type for a new page; an existing page goes by its own address or title first. The Content Plan follows the same rules. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): open the Content Editor from Content Opportunities From the user's spec, PR B of the Content Editor entry points, with the user's follow-up choices: - Opportunity panel: three buttons in front, in this order: Send to Actions, Generate Brief and Send to Editor. Each turns into its done state in place (Open in Actions, Brief Generated, Open draft). The rest move into a "..." menu on the right: Send to Plan, Another angle, Send to Workflow, Copy All Data, Mark as reviewed, Restore, Dismiss. - Opportunities list: a row's actions sit in one "..." menu: Send to Editor or Open draft, Send to Plan or Open in Plan, Send to Workflow, Open in new tab, Dismiss. The Actions column narrows to fit. - Send to Editor opens New content > Start. A create decision starts a new page; any other decision starts on its first target page (lib/content/opportunity-start.ts). Owned work still open only. getOpportunityDrafts finds the draft already being written. - Send to Plan marks the opportunity's Plan row as a priority (content_plan_marks, #1321) for admins and managers; getPlanPriorities reads which rows already are. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): export an opportunity as CSV, Excel or Word The user asked for an Export button on the opportunity's full page and in the right-hand panel, listing Export CSV, Export Excel and Export Word one under the other. It sits on the actions row, left of the "..." menu. All three formats come from what Copy All Data copies. opportunityToMarkdown now renders a structured write-up (opportunityDocument: sections of fields, items, numbered steps and text), and its Markdown output is unchanged. lib/content/opportunity-export.ts writes that same write-up as: - CSV: section, field and value rows, with a byte order mark; - Excel: one sheet with a bold header (write-excel-file); - Word: a .docx with the title, section headings, bold field labels and lists. Word uses the docx package, added at the user's OK. It is pinned to 9.9.0, a release at least two weeks old, and loaded only on the click. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): read a Plan row's opportunity from its key, and restore only what is still dismissed hidePlanRow and showPlanRow no longer take an opportunity id from the client: the server reads it from the row key the mark is written under (a uuid, or 'invalid'). Show again gives an opportunity back its status only while it is still dismissed; one completed or reopened elsewhere keeps its status and only the mark goes. Hidden rows read only dismissed opportunities. The Priority card's dot is in ink, as its outline badge. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): keep a failed draft read from offering Send to Editor, and tell the list about Send to Plan - A failed getOpportunityDrafts is no "no draft": the row menu and the panel offer "Couldn't check for a draft · Retry" instead of Start, so a failed read never starts a second draft for the same opportunity. - Send to Plan from the panel calls the page's onPrioritized, so the row's menu says Open in Plan without a reload. - Start's page types come from the opportunity's brand, not the active one. - content.send is gone; content.alternative.hint is Another angle's title. - Drop the unused contains mock and fix the content prop's doc. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(content): count Export in front of the panel's draft retry #1334's retry test lists the panel's front buttons; with this PR's Export button there is one more. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): guard archived drafts on insert too, and keep them out of the Action Center - 00233: guard_content_draft_archive runs before insert or update. A member's new draft with archived_at or archived_by set is refused (42501), so archived_by is never the app's word; the server, which bypasses RLS, is unaffected. - readActionDrafts skips archived drafts: the Action Center drawer doesn't list them, and a task's Start writes a new draft instead of reopening one. - Remove aeoScoreText and the list's scoreBefore/scoreAfter, unused since the AEO Score column went. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): pin docx to 9.7.0, which installs on Node 20 [email protected] depends on nanoid@^6, whose engines need Node 22+, so CI's Node 20 web job (and Vercel's install on Node 20) stopped at yarn install. 9.7.0 is the last release on nanoid@^5 (Node ^18 || >=20) and @types/node ^25, and has every API the export uses. The lockfile drops docx 9.9.0's nanoid 6, @types/node 26 and undici-types 8.9; @types/node@^25.2.3 joins the existing 25.7.0 entry. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): wrap multi-line export cells, and use the sheet's header case in the CSV An outline step's points sit on their own lines in one value; the sheet's cell now wraps, so Excel shows them. The CSV's header reads Section,Field,Value like the sheet's. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): let Start write a new draft once its work's draft is archived 00218's content_drafts_action_work_key counted archived drafts too, so a task whose draft was archived could never start again: readActionDrafts skips the archived one, the insert hit the key, and the 23505 retry found no winner. 00233 recreates the key over drafts not archived. Restoring the archived one while a newer draft does the same work is refused (23505), named newer_draft, and the Library says what to do. getOpportunityDrafts (from #1334, now on main) skips archived drafts too. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): put the editor's tags on a second line, and keep the side panel's tabs in sight, Rules first The header's top row keeps the title and the page's actions; the page type, method, status, rules and cited-passages tags move to a line of their own under the title, all of them at any width and lined up (the status badge sat lower in its wrapper). While the side panel is closed, its tabs stay down the editor's right edge and open it on the one picked, so the panel is never out of sight on a window under 1280px, where it starts closed. Rules is the first tab and the panel opens on it; Impact reads when first opened. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): export the page from the Content Editor as Word, HTML or Markdown Export sits beside Copy HTML in the editor's header and downloads the page as Copy HTML gives it. HTML is that page as a titled document. Word and Markdown read it as blocks first (headings, paragraphs, quotes, nested and numbered lists, tables, links, bold and italic): Markdown keeps an HTML block as HTML, Word keeps its text. The schema JSON-LD is markup, so only the HTML file carries it. A page without an H1 opens with its title. On a phone the button is an icon, so the header's one row still fits. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): export the Library as CSV, Excel or Word, by tab and creation date The Library's header gets Export: the drafts listed (the tab, within a new Created range: any time or the last 7, 30 or 90 days, kept in the URL) with their pages. CSV and Excel hold a row per draft: title, status, method, page type, who wrote it, dates, the live page's address, its length and its text (Excel cuts a page past a cell's 32,767 characters). Word puts every draft in one document, each from a page of its own under a line saying where it stands. A row's menu exports one draft as Word, HTML or Markdown, as the editor's Export does. The pages are read for the export only (getContentDraftPages, 100 ids a read). draftDocx's rendering is shared with the Library's document, whose numbered lists each count on their own. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): don't open an archived draft from a tracked prompt getDraftForPrompt (#1333) skips archived drafts, as getOpportunityDrafts does, so Start opens the work in hand, never one sent to the Archive. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]>
Summary
From the user's spec (Content Editor entry points, PR A of 2): a shorter path from a tracked prompt to the Content Editor.
Tracked Prompts row menu (…)
content_drafts.prompt_ids: a draft started from the prompt, its topic or an opportunity. The menu looks this up as it opens, withgetDraftForPrompt.Positions panel › Improve tab
A content step now sits first in the tab.
lib/prompt-content.tsdecides it, on the thresholds the user picked, over the panel's period:citedPageingetPromptPositions, worked out from the source lists the panel already reads. One page counts once per answer, whatever its query orwww(ChatGPT adds?utm_source=…); a tie goes to the newest answer.Start (
NewContentDialog){ kind: 'prompt', id, text, method, page? }.Web only, no migration. One thing to watch: if #1328 (Library archive) merges first,
getDraftForPromptshould also skip archived drafts (.is('archived_at', null)). The column isn't on main yet, so this PR can't filter on it; whichever of the two lands second adds it.Related issue
None. Product spec 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
Locally, every demo prompt mentions the brand in every answer, so I added six temporary answers to one prompt to see both steps. They're deleted.
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 test: 283 files, 2,501 tests pass.yarn buildpasses with CI's placeholders.🤖 Generated with Claude Code