Skip to content

feat(content): list the sources a draft draws on in the editor's Sources tab - #1292

Merged
gkhngyk merged 89 commits into
ansvisor:mainfrom
cihan-gyk:feature/content-sources
Oct 21, 2026
Merged

gkhngyk merged 89 commits into
ansvisor:mainfrom
cihan-gyk:feature/content-sources

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Content Editor PR 8a: the editor's Sources tab (CE-008, spec v2 §10). It lists every source the draft draws on by name, with its numbers and where the draft uses it as written now. A person can uncheck a source to leave it out, or add a prompt, a page or a Search Console query.

Stacked on #1291 → #1290 → … → #1256. Please merge them in order. This PR's own change is aa92b21.

Apply 00211 before the web. Without it the Sources tab says it couldn't load. Impact is unaffected.

Sources tab (_sources-tab.tsx, second tab of the side panel)

  • Summary: "Built from N sources · N prompts · N fan-outs · N cited pages · N Search Console queries". It counts the checked sources.

  • Groups, one row per source. Each row has a checkbox, the full name or URL (up to two lines), a detail, and a "used in" tag:

    • Prompts: the draft's prompts (prompt_ids), plus, for a draft that optimizes a live page, the prompts whose answers cited that page ("cites this page"). Detail: answers in the window and the answers that name the brand.
    • Fan-outs: the searches AI engines ran for those prompts (prompt_results.search_queries), one row per normalized query. Detail: platforms and how many answers ran it (top 30).
    • Cited pages (what AI quotes today): the pages those answers cited (top 20, ChatGPT Shopping left out). Detail: citations and the kind of site, from the existing classifyDomain (yours, competitor, forum, publication, review site, institution…).
    • Search Console: Search Console keeps no queries per page. So, like page-prompt-suggestions.js, these are the brand's 28-day queries that share at least half their words with the draft's title, prompts and page path (top 10). Detail: clicks and impressions.
  • "Used in" is computed live from the editor's HTML, so it follows the page as it's written:

    • A prompt, fan-out or query counts as used in the first heading (H1, H2 · …), then the first paragraph, that carries three quarters of its words.
    • A cited page is Outbound link / Internal link where the draft links to it, or This page.
    • Anything else is Not used.
  • Unchecking saves the choice and fades the row. The brief rebuild (8b) and the agent will leave unchecked sources out.

  • + Add source, with three tabs:

    • Prompt: one of the brand's prompts. It joins the draft's prompt_ids, so its fan-outs and cited pages follow, and check_content_draft_links (00206) still applies.
    • Page URL: any http(s) address.
    • Search Console query: one of the brand's 28-day queries.

    Added pages and queries are marked "added by you".

  • Panel: Sources loads only when its tab is first picked, and a tab stays mounted once opened, so switching back keeps Impact as it was.

Migration 00211_content_draft_sources.sql

  • Function content_draft_sources(p_draft_id, p_days = 30) returns jsonb → {prompts, fanouts, citedPages, gscQueries, brandDomains, competitorDomains}.
    • Security definer with the organization check through the draft's brand, so an outsider gets null. citation_urls has no member select policy.
    • p_days must be between 1 and 90.
  • Table content_draft_sources(draft_id, kind, ref, included, added, …), primary key (draft_id, kind, ref).
    • kind is one of prompt, fanout, cited_page or gsc_query.
    • Only pages and queries can be added, because a prompt joins prompt_ids.
    • RLS for select, insert, update and delete through content_drafts (the member can read the draft); rows cascade with the draft.
  • Checked on the dev DB in a rolled-back transaction:
    • as a member: the page's citing prompt joins the draft's prompt, and fan-outs, cited pages, GSC queries and competitor domains come back;
    • choices can be inserted and updated;
    • an added prompt is refused (check);
    • an outsider sees no rows, can't insert, and gets null.
  • Applied on the dev DB; schema.sql rebuilt.

Left out, on purpose:

  • Mentions group: there's no data on web pages that mention the brand. Mentions exist only as AI answers, which carry no URL.
  • Product feed: the ECOM work.
  • Your files: needs workspace file storage (CHAT-06), along with the attachment's "Use as source".
  • "Rebuild with selection": comes with the Brief tab in PR 8b.

