Repository navigation
feat(content): start a page brought in with the prompts it answers - #1374
Conversation
A replace on a heading that carried its answer ("What is X? X is …") or a
whole FAQ was flattened into the heading's line. Content Agent and the
editor API now split such a replace: the heading keeps its words and the
answer or blocks become an insert after it, kept together or not at all.
An agent change may not grow an H1 past 70 characters or another heading
past 90 (a long imported heading may still be shortened); both agent
prompts and the MCP description say a heading stays one line, and the
editor won't accept an older suggestion that would glue text into one.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A page's H1 is its title. The editor now makes a second H1 an H2 however it comes (typed, pasted, the HTML view, Add HTML or an agent suggestion), keeping the page's own; Heading 1 is off while the page has one, and says why on hover. A version restored from History and older drafts keep theirs, and a new always-on "One H1 per page" rule flags them. The Content Agent is never asked to fix it (it doesn't change heading levels) and its inserted H1s become H2s. URL import keeps the H1 nearest the article's text, not a logo's or a site name's, and makes the rest H2s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
…nly a real answer Review fixes for ansvisor#1369 (gkhngyk): - the question/answer split runs whenever the passage is a heading, also when blocks follow, and the answer goes first under it (inline answer plus a list, or <h2>Q? A.</h2><p>…); - a heading that fits keeps a subtitle: only an answer that ends a sentence (. ! 。 !) is split off; past the limit the rest always goes; - "?" ends a question only before a space; a full-width "?" with or without one; - the regex has no catastrophic case on long text, and the garbled doc comment in agent-suggestions.ts reads again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ent, count HTML blocks' Review fixes for ansvisor#1370 (gkhngyk): - URL import picks the title's H1 once, before the frame and the root go: the last H1 with words before the text's first paragraph (a byline, date or breadcrumb line doesn't count as one), else the first; the title comes from it, and the root's other H1s become H2s; - New content keeps one H1 in a pasted page, a file or an imported page (oneH1Html in bring(): the first H1 with words stays, others are H2s, empty ones unwrapped); - "One H1 per page" counts H1s with words inside HTML blocks too; - an empty H1 line never counts as the page's H1 in the editor, so it never stays over one with words, and Heading 1 stays on beside it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e draft's sources The agent could never meet the Internal links, Outbound links or Cite sources inline rules: a replace's new words were plain text, inserts took no <a>, and it had nowhere to link to. When one of those rules is asked for, it now gets the brand's own pages (site_pages, the most cited and visited first) and the draft's sources (cited pages, not the brand's or a competitor's, not left out), and may link only to those URLs: any other link is unwrapped, tracking parameters come off. A replace keeps its links beside its words (after_links, 00240); an insert keeps them in its HTML. The editor puts them on as link marks when a suggestion is accepted, takes them off on undo, and shows on the card where each one goes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # server/src/lib/content-agent.js
…esults Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the draft's sources The editor API's suggest_content_changes took no links, so an agent working through MCP could not meet the link rules either. get_content_draft now lists link_targets (the brand's own pages, and the draft's sources without the brand's or a competitor's), and suggest_content_changes keeps a link only to one of those URLs, as the Content Agent does on the server: a replace's links go in after_links, an insert's stay in its HTML, any other link is unwrapped and a link with no words dropped. The targets are read only when a suggestion links. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An Optimize draft pasted, read from its URL or a file started with no prompts, so it had no fan-outs unless AI answers cited that very page, and the fan-out rules read "No fan-outs". It now starts with up to ten of the brand's active prompts its title and headings speak to (60% of a prompt's words and at least two, the most in common first), which the person can leave out in Sources. A draft with no prompts shows "Add prompts" on those rules, opening the Sources tab. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk Content Agent rule gaps E (stacked on #1372, a sibling of #1373): an Optimize page brought in by paste, URL or file now starts with up to 10 of the brand's prompts its headings match, so it has fan-outs; a draft with no prompts gets an Add prompts link to Sources. A review pass before pushing narrowed that link to drafts with no prompts (not ones whose engines ran no searches), and ranked matches by words in common. Two possible follow-ups it noted: Action Center's Optimize page and MCP createContentDraftFor could match prompts the same way. |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good.
Checked:
- The prompts read (
web/src/lib/actions/content-drafts.ts:508-524).- It uses the member's own client, after
getUser, and goes through the prompts RLS. It is filtered toprompt_sets.brand_id = brandIdand active prompts, with at most 1,000 rows. That is the same shape as the topic and prompt sources next to it. - A failed read logs the error and starts the draft with no prompts, as before. The overlap check passes no page, so it reads nothing.
- It uses the member's own client, after
- Matching (
web/src/lib/content/page-prompts.ts). It reads only the title and H1–H3 headings of the sanitized body.wordsOfdrops stop words and short words, so the 2-word / 60% floor holds, and more words in common rank first. The cap of 10 is far underMAX_DRAFT_PROMPTS. - Add prompts.
- It shows only once the sources are read without failing and the draft has no prompts at all. A draft whose prompts ran no searches keeps "No fan-outs".
- Sources' Add source dialog does add a prompt, so the hint leads somewhere.
- Both strings are in
en.json, and the button usestext-primary.
- Cost. There is no LLM call. An imported page now brings up to 10 prompts and their fan-outs into the agent's request, which is small.
- Tests. Matching, the cap, headings only, the insert's
prompt_ids, and Add prompts opening Sources.
gkhngyk
left a comment
There was a problem hiding this comment.
Re-approving after merging main into the branch. The merge only brings in the squashed parent PR; the tree matches the one tested (web and server tests, typecheck, lint, format).
Summary
A page brought in to optimize now starts with the brand's prompts it answers, so it has fan-outs, and a page without them points to where they come from.
On prod, an Optimize draft imported from a URL showed "No fan-outs" for both fan-out rules, so they silently dropped out (11 rules instead of 13).
prompt_ids: [].content_draft_sourcesRPC reads them from the draft's prompts, plus prompts whose answers cited that very page in the last 30 days. Most imported pages had neither.Matching (
web/src/lib/content/page-prompts.ts, new)matchPagePrompts(title, html, prompts)reads the title and H1–H3 headings (server-side, with a regex: the action has no DOMParser) aswordsOfwords.createContentDraftdoes this for acontentsource: it reads the brand's newest 1,000 active prompts and matches them against the sanitized body.Rules tab. A fan-out rule shows Add prompts instead of "No fan-outs" only when the sources were read and the draft has no prompts at all. A draft whose prompts' answers ran no searches (e.g. AI Overviews, Gemini) keeps "No fan-outs". It is a button that opens the Sources tab, and its hover hint says the fan-outs come from the page's prompts.
No migration.
Related issue
Content Agent rule gaps, item E (folded into B), found by testing on prod on 2026-10-22. No issue.
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
Tests:
page-prompts.test.ts: the match, a single shared word, the cap, and headings only;content-drafts-start.test.ts: an imported page starts with its matched prompts;page.test.tsx: Add prompts opens Sources.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/) (0 errors; the 6 warnings are in untouched files, as on main)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run:
yarn test(2,860 tests) andyarn build.🤖 Generated with Claude Code