Repository navigation
fix(content): keep one H1 per page - #1370
Conversation
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]>
|
@gkhngyk The user asked that a page never have two H1s.
A review pass before pushing caught:
All four are fixed in adae479. |
gkhngyk
left a comment
There was a problem hiding this comment.
A few fixes before merge:
-
URL import can still pick the wrong H1, and the draft's name is still the site name (
server/src/lib/page-content.js:283,:266-268,:401-417). There are three problems:titleH1takes the first H1 inside the text area before the one just ahead of it. Take a theme that puts the title next to the content block and uses H1s for sections inside it:<article><h1>Pipeline forecasting</h1><div class="entry-meta">…</div><div class="entry-content"><p>…</p><h1>Why it matters</h1>…. This head turns the title into an H2 and makes "Why it matters" the page's H1. Main kept all of them as H1s, so the title at least stayed one.headingis stillbody.find('h1').first(). When a logo or site-name H1 comes first, the root still widens to include that block. With the PR's own logo fixture, the logo's<a><img></a>stays above the title. With the site-branding fixture,<h2>Acme</h2>stays above it.titleis still the page's first H1, and Optimize › URL names the draft with it. On the site-branding fixture the draft is still called "Acme", even though its H1 is "Pipeline forecasting".
Fix: pick the title H1 once, before the root is worked out. Take the last H1 with words that comes before the text area's first paragraph (the first
p, li, pre, blockquotethere of at leastMIN_PARAGRAPH). If there is none, take the first H1 with words. Then:- use that H1 as
heading, for the root andkept; - skip it in the H1 pass;
- set
titlefrom its text when it is in the root.
I tried this against this head's
page-content.test.jsand all 13 tests pass. In all three layouts above, the article's title comes out as the only H1 and as the draft's title, and the logo and site-name block drop out of the content. Please add the entry-title layout as a test. -
New content's paste and file import keep every H1 (
web/src/components/content/new-content-dialog.tsx:358,bring). The body is stored as it was cleaned. The editor then loads it with no transaction, soOneH1never runs on it. A Docs or Word paste that uses Heading 1 for its sections opens with "One H1 per page · N found", and Apply rules with Agent only says to fix each one by hand. The same paste inside the editor is fixed automatically. Fix: add one shared pass that keeps the first H1 with words, makes the others H2s and unwraps H1s without words. Apply it inbring(), so paste, file and URL all go through it. -
Low: H1s in HTML blocks are neither rewritten nor flagged. The description lists Add HTML as covered, and says the rule flags raw HTML blocks. It does neither: an HTML block keeps its code encoded in
data-html-block, so neitherOneH1norreadPage(web/src/lib/content/rules.ts:442,:728) sees an<h1>inside it. Copy HTML and export then publish that<h1>as a second H1. Either count H1s in the decoded block code in theoneH1check (decodeHtmlBlock, then counth1), or correct the description. -
Low: an empty H1 wins over a worded one (
_one-h1.ts:45-54). Say the person cleared the title to retype it and then pasted an article with its H1 below.samematches the empty text, so the empty H1 stays and the pasted title becomes an H2. Heading 1 is then off in the toolbar, because the page "has" an H1. Fix:- in the
beforeloop, skip H1s without words; - fall back to the first H1 with words (
after.find((at) => newState.doc.nodeAt(at)!.textContent.trim()) ?? after[0]); - count only H1s with words in the toolbar's
h1Taken.
- in the
Checked and fine:
- The extension always terminates. At least one H1 is demoted each round, and the next round returns null.
- Undo works as described. The appended demotion joins the paste's history event, so one Undo removes both.
- Older drafts aren't touched on load. Loading one runs no transaction, so it isn't marked dirty or autosaved.
- History restore keeps the version as it was.
ONE_H1_AS_IScovers the onesetContentthat needs it. - Locked passages aren't affected. The
CitedPassageslock keys on text, so a demotion never trips it. - The toolbar's Heading 1 can't be used while it is off. The click is dropped, and Mod-Alt-1 and
#give an H2 through the extension. - The agent never gets
oneH1.NOT_FOR_AGENTcovers both Apply rules with Agent and Start Agent. - The new always-on rule shows up nowhere else. Nothing else lists or saves rules, and the met count isn't stored.
- The two
cleanInsertHtmlchanges agree. They give the same output, and #1369'ssplitReplacestill takes an H1 replace's words from the H2 it now becomes.
Merge state: this branch merges cleanly on main and with #1369. After #1366 lands it needs main merged in: there is one conflict in _draft-editor.tsx, the rules import line, and the fix is trivial (import { aiTracesFound, lengthWarns, openRulesForAgent } from '@/lib/content/rules';). The toolbar, rules.ts and the tests merge on their own.
# Conflicts: # web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
…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]>
|
@gkhngyk Fixed in 5a58eac, on top of a main merge (09a03f3, the rules import conflict resolved as you wrote):
|
gkhngyk
left a comment
There was a problem hiding this comment.
Approving, with two small follow-ups below. They only show on uncommon layouts, so a separate PR is fine, since #1371 and the rest of the stack depend on this one. The four earlier items are done in 5a58eac3:
- URL import's title H1. I ran the three layouts from the last review against
page-content.jsat this head:- Entry title next to an entry-content with a section H1. "Pipeline forecasting" is the only H1 and the draft's title, and "Why it matters" is an H2.
- A logo H1 first. The logo's link and image drop out. The article's H1 is the only H1, and it is now the draft's title (the title was empty before).
- A site-name H1 first. The article's H1 is the only H1 and the draft's title, not "Acme". In the PR's fixture the site name sits inside
<main>, which is the root, so it stays in the content as an H2. Without<main>it drops out. - A title in the article's own
<header>comes back as the H1, and all 16 tests pass.
- New content.
bring()runsoneH1Htmlon the cleaned HTML from all three paths, paste, file and URL (new-content-dialog.tsx:365). - HTML blocks.
readPagecounts the H1s with words inside HTML blocks (rules.ts:464,:745), and the PR body now says they are flagged, not rewritten. - Empty H1s.
h1Positionscounts only H1s with words (_one-h1.ts:24). An empty H1 never wins over a worded one, andh1Takenignores it. The side effect you describe, where a#line is an H1 until its first keystroke, is fine as it is.
Follow-ups:
-
A plain dated line above the title still counts as the text's first paragraph (
server/src/lib/page-content.js:293-304).- The comment and the PR body say a byline or date line doesn't count. In fact only blocks with furniture names (
meta,byline,breadcrumb) are skipped. - Take
<div class="site-branding"><h1>Acme</h1></div><article><p class="date">Published on October 22, 2026 by Ada Lovelace</p><h1>Pipeline forecasting</h1><p>…. The content now starts with<h1>Acme</h1>, then the date line, then<h2>Pipeline forecasting</h2>, and the draft is called "Acme". Main kept the article's H1 as an H1 there. - Fix: skip byline lines too, as
judgedoes:.find((el) => { const text = clean($(el).text()); return ( text.length >= MIN_PARAGRAPH && !(text.length <= MAX_BYLINE && BYLINE.test(text)) && ![el, ...$(el).parentsUntil(textArea).toArray()].some((block) => named($(block), PAGE_FURNITURE_WORDS), ) ); })
- The comment and the PR body say a byline or date line doesn't count. In fact only blocks with furniture names (
-
On a page with no paragraphs to go by, the site header's H1 takes over (
page-content.js:305-306).wordedis collected before the frame is removed. With nolead, the fallbackworded[0]can be an H1 in the site's<header>.- Take
<header class="site"><h1>Acme</h1></header><main><h1>Pricing</h1><div>Starter</div><div>Pro</div></main>. "Pricing" becomes an H2, the content is headed with<h1>Acme</h1>, and the draft is called "Acme". Main kept "Pricing" as the H1. - Fix: in the fallback, take the first H1 with words that is still on the page before one the frame took:
const titleH1 = (lead && worded.filter((el) => order.get(el) < order.get(lead)).at(-1)) || worded.find((el) => $(el).closest('body').length > 0) || worded[0] || null;
- I tried both fixes on a copy. All 16 tests still pass, and every layout above, plus these two, comes out with the page's own H1 as the only H1 and as the draft's title. Please add both pages as tests.
Known limit, no change needed now: when the text opens with a section H1 before its first paragraph (<article><h1>Title</h1><div class="entry-content"><h1>Why it matters</h1><p>…), that section H1 is picked as the title. It only happens on pages that use H1s for sections and open with one.
Merge notes
09a03f3ahas no hidden changes. Re-merging its parents gives the same tree, apart from the_draft-editor.tsxconflict. That is resolved asimport { aiTracesFound, lengthWarns, openRulesForAgent } from '@/lib/content/rules';, and both new names are used. The toolbar,rules.ts, its tests anden.jsonmerged on their own.- It merges cleanly on current main (
5b679380) and with #1369. 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
A Content Editor page now has at most one H1, its title. The user asked for this on 2026-10-22: "every article can have at most one H1, never two".
Editor
_one-h1.ts(OneH1). When a change raises the page's H1 count above one, the new H1s become H2s and the H1 the page had stays. It matches that H1 by its words first, then by where it moved. This covers typing, paste, the HTML view, Add HTML and accepted agent suggestions.ONE_H1_AS_ISmeta), since the page on the server is that version.aria-disabledrather thandisabled, so the reason still shows on hover: "A page has one H1, its title: use Heading 2 here".Rules
oneH1, structure group,check: 'page'). It reads "2 found" when a page has more than one H1.fixedinRuleDef, so it has no switch, and a draft's or a saved set'son: falsedoesn't turn it off. The editor enforces it anyway.NOT_FOR_AGENTkeeps it out of what the Content Agent is asked, in both Apply rules with Agent (openRulesForAgent) and Start Agent (agent-write.ts). The agent changes words and adds blocks, never a heading's level. When it is the only open rule, Apply says to make the extra H1s H2s in the toolbar.Agent and import
cleanInsertHtmlturns an H1 into an H2, in the server'scontent-agent.jsand the web'sagent-suggestions.ts(MCP). Before, the tag was unwrapped and the H1's words were left as loose text.page-content.js):<header>(removed with the frame) gets it back as the H1.oneH1Htmlkeeps the first H1 with words, makes the rest H2s and unwraps empty ones.HTML blocks: H1s inside raw HTML blocks (
data-html-block) aren't rewritten, but "One H1 per page" counts them. Bodies written through the API aren't rewritten either; the rule flags them in the editor.Review fixes (5a58eac):
Merged main in 09a03f3; the rules import in
_draft-editor.tsxis nowaiTracesFound, lengthWarns, openRulesForAgent.Related issue
User request on 2026-10-22, raised with Content Agent gap D (#1369). 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
<h1>. It arrives as an H2, and Undo removes the paste in one step.Checked locally on the demo brand with two temporary drafts, since deleted:
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,775 tests) andyarn build;npm run format,npm run lintandnpm test(172 files, 2,049 tests).🤖 Generated with Claude Code