Related issue

Content Editor CE-008 (Sources tab), spec v2 §10. Stacked on #1291 → … → #1256.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

Apply 00204–00211. Use a draft with prompts, or one that optimizes a live page that AI answers cite.

  1. Editor → side panel → Sources. Check:
    • the summary;
    • Prompts, Fan-outs, Cited pages and Search Console with their details;
    • a "used in" tag on each row.
  2. Type a fan-out's words as a heading. Its tag turns from Not used to H2 · ….
  3. Link to a cited page. Its tag reads Outbound link; the draft's own page reads This page.
  4. Uncheck a source. The row fades, the summary count drops, and after a reload it stays unchecked.
  5. + Add source:
    • add a prompt: it's listed with its fan-outs and cited pages;
    • add a Page URL or a Search Console query: it's listed as "added by you".

Checked locally with temporary data on the demo brand: an optimize draft with a prompt, a cited own page, a Reddit link in the body, and Search Console queries. The data is deleted. Unchecking, adding a query and adding a prompt were checked against the dev DB. Checked in light and dark, and at 1024px.

Tests:

  • sources.test.ts: words and page keys, related queries (page host ignored), groups with choices and added sources, usedIn (heading, paragraph, outbound/internal link, this page).
  • content-drafts-sources.test.ts: getDraftSources, setDraftSourceIncluded, addDraftSource (prompt joins prompt_ids, page and query added, bad input refused).
  • _sources-tab.test.tsx: rows and details, live "used in", uncheck with failure rollback, unchecked choice, add a page, retry, empty.
  • page.test.tsx: Sources loads only when picked; Impact stays as it was.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/) (0 errors; the 6 warnings are in untouched files, as on main)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Web: yarn test (2,147 tests) and yarn build pass. One local full run had 5 failures in the editor page test that didn't reproduce in three more full runs or six parallel runs of the file. I'll look into it if CI shows it. No server change. bash supabase/build-schema.sh was run.

🤖 Generated with Claude Code

cihan-gyk and others added 27 commits October 20, 2026 17:09
Content Editor CE-001 and CE-002. Content becomes a group in the sidebar,
like Prompts: Opportunities keeps /dashboard/content, and the new Library
(/dashboard/content/library) lists every page a person or the Content Agent
writes or changes in Ansvisor, by status (Drafts, In review, Ready,
Published), with its page type, method, author and AEO score.

- Migration 00203: content_drafts with member RLS (select, insert, update;
  no delete yet). A guard trigger keeps author, created_by, brand and the
  scores server-side, so a member can't pass a draft off as the agent's.
- Sidebar: each submenu remembers its own open state (Prompts keeps its
  key), and only the longest matching entry is current, so Opportunities
  isn't marked on the Library.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Content Editor CE-004, stacked on the Library (ansvisor#1256). A draft opens at
/dashboard/content/editor/{id}: a header with its title, page type,
method and status, whether it's saved, and Mark ready; the toolbar (H1 H2
H3, bold, italic, link, lists, quote, table with add row / add column /
delete, image by address) with the length counter against the page
type's target; and the page as rich text (TipTap 3.31.4, pinned).

- Autosave after a pause in typing; saves never overlap, a failed one
  keeps the text and offers Retry, and leaving with unsaved text asks.
  The draft's title is its first H1.
- saveContentDraft validates the body (500k chars) and title and says
  when RLS matched no row; markContentDraftReady moves draft or in review
  to ready only.
- Links: http(s), mailto or a path on the brand's site; javascript:,
  //host and /\host are refused, in the dialog and when content loads.
