Repository navigation
fix(content): keep agent answers out of headings - #1369
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]>
|
@gkhngyk A Content Agent bug found on prod: accepted suggestions glued answers, and a whole FAQ, into H2s ("Frequently Asked QuestionsWhat is an AEO tracker?…", 797 chars). This is the first of the agent rule-gap fixes.
A review pass before pushing caught:
All three are fixed in be2f890. |
gkhngyk
left a comment
There was a problem hiding this comment.
A few fixes before merge:
-
An answer stays glued into the heading when blocks follow it (
server/src/lib/content-agent.js:227,web/src/lib/content/agent-suggestions.ts:114).- The question/answer split only runs when
!blocks. Two shapes skip it:What is X? X is a platform that tracks brand mentions in AI answers.<ul><li>…</li></ul>giveswords= the question plus its answer (71 characters, under the H2 limit). The list becomes the insert, and the replace puts the answer on the heading's line.<h2>What is X? X is a platform that tracks brand mentions.</h2><p>…</p>does the same, through theownbranch.
- This is the same bug, only with one more block after it. A longer answer instead has the whole suggestion dropped as too long, and the list with it.
- Fix: run the split whenever the passage is a heading, and put the answer first:
blocks = paragraph(answer) + blocks(on the web,`<p>${escapeHtml(answer)}</p>${blocks}`). Add a test for each shape, on both sides.
- The question/answer split only runs when
-
A title with a subtitle gets split too (same lines).
What is AEO? The Complete Guide to Answer Engine Optimization in 2026is a common H1 shape: 69 characters, within the 70 limit.- Its second part is 56 characters, which passes
MIN_ANSWER_CHARS. The H1 becomes "What is AEO?", and "The Complete Guide…" is inserted under it as a paragraph. - Fix: when the whole heading is within its limit, treat the second part as an answer only if it reads as a sentence: it ends in
.,!,。or!. All the existing tests still hold: the prod shapes, the short second clause and the Japanese example all end in sentence punctuation or stay under 40 characters.
-
A full-width
?only matches when a space follows it (same lines).- The pattern is
[??]\s+, but Chinese and Japanese text normally puts no space after?.AEO とは?AEO は…doesn't split. The test only passes because its example has a space. - Fix:
/^(.+?(?:\?(?=\s)|?))\s*(\S.*)$/, and add the no-space case to the test.
- The pattern is
-
Garbled doc comment (
web/src/lib/content/agent-suggestions.ts:162-163): "one that would still leave a heading over grow a heading past its limit".
Checked and fine:
- Sanitizing what goes into the editor.
- The blocks are a slice of
cleanInsertHtml's output, which keeps only the allowed tags, with no attributes. Theownmatch can't cut through a nested block, because the parser never nests h2–h4 or p in themselves. - The answer paragraph is escaped on both sides.
- The editor runs inserts through
cleanHtmland the schema again.
- The blocks are a slice of
- The split pair in the editor.
- After the heading's replace is accepted, the insert still finds the heading through
currentKey. - Accepting the two in either order, or undoing them, works.
blockedReason's'heading'case covers stored suggestions. The card label and the Accept all toast both say it.
- After the heading's replace is accepted, the insert still finds the heading through
- Cap and duplicates. These apply to the pair as a whole, on both sides.
continue/drop('too_many')lets later single suggestions still fit. - MCP.
- The input schema only changes a description, and
heading_too_longadds a new reason without changing the old ones. Existing callers keep working. keptcan now be more than the suggestions sent. The tool description explains why.
- The input schema only changes a description, and
- Paragraph replaces behave as before, apart from the two documented differences.
- Prompts. Both prompts share
HEADING_RULE, and the tests assert it.
…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]>
|
@gkhngyk Fixed in 2895107 (server and web the same, tested on both sides):
Note: a 40+ character answer is about 15 words in English but a long sentence in Japanese. A shorter CJK answer that fits the limit stays in the heading. Say if you want a lower bar for CJK. |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good. All four earlier items are done in 2895107a, the same on both sides (server/src/lib/content-agent.js:182-184, :232-246; web/src/lib/content/agent-suggestions.ts:80-82, :119-133). I ran these shapes through both splitReplaces, and each gave the same result on the server and the web:
- Answer glued in when blocks follow. The split now runs whenever the passage is a heading, and the answer goes first.
What is X? X is a platform….<ul>…</ul>gives the heading "What is X?" and the insert<p>X is a platform….</p><ul>…</ul>.<h2>What is X? X is….</h2><p>…</p>gives the same, through theownbranch.- End to end,
keepSuggestionsandkeepAgentSuggestionskeep that case as one insert (the words don't change), with the answer before the list.
- Title with a subtitle.
What is AEO? The Complete Guide to Answer Engine Optimization in 2026(69 characters) stays whole as an H1. Past the limit, the rest goes under the heading, as the PR describes. - Full-width
?.AEO とは?AEO は…now splits with no space after the?, as it does with one.What?No…doesn't split. A?followed by a non-breaking space splits, the same on both sides. On inputs of 60,000–100,000 characters (no?, many?, many?without a space, many?) each side takes 4–30 ms, so the regex has no slow case. - Doc comment.
agent-suggestions.ts:171-173reads correctly now.
Optional: an answer that ends in a quote or a bracket after its full stop isn't treated as a sentence. What does AEO stand for? AEO stands for "Answer Engine Optimization." (69 characters) stays whole in an H2. If you want those split too, use /[.!。!]["'”’)\]」』]*$/ for ANSWER_END on both sides.
On the CJK bar: keep 40 for now. The heading rule in the prompts is the main guard, and this split is only the safety net.
Merge notes
- It merges cleanly on current main (
5b679380), with no conflicts. It merges cleanly with #1370 too. - It contains no other open PR and adds no migration.
…e draft's sources (#1371) * fix(content): keep agent answers out of headings 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]> * fix(content): keep one H1 per page 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]> * fix(content): split a heading's answer off whatever follows it, and only a real answer Review fixes for #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]> * fix(content): pick an import's title H1 once, keep one H1 in New content, count HTML blocks' Review fixes for #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]> * feat(content): let the Content Agent link to the brand's pages and the 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]> * test(content): read splitReplace's links beside the heading split's results 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]>
… the draft's sources (#1372) * fix(content): keep agent answers out of headings 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]> * fix(content): keep one H1 per page 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]> * fix(content): split a heading's answer off whatever follows it, and only a real answer Review fixes for #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]> * fix(content): pick an import's title H1 once, keep one H1 in New content, count HTML blocks' Review fixes for #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]> * feat(content): let the Content Agent link to the brand's pages and the 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]> * test(content): read splitReplace's links beside the heading split's results Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): let agents link over the API, to the brand's pages and 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]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]>
…1374) * fix(content): keep agent answers out of headings 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]> * fix(content): keep one H1 per page 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]> * fix(content): split a heading's answer off whatever follows it, and only a real answer Review fixes for #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]> * fix(content): pick an import's title H1 once, keep one H1 in New content, count HTML blocks' Review fixes for #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]> * feat(content): let the Content Agent link to the brand's pages and the 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]> * test(content): read splitReplace's links beside the heading split's results Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): let agents link over the API, to the brand's pages and 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]> * feat(content): start a page brought in with the prompts it answers 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]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]>
…1383) * fix(content): keep agent answers out of headings 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]> * fix(content): keep one H1 per page 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]> * fix(content): split a heading's answer off whatever follows it, and only a real answer Review fixes for #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]> * fix(content): pick an import's title H1 once, keep one H1 in New content, count HTML blocks' Review fixes for #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]> * feat(content): let the Content Agent link to the brand's pages and the 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]> * test(content): read splitReplace's links beside the heading split's results Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): let agents link over the API, to the brand's pages and 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]> * feat(content): start a page brought in with the prompts it answers 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]> * feat(content): aim an optimized page's Length rule at its own length A page brought in to optimize (pasted, imported from its URL or a file, read by Start or by an Action Center task) stores its text length as rules.importLength. Its Length rule aims there (±20%), not at a new page's target for the type, and the Content Agent gets the same aim. My rules still apply to such a draft, but not their Length value; Save as my rules keeps the workspace's value, and the person's own value wins. 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]>
…th can't fit the rules (#1384) * fix(content): keep agent answers out of headings 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]> * fix(content): keep one H1 per page 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]> * fix(content): split a heading's answer off whatever follows it, and only a real answer Review fixes for #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]> * fix(content): pick an import's title H1 once, keep one H1 in New content, count HTML blocks' Review fixes for #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]> * feat(content): let the Content Agent link to the brand's pages and the 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]> * test(content): read splitReplace's links beside the heading split's results Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): let agents link over the API, to the brand's pages and 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]> * feat(content): start a page brought in with the prompts it answers 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]> * feat(content): aim an optimized page's Length rule at its own length A page brought in to optimize (pasted, imported from its URL or a file, read by Start or by an Action Center task) stores its text length as rules.importLength. Its Length rule aims there (±20%), not at a new page's target for the type, and the Content Agent gets the same aim. My rules still apply to such a draft, but not their Length value; Save as my rules keeps the workspace's value, and the person's own value wins. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): say when an agent run stops at its most, and when Length can't fit the rules A run of Apply rules with Agent leaves at most 8 changes (the API's cap, mirrored as AGENT_RUN_MAX). A full batch now says so in its toast and, once decided with rules still open, in the agent bar: run it again for the rest. The Rules tab warns under Length when the fan-out H2s, FAQ questions and summary the rules still ask for take more text, at their least, than Length allows (+20%), so the person can raise Length or ask for fewer. 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]>
* fix(content): keep agent answers out of headings
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]>
* fix(content): keep one H1 per page
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]>
* fix(content): split a heading's answer off whatever follows it, and only a real answer
Review fixes for #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]>
* fix(content): pick an import's title H1 once, keep one H1 in New content, count HTML blocks'
Review fixes for #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]>
* feat(content): let the Content Agent link to the brand's pages and the 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]>
* test(content): read splitReplace's links beside the heading split's results
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* feat(content): let agents link over the API, to the brand's pages and 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]>
* feat(content): tell the Content Agent which fan-outs to use
The fan-out rules stayed open after a run: the agent was told only "now: 3
of 4", wrote H2s and FAQ questions of its own, and the check didn't count
them. A fan-out rule's status now names what's missing (fanoutH2: the top
fan-outs no H2 carries; fanoutFaq: the most searched ones no FAQ question
uses, or the top ones while there's no FAQ), and both Apply rules with
Agent and Start Agent send them in the rule's detail, quoted, within the
room the server allows. Both prompts share FANOUT_RULE: an H2 or a FAQ
question per named fan-out, in its words, and a change is called a fan-out
answer only when it uses one listed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fix(content): keep FAQ fan-outs to one question per heading
The Content Agent appended a fan-out's question to an existing FAQ
question heading ("What is AEO? What is an AEO tracker?"), which the
editor's heading guard then refused. The fan-out rule now says to insert
a new question with its answer after an existing answer, or reword a
question only when its answer still answers it. A heading replace that
makes a heading ask more than one question is dropped, on the server and
over the API (heading_two_questions), and a second question is no longer
moved under the heading as its answer.
Review fixes: the new-page prompt names the fan-out rule too, and
fanoutFaq counts the different fan-outs its questions use, asking for no
more than there are, so it never stays open with nothing to name.
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
Content Agent suggestions no longer glue an answer, or a whole FAQ, into a heading.
On prod, the user accepted the agent's suggestions on a page imported for Optimize, and its H2s turned into:
That also broke the FAQ block, h2Answer and fan-out FAQ checks. The cause: a replace's
afterwas flattened to text (textOf). So when the model wrote a heading and its answer as one replace, they became a single heading line.Fix: one rule in both places that keep suggestions. Those are
server/src/lib/content-agent.jskeepSuggestions(Apply rules with Agent, and Start Agent on an existing page) andweb/src/lib/content/agent-suggestions.tskeepAgentSuggestions(MCPsuggest_content_changes).splitReplace(after, tag)cleans the HTML and splits it in two:?or?) keeps the question, and the answer becomes a<p>under it. "Is AEO worth it? Here's what the data says." stays as it is.too_many/duplicateas before.heading_too_longreason;HEADING_LIMITSlives inweb/src/lib/content/suggestions.tsandserver/src/lib/content-agent.js, which point at each other.HEADING_RULE: a heading stays one line; never write an answer, a sentence or a FAQ into a heading's replace; insert a paragraph after it. The schema and MCP descriptions say the same.blockedReasonreturns'heading'when accepting a replace would grow a heading past its limit. That covers older suggestions already stored. The card says "This would put more than a heading into the heading…", and Accept all's toast names it.Pages already broken by this aren't repaired automatically. Their accepted suggestions can be undone, or the headings edited.
Paragraph replaces keep working as before, with two differences:
<p>…</p><ul>…</ul>) now become an insert after the paragraph instead of being flattened into it;Related issue
Content Agent rule gaps, item D, 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
Checked locally on a temporary demo draft, since deleted:
<h2>Frequently Asked Questions</h2><h3>What is an AEO tracker?</h3><p>…</p>;Tests:
content-agent.test.js: the real prod shapes, the 70/71 and 90/91 edges, shortening, the cap, short second clauses,?, nbsp, and the prompt rule;content-writer.test.js: Start Agent's prompt;agent-suggestions.test.ts: the same shapes, plusheading_too_longandtoo_many;suggestions.test.ts: the limits;page.test.tsx: blocked vs accepted.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(314 files, 2,772 tests) andyarn build;npm run format,npm run lintandnpm test(172 files, 2,052 tests).🤖 Generated with Claude Code