- The Library gets New content (a blank draft, until the Start screen),
  and its entry stays current while a draft is open in the editor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Content Editor CE-005 and CE-020, stacked on the editor core (ansvisor#1258).

- Paste: from Word, Google Docs, Notion or a web page, headings (H4-H6
  as H3), paragraphs, bold, italic, lists, links, tables and quotes stay;
  fonts, colors, classes, inline styles, scripts, iframes and utm_*,
  gclid, fbclid on links go. Google Docs' styled bold and italic become
  strong and em first. Pasted images wait for attachments. Cmd/Ctrl +
  Shift + V pastes plain text.
- </> HTML shows the page's HTML as a draft stores it, one block per
  line; Back to visual cleans it with the same allow-list and says how
  many unsafe tags it removed. Schema JSON-LD is kept: a block in the
  editor, written again from its JSON so it can't carry markup.
- The server checks every save against the allow-list again
  (sanitize-html), so a request made without the editor can't store a
  script, a handler or a javascript: link.
- dompurify 3.4.16 and sanitize-html 2.18.0, pinned.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
sanitize-html 2.18.0 needs Node 22.12 or later, and CI and the web
Docker image run Node 20, so yarn install refused it. 2.17.0 has no
engine limit and the same API; @types/sanitize-html 2.16.0 matches it
(both on htmlparser2 8).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Links in a draft looked like the text around them (dark, barely
underlined), so a link just added seemed not to be there. They're blue
and underlined now. With the cursor in a link, the toolbar shows its
address, which opens it in a new tab; Cmd/Ctrl + click on it in the page
does too. A click alone still puts the cursor in it to edit. A path on
the brand's own site is shown, not opened: it has no address here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-html

# Conflicts:
#	web/messages/en.json
#	web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
#	web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_toolbar.tsx
#	web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
On the user's request, as Webflow's custom code in rich text: as many
HTML blocks as a page needs, each carrying code as written (an embed, a
widget, a form), and one-click Copy HTML for a block or the whole page.

- An HTML block is added from the toolbar where the cursor is, and edited
  or removed from its own Edit. The editor shows its code as text; it
  never runs in Ansvisor. A draft stores it as UTF-8 base64 in an empty
  element, so no markup in it can act, and the server checks each one
  decodes and fits 50,000 characters.
- Copy HTML (header) puts the page on the clipboard as HTML to publish:
  each block as its own code, schema JSON-LD as its script. A block's
  own Copy HTML copies just its code. A refused Clipboard API falls back
  to the browser's copy command.
- The HTML view shows each block between <!-- html-block --> markers,
  kept as written; code typed between new markers becomes a block. A
  paste from elsewhere can't bring blocks in.
- The link, image and block dialogs focus their field when they open.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…locks

# Conflicts:
#	web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_toolbar.tsx
#	web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
Inserting an HTML block scrolls the cursor into view, and ProseMirror
measures a Range to do it. jsdom's ranges have no getClientRects, so on
CI's Node 20 the measuring threw on a timer after the test and failed the
run as an unhandled error. The editor test gives ranges an empty
measurement, as jsdom has no layout anyway.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…es to a draft

A paperclip tool and drag-and-drop on the editor (CE-006). Excel and CSV
open a preview (sheet picker, first 10 rows, header row) and insert as a
table, asking first above 200 rows. Word (.docx, via mammoth), Markdown,
HTML and plain text import as content through the same cleaning as a
paste. Images, old .xls/.doc and files over 10 MB get a clear message.
Imports land under a table when the cursor is inside one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Page types follow the kind of site (CE-023). Brand settings get a Site
type (B2B SaaS, E-commerce, B2C; guessed from Shopping mode and the
industry until picked), stored in brands.site_type (migration 00205). A
draft's page type is detected from its URL, JSON-LD schema and title,
and kept in step as the page changes, until the person picks one from
the editor header's page type menu (content_drafts.page_type_source).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ansvisor#1257 took 00203 (citation gap rollups) on main, so the content drafts
table moves to the next free number. The file is otherwise unchanged;
schema.sql is rebuilt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
New content (CE-003) starts a page from an open Content Opportunity, a
tracked prompt or a topic, or brings content to optimize by pasting
(cleaned like the editor's paste) or uploading a Word, Markdown, HTML or
text file. Start (CE-015) offers the site type's page types, the one the
title or content shows picked first, and opens the editor.

The draft keeps the opportunity it came from and the prompts it should
answer (migration 00206: opportunity_id, prompt_ids, and a trigger that
refuses another brand's opportunity or prompts). A new page starts with
its title as the H1; content to optimize is checked against the draft
allow-list. The editor's file readers move to lib/content/import-document
so both use them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Start (CE-015) now shows which of the brand's own pages AI already cites
for the prompts a new page would answer: prompts in common, citations in
the last 30 days and the Google position from Search Console, through a
new security-definer RPC, content_page_overlap (migration 00207). It
recommends one option: optimize a page that already answers half the
prompts or more, otherwise create the page and link the others to it,
or say it is safe to create.

Picking an existing page makes the draft that page's: optimize, its
title as H1, the page type read from its address, and its URL kept in
content_drafts.source_url, which the editor shows beside the page type.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Optimize content gets a Page URL option (CE-003), and Start's "Optimize
this page instead" now brings the page's live text. The API reads the
page through a new guarded fetch (server lib/safe-fetch.js):
- http(s) on the web ports, no credentials in the address;
- every address the host resolves to must be public, checked in the
  connection's own lookup, and an address written as an IP checked
  before it, since a literal skips the lookup;
- redirects followed by hand and checked the same way; 10 s, 3 MB,
  HTML only.
POST /api/content-pages/import reads only the brand's own domains,
before and after redirects, and returns the page's main content, title
and JSON-LD (lib/page-content.js). The web cleans it like a paste and
reads the page type from the address and the content.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…team

Start's Who does it (CE-015): Me opens the editor; Agent waits for the
Content Agent; Team sends the draft to the Action Center as an action
for someone on the team to write.

The API gets a person-sent action kind, content_draft (from-content-draft.js,
POST /api/action-center/content-drafts): a new page's or an existing
page's library tasks, as an opportunity's page gets, prioritised and
measured on the draft's prompts and page. The draft records its action
(content_drafts.action_id, migration 00208, server-set: the drafts guard
is redefined to keep members from writing it). The Action Center names
it "Write: …" / "Optimize: …" and links back to the draft.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The editor gets its right side panel (Content Editor spec v2 §6), with the
Impact tab first (CE-016): for the live page a draft optimizes, the last
7, 30, 90 or 365 days against the period before.

- content_page_impact (00209): citations on the brand's own domains, AI
  visits by ai_traffic_merged's rule (snippet on its days, GA4 otherwise),
  Search Console clicks with the first day of page data, the prompts citing
  the page in either window with their platforms, and the brand's other
  pages cited for the same prompts. Security definer with an organization
  check; whole UTC days, today included.
- Impact tab: four cards with their change (low sample under 30, as the AI
  Traffic page), prompts cited with the lost ones marked, "See in
  Citations", the overlap line and where the numbers come from; a new page
  says there is nothing to measure yet.
- The panel opens beside the page on a wide window, closes from the header
  and remembers the choice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the page's AI visits

normalize_page_path('') is '/', so a GA4 row with no landing page read
as the home page's visit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mpact tab

The Impact tab (CE-016, spec §7) now shows what visitors from AI
assistants did after landing on the page, and which assistant sent them.

- content_page_results (00210): per AI source key, the page's AI visits by
  ai_traffic_merged's rule (they add up to the AI visits card) and Google
  Analytics' AI sessions landing on it, with key events, sessions with a
  key event, purchases and revenue; whether a property is mapped and
  whether it reported purchases in the window. Security definer with an
  organization check, same window as content_page_impact.
- Results from AI visits: key events and key event rate (low sample under
  30 sessions), plus orders and revenue when the property reports
  purchases; a table by AI source (visits, key events, revenue), one row
  per platform name with unnamed keys as Other. Without Google Analytics,
  the visits per source and a link to AI Traffic to connect it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ces tab

The editor's side panel gets its Sources tab (CE-008, spec §10): every
source the draft draws on, by name, with where the draft uses it.

- content_draft_sources (00211): over the last 30 days, the draft's
  prompts and those whose answers cited its page, the searches AI ran for
  them (prompt_results.search_queries), the pages their answers cited, the
  brand's Search Console queries, and the brand and competitor domains.
  Security definer with an organization check through the draft's brand.
  A table of the same name keeps a person's choices: a source left out, a
  page or query added by hand (member RLS through content_drafts).
- Sources tab: "Built from N sources" with counts per group; Prompts,
  Fan-outs, Cited pages (kind named by the citations classifier) and
  Search Console (queries sharing half their words with the draft); each
  row with a checkbox, its numbers and where the draft uses it now — a
  heading or paragraph carrying three quarters of its words, an outbound
  or internal link, or this page.
- + Add source: a prompt joins the draft's prompts; a page address or a
  Search Console query is kept as added by hand.
- The panel opens Sources only when its tab is picked and keeps a tab
  mounted once opened.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk Content Editor PR 8a is up: the Sources tab (CE-008). It's stacked on #1291.

Two questions:

  1. Search Console per page. GSC keeps no queries per page (gsc_query_stats has no page column), so the tab shows the brand's queries that share half their words with the draft, as page-prompt-suggestions.js does. Should we add a [page, query] pull to gsc-sync.js as a follow-up so this group is exact? That would mean a new table and more GSC API rows per brand.
  2. Cost of content_draft_sources. It reads prompt_results for the draft's prompts over 30 days, expands search_queries, and joins citations. Could you run it once on the largest brand with a draft that has ~20 prompts, to check the time?

"Rebuild with selection" and the Brief tab come next in 8b.

@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 20, 2026
cihan-gyk and others added 22 commits October 21, 2026 17:54
…İ before them keeps them

`toLowerCase()` turns 'İ' into two UTF-16 units, so every İ before a JSON-LD
script shifted the positions taken from the lower-cased copy: the schema was
dropped on save, with as many characters of the text after it. Only ASCII
letters are lower-cased now, which keeps the length and stays linear.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`substring(source_url from '^https?://…')` is case-sensitive, while Start
takes /^https?:\/\//i, so an HTTPS:// address got no host and no sources
from its page. The address is lower-cased before the host is read (00211).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…locks

# Conflicts:
#	web/src/lib/content/sanitize-draft-html.test.ts
The test merged up from ansvisor#1259 used extractJsonLd, which this branch
replaces with extractKeptBlocks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most fixes check out:

  • prompts are scoped through prompt_sets;
  • the page is matched on its host;
  • the read is debounced at 400 ms;
  • toggles update per row;
  • the updated_at trigger is in place.

The read is still over 8 s on prod for the same draft as last time: the brand with the most citations, its most-cited page plus an 80-prompt topic (92 prompts), 30 days, custom plan.

Run Time
Cold-ish 21.7 s, 11.8 s, 8.3 s
Fully warm 0.76 s
  1. answers still runs on idx_prompt_results_prompt_id (supabase/migrations/00211_content_draft_sources.sql:174-181). brand_id and created_at only filter rows after they're read from the heap. The scan reads every result each prompt ever had (about 400 per prompt, 148 of them in the window): 36k buffers, 8.2k read from disk on the 8.3 s run. Two fixes, both needed:
    • Bound the scan to the window. Either add create index concurrently … on prompt_results (prompt_id, created_at), or pick the window's ids from the cover index first (as window_answers does) and fetch only those rows.
    • The heap rows themselves are needed for search_queries, so cap the sample: for example, the latest 30 answers per prompt through a lateral order by created_at desc limit 30.
  2. cited_ids reads prompt_result_citations through its primary key, once per answer (:208-218). That's 106k citations and 55k buffers (6.5k read from disk), plus an on-disk merge sort. Take the window's citations from prompt_result_citations_brand_created_cover_idx (brand_id, created_at, which includes url_id, prompt_result_id) and hash-join them to the answer ids instead. That only becomes index-only once the visibility-map setting from the review on #1287 is applied.

The PRs below this one are squash-merged on main; this keeps only this branch's own change on top.

Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging with the stack. The open items from the last review go into a follow-up PR on main. 00204–00221 are applied on production now, so changes to them need new migration files.

The vacuum part is done separately: #1315 makes autovacuum's insert pass and analyze run about daily on prompt_results and prompt_result_citations, which keeps the cover-index scans index-only. It's applied on production.

@gkhngyk
gkhngyk merged commit 6b2ed53 into ansvisor:main Oct 21, 2026
4 checks passed
gkhngyk added a commit that referenced this pull request Oct 21, 2026
…My rules per site type (00227) (#1316)

* perf(content): bound the overlap, Sources and Plan reads in migration 00226

The third review timed four content reads on production. 00204–00221 are
applied there, so 00226 redefines them:

- content_page_overlap (#1287): the window's answers come from
  idx_prompt_results_brand_created_cover alone; the prompts are picked
  where the citations meet them.
- content_draft_sources (#1292): the window from the cover index, each
  prompt's answers counted there, "named in" from mentions_prompt_daily
  plus the first partial day, fan-outs from each prompt's latest 30
  answers, citations from their cover index hash-joined to the answers.
- content_plan_pages (#1308, 00221's copy): the overlap pairs take their
  window from the current answers alone, no prc.created_at bounds.
- content_plan_insights (#1309): own ids from the domain index, rows picked
  on url ids before citation_urls is read, own list capped at 5,000,
  force_custom_plan.

Each matches its 00207–00221 version on a rolled-back dev DB fixture;
the Sources fan-outs differ only where a prompt has more than 30 answers
in the window.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): keep My rules per kind of site (00227)

content_rule_sets was keyed by organization and page type, so a "guide"
set saved for a B2B brand also applied to the same organization's shops
and travel sites. 00227 adds site_type to the key; getMyRuleSets and
saveMyRuleSet use the brand's kind of site (chosen, or guessed). A set
saved before is copied to each kind, so it keeps applying where it did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): the third review's Plan, Start, page type and prompt items

- Plan (#1308): the reason reads "Citation rate −{pct}%"; Start lists the
  page the plan named first when the overlap check recommends another, so
  a person can come back to it (pages matched by address).
- Collection sign (#1310): whole words of the slug, so /collections/kitchen
  or /collections/limited-edition are categories; the best-of sign leaves
  best-sellers to it.
- #1310's low items: a title naming FAQ with a policy word reads as Policy,
  as its address does; "what is the best/difference/cost/benefits …" and
  "what is new" aren't definitions, in titles and paths; the numbered-steps
  rule checks only a how-to H1 ("Not a how-to" otherwise); "Defined first"
  needs the verb within the first eight words, after a subject that isn't
  a pronoun; the writer, brief and agent prompts name the page type and its
  format (content-page-types.js) instead of its key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(content): count the Sources tab's cited pages over the fan-outs' sample

cited_ids needed every citation of the draft's window answers (106k for a
92-prompt draft on the biggest brand), read one answer at a time, and the
cold first call still took 10.7 s on prod. It now reads the citations of
the same sample as the fan-outs, each prompt's latest 30 answers (2,760
answers instead of 13,618). With the cap lifted it matches the previous
read on the dev DB fixture.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): show the plan's page in Start when nothing overlaps

Start pre-selects the page the Content plan named, but when the overlap
check found no page, the box only said "Safe to create" and offered no
option: the person couldn't see the draft would optimize that page, or
switch to a new one. With a page from the plan and nothing overlapping,
Start now offers "Optimize /page" (chosen) and "Create a new page instead".

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): fingerprint a lost save as the server stores it

When a save's answer never came back, the editor sent the hash of its raw
HTML as unconfirmedHash, but the server compares it with the stored page,
which is sanitizeDraftHtml's output. sanitize-html rewrites most real
pages (<br> to <br />, &nbsp; to U+00A0, links without target/rel, tables
without style/colgroup), so on those pages the lost save still ended in a
conflict. The editor now hashes the sanitized page, loading the sanitizer
only on that path, and the server also takes a stored page equal to the
one being saved as its own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): make a decision again on the page at once, before the second save

When the page changed while a decision was saved, redo.tr was built on the
new page, but dispatched only after the second save (the suggestions it no
longer fits going back to review). If the page changed again during that
call, dispatching threw "Applying a mismatched transaction": the person saw
the save-failed toast, and the page and the cards stayed as they were. The
redo is now dispatched right after it is built.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): write the detected type only over the save or restore it follows

The type update after a save or a restore wasn't tied to that version. A
write landing between them would have its updated_at become the editor's
base, and the next autosave would go over it. Both updates now match the
version they follow (updated_at); otherwise the type catches up on the
next save, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(content): put ruleSet's doc comment back above ruleSet

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): read "Defined first" past punctuation, and in English only

- The verb check compared words with their punctuation attached, so
  "Cold brew is, simply, …" read as Missing; words are compared bare now.
- The check reads English words ("is", "means", "refers to"), so for a
  brand whose language isn't English it shows "English only" and isn't
  counted. The rule context carries the brand's language.

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-migration Adds or edits a migration — apply it to the hosted database

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants