Skip to content

feat(content): check the page before it's marked ready, with its JSON-LD to paste (CE-041) - #1420

Merged
gkhngyk merged 143 commits into
ansvisor:mainfrom
cihan-gyk:feature/quality-before-publish
Oct 23, 2026
Merged

gkhngyk merged 143 commits into
ansvisor:mainfrom
cihan-gyk:feature/quality-before-publish

Conversation

@cihan-gyk

@cihan-gyk cihan-gyk commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Content Editor Quality spec §7, CE-041 Before you publish + the Mark ready gate. Behind NEXT_PUBLIC_CONTENT_QUALITY_PHASE like the rest of Quality; with the flag off, Mark ready marks at once as before.

Stacked on #1419 (→ #1418 → … → #1411). Migration 00260 (applied on the dev database). Deploy it before the web.

Before you publish (_before-publish.tsx) opens on the header's Mark ready.

  • Warning only when Trust is under 60 (nothing else blocks): "Trust 37, below 60. 2 sentences with figures have no source. You can mark it ready, but fixing them first raises Trust to about 94."
    • The reason is the Trust check that raises it most; "about 94" is Trust with that check in full.
    • With Trust low only from Site trust, it says so without a reason.
    • "Mark ready anyway is logged, with this Trust."
  • While the page's links are still being read, a line says Trust may change (useLinkChecks now also returns how many reads may still come).
  • What the CMS does for the page, each as "check it":
    • Author for your CMS: "Set Ada Lovelace as the page's author in your CMS. Its template shows the byline; nothing is added to the content." With the team byline: No author yet (missing).
    • Visible published and updated dates, with the spec's CMS note.
    • Article schema with datePublished and dateModified, "Often added by your CMS. If not, paste the code below into the page."
  • JSON-LD (lib/content/page-schema.ts) with Copy JSON-LD, a <script type="application/ld+json"> to paste:
    • Article: headline, the page's first https image, author, publisher, dates. < is escaped.
    • Author: Person (jobTitle, image, sameAs from the profile links, url from Site trust's author page) or the brand's Organization.
    • Nothing made up:
      • While the authors can't be read, the author is left out (and the row says so).
      • A live (optimize) page gets only dateModified, since it keeps the published date it has.
      • "The dates are today's: change them if the page goes out on another day."
      • The publisher's url is the home page Site trust read, if any.
    • Articles only: blog post, guide, comparison, buying guide, best-of, definition, alternatives, itinerary, or no type yet. Other page types get "Schema for this page type · check what your CMS adds for it". Their own schema is a Phase 3 page-type item.
  • Buttons: Copy JSON-LD · Fix first (closes, opens Quality, scrolls to the passage named and puts the caret there) · Mark ready anyway (or plain Mark ready with no warning).
    • Focus starts on the action, not the code.
    • The dialog scrolls on short screens.
    • The CE-040 nudge shows behind it.

Logged: 00260_content_draft_ready_log. Each Mark ready anyway adds a row with:

  • the page's Trust;
  • the check the warning named (claimsSourced …) and its count;
  • who, and when.

markContentDraftReady(id, anyway?) validates it with Zod and writes it after the status changes. The draft is ready even if the log fails, which is reported in the logs.

  • RLS: members insert only as themselves (created_by defaults to auth.uid()), only for a ready draft of their brand, and only draft_id, trust, reason, reason_count (column grant). Nothing updates or deletes rows.
  • Checked on dev as the demo user:
    • a draft not ready: refused;
    • a ready draft: allowed;
    • a backdated created_at: refused.

Not in this PR

  • Export opening the same check: CE-057, next, with its "Ready to paste" row.
  • "After you publish, Ansvisor checks the live page…": CE-042 adds that line when it is true.
  • Author schema in E-E-A-T: it isn't counted yet. The pre-push review pointed out it would be points for schema nothing has verified. CE-042 counts it once the live page has it.
  • Library's own status menu still marks ready directly.

Pre-push review: no high findings. Fixed:

  • the author when the authors aren't read;
  • the gate while links are being read;
  • unverified schema points;
  • log forging, and the reason stored as English text;
  • dates note, live-page title, article-only schema, image, 0-gain reasons, focus, dialog height;
  • dead props, and tests for each.

After review (2026-10-23): while the title has a placeholder, the JSON-LD leaves headline out and says why.

Related issue

Drive spec Quality §7, CE-041. No GitHub issue.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation

How to test

  1. Apply 00260_content_draft_ready_log.sql and set NEXT_PUBLIC_CONTENT_QUALITY_PHASE=1.
  2. Open a blog draft with a figure and no source ("…sold 40% more…"). Click Mark ready.
    • The warning reads "Trust 0, below 60. 1 sentence with a figure has no source…".
    • The rows and the JSON-LD show. Copy JSON-LD copies the script.
  3. Click Fix first. Quality opens and the passage is marked, with the caret in it.
  4. Click Mark ready again, then Mark ready anyway. The draft is ready, and content_draft_ready_log has a row (Trust 0, claimsSourced, 1, you).
  5. On a draft with Trust 60 or more, or none to read: no warning, and a plain Mark ready.
  6. On a product page: no JSON-LD, and the "Schema for this page type" row.

Checked locally at 1024 px in light and dark, and at 1024×600 (the dialog scrolls), on a temporary demo draft and author (removed afterwards). The log row was written and read back, and the RLS cases were checked in a rolled-back transaction.

Checklist

  • web/ at the final commit: yarn lint (0 errors; 6 existing warnings elsewhere), yarn typecheck, yarn test (350 files, 3,117 tests), yarn format:check and yarn build pass
  • Tests:
    • _before-publish.test.tsx (10): the warning and its biggest reason, the no-reason warning, Trust exactly 60 and unread, links still read, the rows, the JSON-LD and Copy, authors unread, team byline and live page, non-article types, focus
    • page-schema.test.ts (8)
    • content-drafts.test.ts: the log and its validation
    • _use-link-checks.test.tsx: pending reads
    • page.test.tsx: opens on Mark ready, anyway logged, Fix first, off without the flag, the CE-040 nudge behind it
  • Migration added, schema.sql rebuilt, applied on the dev database
  • UI text in messages/en.json

🤖 Generated with Claude Code

cihan-gyk and others added 30 commits October 23, 2026 02:24
The workspace's one AI budget (Improve, the Content Editor's AI and the
Action Center's task writer) had no meter: the first sign of it was an
"AI usage is used up" error. Migration 00242 records what each AI call
was for (prompt_improve_usage.feature, backfilled) and sums the period's
spend by feature (ai_usage_by_feature). GET /api/billing/ai-usage
returns the shares of the plan's budget, and the Billing page shows the
share used, when it resets and what used it, with Agent Chat noted as
running on the workspace's own key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The workspace's AI budget was checked by reading the period's spend; the
call's cost was written once the model answered. Calls running at once
(two tabs, a teammate, an Action Center sweep) all read the same spend
and all ran past the budget. 00243's reserve_ai_usage takes a
per-organization lock, reads the spend with the calls in flight, and
holds the call's estimated cost; reserveAiBudget turns the hold into the
real cost or releases it. Improve, the brief rebuild, Apply rules with
Agent, Start Agent and the Action Center task writer use it in place of
enforceImproveQuota, which goes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fixes:
- Apply rules with Agent and Start Agent charge an answer the provider
  billed but that missed the schema (NoObjectGeneratedError), as Improve,
  the brief and the task writer do; before, the hold was let go and the
  call ran free.
- A call holds the org's median cost over its last 20 calls this period,
  never less than the model's typical cost, so calls in flight pass the
  budget by far less.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Apply rules with Agent makes at most 8 small edits a run, which can't
bring a long page to its Length (about 2% a run on prod). The Content
Agent can now rewrite the whole page in one background call, left as ONE
suggestion (kind 'page', migration 00247) to compare and accept or reject:
- POST /api/content-drafts/:draftId/rewrite, through Start Agent's claim,
  budget hold and background run;
- passages AI quotes today, tables, images, quotes and HTML blocks go to
  the model as [[KEEP n]] lines and come back as they were; a rewrite that
  drops one fails the run;
- one H1, only the page's own links and the ones offered, the editor's
  tags; the page as it was is kept on the suggestion (before_html).

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

Review fixes:
- Kept blocks are described under the page (a quoted passage's words, a
  table's rows, an image's alt) and their text counts toward Length, so a
  rewrite aims at the whole page's length; with Length off it keeps the
  page's own. A kept H1 stays first, and the page's language is kept.
- The answer is taken out of a code fence, text left at its root goes in
  paragraphs, and an answer in Markdown fails the run.
- The page's own links stay exactly as written (query and anchor too).
- Kept blocks go back untouched (an empty table cell stays), only the
  page's first H1 counts as its title, a page that writes "[[KEEP" gets
  markers of its own, and a page that is only kept blocks isn't sent.

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

The Rules tab opens with the agent's two ways to meet its rules: Apply
rules with Agent (small edits, up to 8 a run) and Rewrite the page to
these rules (the whole page as one change). The rewrite is recommended,
with a one-line reason, when the page is more than 30% off its Length or
4 rules or more are open.

A rewritten page comes back as one suggestion with its own bar over the
page: the characters before and after and the agent's reason, Compare
(the page and the rewrite side by side), Accept (History keeps the page
first), Reject, and Undo. A page that changed since the agent read it
isn't written over. The page waits for the rewrite with its own steps,
and a failed rewrite's Try again rewrites again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fixes:
- A page is compared with the one the agent read by its words, with a
  space between blocks, so stored line breaks and lists don't read as a
  change (Accept and Undo were refused on imported pages).
- One agent run at a time from the page; a rewrite never starts before
  the locked passages are read, and sends the editor's own locked keys.
- Accept holds the page still from the start and checks it again before
  putting the rewrite in; Undo puts the page back as it was (two H1s too),
  and the bar waits while the HTML view is open.
- No rewrite advice for an empty page or one too long to send whole; the
  rewrite mark survives a reload; the waiting view says the rewrite waits
  in the editor; Compare's links don't navigate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Content Editor v1.1, part 1 (CE-025, CE-026, §4): the agent row and the
rewrite bar become one card above the toolbar, in three states:
- waiting: "Content Agent has {n} suggestions for you", what they change
  and the rules they gain ("Rules 5 → 6 of 13"), with Review (scrolls to
  the first suggestion and marks it), Reject all and Accept all; a page
  rewritten shows its characters, with Compare;
- all reviewed: what was accepted and the rules met and still open, with
  Undo all and Run Agent;
- working: while Apply rules with Agent runs.
The tile moves a little (a soft ring, a blink, a spark; a sweep and a
breath while working), never a rotating ring, and not at all with reduced
motion. The card wraps on a narrow page; Accept all and Run Agent are the
primary buttons.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Run Agent on the card keeps to one agent run at a time and says why it
  waits; Apply rules never starts beside another run or before the locked
  passages are read.
- Ghost buttons show their hover on the card's grey; the tile and its
  count are hidden from screen readers (the title says it) and the count
  is darker for contrast; "+N more" comes from en.json, the reason's first
  letter is upper-cased in the page's locale.
- Review picks the first open suggestion in the page's order and focuses
  it; the sweep shows on the light tile in dark mode; the spark is slower
  once all are reviewed; without motion the working line is a faint full
  line; "0 still open" isn't said.
- globals.css keeps its own lines; only the motion block is added.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…split Run Agent

Content Editor v1.1 part 2 (CE-028–CE-031): the side panel's tabs become
Instructions · Sources · Live page. Instructions holds Brief | Rules, with
the rules still open on the tab and the segment. Each segment opens with a
status card: Rules has one split Run Agent ▾ (Fix open rules, or Rewrite
the whole page, which renames it "Rewrite page") in place of the two rule
buttons; Brief has Run Agent while empty and Rebuild brief once written.
Why the agent can't run is written under the card, and each card's ⓘ tip
opens below it. The brief shows "Not set yet" and its Length in characters
and about as many words; the toolbar counter adds the page's words.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Run Agent's choice is worked out once and falls back to Fix without a
  rewrite; once a rewrite starts, the button is back on Fix.
- ▾'s choices are menu radio items; Fix is off when only rules the agent
  can't fix are open, and the card says what to do instead.
- The reason line under the card stays mounted for screen readers; Rewrite
  from brief writes its reason too; the tab's count is read out.
- Brief | Rules switch with the arrow keys, one tab stop.
- An edited brief's rebuild question sits under the card; a brief without
  H2s says to rebuild it; an empty brief shows no origin line.
- Plural copy for the open suggestions and the counter's words; rule names
  joined by the formatter; Run Agent's tip leaves ▾ out without a rewrite.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Content Editor v1.1 part 3 (CE-032, CE-034): under each Run Agent card,
"Uses your data: 1 prompt · 21 fan-outs · 20 cited pages · 10 Search
Console queries · Edit sources", counted as the Sources tab keeps them, so
turning one off lowers it at once. The Sources tab carries its count, and
its top says "N sources in use" and when the Content Agent last wrote from
them (its latest suggestions or the brief it built). A first visit's note
at the top of Instructions says the agent writes from the person's data;
closing it is kept in their own user metadata.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- "Last used by Content Agent" also counts the agent writing the page
  (agent_state_at: Start with Agent, Rewrite from brief on a new page),
  not a run that failed; a value that isn't a date is skipped.
- The latest batch's time is its first suggestion's, not a sort per render.
- Tests: the Brief segment's line, no line while the sources can't be read,
  the tab's count, the note showing again after a failed write, and a
  suggestion read with its createdAt.

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

Content Editor v1.1, CE-033 (server): Fix open rules, Start with Agent and
Rewrite the whole page read the sources the Sources tab keeps, numbered
S1, S2… (content-sources.js). Each suggestion keeps the sources it names
and the words each supports (content_draft_suggestions.sources and
source_marks, 00248); a page rewritten whole keeps its sources.

No number without a source: the model reads a source by its words only, so
a number the agent adds must be the page's, the brand's, the brief's, the
rules', today's, or in a source's own words (then marked to it). A
suggestion with any other number is not kept; a page written whole gets a
placeholder in its place. Source numbers written into the words are taken
out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Content Editor v1.1, CE-033 (web) and the rest of CE-034: under each
suggestion, "Based on" chips name the sources it used (number, kind, name;
the Sources tab's details on hover), and a small number marks the words
each supports. A click on either opens Sources on that row, scrolled to
and ringed for a moment, once. The agent card adds "built from N of your
sources · See sources". Fix open rules sends the kept sources, and the
first-visit note says every change shows the sources it used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Content Editor v1.1, CE-027/035 (server): each Content Agent run (Fix open
rules, Start with Agent, Rewrite the whole page, the brief) is written in
content_agent_runs (00249) with its steps named by the data it reads
("Reading 20 cited pages", "Matching 21 fan-outs", "Writing 3 changes") as
it reaches them. POST /api/content-drafts/:id/stop marks the run stopped
and aborts its model call; the run checks before it keeps anything, so a
stopped run changes nothing (no suggestions, page, brief or History).

A run that can't be written still runs; runs a stopped server left are
closed when the next starts, and Stop ignores them. Background runs are
written before Start answers, so Stop finds them at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Stop also clears the draft's 'writing' state at once: a background run lets
go once it sees the stop, but one no server holds any more never would, and
the waiting page would wait out the 10 minutes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…p it (CE-027, CE-035)

The agent card, the brief and the waiting page show the run's real steps
(content_agent_runs, read from the browser every second) and a Stop button
that ends the run through the API proxy, leaving the page as it was. A dashed
decoration under the H1 says where Fix is drafting, and the agent's dots
replace every spinner on its buttons.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…h (CE-030)

When the brief is rebuilt, the server reads the first few cited pages kept
in Sources (only addresses AI answers cited for the brand, never the draft's
own page), counts their main text as the Rules tab counts length, and saves
the median as brief.citedLength. The Brief tab says "From the rules · cited
pages average N characters"; with fewer than two pages read it stays "From
the rules". textLength moves to page-content.js to avoid an import cycle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	server/src/lib/content-writer.js
#	server/src/lib/content-writer.test.js
#	supabase/schema.sql
…le it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…le it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…st batch's rows

The editor reads content_drafts.agent_run, so a failed rewrite is tried again
as one on every device (the localStorage mark is gone). Fix open rules' new
409 'writing' says the agent is already writing. getDraftSuggestions finds
the latest batch first and reads only its rows, and Compare's links can't
take focus.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The card's Run Agent writes its reason in the card's second line (amber, tied
to the button by aria-describedby) instead of a hover title, and is turned
off when the only rules left open are ones the agent doesn't fix (one H1),
as the Rules card does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
cihan-gyk added a commit to cihan-gyk/ansvisor that referenced this pull request Oct 23, 2026
ansvisor#1420 kept its own copy while placeholders.ts wasn't below it; now it is.

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

Copy link
Copy Markdown
Collaborator Author

@gkhngyk Fixed, and main merged.

  1. Migration: 00260_content_draft_ready_log.sql, with its header and the content-drafts.ts comment. The rest of the stack is 00256–00259, as you listed.
  2. A placeholder in the title: headline is left out of the JSON-LD while the title has one, and an amber line under the code says why. That matches how the dialog already treats an unknown author.

One test now expects #1416's corrected plural ("1 of 1 dated source is…").

gkhngyk
gkhngyk previously approved these changes Oct 23, 2026

@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.

All items done:

  1. The migration is 00260_content_draft_ready_log, and its header and the content-drafts.ts comment match. schema.sql rebuilds to the committed file.
  2. headline is left out while the title has a placeholder. A line under the code says why, and Copy JSON-LD still works. Both are tested.

The merges add nothing beyond the renumber and the trustSuggestions conflict. That one is resolved to #1418's version (trustGain, and a broken link listed before Trust is scored) with this PR's count kept.

Merge note:

  • Apply 00260 before the web deploy that carries this PR.
  • It needs only content_drafts, profiles and content_draft_member, which are all on prod, and none of 00256–00259.
  • Without it, Mark ready anyway still marks the draft. Only its log row is lost.

Merge state: merges cleanly on main.

@gkhngyk
gkhngyk dismissed their stale review October 23, 2026 21:08

The merge-base changed after approval.

@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.

Re-approving after merging main into the branch. The merge only brings in the squashed parent PR; the tree matches the one tested (web and server tests, typecheck, lint, format).

@gkhngyk
gkhngyk merged commit 80743e9 into ansvisor:main Oct 23, 2026
4 of 5 checks passed
gkhngyk added a commit that referenced this pull request Oct 23, 2026
…o (CE-044) (#1422)

* feat(billing): show this period's AI usage on the Billing page

The workspace's one AI budget (Improve, the Content Editor's AI and the
Action Center's task writer) had no meter: the first sign of it was an
"AI usage is used up" error. Migration 00242 records what each AI call
was for (prompt_improve_usage.feature, backfilled) and sums the period's
spend by feature (ai_usage_by_feature). GET /api/billing/ai-usage
returns the shares of the plan's budget, and the Billing page shows the
share used, when it resets and what used it, with Agent Chat noted as
running on the workspace's own key.

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

* fix(billing): hold an AI call's share of the budget before it runs

The workspace's AI budget was checked by reading the period's spend; the
call's cost was written once the model answered. Calls running at once
(two tabs, a teammate, an Action Center sweep) all read the same spend
and all ran past the budget. 00243's reserve_ai_usage takes a
per-organization lock, reads the spend with the calls in flight, and
holds the call's estimated cost; reserveAiBudget turns the hold into the
real cost or releases it. Improve, the brief rebuild, Apply rules with
Agent, Start Agent and the Action Center task writer use it in place of
enforceImproveQuota, which goes.

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

* fix(billing): charge a schema miss and hold the org's recent median cost

Review fixes:
- Apply rules with Agent and Start Agent charge an answer the provider
  billed but that missed the schema (NoObjectGeneratedError), as Improve,
  the brief and the task writer do; before, the hold was let go and the
  call ran free.
- A call holds the org's median cost over its last 20 calls this period,
  never less than the model's typical cost, so calls in flight pass the
  budget by far less.

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

* feat(content): rewrite a whole page to its rules as one suggestion

Apply rules with Agent makes at most 8 small edits a run, which can't
bring a long page to its Length (about 2% a run on prod). The Content
Agent can now rewrite the whole page in one background call, left as ONE
suggestion (kind 'page', migration 00247) to compare and accept or reject:
- POST /api/content-drafts/:draftId/rewrite, through Start Agent's claim,
  budget hold and background run;
- passages AI quotes today, tables, images, quotes and HTML blocks go to
  the model as [[KEEP n]] lines and come back as they were; a rewrite that
  drops one fails the run;
- one H1, only the page's own links and the ones offered, the editor's
  tags; the page as it was is kept on the suggestion (before_html).

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

* fix(content): describe a rewrite's kept blocks and count them toward Length

Review fixes:
- Kept blocks are described under the page (a quoted passage's words, a
  table's rows, an image's alt) and their text counts toward Length, so a
  rewrite aims at the whole page's length; with Length off it keeps the
  page's own. A kept H1 stays first, and the page's language is kept.
- The answer is taken out of a code fence, text left at its root goes in
  paragraphs, and an answer in Markdown fails the run.
- The page's own links stay exactly as written (query and anchor too).
- Kept blocks go back untouched (an empty table cell stays), only the
  page's first H1 counts as its title, a page that writes "[[KEEP" gets
  markers of its own, and a page that is only kept blocks isn't sent.

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

* feat(content): rewrite the page to its rules from the Rules tab, and compare it

The Rules tab opens with the agent's two ways to meet its rules: Apply
rules with Agent (small edits, up to 8 a run) and Rewrite the page to
these rules (the whole page as one change). The rewrite is recommended,
with a one-line reason, when the page is more than 30% off its Length or
4 rules or more are open.

A rewritten page comes back as one suggestion with its own bar over the
page: the characters before and after and the agent's reason, Compare
(the page and the rewrite side by side), Accept (History keeps the page
first), Reject, and Undo. A page that changed since the agent read it
isn't written over. The page waits for the rewrite with its own steps,
and a failed rewrite's Try again rewrites again.

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

* fix(content): compare a rewrite by its words and run one agent at a time

Review fixes:
- A page is compared with the one the agent read by its words, with a
  space between blocks, so stored line breaks and lists don't read as a
  change (Accept and Undo were refused on imported pages).
- One agent run at a time from the page; a rewrite never starts before
  the locked passages are read, and sends the editor's own locked keys.
- Accept holds the page still from the start and checks it again before
  putting the rewrite in; Undo puts the page back as it was (two H1s too),
  and the bar waits while the HTML view is open.
- No rewrite advice for an empty page or one too long to send whole; the
  rewrite mark survives a reload; the waiting view says the rewrite waits
  in the editor; Compare's links don't navigate.

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

* feat(content): show the Content Agent as a card over the page

Content Editor v1.1, part 1 (CE-025, CE-026, §4): the agent row and the
rewrite bar become one card above the toolbar, in three states:
- waiting: "Content Agent has {n} suggestions for you", what they change
  and the rules they gain ("Rules 5 → 6 of 13"), with Review (scrolls to
  the first suggestion and marks it), Reject all and Accept all; a page
  rewritten shows its characters, with Compare;
- all reviewed: what was accepted and the rules met and still open, with
  Undo all and Run Agent;
- working: while Apply rules with Agent runs.
The tile moves a little (a soft ring, a blink, a spark; a sweep and a
breath while working), never a rotating ring, and not at all with reduced
motion. The card wraps on a narrow page; Accept all and Run Agent are the
primary buttons.

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

* fix(content): agent card review fixes

- Run Agent on the card keeps to one agent run at a time and says why it
  waits; Apply rules never starts beside another run or before the locked
  passages are read.
- Ghost buttons show their hover on the card's grey; the tile and its
  count are hidden from screen readers (the title says it) and the count
  is darker for contrast; "+N more" comes from en.json, the reason's first
  letter is upper-cased in the page's locale.
- Review picks the first open suggestion in the page's order and focuses
  it; the sweep shows on the light tile in dark mode; the spark is slower
  once all are reviewed; without motion the working line is a faint full
  line; "0 still open" isn't said.
- globals.css keeps its own lines; only the motion block is added.

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

* feat(content): put brief and rules under one Instructions tab with a split Run Agent

Content Editor v1.1 part 2 (CE-028–CE-031): the side panel's tabs become
Instructions · Sources · Live page. Instructions holds Brief | Rules, with
the rules still open on the tab and the segment. Each segment opens with a
status card: Rules has one split Run Agent ▾ (Fix open rules, or Rewrite
the whole page, which renames it "Rewrite page") in place of the two rule
buttons; Brief has Run Agent while empty and Rebuild brief once written.
Why the agent can't run is written under the card, and each card's ⓘ tip
opens below it. The brief shows "Not set yet" and its Length in characters
and about as many words; the toolbar counter adds the page's words.

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

* fix(content): instructions tab review fixes

- Run Agent's choice is worked out once and falls back to Fix without a
  rewrite; once a rewrite starts, the button is back on Fix.
- ▾'s choices are menu radio items; Fix is off when only rules the agent
  can't fix are open, and the card says what to do instead.
- The reason line under the card stays mounted for screen readers; Rewrite
  from brief writes its reason too; the tab's count is read out.
- Brief | Rules switch with the arrow keys, one tab stop.
- An edited brief's rebuild question sits under the card; a brief without
  H2s says to rebuild it; an empty brief shows no origin line.
- Plural copy for the open suggestions and the counter's words; rule names
  joined by the formatter; Run Agent's tip leaves ▾ out without a rewrite.

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

* feat(content): show the data the Content Agent writes from

Content Editor v1.1 part 3 (CE-032, CE-034): under each Run Agent card,
"Uses your data: 1 prompt · 21 fan-outs · 20 cited pages · 10 Search
Console queries · Edit sources", counted as the Sources tab keeps them, so
turning one off lowers it at once. The Sources tab carries its count, and
its top says "N sources in use" and when the Content Agent last wrote from
them (its latest suggestions or the brief it built). A first visit's note
at the top of Instructions says the agent writes from the person's data;
closing it is kept in their own user metadata.

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

* fix(content): data note review fixes

- "Last used by Content Agent" also counts the agent writing the page
  (agent_state_at: Start with Agent, Rewrite from brief on a new page),
  not a run that failed; a value that isn't a date is skipped.
- The latest batch's time is its first suggestion's, not a sort per render.
- Tests: the Brief segment's line, no line while the sources can't be read,
  the tab's count, the note showing again after a failed write, and a
  suggestion read with its createdAt.

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

* feat(content): have the Content Agent write from the kept sources and name them

Content Editor v1.1, CE-033 (server): Fix open rules, Start with Agent and
Rewrite the whole page read the sources the Sources tab keeps, numbered
S1, S2… (content-sources.js). Each suggestion keeps the sources it names
and the words each supports (content_draft_suggestions.sources and
source_marks, 00248); a page rewritten whole keeps its sources.

No number without a source: the model reads a source by its words only, so
a number the agent adds must be the page's, the brand's, the brief's, the
rules', today's, or in a source's own words (then marked to it). A
suggestion with any other number is not kept; a page written whole gets a
placeholder in its place. Source numbers written into the words are taken
out.

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

* feat(content): show what each agent suggestion was written from

Content Editor v1.1, CE-033 (web) and the rest of CE-034: under each
suggestion, "Based on" chips name the sources it used (number, kind, name;
the Sources tab's details on hover), and a small number marks the words
each supports. A click on either opens Sources on that row, scrolled to
and ringed for a moment, once. The agent card adds "built from N of your
sources · See sources". Fix open rules sends the kept sources, and the
first-visit note says every change shows the sources it used.

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

* feat(content): write the Content Agent's runs step by step and stop them

Content Editor v1.1, CE-027/035 (server): each Content Agent run (Fix open
rules, Start with Agent, Rewrite the whole page, the brief) is written in
content_agent_runs (00249) with its steps named by the data it reads
("Reading 20 cited pages", "Matching 21 fan-outs", "Writing 3 changes") as
it reaches them. POST /api/content-drafts/:id/stop marks the run stopped
and aborts its model call; the run checks before it keeps anything, so a
stopped run changes nothing (no suggestions, page, brief or History).

A run that can't be written still runs; runs a stopped server left are
closed when the next starts, and Stop ignores them. Background runs are
written before Start answers, so Stop finds them at once.

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

* fix(content): let go of a background draft when its run is stopped

Stop also clears the draft's 'writing' state at once: a background run lets
go once it sees the stop, but one no server holds any more never would, and
the waiting page would wait out the 10 minutes.

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

* feat(content): show the content agent's steps while it works, and stop it (CE-027, CE-035)

The agent card, the brief and the waiting page show the run's real steps
(content_agent_runs, read from the browser every second) and a Stop button
that ends the run through the API proxy, leaving the page as it was. A dashed
decoration under the H1 says where Fix is drafting, and the agent's dots
replace every spinner on its buttons.

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

* feat(content): show the cited pages' length next to the brief's Length (CE-030)

When the brief is rebuilt, the server reads the first few cited pages kept
in Sources (only addresses AI answers cited for the brand, never the draft's
own page), counts their main text as the Rules tab counts length, and saves
the median as brief.citedLength. The Brief tab says "From the rules · cited
pages average N characters"; with fewer than two pages read it stays "From
the rules". textLength moves to page-content.js to avoid an import cycle.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): read a failed rewrite from the draft, and only the latest batch's rows

The editor reads content_drafts.agent_run, so a failed rewrite is tried again
as one on every device (the localStorage mark is gone). Fix open rules' new
409 'writing' says the agent is already writing. getDraftSuggestions finds
the latest batch first and reads only its rows, and Compare's links can't
take focus.

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

* fix(content): say in the agent card why Run Agent won't run

The card's Run Agent writes its reason in the card's second line (amber, tied
to the button by aria-describedby) instead of a hover title, and is turned
off when the only rules left open are ones the agent doesn't fix (one H1),
as the Rules card does.

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

* chore(content): keep AddSourceInput as Prettier formats it

A merge brought in a line formatted by another Prettier version; this puts
back main's formatting, so format:check passes.

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

* fix(content): recommend no Run Agent choice that is turned off

With only One H1 open and no rewrite advice, ▾ no longer shows the disabled
Fix as Recommended.

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

* fix(content): match an added figure by its unit, and read none from dates, addresses or words

A claim (a %, a ×, a scale, a currency) is known only with the same unit or
sign, so a fan-out's "crm for 50 users" no longer sources "50%". Today adds
only its year. A cited page's address is no words of its own. The brand's
name and industry are known, digits stuck to a letter ("B2B", "H2") are no
figure, and a source number written into a reason is taken out.

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

* feat(content): name the agent's steps by the work the server does

Short names for what each run does (CE-027/035): Fix and a rewrite read the
rules, gather the sources (numbered, so a number can be checked), write, and
check what they wrote (a number needs a source, a link must be allowed, a
locked passage stays). The brief gathers, writes the outline and matches
fan-outs. "Reading 20 cited pages" is gone: the agent sees their addresses,
not their content.

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

* fix(content): name the Rules tab's button as it reads now in a test and two lines

A test from main still pressed "Apply rules with Agent", and two messages
still named it; the button is Run Agent, its default Fix open rules.

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

* fix(content): charge a call Stop aborted, end only a run's own claim, and stop the run named

- A Stop that aborts a model call already sent keeps its hold on the AI
  budget as its cost (reserveAiBudget's keep()), since the provider bills
  it; a run stopped before its call sends nothing (runCall).
- A background run ends only the claim it still holds (agent_state_at), so
  one stopped from another server never clears a newer run's.
- A run closes only runs a stopped server left (older than RUN_STALE_MS),
  and /stop takes an optional runId, so another tab's run goes on.

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

* feat(content): show the steps by their new names, and stop the run the editor shows

The step chips read the server's short names (Reading 4 rules, Gathering 52
sources, Writing changes, Checking sources). Stop sends the run's id, so
another tab's run goes on. The waiting page keeps the run's last steps and
reads the draft as soon as its run ends, and a hidden tab reads the run every
AGENT_POLL_MS, then at once when it shows again.

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

* test(content): read the hook's run from what it renders

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

* fix(content): call the cited-page figure the median it is, and stop its reads with the run

The Brief's Length now says "a typical cited page has N characters (median of
M)". A Stop settles the cited-page read on nothing at once: the run's signal
ends each page read (fetchPage takes a signal beside its timeout), so a fast
model answer followed by a Stop never waits on them.

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

* fix(content): show loading without a spinning ring anywhere in Content

Every Loader2 spinner in Content (the editor, Library, Plan, the content
page and its dialogs and menus, the webhook settings) is now LoadingDots:
three dots that bounce in turn, in the text's color, still with reduced
motion, as the Content Editor brief asks ("no spinning ring anywhere"). The
agent's WorkingDots are built on it.

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

* feat(content): read the draft's Readability and show it in Instructions › Quality (CE-036, CE-039)

Quality spec Phase 1, behind NEXT_PUBLIC_CONTENT_QUALITY_PHASE (off unset):
- readability.ts: seven checks read from the draft in the browser, no AI
  cost — average sentence 15–20 words, none over 35, reading level by the
  language's formula (Flesch, Ateşman, Amstad, Kandel–Moles,
  Fernández-Huerta; else sentence and word length), answer first, short
  paragraphs, a heading every 200–300 words, passive voice and jargon
  (English). A check a language can't be read for is left out and the
  score rescaled to 100.
- Instructions gets a Quality segment: the score with its band (80+
  Strong, 60–79 Can improve, under 60 Needs work), "Ansvisor estimates
  based on Google's published quality signals. Not a Google score.", and
  what would raise it, the biggest gain first, with Show.
- The header gets a "Quality {score}" chip that opens it.

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

* fix(content): read Readability from the page's own blocks, and show a passage by its block

- A quote's and a list item's paragraphs are read apart (the editor's HTML
  has no space between tags) and a nested list once; sentence length is
  measured on running text, a list's points aside, and a page of short
  sentences is asked to join some.
- Fernández-Huerta subtracts words per sentence (the corrected form).
- Answer first skips an empty line, fails without an H1, and reads an H1's
  subject without its question and common words.
- Abbreviations don't end a sentence; "-ted" keeps its syllable, French
  "-ent" is no silent ending, Turkish â î û are vowels; "is indeed" isn't
  passive, jargon is read in all its forms, and Show goes to what falls short.
- Show finds the passage's block in the page (never a suggestion's card)
  and marks it with a decoration; the band is read out with the chip and
  the segment's badge.

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

* fix(content): count a passive sentence that says not or never in Readability

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

* feat(content): add Settings › Authors, the real people a page is by (CE-037)

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

* fix(content): let whoever added an author edit it, link only yourself, and renumber to 00251

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

* feat(content): name the page's author in the editor's header and a Page info strip outside the page (CE-038)

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

* fix(content): keep the Page info strip right under the H1, count authors' pages only in Settings

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

* fix(content): draw the Page info strip as the mockup's one line, with the author's face and title at the brand

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

* feat(content): score E-E-A-T from the page's author and Trust from the agent's sourced claims in Quality (CE-039)

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

* fix(content): score only checks that can fail: no Trust and no author schema until they read the page

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

* fix(content): say only what an author's profile is missing in Quality

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

* feat(content): read a draft's links once a day for Trust: working or broken, and their page's date

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

* fix(content): read only a saved draft's links, a few at a time and within a budget, and date pages by their own entity

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

* feat(content): score Trust from the page's sourced figures, fresh sources and working links (CE-039)

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

* fix(content): reserve link reads up front, say which links are never read, and date an article before its page

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

* fix(content): compare links as the draft saves them, count each link and sentence once, and read prices and sizes as no figures

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

* feat(audit): read a brand's site trust: About, Contact, editorial policy, Organization schema and author pages (CE-043)

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

* fix(audit): read site trust in parallel and once per brand, tell a page from the home page, and re-read a partial read soon

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

* feat(audit): show Site trust n/5 in Site Audit, and count it in Quality's Trust (CE-043)

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

* fix(audit): scroll to Site trust from Quality, keep it per brand, say when checking again fails, and count it only beside the page's own Trust

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

* fix(audit): give the Site trust card its own key beside the auto-run notice

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

* feat(content): list what only you can do in Quality, and nudge the next one (CE-040)

Your to-dos in Instructions › Quality: picking the page's author (or adding
one) and completing their profile move out of the suggestions, with a box
the checks tick and E-E-A-T's gain. A dark "Next for you" pill names the
first open one when the agent's run ends (not a failed or stopped one),
when the last open suggestion is accepted (Accept all, one by one, or the
page rewrite) and on Mark ready, once per moment and to-do in the session;
Later hides it. Its words go to a status kept on the page for screen
readers.

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

* feat(content): check the page before it's marked ready, with its JSON-LD to paste (CE-041)

Before you publish opens on Mark ready once Quality is live: a warning
only when Trust is under 60 (the check that raises it most, and to about
what), a note while the page's links are still being read, what the CMS
does for the page (author, visible dates, schema), and for an article an
Article JSON-LD from the title, author, brand, its image and today's date
(Person with sameAs, or the brand's Organization; no author while the
authors aren't read; a live page keeps its published date) with Copy
JSON-LD. Fix first goes to Quality and puts the caret at the passage.
Mark ready anyway is logged with the page's Trust and the check named
(00255 content_draft_ready_log: members add rows as themselves for a
ready draft, three columns only). useLinkChecks also says how many reads
may still come.

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

* feat(content): keep the Content Agent from inventing people and quotes (CE-044)

Every person's name and quoted sentence the agent writes is looked up in
what it was given: the page, the brand, the brief, the rules, the
person's data (Sources) and Settings › Authors. One that isn't becomes a
placeholder ("[name of a real person]", "[quote from a real person, with
its source]"): in Fix open rules' and the first optimize's suggestions,
read in their words as written before they are cleaned; in a page
written whole; and in a rewrite before what it kept goes back, so the
page's own passages are never touched.

A name is read where a person is plainly meant: an honorific, a role
("CEO Jane Doe", "Jane Doe, head of sales", "Jane Doe (CEO)"), or speech
("Jane Doe said", "according to Jane Doe", "Ayşe Yılmaz'a göre"); a
known author stays with the words before it, and a heading is read for
quotes and speech only. A quote is two words or more in quotation marks
next to speech, four or more anywhere, or a blockquote or <q> (its cite
read for the name), across the bold and the links in a line. One reading
per word keeps long text fast.

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

* feat(content): list the placeholders the agent left as the first to-do (CE-044)

Your to-dos in Quality now opens with "Fill {n} placeholders" while the
page has words in square brackets (what the agent leaves where it had no
real name, quote or number), with Show on the first. The Next for you
nudge names it too ("Show now"). Only the person can fill them; an export
never ships one (CE-057).

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

* fix(content): keep the loading dots visible with reduced motion

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

* fix(content): check author profile links in the table, unlink a removed member and revoke anon

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

* fix(content): let a Stop go only of the claim the stopped run holds

A Stop that named a Fix or brief run cleared agent_state whatever the run
was, so a Start or Rewrite on the same draft went on without its claim.
Each run now carries the claim it holds (content_agent_runs.claimed_at,
00249), stopDraftRun answers it, and the route clears agent_state only
where agent_state_at is still that claim.

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

* fix(content): say in the Remove dialog that the author's pages go back to the team byline

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

* fix(content): date a page over the read cap from its start, and count a private-address link as broken

fetchPage gets an opt-in truncate that resolves with the first maxBytes
instead of refusing the page, and the link check uses it, so a large
article page still gives its date and stays working. A link the fetch
refuses as a private or local address reads as broken, since no reader
of the published page can open it; a non-standard port stays unknown.

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

* fix(content): offer Edit author in Quality only to who can edit that author, and say who can otherwise

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

* fix(content): read discounts, materials and short forms as no figures, and score Trust only with a figure or a dated source

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

* fix(audit): read a bot wall as unsure, read a walled home page through Scrape.do once a day, and look for author pages at the usual addresses

A 401/403/429, or a 200 challenge page, now leaves the read incomplete
instead of failing About, Contact, Editorial or Organization schema for a
day (looksBlocked from site-pages.js). A walled home page goes through
Scrape.do, unrendered, at most once a day per brand (site_trust.scraped_at),
and a pass it read stands for that day while the wall hides the page.
An author the page list has no page for is looked for at /author/<slug>
and /authors/<slug> (a few authors per read), with the probes' guards and
their name in the title or H1. readSiteTrust returns complete, so the web
can tell a partial read from a fix to make.

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

* fix(audit): hold Check again until the read can change, say when the site didn't answer, and say Site trust counts in Quality

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

* fix(content): leave a placeholder title out of the JSON-LD headline, and say why

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

* chore(content): move Show's doc comment back onto showInPage

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

* fix(content): read Readability in the draft's language, and split its sentences where they end

- Japanese, Chinese and Thai, written without spaces between words, get no
  score: Quality says "Readability isn't read for this language yet"
  instead of asking for more paragraphs. Sentences also end after 。!?,
  । and ؟, and a Hindi word keeps its vowel signs, so Hindi is read by its
  own sentences and words.
- The language is the draft's Language rule when it is on, else the
  brand's; every brand language's name is read ("Portuguese", "Brazilian
  Portuguese", "日本語"…).
- A sentence doesn't end before a lower-case word, nor at a German or
  Turkish ordinal ("am 3. Oktober") or a language's common abbreviations
  ("z. B.", "p. ex.", "örn."); one before a number only ("No. 5") counts
  there. A full stop before a closing quote or bracket ends one.
- Show goes to the first copy of a passage, and a second Show within the
  moment keeps its mark for the full time.
- Passive voice reads common irregular participles (sent, found, held…).

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

* fix(content): know a name only as whole words, read a bare name only with a verb said of people, and run on without the authors

isKnown matched names as substrings of what the agent was given, so
"Dr. Sarah Chen" passed on a page with "kitchen" and "Mr. Doe" on one
with "does". Both sides are now compared as whole words. A name without
an honorific or role is read only with said, told, explained, recalled,
admitted, insisted or argued (and German sagte, Turkish söyledi), so
"Google Ads recommends" or "according to Google Analytics" no longer
become name placeholders. authorWords logs a failed read (content_authors
not there yet) and reads as no author words instead of failing the run.

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

* fix(content): offer Edit author on the profile to-do only to who can edit the author

#1414's review fix moved here: the to-dos replaced E-E-A-T's suggestions,
so the to-do now carries the rule (whoever added the author, the author
themself or an admin) and tells anyone else who can.

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

* refactor(content): read the title's placeholder with the shared pattern

#1420 kept its own copy while placeholders.ts wasn't below it; now it is.

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

* test(content): expect the dated source line's corrected plural

#1416's review fix reads "1 of 1 dated source is over 24 months old".

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

* fix(content): pass the nudge whether the member can edit the author

Its to-do text names who can complete the profile when they can't.

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

* test(content): give Before you publish's quality read whether the member can edit the author

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

* chore(content): type the agent run's claimed_at

#1400 adds the column to 00249.

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]>
gkhngyk added a commit that referenced this pull request Oct 23, 2026
…CE-057) (#1423)

* feat(billing): show this period's AI usage on the Billing page

The workspace's one AI budget (Improve, the Content Editor's AI and the
Action Center's task writer) had no meter: the first sign of it was an
"AI usage is used up" error. Migration 00242 records what each AI call
was for (prompt_improve_usage.feature, backfilled) and sums the period's
spend by feature (ai_usage_by_feature). GET /api/billing/ai-usage
returns the shares of the plan's budget, and the Billing page shows the
share used, when it resets and what used it, with Agent Chat noted as
running on the workspace's own key.

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

* fix(billing): hold an AI call's share of the budget before it runs

The workspace's AI budget was checked by reading the period's spend; the
call's cost was written once the model answered. Calls running at once
(two tabs, a teammate, an Action Center sweep) all read the same spend
and all ran past the budget. 00243's reserve_ai_usage takes a
per-organization lock, reads the spend with the calls in flight, and
holds the call's estimated cost; reserveAiBudget turns the hold into the
real cost or releases it. Improve, the brief rebuild, Apply rules with
Agent, Start Agent and the Action Center task writer use it in place of
enforceImproveQuota, which goes.

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

* fix(billing): charge a schema miss and hold the org's recent median cost

Review fixes:
- Apply rules with Agent and Start Agent charge an answer the provider
  billed but that missed the schema (NoObjectGeneratedError), as Improve,
  the brief and the task writer do; before, the hold was let go and the
  call ran free.
- A call holds the org's median cost over its last 20 calls this period,
  never less than the model's typical cost, so calls in flight pass the
  budget by far less.

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

* feat(content): rewrite a whole page to its rules as one suggestion

Apply rules with Agent makes at most 8 small edits a run, which can't
bring a long page to its Length (about 2% a run on prod). The Content
Agent can now rewrite the whole page in one background call, left as ONE
suggestion (kind 'page', migration 00247) to compare and accept or reject:
- POST /api/content-drafts/:draftId/rewrite, through Start Agent's claim,
  budget hold and background run;
- passages AI quotes today, tables, images, quotes and HTML blocks go to
  the model as [[KEEP n]] lines and come back as they were; a rewrite that
  drops one fails the run;
- one H1, only the page's own links and the ones offered, the editor's
  tags; the page as it was is kept on the suggestion (before_html).

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

* fix(content): describe a rewrite's kept blocks and count them toward Length

Review fixes:
- Kept blocks are described under the page (a quoted passage's words, a
  table's rows, an image's alt) and their text counts toward Length, so a
  rewrite aims at the whole page's length; with Length off it keeps the
  page's own. A kept H1 stays first, and the page's language is kept.
- The answer is taken out of a code fence, text left at its root goes in
  paragraphs, and an answer in Markdown fails the run.
- The page's own links stay exactly as written (query and anchor too).
- Kept blocks go back untouched (an empty table cell stays), only the
  page's first H1 counts as its title, a page that writes "[[KEEP" gets
  markers of its own, and a page that is only kept blocks isn't sent.

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

* feat(content): rewrite the page to its rules from the Rules tab, and compare it

The Rules tab opens with the agent's two ways to meet its rules: Apply
rules with Agent (small edits, up to 8 a run) and Rewrite the page to
these rules (the whole page as one change). The rewrite is recommended,
with a one-line reason, when the page is more than 30% off its Length or
4 rules or more are open.

A rewritten page comes back as one suggestion with its own bar over the
page: the characters before and after and the agent's reason, Compare
(the page and the rewrite side by side), Accept (History keeps the page
first), Reject, and Undo. A page that changed since the agent read it
isn't written over. The page waits for the rewrite with its own steps,
and a failed rewrite's Try again rewrites again.

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

* fix(content): compare a rewrite by its words and run one agent at a time

Review fixes:
- A page is compared with the one the agent read by its words, with a
  space between blocks, so stored line breaks and lists don't read as a
  change (Accept and Undo were refused on imported pages).
- One agent run at a time from the page; a rewrite never starts before
  the locked passages are read, and sends the editor's own locked keys.
- Accept holds the page still from the start and checks it again before
  putting the rewrite in; Undo puts the page back as it was (two H1s too),
  and the bar waits while the HTML view is open.
- No rewrite advice for an empty page or one too long to send whole; the
  rewrite mark survives a reload; the waiting view says the rewrite waits
  in the editor; Compare's links don't navigate.

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

* feat(content): show the Content Agent as a card over the page

Content Editor v1.1, part 1 (CE-025, CE-026, §4): the agent row and the
rewrite bar become one card above the toolbar, in three states:
- waiting: "Content Agent has {n} suggestions for you", what they change
  and the rules they gain ("Rules 5 → 6 of 13"), with Review (scrolls to
  the first suggestion and marks it), Reject all and Accept all; a page
  rewritten shows its characters, with Compare;
- all reviewed: what was accepted and the rules met and still open, with
  Undo all and Run Agent;
- working: while Apply rules with Agent runs.
The tile moves a little (a soft ring, a blink, a spark; a sweep and a
breath while working), never a rotating ring, and not at all with reduced
motion. The card wraps on a narrow page; Accept all and Run Agent are the
primary buttons.

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

* fix(content): agent card review fixes

- Run Agent on the card keeps to one agent run at a time and says why it
  waits; Apply rules never starts beside another run or before the locked
  passages are read.
- Ghost buttons show their hover on the card's grey; the tile and its
  count are hidden from screen readers (the title says it) and the count
  is darker for contrast; "+N more" comes from en.json, the reason's first
  letter is upper-cased in the page's locale.
- Review picks the first open suggestion in the page's order and focuses
  it; the sweep shows on the light tile in dark mode; the spark is slower
  once all are reviewed; without motion the working line is a faint full
  line; "0 still open" isn't said.
- globals.css keeps its own lines; only the motion block is added.

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

* feat(content): put brief and rules under one Instructions tab with a split Run Agent

Content Editor v1.1 part 2 (CE-028–CE-031): the side panel's tabs become
Instructions · Sources · Live page. Instructions holds Brief | Rules, with
the rules still open on the tab and the segment. Each segment opens with a
status card: Rules has one split Run Agent ▾ (Fix open rules, or Rewrite
the whole page, which renames it "Rewrite page") in place of the two rule
buttons; Brief has Run Agent while empty and Rebuild brief once written.
Why the agent can't run is written under the card, and each card's ⓘ tip
opens below it. The brief shows "Not set yet" and its Length in characters
and about as many words; the toolbar counter adds the page's words.

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

* fix(content): instructions tab review fixes

- Run Agent's choice is worked out once and falls back to Fix without a
  rewrite; once a rewrite starts, the button is back on Fix.
- ▾'s choices are menu radio items; Fix is off when only rules the agent
  can't fix are open, and the card says what to do instead.
- The reason line under the card stays mounted for screen readers; Rewrite
  from brief writes its reason too; the tab's count is read out.
- Brief | Rules switch with the arrow keys, one tab stop.
- An edited brief's rebuild question sits under the card; a brief without
  H2s says to rebuild it; an empty brief shows no origin line.
- Plural copy for the open suggestions and the counter's words; rule names
  joined by the formatter; Run Agent's tip leaves ▾ out without a rewrite.

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

* feat(content): show the data the Content Agent writes from

Content Editor v1.1 part 3 (CE-032, CE-034): under each Run Agent card,
"Uses your data: 1 prompt · 21 fan-outs · 20 cited pages · 10 Search
Console queries · Edit sources", counted as the Sources tab keeps them, so
turning one off lowers it at once. The Sources tab carries its count, and
its top says "N sources in use" and when the Content Agent last wrote from
them (its latest suggestions or the brief it built). A first visit's note
at the top of Instructions says the agent writes from the person's data;
closing it is kept in their own user metadata.

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

* fix(content): data note review fixes

- "Last used by Content Agent" also counts the agent writing the page
  (agent_state_at: Start with Agent, Rewrite from brief on a new page),
  not a run that failed; a value that isn't a date is skipped.
- The latest batch's time is its first suggestion's, not a sort per render.
- Tests: the Brief segment's line, no line while the sources can't be read,
  the tab's count, the note showing again after a failed write, and a
  suggestion read with its createdAt.

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

* feat(content): have the Content Agent write from the kept sources and name them

Content Editor v1.1, CE-033 (server): Fix open rules, Start with Agent and
Rewrite the whole page read the sources the Sources tab keeps, numbered
S1, S2… (content-sources.js). Each suggestion keeps the sources it names
and the words each supports (content_draft_suggestions.sources and
source_marks, 00248); a page rewritten whole keeps its sources.

No number without a source: the model reads a source by its words only, so
a number the agent adds must be the page's, the brand's, the brief's, the
rules', today's, or in a source's own words (then marked to it). A
suggestion with any other number is not kept; a page written whole gets a
placeholder in its place. Source numbers written into the words are taken
out.

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

* feat(content): show what each agent suggestion was written from

Content Editor v1.1, CE-033 (web) and the rest of CE-034: under each
suggestion, "Based on" chips name the sources it used (number, kind, name;
the Sources tab's details on hover), and a small number marks the words
each supports. A click on either opens Sources on that row, scrolled to
and ringed for a moment, once. The agent card adds "built from N of your
sources · See sources". Fix open rules sends the kept sources, and the
first-visit note says every change shows the sources it used.

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

* feat(content): write the Content Agent's runs step by step and stop them

Content Editor v1.1, CE-027/035 (server): each Content Agent run (Fix open
rules, Start with Agent, Rewrite the whole page, the brief) is written in
content_agent_runs (00249) with its steps named by the data it reads
("Reading 20 cited pages", "Matching 21 fan-outs", "Writing 3 changes") as
it reaches them. POST /api/content-drafts/:id/stop marks the run stopped
and aborts its model call; the run checks before it keeps anything, so a
stopped run changes nothing (no suggestions, page, brief or History).

A run that can't be written still runs; runs a stopped server left are
closed when the next starts, and Stop ignores them. Background runs are
written before Start answers, so Stop finds them at once.

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

* fix(content): let go of a background draft when its run is stopped

Stop also clears the draft's 'writing' state at once: a background run lets
go once it sees the stop, but one no server holds any more never would, and
the waiting page would wait out the 10 minutes.

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

* feat(content): show the content agent's steps while it works, and stop it (CE-027, CE-035)

The agent card, the brief and the waiting page show the run's real steps
(content_agent_runs, read from the browser every second) and a Stop button
that ends the run through the API proxy, leaving the page as it was. A dashed
decoration under the H1 says where Fix is drafting, and the agent's dots
replace every spinner on its buttons.

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

* feat(content): show the cited pages' length next to the brief's Length (CE-030)

When the brief is rebuilt, the server reads the first few cited pages kept
in Sources (only addresses AI answers cited for the brand, never the draft's
own page), counts their main text as the Rules tab counts length, and saves
the median as brief.citedLength. The Brief tab says "From the rules · cited
pages average N characters"; with fewer than two pages read it stays "From
the rules". textLength moves to page-content.js to avoid an import cycle.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): read a failed rewrite from the draft, and only the latest batch's rows

The editor reads content_drafts.agent_run, so a failed rewrite is tried again
as one on every device (the localStorage mark is gone). Fix open rules' new
409 'writing' says the agent is already writing. getDraftSuggestions finds
the latest batch first and reads only its rows, and Compare's links can't
take focus.

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

* fix(content): say in the agent card why Run Agent won't run

The card's Run Agent writes its reason in the card's second line (amber, tied
to the button by aria-describedby) instead of a hover title, and is turned
off when the only rules left open are ones the agent doesn't fix (one H1),
as the Rules card does.

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

* chore(content): keep AddSourceInput as Prettier formats it

A merge brought in a line formatted by another Prettier version; this puts
back main's formatting, so format:check passes.

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

* fix(content): recommend no Run Agent choice that is turned off

With only One H1 open and no rewrite advice, ▾ no longer shows the disabled
Fix as Recommended.

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

* fix(content): match an added figure by its unit, and read none from dates, addresses or words

A claim (a %, a ×, a scale, a currency) is known only with the same unit or
sign, so a fan-out's "crm for 50 users" no longer sources "50%". Today adds
only its year. A cited page's address is no words of its own. The brand's
name and industry are known, digits stuck to a letter ("B2B", "H2") are no
figure, and a source number written into a reason is taken out.

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

* feat(content): name the agent's steps by the work the server does

Short names for what each run does (CE-027/035): Fix and a rewrite read the
rules, gather the sources (numbered, so a number can be checked), write, and
check what they wrote (a number needs a source, a link must be allowed, a
locked passage stays). The brief gathers, writes the outline and matches
fan-outs. "Reading 20 cited pages" is gone: the agent sees their addresses,
not their content.

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

* fix(content): name the Rules tab's button as it reads now in a test and two lines

A test from main still pressed "Apply rules with Agent", and two messages
still named it; the button is Run Agent, its default Fix open rules.

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

* fix(content): charge a call Stop aborted, end only a run's own claim, and stop the run named

- A Stop that aborts a model call already sent keeps its hold on the AI
  budget as its cost (reserveAiBudget's keep()), since the provider bills
  it; a run stopped before its call sends nothing (runCall).
- A background run ends only the claim it still holds (agent_state_at), so
  one stopped from another server never clears a newer run's.
- A run closes only runs a stopped server left (older than RUN_STALE_MS),
  and /stop takes an optional runId, so another tab's run goes on.

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

* feat(content): show the steps by their new names, and stop the run the editor shows

The step chips read the server's short names (Reading 4 rules, Gathering 52
sources, Writing changes, Checking sources). Stop sends the run's id, so
another tab's run goes on. The waiting page keeps the run's last steps and
reads the draft as soon as its run ends, and a hidden tab reads the run every
AGENT_POLL_MS, then at once when it shows again.

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

* test(content): read the hook's run from what it renders

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

* fix(content): call the cited-page figure the median it is, and stop its reads with the run

The Brief's Length now says "a typical cited page has N characters (median of
M)". A Stop settles the cited-page read on nothing at once: the run's signal
ends each page read (fetchPage takes a signal beside its timeout), so a fast
model answer followed by a Stop never waits on them.

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

* fix(content): show loading without a spinning ring anywhere in Content

Every Loader2 spinner in Content (the editor, Library, Plan, the content
page and its dialogs and menus, the webhook settings) is now LoadingDots:
three dots that bounce in turn, in the text's color, still with reduced
motion, as the Content Editor brief asks ("no spinning ring anywhere"). The
agent's WorkingDots are built on it.

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

* feat(content): read the draft's Readability and show it in Instructions › Quality (CE-036, CE-039)

Quality spec Phase 1, behind NEXT_PUBLIC_CONTENT_QUALITY_PHASE (off unset):
- readability.ts: seven checks read from the draft in the browser, no AI
  cost — average sentence 15–20 words, none over 35, reading level by the
  language's formula (Flesch, Ateşman, Amstad, Kandel–Moles,
  Fernández-Huerta; else sentence and word length), answer first, short
  paragraphs, a heading every 200–300 words, passive voice and jargon
  (English). A check a language can't be read for is left out and the
  score rescaled to 100.
- Instructions gets a Quality segment: the score with its band (80+
  Strong, 60–79 Can improve, under 60 Needs work), "Ansvisor estimates
  based on Google's published quality signals. Not a Google score.", and
  what would raise it, the biggest gain first, with Show.
- The header gets a "Quality {score}" chip that opens it.

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

* fix(content): read Readability from the page's own blocks, and show a passage by its block

- A quote's and a list item's paragraphs are read apart (the editor's HTML
  has no space between tags) and a nested list once; sentence length is
  measured on running text, a list's points aside, and a page of short
  sentences is asked to join some.
- Fernández-Huerta subtracts words per sentence (the corrected form).
- Answer first skips an empty line, fails without an H1, and reads an H1's
  subject without its question and common words.
- Abbreviations don't end a sentence; "-ted" keeps its syllable, French
  "-ent" is no silent ending, Turkish â î û are vowels; "is indeed" isn't
  passive, jargon is read in all its forms, and Show goes to what falls short.
- Show finds the passage's block in the page (never a suggestion's card)
  and marks it with a decoration; the band is read out with the chip and
  the segment's badge.

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

* fix(content): count a passive sentence that says not or never in Readability

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

* feat(content): add Settings › Authors, the real people a page is by (CE-037)

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

* fix(content): let whoever added an author edit it, link only yourself, and renumber to 00251

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

* feat(content): name the page's author in the editor's header and a Page info strip outside the page (CE-038)

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

* fix(content): keep the Page info strip right under the H1, count authors' pages only in Settings

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

* fix(content): draw the Page info strip as the mockup's one line, with the author's face and title at the brand

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

* feat(content): score E-E-A-T from the page's author and Trust from the agent's sourced claims in Quality (CE-039)

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

* fix(content): score only checks that can fail: no Trust and no author schema until they read the page

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

* fix(content): say only what an author's profile is missing in Quality

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

* feat(content): read a draft's links once a day for Trust: working or broken, and their page's date

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

* fix(content): read only a saved draft's links, a few at a time and within a budget, and date pages by their own entity

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

* feat(content): score Trust from the page's sourced figures, fresh sources and working links (CE-039)

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

* fix(content): reserve link reads up front, say which links are never read, and date an article before its page

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

* fix(content): compare links as the draft saves them, count each link and sentence once, and read prices and sizes as no figures

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

* feat(audit): read a brand's site trust: About, Contact, editorial policy, Organization schema and author pages (CE-043)

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

* fix(audit): read site trust in parallel and once per brand, tell a page from the home page, and re-read a partial read soon

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

* feat(audit): show Site trust n/5 in Site Audit, and count it in Quality's Trust (CE-043)

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

* fix(audit): scroll to Site trust from Quality, keep it per brand, say when checking again fails, and count it only beside the page's own Trust

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

* fix(audit): give the Site trust card its own key beside the auto-run notice

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

* feat(content): list what only you can do in Quality, and nudge the next one (CE-040)

Your to-dos in Instructions › Quality: picking the page's author (or adding
one) and completing their profile move out of the suggestions, with a box
the checks tick and E-E-A-T's gain. A dark "Next for you" pill names the
first open one when the agent's run ends (not a failed or stopped one),
when the last open suggestion is accepted (Accept all, one by one, or the
page rewrite) and on Mark ready, once per moment and to-do in the session;
Later hides it. Its words go to a status kept on the page for screen
readers.

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

* feat(content): check the page before it's marked ready, with its JSON-LD to paste (CE-041)

Before you publish opens on Mark ready once Quality is live: a warning
only when Trust is under 60 (the check that raises it most, and to about
what), a note while the page's links are still being read, what the CMS
does for the page (author, visible dates, schema), and for an article an
Article JSON-LD from the title, author, brand, its image and today's date
(Person with sameAs, or the brand's Organization; no author while the
authors aren't read; a live page keeps its published date) with Copy
JSON-LD. Fix first goes to Quality and puts the caret at the passage.
Mark ready anyway is logged with the page's Trust and the check named
(00255 content_draft_ready_log: members add rows as themselves for a
ready draft, three columns only). useLinkChecks also says how many reads
may still come.

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

* feat(content): keep the Content Agent from inventing people and quotes (CE-044)

Every person's name and quoted sentence the agent writes is looked up in
what it was given: the page, the brand, the brief, the rules, the
person's data (Sources) and Settings › Authors. One that isn't becomes a
placeholder ("[name of a real person]", "[quote from a real person, with
its source]"): in Fix open rules' and the first optimize's suggestions,
read in their words as written before they are cleaned; in a page
written whole; and in a rewrite before what it kept goes back, so the
page's own passages are never touched.

A name is read where a person is plainly meant: an honorific, a role
("CEO Jane Doe", "Jane Doe, head of sales", "Jane Doe (CEO)"), or speech
("Jane Doe said", "according to Jane Doe", "Ayşe Yılmaz'a göre"); a
known author stays with the words before it, and a heading is read for
quotes and speech only. A quote is two words or more in quotation marks
next to speech, four or more anywhere, or a blockquote or <q> (its cite
read for the name), across the bold and the links in a line. One reading
per word keeps long text fast.

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

* feat(content): list the placeholders the agent left as the first to-do (CE-044)

Your to-dos in Quality now opens with "Fill {n} placeholders" while the
page has words in square brackets (what the agent leaves where it had no
real name, quote or number), with Show on the first. The Next for you
nudge names it too ("Show now"). Only the person can fill them; an export
never ships one (CE-057).

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

* feat(content): export the page ready to paste, with its page fields (CE-057)

Export, once Quality is live, asks where the page goes: Webflow,
WordPress, Shopify or Google Docs (copied as rich text to paste in; the
CMSs' H1 left out for their title field), Word or Markdown (downloaded),
or HTML. It shows the page as it was when it opened.

No export carries a placeholder. Fill now selects the first (in the HTML
view's text too, or says it is in an HTML block); Export without them
leaves out the sentences they are in, read as a reader would ("1.5",
"e.g." and "acme.com" end none), one outside a line, in alt text or in
JSON-LD alone. One in the title or a heading is filled first. Copy HTML
sends a page with one to Export too.

It lists what it checks (clean HTML or the HTML blocks' own code, the
links that answer or couldn't be read, the images' alt text) and the
page fields, read from the page as it goes out (its title, first
paragraph, live address or title as a slug, author, first image), each
with Copy. Word gets them as a table on page 1, Markdown as front matter
(with the date, the title not again as an H1), HTML in its head.

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

* fix(content): count a link the site refused as unread, and the title's placeholder once

Trust's link reads say "unknown" when a site refused the read or timed
out (a bot wall, a 403): Export no longer counts such a link as read, so
it never says the links answer for one that wasn't. A title that is the
page's H1 has its placeholders counted with the page, not twice.

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

* fix(content): keep the loading dots visible with reduced motion

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

* fix(content): check author profile links in the table, unlink a removed member and revoke anon

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

* fix(content): let a Stop go only of the claim the stopped run holds

A Stop that named a Fix or brief run cleared agent_state whatever the run
was, so a Start or Rewrite on the same draft went on without its claim.
Each run now carries the claim it holds (content_agent_runs.claimed_at,
00249), stopDraftRun answers it, and the route clears agent_state only
where agent_state_at is still that claim.

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

* fix(content): say in the Remove dialog that the author's pages go back to the team byline

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

* fix(content): date a page over the read cap from its start, and count a private-address link as broken

fetchPage gets an opt-in truncate that resolves with the first maxBytes
instead of refusing the page, and the link check uses it, so a large
article page still gives its date and stays working. A link the fetch
refuses as a private or local address reads as broken, since no reader
of the published page can open it; a non-standard port stays unknown.

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

* fix(content): offer Edit author in Quality only to who can edit that author, and say who can otherwise

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

* fix(content): read discounts, materials and short forms as no figures, and score Trust only with a figure or a dated source

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

* fix(audit): read a bot wall as unsure, read a walled home page through Scrape.do once a day, and look for author pages at the usual addresses

A 401/403/429, or a 200 challenge page, now leaves the read incomplete
instead of failing About, Contact, Editorial or Organization schema for a
day (looksBlocked from site-pages.js). A walled home page goes through
Scrape.do, unrendered, at most once a day per brand (site_trust.scraped_at),
and a pass it read stands for that day while the wall hides the page.
An author the page list has no page for is looked for at /author/<slug>
and /authors/<slug> (a few authors per read), with the probes' guards and
their name in the title or H1. readSiteTrust returns complete, so the web
can tell a partial read from a fix to make.

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

* fix(audit): hold Check again until the read can change, say when the site didn't answer, and say Site trust counts in Quality

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

* fix(content): leave a placeholder title out of the JSON-LD headline, and say why

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

* chore(content): move Show's doc comment back onto showInPage

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

* fix(content): read Readability in the draft's language, and split its sentences where they end

- Japanese, Chinese and Thai, written without spaces between words, get no
  score: Quality says "Readability isn't read for this language yet"
  instead of asking for more paragraphs. Sentences also end after 。!?,
  । and ؟, and a Hindi word keeps its vowel signs, so Hindi is read by its
  own sentences and words.
- The language is the draft's Language rule when it is on, else the
  brand's; every brand language's name is read ("Portuguese", "Brazilian
  Portuguese", "日本語"…).
- A sentence doesn't end before a lower-case word, nor at a German or
  Turkish ordinal ("am 3. Oktober") or a language's common abbreviations
  ("z. B.", "p. ex.", "örn."); one before a number only ("No. 5") counts
  there. A full stop before a closing quote or bracket ends one.
- Show goes to the first copy of a passage, and a second Show within the
  moment keeps its mark for the full time.
- Passive voice reads common irregular participles (sent, found, held…).

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

* fix(content): know a name only as whole words, read a bare name only with a verb said of people, and run on without the authors

isKnown matched names as substrings of what the agent was given, so
"Dr. Sarah Chen" passed on a page with "kitchen" and "Mr. Doe" on one
with "does". Both sides are now compared as whole words. A name without
an honorific or role is read only with said, told, explained, recalled,
admitted, insisted or argued (and German sagte, Turkish söyledi), so
"Google Ads recommends" or "according to Google Analytics" no longer
become name placeholders. authorWords logs a failed read (content_authors
not there yet) and reads as no author words instead of failing the run.

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

* fix(content): read the page for export in a document of its own, and JSON-LD by its strings

Export reads the page in a document of its own, so nothing in it loads or
runs. A JSON-LD is read by its string values: its arrays are no placeholders,
and Export without them clears the strings and keeps it valid JSON. In a
title or a heading only the agent's own placeholder forms hold the export,
so "Best CRM tools [2026 Update]" goes out as written. A live page's
Markdown front matter gets lastmod instead of date, and the draftHtmlDocument
comment is back on its function.

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

* fix(content): offer Edit author on the profile to-do only to who can edit the author

#1414's review fix moved here: the to-dos replaced E-E-A-T's suggestions,
so the to-do now carries the rule (whoever added the author, the author
themself or an admin) and tells anyone else who can.

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

* refactor(content): read the title's placeholder with the shared pattern

#1420 kept its own copy while placeholders.ts wasn't below it; now it is.

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

* test(content): expect the dated source line's corrected plural

#1416's review fix reads "1 of 1 dated source is over 24 months old".

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

* fix(content): pass the nudge whether the member can edit the author

Its to-do text names who can complete the profile when they can't.

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

* test(content): give Before you publish's quality read whether the member can edit the author

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

* chore(content): type the agent run's claimed_at

#1400 adds the column to 00249.

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]>
gkhngyk added a commit that referenced this pull request Oct 23, 2026
…w (CE-057) (#1426)

* feat(billing): show this period's AI usage on the Billing page

The workspace's one AI budget (Improve, the Content Editor's AI and the
Action Center's task writer) had no meter: the first sign of it was an
"AI usage is used up" error. Migration 00242 records what each AI call
was for (prompt_improve_usage.feature, backfilled) and sums the period's
spend by feature (ai_usage_by_feature). GET /api/billing/ai-usage
returns the shares of the plan's budget, and the Billing page shows the
share used, when it resets and what used it, with Agent Chat noted as
running on the workspace's own key.

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

* fix(billing): hold an AI call's share of the budget before it runs

The workspace's AI budget was checked by reading the period's spend; the
call's cost was written once the model answered. Calls running at once
(two tabs, a teammate, an Action Center sweep) all read the same spend
and all ran past the budget. 00243's reserve_ai_usage takes a
per-organization lock, reads the spend with the calls in flight, and
holds the call's estimated cost; reserveAiBudget turns the hold into the
real cost or releases it. Improve, the brief rebuild, Apply rules with
Agent, Start Agent and the Action Center task writer use it in place of
enforceImproveQuota, which goes.

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

* fix(billing): charge a schema miss and hold the org's recent median cost

Review fixes:
- Apply rules with Agent and Start Agent charge an answer the provider
  billed but that missed the schema (NoObjectGeneratedError), as Improve,
  the brief and the task writer do; before, the hold was let go and the
  call ran free.
- A call holds the org's median cost over its last 20 calls this period,
  never less than the model's typical cost, so calls in flight pass the
  budget by far less.

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

* feat(content): rewrite a whole page to its rules as one suggestion

Apply rules with Agent makes at most 8 small edits a run, which can't
bring a long page to its Length (about 2% a run on prod). The Content
Agent can now rewrite the whole page in one background call, left as ONE
suggestion (kind 'page', migration 00247) to compare and accept or reject:
- POST /api/content-drafts/:draftId/rewrite, through Start Agent's claim,
  budget hold and background run;
- passages AI quotes today, tables, images, quotes and HTML blocks go to
  the model as [[KEEP n]] lines and come back as they were; a rewrite that
  drops one fails the run;
- one H1, only the page's own links and the ones offered, the editor's
  tags; the page as it was is kept on the suggestion (before_html).

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

* fix(content): describe a rewrite's kept blocks and count them toward Length

Review fixes:
- Kept blocks are described under the page (a quoted passage's words, a
  table's rows, an image's alt) and their text counts toward Length, so a
  rewrite aims at the whole page's length; with Length off it keeps the
  page's own. A kept H1 stays first, and the page's language is kept.
- The answer is taken out of a code fence, text left at its root goes in
  paragraphs, and an answer in Markdown fails the run.
- The page's own links stay exactly as written (query and anchor too).
- Kept blocks go back untouched (an empty table cell stays), only the
  page's first H1 counts as its title, a page that writes "[[KEEP" gets
  markers of its own, and a page that is only kept blocks isn't sent.

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

* feat(content): rewrite the page to its rules from the Rules tab, and compare it

The Rules tab opens with the agent's two ways to meet its rules: Apply
rules with Agent (small edits, up to 8 a run) and Rewrite the page to
these rules (the whole page as one change). The rewrite is recommended,
with a one-line reason, when the page is more than 30% off its Length or
4 rules or more are open.

A rewritten page comes back as one suggestion with its own bar over the
page: the characters before and after and the agent's reason, Compare
(the page and the rewrite side by side), Accept (History keeps the page
first), Reject, and Undo. A page that changed since the agent read it
isn't written over. The page waits for the rewrite with its own steps,
and a failed rewrite's Try again rewrites again.

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

* fix(content): compare a rewrite by its words and run one agent at a time

Review fixes:
- A page is compared with the one the agent read by its words, with a
  space between blocks, so stored line breaks and lists don't read as a
  change (Accept and Undo were refused on imported pages).
- One agent run at a time from the page; a rewrite never starts before
  the locked passages are read, and sends the editor's own locked keys.
- Accept holds the page still from the start and checks it again before
  putting the rewrite in; Undo puts the page back as it was (two H1s too),
  and the bar waits while the HTML view is open.
- No rewrite advice for an empty page or one too long to send whole; the
  rewrite mark survives a reload; the waiting view says the rewrite waits
  in the editor; Compare's links don't navigate.

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

* feat(content): show the Content Agent as a card over the page

Content Editor v1.1, part 1 (CE-025, CE-026, §4): the agent row and the
rewrite bar become one card above the toolbar, in three states:
- waiting: "Content Agent has {n} suggestions for you", what they change
  and the rules they gain ("Rules 5 → 6 of 13"), with Review (scrolls to
  the first suggestion and marks it), Reject all and Accept all; a page
  rewritten shows its characters, with Compare;
- all reviewed: what was accepted and the rules met and still open, with
  Undo all and Run Agent;
- working: while Apply rules with Agent runs.
The tile moves a little (a soft ring, a blink, a spark; a sweep and a
breath while working), never a rotating ring, and not at all with reduced
motion. The card wraps on a narrow page; Accept all and Run Agent are the
primary buttons.

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

* fix(content): agent card review fixes

- Run Agent on the card keeps to one agent run at a time and says why it
  waits; Apply rules never starts beside another run or before the locked
  passages are read.
- Ghost buttons show their hover on the card's grey; the tile and its
  count are hidden from screen readers (the title says it) and the count
  is darker for contrast; "+N more" comes from en.json, the reason's first
  letter is upper-cased in the page's locale.
- Review picks the first open suggestion in the page's order and focuses
  it; the sweep shows on the light tile in dark mode; the spark is slower
  once all are reviewed; without motion the working line is a faint full
  line; "0 still open" isn't said.
- globals.css keeps its own lines; only the motion block is added.

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

* feat(content): put brief and rules under one Instructions tab with a split Run Agent

Content Editor v1.1 part 2 (CE-028–CE-031): the side panel's tabs become
Instructions · Sources · Live page. Instructions holds Brief | Rules, with
the rules still open on the tab and the segment. Each segment opens with a
status card: Rules has one split Run Agent ▾ (Fix open rules, or Rewrite
the whole page, which renames it "Rewrite page") in place of the two rule
buttons; Brief has Run Agent while empty and Rebuild brief once written.
Why the agent can't run is written under the card, and each card's ⓘ tip
opens below it. The brief shows "Not set yet" and its Length in characters
and about as many words; the toolbar counter adds the page's words.

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

* fix(content): instructions tab review fixes

- Run Agent's choice is worked out once and falls back to Fix without a
  rewrite; once a rewrite starts, the button is back on Fix.
- ▾'s choices are menu radio items; Fix is off when only rules the agent
  can't fix are open, and the card says what to do instead.
- The reason line under the card stays mounted for screen readers; Rewrite
  from brief writes its reason too; the tab's count is read out.
- Brief | Rules switch with the arrow keys, one tab stop.
- An edited brief's rebuild question sits under the card; a brief without
  H2s says to rebuild it; an empty brief shows no origin line.
- Plural copy for the open suggestions and the counter's words; rule names
  joined by the formatter; Run Agent's tip leaves ▾ out without a rewrite.

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

* feat(content): show the data the Content Agent writes from

Content Editor v1.1 part 3 (CE-032, CE-034): under each Run Agent card,
"Uses your data: 1 prompt · 21 fan-outs · 20 cited pages · 10 Search
Console queries · Edit sources", counted as the Sources tab keeps them, so
turning one off lowers it at once. The Sources tab carries its count, and
its top says "N sources in use" and when the Content Agent last wrote from
them (its latest suggestions or the brief it built). A first visit's note
at the top of Instructions says the agent writes from the person's data;
closing it is kept in their own user metadata.

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

* fix(content): data note review fixes

- "Last used by Content Agent" also counts the agent writing the page
  (agent_state_at: Start with Agent, Rewrite from brief on a new page),
  not a run that failed; a value that isn't a date is skipped.
- The latest batch's time is its first suggestion's, not a sort per render.
- Tests: the Brief segment's line, no line while the sources can't be read,
  the tab's count, the note showing again after a failed write, and a
  suggestion read with its createdAt.

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

* feat(content): have the Content Agent write from the kept sources and name them

Content Editor v1.1, CE-033 (server): Fix open rules, Start with Agent and
Rewrite the whole page read the sources the Sources tab keeps, numbered
S1, S2… (content-sources.js). Each suggestion keeps the sources it names
and the words each supports (content_draft_suggestions.sources and
source_marks, 00248); a page rewritten whole keeps its sources.

No number without a source: the model reads a source by its words only, so
a number the agent adds must be the page's, the brand's, the brief's, the
rules', today's, or in a source's own words (then marked to it). A
suggestion with any other number is not kept; a page written whole gets a
placeholder in its place. Source numbers written into the words are taken
out.

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

* feat(content): show what each agent suggestion was written from

Content Editor v1.1, CE-033 (web) and the rest of CE-034: under each
suggestion, "Based on" chips name the sources it used (number, kind, name;
the Sources tab's details on hover), and a small number marks the words
each supports. A click on either opens Sources on that row, scrolled to
and ringed for a moment, once. The agent card adds "built from N of your
sources · See sources". Fix open rules sends the kept sources, and the
first-visit note says every change shows the sources it used.

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

* feat(content): write the Content Agent's runs step by step and stop them

Content Editor v1.1, CE-027/035 (server): each Content Agent run (Fix open
rules, Start with Agent, Rewrite the whole page, the brief) is written in
content_agent_runs (00249) with its steps named by the data it reads
("Reading 20 cited pages", "Matching 21 fan-outs", "Writing 3 changes") as
it reaches them. POST /api/content-drafts/:id/stop marks the run stopped
and aborts its model call; the run checks before it keeps anything, so a
stopped run changes nothing (no suggestions, page, brief or History).

A run that can't be written still runs; runs a stopped server left are
closed when the next starts, and Stop ignores them. Background runs are
written before Start answers, so Stop finds them at once.

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

* fix(content): let go of a background draft when its run is stopped

Stop also clears the draft's 'writing' state at once: a background run lets
go once it sees the stop, but one no server holds any more never would, and
the waiting page would wait out the 10 minutes.

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

* feat(content): show the content agent's steps while it works, and stop it (CE-027, CE-035)

The agent card, the brief and the waiting page show the run's real steps
(content_agent_runs, read from the browser every second) and a Stop button
that ends the run through the API proxy, leaving the page as it was. A dashed
decoration under the H1 says where Fix is drafting, and the agent's dots
replace every spinner on its buttons.

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

* feat(content): show the cited pages' length next to the brief's Length (CE-030)

When the brief is rebuilt, the server reads the first few cited pages kept
in Sources (only addresses AI answers cited for the brand, never the draft's
own page), counts their main text as the Rules tab counts length, and saves
the median as brief.citedLength. The Brief tab says "From the rules · cited
pages average N characters"; with fewer than two pages read it stays "From
the rules". textLength moves to page-content.js to avoid an import cycle.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): read a failed rewrite from the draft, and only the latest batch's rows

The editor reads content_drafts.agent_run, so a failed rewrite is tried again
as one on every device (the localStorage mark is gone). Fix open rules' new
409 'writing' says the agent is already writing. getDraftSuggestions finds
the latest batch first and reads only its rows, and Compare's links can't
take focus.

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

* fix(content): say in the agent card why Run Agent won't run

The card's Run Agent writes its reason in the card's second line (amber, tied
to the button by aria-describedby) instead of a hover title, and is turned
off when the only rules left open are ones the agent doesn't fix (one H1),
as the Rules card does.

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

* chore(content): keep AddSourceInput as Prettier formats it

A merge brought in a line formatted by another Prettier version; this puts
back main's formatting, so format:check passes.

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

* fix(content): recommend no Run Agent choice that is turned off

With only One H1 open and no rewrite advice, ▾ no longer shows the disabled
Fix as Recommended.

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

* fix(content): match an added figure by its unit, and read none from dates, addresses or words

A claim (a %, a ×, a scale, a currency) is known only with the same unit or
sign, so a fan-out's "crm for 50 users" no longer sources "50%". Today adds
only its year. A cited page's address is no words of its own. The brand's
name and industry are known, digits stuck to a letter ("B2B", "H2") are no
figure, and a source number written into a reason is taken out.

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

* feat(content): name the agent's steps by the work the server does

Short names for what each run does (CE-027/035): Fix and a rewrite read the
rules, gather the sources (numbered, so a number can be checked), write, and
check what they wrote (a number needs a source, a link must be allowed, a
locked passage stays). The brief gathers, writes the outline and matches
fan-outs. "Reading 20 cited pages" is gone: the agent sees their addresses,
not their content.

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

* fix(content): name the Rules tab's button as it reads now in a test and two lines

A test from main still pressed "Apply rules with Agent", and two messages
still named it; the button is Run Agent, its default Fix open rules.

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

* fix(content): charge a call Stop aborted, end only a run's own claim, and stop the run named

- A Stop that aborts a model call already sent keeps its hold on the AI
  budget as its cost (reserveAiBudget's keep()), since the provider bills
  it; a run stopped before its call sends nothing (runCall).
- A background run ends only the claim it still holds (agent_state_at), so
  one stopped from another server never clears a newer run's.
- A run closes only runs a stopped server left (older than RUN_STALE_MS),
  and /stop takes an optional runId, so another tab's run goes on.

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

* feat(content): show the steps by their new names, and stop the run the editor shows

The step chips read the server's short names (Reading 4 rules, Gathering 52
sources, Writing changes, Checking sources). Stop sends the run's id, so
another tab's run goes on. The waiting page keeps the run's last steps and
reads the draft as soon as its run ends, and a hidden tab reads the run every
AGENT_POLL_MS, then at once when it shows again.

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

* test(content): read the hook's run from what it renders

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

* fix(content): call the cited-page figure the median it is, and stop its reads with the run

The Brief's Length now says "a typical cited page has N characters (median of
M)". A Stop settles the cited-page read on nothing at once: the run's signal
ends each page read (fetchPage takes a signal beside its timeout), so a fast
model answer followed by a Stop never waits on them.

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

* fix(content): show loading without a spinning ring anywhere in Content

Every Loader2 spinner in Content (the editor, Library, Plan, the content
page and its dialogs and menus, the webhook settings) is now LoadingDots:
three dots that bounce in turn, in the text's color, still with reduced
motion, as the Content Editor brief asks ("no spinning ring anywhere"). The
agent's WorkingDots are built on it.

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

* feat(content): read the draft's Readability and show it in Instructions › Quality (CE-036, CE-039)

Quality spec Phase 1, behind NEXT_PUBLIC_CONTENT_QUALITY_PHASE (off unset):
- readability.ts: seven checks read from the draft in the browser, no AI
  cost — average sentence 15–20 words, none over 35, reading level by the
  language's formula (Flesch, Ateşman, Amstad, Kandel–Moles,
  Fernández-Huerta; else sentence and word length), answer first, short
  paragraphs, a heading every 200–300 words, passive voice and jargon
  (English). A check a language can't be read for is left out and the
  score rescaled to 100.
- Instructions gets a Quality segment: the score with its band (80+
  Strong, 60–79 Can improve, under 60 Needs work), "Ansvisor estimates
  based on Google's published quality signals. Not a Google score.", and
  what would raise it, the biggest gain first, with Show.
- The header gets a "Quality {score}" chip that opens it.

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

* fix(content): read Readability from the page's own blocks, and show a passage by its block

- A quote's and a list item's paragraphs are read apart (the editor's HTML
  has no space between tags) and a nested list once; sentence length is
  measured on running text, a list's points aside, and a page of short
  sentences is asked to join some.
- Fernández-Huerta subtracts words per sentence (the corrected form).
- Answer first skips an empty line, fails without an H1, and reads an H1's
  subject without its question and common words.
- Abbreviations don't end a sentence; "-ted" keeps its syllable, French
  "-ent" is no silent ending, Turkish â î û are vowels; "is indeed" isn't
  passive, jargon is read in all its forms, and Show goes to what falls short.
- Show finds the passage's block in the page (never a suggestion's card)
  and marks it with a decoration; the band is read out with the chip and
  the segment's badge.

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

* fix(content): count a passive sentence that says not or never in Readability

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

* feat(content): add Settings › Authors, the real people a page is by (CE-037)

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

* fix(content): let whoever added an author edit it, link only yourself, and renumber to 00251

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

* feat(content): name the page's author in the editor's header and a Page info strip outside the page (CE-038)

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

* fix(content): keep the Page info strip right under the H1, count authors' pages only in Settings

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

* fix(content): draw the Page info strip as the mockup's one line, with the author's face and title at the brand

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

* feat(content): score E-E-A-T from the page's author and Trust from the agent's sourced claims in Quality (CE-039)

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

* fix(content): score only checks that can fail: no Trust and no author schema until they read the page

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

* fix(content): say only what an author's profile is missing in Quality

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

* feat(content): read a draft's links once a day for Trust: working or broken, and their page's date

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

* fix(content): read only a saved draft's links, a few at a time and within a budget, and date pages by their own entity

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

* feat(content): score Trust from the page's sourced figures, fresh sources and working links (CE-039)

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

* fix(content): reserve link reads up front, say which links are never read, and date an article before its page

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

* fix(content): compare links as the draft saves them, count each link and sentence once, and read prices and sizes as no figures

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

* feat(audit): read a brand's site trust: About, Contact, editorial policy, Organization schema and author pages (CE-043)

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

* fix(audit): read site trust in parallel and once per brand, tell a page from the home page, and re-read a partial read soon

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

* feat(audit): show Site trust n/5 in Site Audit, and count it in Quality's Trust (CE-043)

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

* fix(audit): scroll to Site trust from Quality, keep it per brand, say when checking again fails, and count it only beside the page's own Trust

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

* fix(audit): give the Site trust card its own key beside the auto-run notice

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

* feat(content): list what only you can do in Quality, and nudge the next one (CE-040)

Your to-dos in Instructions › Quality: picking the page's author (or adding
one) and completing their profile move out of the suggestions, with a box
the checks tick and E-E-A-T's gain. A dark "Next for you" pill names the
first open one when the agent's run ends (not a failed or stopped one),
when the last open suggestion is accepted (Accept all, one by one, or the
page rewrite) and on Mark ready, once per moment and to-do in the session;
Later hides it. Its words go to a status kept on the page for screen
readers.

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

* feat(content): check the page before it's marked ready, with its JSON-LD to paste (CE-041)

Before you publish opens on Mark ready once Quality is live: a warning
only when Trust is under 60 (the check that raises it most, and to about
what), a note while the page's links are still being read, what the CMS
does for the page (author, visible dates, schema), and for an article an
Article JSON-LD from the title, author, brand, its image and today's date
(Person with sameAs, or the brand's Organization; no author while the
authors aren't read; a live page keeps its published date) with Copy
JSON-LD. Fix first goes to Quality and puts the caret at the passage.
Mark ready anyway is logged with the page's Trust and the check named
(00255 content_draft_ready_log: members add rows as themselves for a
ready draft, three columns only). useLinkChecks also says how many reads
may still come.

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

* feat(content): keep the Content Agent from inventing people and quotes (CE-044)

Every person's name and quoted sentence the agent writes is looked up in
what it was given: the page, the brand, the brief, the rules, the
person's data (Sources) and Settings › Authors. One that isn't becomes a
placeholder ("[name of a real person]", "[quote from a real person, with
its source]"): in Fix open rules' and the first optimize's suggestions,
read in their words as written before they are cleaned; in a page
written whole; and in a rewrite before what it kept goes back, so the
page's own passages are never touched.

A name is read where a person is plainly meant: an honorific, a role
("CEO Jane Doe", "Jane Doe, head of sales", "Jane Doe (CEO)"), or speech
("Jane Doe said", "according to Jane Doe", "Ayşe Yılmaz'a göre"); a
known author stays with the words before it, and a heading is read for
quotes and speech only. A quote is two words or more in quotation marks
next to speech, four or more anywhere, or a blockquote or <q> (its cite
read for the name), across the bold and the links in a line. One reading
per word keeps long text fast.

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

* feat(content): list the placeholders the agent left as the first to-do (CE-044)

Your to-dos in Quality now opens with "Fill {n} placeholders" while the
page has words in square brackets (what the agent leaves where it had no
real name, quote or number), with Show on the first. The Next for you
nudge names it too ("Show now"). Only the person can fill them; an export
never ships one (CE-057).

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

* feat(content): export the page ready to paste, with its page fields (CE-057)

Export, once Quality is live, asks where the page goes: Webflow,
WordPress, Shopify or Google Docs (copied as rich text to paste in; the
CMSs' H1 left out for their title field), Word or Markdown (downloaded),
or HTML. It shows the page as it was when it opened.

No export carries a placeholder. Fill now selects the first (in the HTML
view's text too, or says it is in an HTML block); Export without them
leaves out the sentences they are in, read as a reader would ("1.5",
"e.g." and "acme.com" end none), one outside a line, in alt text or in
JSON-LD alone. One in the title or a heading is filled first. Copy HTML
sends a page with one to Export too.

It lists what it checks (clean HTML or the HTML blocks' own code, the
links that answer or couldn't be read, the images' alt text) and the
page fields, read from the page as it goes out (its title, first
paragraph, live address or title as a slug, author, first image), each
with Copy. Word gets them as a table on page 1, Markdown as front matter
(with the date, the title not again as an H1), HTML in its head.

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

* fix(content): count a link the site refused as unread, and the title's placeholder once

Trust's link reads say "unknown" when a site refused the read or timed
out (a bot wall, a 403): Export no longer counts such a link as read, so
it never says the links answer for one that wasn't. A title that is the
page's H1 has its placeholders counted with the page, not twice.

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

* feat(content): check the page before Export, with a Ready to paste row (CE-057)

Before you publish now opens on Export too (§7), then goes on to Export
with Continue to export; its Trust warning says the page can be exported
anyway, and nothing is logged. On Mark ready and on Export alike, a last
row reads Ready to paste: no placeholders, every image with alt text,
every link working; what is still open is named ("2 placeholders still
open · 1 image has no alt text"), and links that weren't read are said
to be unchecked, never to work. It is read from the page as it is when
the dialog opens.

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

* fix(content): keep the loading dots visible with reduced motion

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

* fix(content): check author profile links in the table, unlink a removed member and revoke anon

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

* fix(content): let a Stop go only of the claim the stopped run holds

A Stop that named a Fix or brief run cleared agent_state whatever the run
was, so a Start or Rewrite on the same draft went on without its claim.
Each run now carries the claim it holds (content_agent_runs.claimed_at,
00249), stopDraftRun answers it, and the route clears agent_state only
where agent_state_at is still that claim.

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

* fix(content): say in the Remove dialog that the author's pages go back to the team byline

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

* fix(content): date a page over the read cap from its start, and count a private-address link as broken

fetchPage gets an opt-in truncate that resolves with the first maxBytes
instead of refusing the page, and the link check uses it, so a large
article page still gives its date and stays working. A link the fetch
refuses as a private or local address reads as broken, since no reader
of the published page can open it; a non-standard port stays unknown.

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

* fix(content): offer Edit author in Quality only to who can edit that author, and say who can otherwise

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

* fix(content): read discounts, materials and short forms as no figures, and score Trust only with a figure or a dated source

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

* fix(audit): read a bot wall as unsure, read a walled home page through Scrape.do once a day, and look for author pages at the usual addresses

A 401/403/429, or a 200 challenge page, now leaves the read incomplete
instead of failing About, Contact, Editorial or Organization schema for a
day (looksBlocked from site-pages.js). A walled home page goes through
Scrape.do, unrendered, at most once a day per brand (site_trust.scraped_at),
and a pass it read stands for that day while the wall hides the page.
An author the page list has no page for is looked for at /author/<slug>
and /authors/<slug> (a few authors per read), with the probes' guards and
their name in the title or H1. readSiteTrust returns complete, so the web
can tell a partial read from a fix to make.

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

* fix(audit): hold Check again until the read can change, say when the site didn't answer, and say Site trust counts in Quality

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

* fix(content): leave a placeholder title out of the JSON-LD headline, and say why

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

* chore(content): move Show's doc comment back onto showInPage

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

* fix(content): read Readability in the draft's language, and split its sentences where they end

- Japanese, Chinese and Thai, written without spaces between words, get no
  score: Quality says "Readability isn't read for this language yet"
  instead of asking for more paragraphs. Sentences also end after 。!?,
  । and ؟, and a Hindi word keeps its vowel signs, so Hindi is read by its
  own sentences and words.
- The language is the draft's Language rule when it is on, else the
  brand's; every brand language's name is read ("Portuguese", "Brazilian
  Portuguese", "日本語"…).
- A sentence doesn't end before a lower-case word, nor at a German or
  Turkish ordinal ("am 3. Oktober") or a language's common abbreviations
  ("z. B.", "p. ex.", "örn."); one before a number only ("No. 5") counts
  there. A full stop before a closing quote or bracket ends one.
- Show goes to the first copy of a passage, and a second Show within the
  moment keeps its mark for the full time.
- Passive voice reads common irregular participles (sent, found, held…).

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

* fix(content): know a name only as whole words, read a bare name only with a verb said of people, and run on without the authors

isKnown matched names as substrings of what the agent was given, so
"Dr. Sarah Chen" passed on a page with "kitchen" and "Mr. Doe" on one
with "does". Both sides are now compared as whole words. A name without
an honorific or role is read only with said, told, explained, recalled,
admitted, insisted or argued (and German sagte, Turkish söyledi), so
"Google Ads recommends" or "according to Google Analytics" no longer
become name placeholders. authorWords logs a failed read (content_authors
not there yet) and reads as no author words instead of failing the run.

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

* fix(content): read the page for export in a document of its own, and JSON-LD by its strings

Export reads the page in a document of its own, so nothing in it loads or
runs. A JSON-LD is read by its string values: its arrays are no placeholders,
and Export without them clears the strings and keeps it valid JSON. In a
title or a heading only the agent's own placeholder forms hold the export,
so "Best CRM tools [2026 Update]" goes out as written. A live page's
Markdown front matter gets lastmod instead of date, and the draftHtmlDocument
comment is back on its function.

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

* fix(content): offer Edit author on the profile to-do only to who can edit the author

#1414's review fix moved here: the to-dos replaced E-E-A-T's suggestions,
so the to-do now carries the rule (whoever added the author, the author
themself or an admin) and tells anyone else who can.

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

* refactor(content): read the title's placeholder with the shared pattern

#1420 kept its own copy while placeholders.ts wasn't below it; now it is.

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

* test(content): expect the dated source line's corrected plural

#1416's review fix reads "1 of 1 dated source is over 24 months old".

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

* fix(content): read Ready to paste once per change, and fill in the HTML view only where it counts

Ready to paste is read in a useMemo while Before you publish is open, not
on every render. A link still being read is told from one no read is coming
for (a refused read, one past the limit, one in an HTML block). The title's
placeholders count once when any heading or the page's first line reads as
it, H1 or not. In the HTML view, Fill now searches only where the count
reads: tags (but alt and title), styles, other scripts and a JSON-LD's
non-strings are blanked first (blankCode, reused for the byline). A page
test shows a FAQPage's JSON-LD reads Ready to paste as done.

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

* fix(content): pass the nudge whether the member can edit the author

Its to-do text names who can complete the profile when they can't.

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

* test(content): give Before you publish's quality read whether the member can edit the author

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

* chore(content): type the agent run's claimed_at

#1400 adds the column to 00249.

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

* test(content): wait for Before you publish to move focus to Continue to export

The dialog focuses its button after it opens; checking at once failed now
and then under load.

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]>
gkhngyk added a commit that referenced this pull request Oct 23, 2026
…-057) (#1427)

* feat(billing): show this period's AI usage on the Billing page

The workspace's one AI budget (Improve, the Content Editor's AI and the
Action Center's task writer) had no meter: the first sign of it was an
"AI usage is used up" error. Migration 00242 records what each AI call
was for (prompt_improve_usage.feature, backfilled) and sums the period's
spend by feature (ai_usage_by_feature). GET /api/billing/ai-usage
returns the shares of the plan's budget, and the Billing page shows the
share used, when it resets and what used it, with Agent Chat noted as
running on the workspace's own key.

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

* fix(billing): hold an AI call's share of the budget before it runs

The workspace's AI budget was checked by reading the period's spend; the
call's cost was written once the model answered. Calls running at once
(two tabs, a teammate, an Action Center sweep) all read the same spend
and all ran past the budget. 00243's reserve_ai_usage takes a
per-organization lock, reads the spend with the calls in flight, and
holds the call's estimated cost; reserveAiBudget turns the hold into the
real cost or releases it. Improve, the brief rebuild, Apply rules with
Agent, Start Agent and the Action Center task writer use it in place of
enforceImproveQuota, which goes.

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

* fix(billing): charge a schema miss and hold the org's recent median cost

Review fixes:
- Apply rules with Agent and Start Agent charge an answer the provider
  billed but that missed the schema (NoObjectGeneratedError), as Improve,
  the brief and the task writer do; before, the hold was let go and the
  call ran free.
- A call holds the org's median cost over its last 20 calls this period,
  never less than the model's typical cost, so calls in flight pass the
  budget by far less.

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

* feat(content): rewrite a whole page to its rules as one suggestion

Apply rules with Agent makes at most 8 small edits a run, which can't
bring a long page to its Length (about 2% a run on prod). The Content
Agent can now rewrite the whole page in one background call, left as ONE
suggestion (kind 'page', migration 00247) to compare and accept or reject:
- POST /api/content-drafts/:draftId/rewrite, through Start Agent's claim,
  budget hold and background run;
- passages AI quotes today, tables, images, quotes and HTML blocks go to
  the model as [[KEEP n]] lines and come back as they were; a rewrite that
  drops one fails the run;
- one H1, only the page's own links and the ones offered, the editor's
  tags; the page as it was is kept on the suggestion (before_html).

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

* fix(content): describe a rewrite's kept blocks and count them toward Length

Review fixes:
- Kept blocks are described under the page (a quoted passage's words, a
  table's rows, an image's alt) and their text counts toward Length, so a
  rewrite aims at the whole page's length; with Length off it keeps the
  page's own. A kept H1 stays first, and the page's language is kept.
- The answer is taken out of a code fence, text left at its root goes in
  paragraphs, and an answer in Markdown fails the run.
- The page's own links stay exactly as written (query and anchor too).
- Kept blocks go back untouched (an empty table cell stays), only the
  page's first H1 counts as its title, a page that writes "[[KEEP" gets
  markers of its own, and a page that is only kept blocks isn't sent.

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

* feat(content): rewrite the page to its rules from the Rules tab, and compare it

The Rules tab opens with the agent's two ways to meet its rules: Apply
rules with Agent (small edits, up to 8 a run) and Rewrite the page to
these rules (the whole page as one change). The rewrite is recommended,
with a one-line reason, when the page is more than 30% off its Length or
4 rules or more are open.

A rewritten page comes back as one suggestion with its own bar over the
page: the characters before and after and the agent's reason, Compare
(the page and the rewrite side by side), Accept (History keeps the page
first), Reject, and Undo. A page that changed since the agent read it
isn't written over. The page waits for the rewrite with its own steps,
and a failed rewrite's Try again rewrites again.

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

* fix(content): compare a rewrite by its words and run one agent at a time

Review fixes:
- A page is compared with the one the agent read by its words, with a
  space between blocks, so stored line breaks and lists don't read as a
  change (Accept and Undo were refused on imported pages).
- One agent run at a time from the page; a rewrite never starts before
  the locked passages are read, and sends the editor's own locked keys.
- Accept holds the page still from the start and checks it again before
  putting the rewrite in; Undo puts the page back as it was (two H1s too),
  and the bar waits while the HTML view is open.
- No rewrite advice for an empty page or one too long to send whole; the
  rewrite mark survives a reload; the waiting view says the rewrite waits
  in the editor; Compare's links don't navigate.

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

* feat(content): show the Content Agent as a card over the page

Content Editor v1.1, part 1 (CE-025, CE-026, §4): the agent row and the
rewrite bar become one card above the toolbar, in three states:
- waiting: "Content Agent has {n} suggestions for you", what they change
  and the rules they gain ("Rules 5 → 6 of 13"), with Review (scrolls to
  the first suggestion and marks it), Reject all and Accept all; a page
  rewritten shows its characters, with Compare;
- all reviewed: what was accepted and the rules met and still open, with
  Undo all and Run Agent;
- working: while Apply rules with Agent runs.
The tile moves a little (a soft ring, a blink, a spark; a sweep and a
breath while working), never a rotating ring, and not at all with reduced
motion. The card wraps on a narrow page; Accept all and Run Agent are the
primary buttons.

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

* fix(content): agent card review fixes

- Run Agent on the card keeps to one agent run at a time and says why it
  waits; Apply rules never starts beside another run or before the locked
  passages are read.
- Ghost buttons show their hover on the card's grey; the tile and its
  count are hidden from screen readers (the title says it) and the count
  is darker for contrast; "+N more" comes from en.json, the reason's first
  letter is upper-cased in the page's locale.
- Review picks the first open suggestion in the page's order and focuses
  it; the sweep shows on the light tile in dark mode; the spark is slower
  once all are reviewed; without motion the working line is a faint full
  line; "0 still open" isn't said.
- globals.css keeps its own lines; only the motion block is added.

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

* feat(content): put brief and rules under one Instructions tab with a split Run Agent

Content Editor v1.1 part 2 (CE-028–CE-031): the side panel's tabs become
Instructions · Sources · Live page. Instructions holds Brief | Rules, with
the rules still open on the tab and the segment. Each segment opens with a
status card: Rules has one split Run Agent ▾ (Fix open rules, or Rewrite
the whole page, which renames it "Rewrite page") in place of the two rule
buttons; Brief has Run Agent while empty and Rebuild brief once written.
Why the agent can't run is written under the card, and each card's ⓘ tip
opens below it. The brief shows "Not set yet" and its Length in characters
and about as many words; the toolbar counter adds the page's words.

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

* fix(content): instructions tab review fixes

- Run Agent's choice is worked out once and falls back to Fix without a
  rewrite; once a rewrite starts, the button is back on Fix.
- ▾'s choices are menu radio items; Fix is off when only rules the agent
  can't fix are open, and the card says what to do instead.
- The reason line under the card stays mounted for screen readers; Rewrite
  from brief writes its reason too; the tab's count is read out.
- Brief | Rules switch with the arrow keys, one tab stop.
- An edited brief's rebuild question sits under the card; a brief without
  H2s says to rebuild it; an empty brief shows no origin line.
- Plural copy for the open suggestions and the counter's words; rule names
  joined by the formatter; Run Agent's tip leaves ▾ out without a rewrite.

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

* feat(content): show the data the Content Agent writes from

Content Editor v1.1 part 3 (CE-032, CE-034): under each Run Agent card,
"Uses your data: 1 prompt · 21 fan-outs · 20 cited pages · 10 Search
Console queries · Edit sources", counted as the Sources tab keeps them, so
turning one off lowers it at once. The Sources tab carries its count, and
its top says "N sources in use" and when the Content Agent last wrote from
them (its latest suggestions or the brief it built). A first visit's note
at the top of Instructions says the agent writes from the person's data;
closing it is kept in their own user metadata.

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

* fix(content): data note review fixes

- "Last used by Content Agent" also counts the agent writing the page
  (agent_state_at: Start with Agent, Rewrite from brief on a new page),
  not a run that failed; a value that isn't a date is skipped.
- The latest batch's time is its first suggestion's, not a sort per render.
- Tests: the Brief segment's line, no line while the sources can't be read,
  the tab's count, the note showing again after a failed write, and a
  suggestion read with its createdAt.

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

* feat(content): have the Content Agent write from the kept sources and name them

Content Editor v1.1, CE-033 (server): Fix open rules, Start with Agent and
Rewrite the whole page read the sources the Sources tab keeps, numbered
S1, S2… (content-sources.js). Each suggestion keeps the sources it names
and the words each supports (content_draft_suggestions.sources and
source_marks, 00248); a page rewritten whole keeps its sources.

No number without a source: the model reads a source by its words only, so
a number the agent adds must be the page's, the brand's, the brief's, the
rules', today's, or in a source's own words (then marked to it). A
suggestion with any other number is not kept; a page written whole gets a
placeholder in its place. Source numbers written into the words are taken
out.

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

* feat(content): show what each agent suggestion was written from

Content Editor v1.1, CE-033 (web) and the rest of CE-034: under each
suggestion, "Based on" chips name the sources it used (number, kind, name;
the Sources tab's details on hover), and a small number marks the words
each supports. A click on either opens Sources on that row, scrolled to
and ringed for a moment, once. The agent card adds "built from N of your
sources · See sources". Fix open rules sends the kept sources, and the
first-visit note says every change shows the sources it used.

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

* feat(content): write the Content Agent's runs step by step and stop them

Content Editor v1.1, CE-027/035 (server): each Content Agent run (Fix open
rules, Start with Agent, Rewrite the whole page, the brief) is written in
content_agent_runs (00249) with its steps named by the data it reads
("Reading 20 cited pages", "Matching 21 fan-outs", "Writing 3 changes") as
it reaches them. POST /api/content-drafts/:id/stop marks the run stopped
and aborts its model call; the run checks before it keeps anything, so a
stopped run changes nothing (no suggestions, page, brief or History).

A run that can't be written still runs; runs a stopped server left are
closed when the next starts, and Stop ignores them. Background runs are
written before Start answers, so Stop finds them at once.

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

* fix(content): let go of a background draft when its run is stopped

Stop also clears the draft's 'writing' state at once: a background run lets
go once it sees the stop, but one no server holds any more never would, and
the waiting page would wait out the 10 minutes.

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

* feat(content): show the content agent's steps while it works, and stop it (CE-027, CE-035)

The agent card, the brief and the waiting page show the run's real steps
(content_agent_runs, read from the browser every second) and a Stop button
that ends the run through the API proxy, leaving the page as it was. A dashed
decoration under the H1 says where Fix is drafting, and the agent's dots
replace every spinner on its buttons.

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

* feat(content): show the cited pages' length next to the brief's Length (CE-030)

When the brief is rebuilt, the server reads the first few cited pages kept
in Sources (only addresses AI answers cited for the brand, never the draft's
own page), counts their main text as the Rules tab counts length, and saves
the median as brief.citedLength. The Brief tab says "From the rules · cited
pages average N characters"; with fewer than two pages read it stays "From
the rules". textLength moves to page-content.js to avoid an import cycle.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): read a failed rewrite from the draft, and only the latest batch's rows

The editor reads content_drafts.agent_run, so a failed rewrite is tried again
as one on every device (the localStorage mark is gone). Fix open rules' new
409 'writing' says the agent is already writing. getDraftSuggestions finds
the latest batch first and reads only its rows, and Compare's links can't
take focus.

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

* fix(content): say in the agent card why Run Agent won't run

The card's Run Agent writes its reason in the card's second line (amber, tied
to the button by aria-describedby) instead of a hover title, and is turned
off when the only rules left open are ones the agent doesn't fix (one H1),
as the Rules card does.

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

* chore(content): keep AddSourceInput as Prettier formats it

A merge brought in a line formatted by another Prettier version; this puts
back main's formatting, so format:check passes.

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

* fix(content): recommend no Run Agent choice that is turned off

With only One H1 open and no rewrite advice, ▾ no longer shows the disabled
Fix as Recommended.

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

* fix(content): match an added figure by its unit, and read none from dates, addresses or words

A claim (a %, a ×, a scale, a currency) is known only with the same unit or
sign, so a fan-out's "crm for 50 users" no longer sources "50%". Today adds
only its year. A cited page's address is no words of its own. The brand's
name and industry are known, digits stuck to a letter ("B2B", "H2") are no
figure, and a source number written into a reason is taken out.

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

* feat(content): name the agent's steps by the work the server does

Short names for what each run does (CE-027/035): Fix and a rewrite read the
rules, gather the sources (numbered, so a number can be checked), write, and
check what they wrote (a number needs a source, a link must be allowed, a
locked passage stays). The brief gathers, writes the outline and matches
fan-outs. "Reading 20 cited pages" is gone: the agent sees their addresses,
not their content.

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

* fix(content): name the Rules tab's button as it reads now in a test and two lines

A test from main still pressed "Apply rules with Agent", and two messages
still named it; the button is Run Agent, its default Fix open rules.

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

* fix(content): charge a call Stop aborted, end only a run's own claim, and stop the run named

- A Stop that aborts a model call already sent keeps its hold on the AI
  budget as its cost (reserveAiBudget's keep()), since the provider bills
  it; a run stopped before its call sends nothing (runCall).
- A background run ends only the claim it still holds (agent_state_at), so
  one stopped from another server never clears a newer run's.
- A run closes only runs a stopped server left (older than RUN_STALE_MS),
  and /stop takes an optional runId, so another tab's run goes on.

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

* feat(content): show the steps by their new names, and stop the run the editor shows

The step chips read the server's short names (Reading 4 rules, Gathering 52
sources, Writing changes, Checking sources). Stop sends the run's id, so
another tab's run goes on. The waiting page keeps the run's last steps and
reads the draft as soon as its run ends, and a hidden tab reads the run every
AGENT_POLL_MS, then at once when it shows again.

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

* test(content): read the hook's run from what it renders

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

* fix(content): call the cited-page figure the median it is, and stop its reads with the run

The Brief's Length now says "a typical cited page has N characters (median of
M)". A Stop settles the cited-page read on nothing at once: the run's signal
ends each page read (fetchPage takes a signal beside its timeout), so a fast
model answer followed by a Stop never waits on them.

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

* fix(content): show loading without a spinning ring anywhere in Content

Every Loader2 spinner in Content (the editor, Library, Plan, the content
page and its dialogs and menus, the webhook settings) is now LoadingDots:
three dots that bounce in turn, in the text's color, still with reduced
motion, as the Content Editor brief asks ("no spinning ring anywhere"). The
agent's WorkingDots are built on it.

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

* feat(content): read the draft's Readability and show it in Instructions › Quality (CE-036, CE-039)

Quality spec Phase 1, behind NEXT_PUBLIC_CONTENT_QUALITY_PHASE (off unset):
- readability.ts: seven checks read from the draft in the browser, no AI
  cost — average sentence 15–20 words, none over 35, reading level by the
  language's formula (Flesch, Ateşman, Amstad, Kandel–Moles,
  Fernández-Huerta; else sentence and word length), answer first, short
  paragraphs, a heading every 200–300 words, passive voice and jargon
  (English). A check a language can't be read for is left out and the
  score rescaled to 100.
- Instructions gets a Quality segment: the score with its band (80+
  Strong, 60–79 Can improve, under 60 Needs work), "Ansvisor estimates
  based on Google's published quality signals. Not a Google score.", and
  what would raise it, the biggest gain first, with Show.
- The header gets a "Quality {score}" chip that opens it.

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

* fix(content): read Readability from the page's own blocks, and show a passage by its block

- A quote's and a list item's paragraphs are read apart (the editor's HTML
  has no space between tags) and a nested list once; sentence length is
  measured on running text, a list's points aside, and a page of short
  sentences is asked to join some.
- Fernández-Huerta subtracts words per sentence (the corrected form).
- Answer first skips an empty line, fails without an H1, and reads an H1's
  subject without its question and common words.
- Abbreviations don't end a sentence; "-ted" keeps its syllable, French
  "-ent" is no silent ending, Turkish â î û are vowels; "is indeed" isn't
  passive, jargon is read in all its forms, and Show goes to what falls short.
- Show finds the passage's block in the page (never a suggestion's card)
  and marks it with a decoration; the band is read out with the chip and
  the segment's badge.

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

* fix(content): count a passive sentence that says not or never in Readability

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

* feat(content): add Settings › Authors, the real people a page is by (CE-037)

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

* fix(content): let whoever added an author edit it, link only yourself, and renumber to 00251

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

* feat(content): name the page's author in the editor's header and a Page info strip outside the page (CE-038)

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

* fix(content): keep the Page info strip right under the H1, count authors' pages only in Settings

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

* fix(content): draw the Page info strip as the mockup's one line, with the author's face and title at the brand

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

* feat(content): score E-E-A-T from the page's author and Trust from the agent's sourced claims in Quality (CE-039)

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

* fix(content): score only checks that can fail: no Trust and no author schema until they read the page

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

* fix(content): say only what an author's profile is missing in Quality

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

* feat(content): read a draft's links once a day for Trust: working or broken, and their page's date

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

* fix(content): read only a saved draft's links, a few at a time and within a budget, and date pages by their own entity

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

* feat(content): score Trust from the page's sourced figures, fresh sources and working links (CE-039)

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

* fix(content): reserve link reads up front, say which links are never read, and date an article before its page

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

* fix(content): compare links as the draft saves them, count each link and sentence once, and read prices and sizes as no figures

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

* feat(audit): read a brand's site trust: About, Contact, editorial policy, Organization schema and author pages (CE-043)

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

* fix(audit): read site trust in parallel and once per brand, tell a page from the home page, and re-read a partial read soon

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

* feat(audit): show Site trust n/5 in Site Audit, and count it in Quality's Trust (CE-043)

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

* fix(audit): scroll to Site trust from Quality, keep it per brand, say when checking again fails, and count it only beside the page's own Trust

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

* fix(audit): give the Site trust card its own key beside the auto-run notice

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

* feat(content): list what only you can do in Quality, and nudge the next one (CE-040)

Your to-dos in Instructions › Quality: picking the page's author (or adding
one) and completing their profile move out of the suggestions, with a box
the checks tick and E-E-A-T's gain. A dark "Next for you" pill names the
first open one when the agent's run ends (not a failed or stopped one),
when the last open suggestion is accepted (Accept all, one by one, or the
page rewrite) and on Mark ready, once per moment and to-do in the session;
Later hides it. Its words go to a status kept on the page for screen
readers.

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

* feat(content): check the page before it's marked ready, with its JSON-LD to paste (CE-041)

Before you publish opens on Mark ready once Quality is live: a warning
only when Trust is under 60 (the check that raises it most, and to about
what), a note while the page's links are still being read, what the CMS
does for the page (author, visible dates, schema), and for an article an
Article JSON-LD from the title, author, brand, its image and today's date
(Person with sameAs, or the brand's Organization; no author while the
authors aren't read; a live page keeps its published date) with Copy
JSON-LD. Fix first goes to Quality and puts the caret at the passage.
Mark ready anyway is logged with the page's Trust and the check named
(00255 content_draft_ready_log: members add rows as themselves for a
ready draft, three columns only). useLinkChecks also says how many reads
may still come.

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

* feat(content): keep the Content Agent from inventing people and quotes (CE-044)

Every person's name and quoted sentence the agent writes is looked up in
what it was given: the page, the brand, the brief, the rules, the
person's data (Sources) and Settings › Authors. One that isn't becomes a
placeholder ("[name of a real person]", "[quote from a real person, with
its source]"): in Fix open rules' and the first optimize's suggestions,
read in their words as written before they are cleaned; in a page
written whole; and in a rewrite before what it kept goes back, so the
page's own passages are never touched.

A name is read where a person is plainly meant: an honorific, a role
("CEO Jane Doe", "Jane Doe, head of sales", "Jane Doe (CEO)"), or speech
("Jane Doe said", "according to Jane Doe", "Ayşe Yılmaz'a göre"); a
known author stays with the words before it, and a heading is read for
quotes and speech only. A quote is two words or more in quotation marks
next to speech, four or more anywhere, or a blockquote or <q> (its cite
read for the name), across the bold and the links in a line. One reading
per word keeps long text fast.

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

* feat(content): list the placeholders the agent left as the first to-do (CE-044)

Your to-dos in Quality now opens with "Fill {n} placeholders" while the
page has words in square brackets (what the agent leaves where it had no
real name, quote or number), with Show on the first. The Next for you
nudge names it too ("Show now"). Only the person can fill them; an export
never ships one (CE-057).

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

* feat(content): export the page ready to paste, with its page fields (CE-057)

Export, once Quality is live, asks where the page goes: Webflow,
WordPress, Shopify or Google Docs (copied as rich text to paste in; the
CMSs' H1 left out for their title field), Word or Markdown (downloaded),
or HTML. It shows the page as it was when it opened.

No export carries a placeholder. Fill now selects the first (in the HTML
view's text too, or says it is in an HTML block); Export without them
leaves out the sentences they are in, read as a reader would ("1.5",
"e.g." and "acme.com" end none), one outside a line, in alt text or in
JSON-LD alone. One in the title or a heading is filled first. Copy HTML
sends a page with one to Export too.

It lists what it checks (clean HTML or the HTML blocks' own code, the
links that answer or couldn't be read, the images' alt text) and the
page fields, read from the page as it goes out (its title, first
paragraph, live address or title as a slug, author, first image), each
with Copy. Word gets them as a table on page 1, Markdown as front matter
(with the date, the title not again as an H1), HTML in its head.

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

* fix(content): count a link the site refused as unread, and the title's placeholder once

Trust's link reads say "unknown" when a site refused the read or timed
out (a bot wall, a 403): Export no longer counts such a link as read, so
it never says the links answer for one that wasn't. A title that is the
page's H1 has its placeholders counted with the page, not twice.

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

* feat(content): check the page before Export, with a Ready to paste row (CE-057)

Before you publish now opens on Export too (§7), then goes on to Export
with Continue to export; its Trust warning says the page can be exported
anyway, and nothing is logged. On Mark ready and on Export alike, a last
row reads Ready to paste: no placeholders, every image with alt text,
every link working; what is still open is named ("2 placeholders still
open · 1 image has no alt text"), and links that weren't read are said
to be unchecked, never to work. It is read from the page as it is when
the dialog opens.

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

* feat(content): let a brand add the byline to its exported content (CE-057)

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

* fix(content): keep the loading dots visible with reduced motion

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

* fix(content): check author profile links in the table, unlink a removed member and revoke anon

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

* fix(content): let a Stop go only of the claim the stopped run holds

A Stop that named a Fix or brief run cleared agent_state whatever the run
was, so a Start or Rewrite on the same draft went on without its claim.
Each run now carries the claim it holds (content_agent_runs.claimed_at,
00249), stopDraftRun answers it, and the route clears agent_state only
where agent_state_at is still that claim.

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

* fix(content): say in the Remove dialog that the author's pages go back to the team byline

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

* fix(content): date a page over the read cap from its start, and count a private-address link as broken

fetchPage gets an opt-in truncate that resolves with the first maxBytes
instead of refusing the page, and the link check uses it, so a large
article page still gives its date and stays working. A link the fetch
refuses as a private or local address reads as broken, since no reader
of the published page can open it; a non-standard port stays unknown.

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

* fix(content): offer Edit author in Quality only to who can edit that author, and say who can otherwise

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

* fix(content): read discounts, materials and short forms as no figures, and score Trust only with a figure or a dated source

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

* fix(audit): read a bot wall as unsure, read a walled home page through Scrape.do once a day, and look for author pages at the usual addresses

A 401/403/429, or a 200 challenge page, now leaves the read incomplete
instead of failing About, Contact, Editorial or Organization schema for a
day (looksBlocked from site-pages.js). A walled home page goes through
Scrape.do, unrendered, at most once a day per brand (site_trust.scraped_at),
and a pass it read stands for that day while the wall hides the page.
An author the page list has no page for is looked for at /author/<slug>
and /authors/<slug> (a few authors per read), with the probes' guards and
their name in the title or H1. readSiteTrust returns complete, so the web
can tell a partial read from a fix to make.

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

* fix(audit): hold Check again until the read can change, say when the site didn't answer, and say Site trust counts in Quality

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

* fix(content): leave a placeholder title out of the JSON-LD headline, and say why

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

* chore(content): move Show's doc comment back onto showInPage

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

* fix(content): read Readability in the draft's language, and split its sentences where they end

- Japanese, Chinese and Thai, written without spaces between words, get no
  score: Quality says "Readability isn't read for this language yet"
  instead of asking for more paragraphs. Sentences also end after 。!?,
  । and ؟, and a Hindi word keeps its vowel signs, so Hindi is read by its
  own sentences and words.
- The language is the draft's Language rule when it is on, else the
  brand's; every brand language's name is read ("Portuguese", "Brazilian
  Portuguese", "日本語"…).
- A sentence doesn't end before a lower-case word, nor at a German or
  Turkish ordinal ("am 3. Oktober") or a language's common abbreviations
  ("z. B.", "p. ex.", "örn."); one before a number only ("No. 5") counts
  there. A full stop before a closing quote or bracket ends one.
- Show goes to the first copy of a passage, and a second Show within the
  moment keeps its mark for the full time.
- Passive voice reads common irregular participles (sent, found, held…).

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

* fix(content): know a name only as whole words, read a bare name only with a verb said of people, and run on without the authors

isKnown matched names as substrings of what the agent was given, so
"Dr. Sarah Chen" passed on a page with "kitchen" and "Mr. Doe" on one
with "does". Both sides are now compared as whole words. A name without
an honorific or role is read only with said, told, explained, recalled,
admitted, insisted or argued (and German sagte, Turkish söyledi), so
"Google Ads recommends" or "according to Google Analytics" no longer
become name placeholders. authorWords logs a failed read (content_authors
not there yet) and reads as no author words instead of failing the run.

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

* fix(content): read the page for export in a document of its own, and JSON-LD by its strings

Export reads the page in a document of its own, so nothing in it loads or
runs. A JSON-LD is read by its string values: its arrays are no placeholders,
and Export without them clears the strings and keeps it valid JSON. In a
title or a heading only the agent's own placeholder forms hold the export,
so "Best CRM tools [2026 Update]" goes out as written. A live page's
Markdown front matter gets lastmod instead of date, and the draftHtmlDocument
comment is back on its function.

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

* fix(content): offer Edit author on the profile to-do only to who can edit the author

#1414's review fix moved here: the to-dos replaced E-E-A-T's suggestions,
so the to-do now carries the rule (whoever added the author, the author
themself or an admin) and tells anyone else who can.

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

* refactor(content): read the title's placeholder with the shared pattern

#1420 kept its own copy while placeholders.ts wasn't below it; now it is.

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

* test(content): expect the dated source line's corrected plural

#1416's review fix reads "1 of 1 dated source is over 24 months old".

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

* fix(content): read Ready to paste once per change, and fill in the HTML view only where it counts

Ready to paste is read in a useMemo while Before you publish is open, not
on every render. A link still being read is told from one no read is coming
for (a refused read, one past the limit, one in an HTML block). The title's
placeholders count once when any heading or the page's first line reads as
it, H1 or not. In the HTML view, Fill now searches only where the count
reads: tags (but alt and title), styles, other scripts and a JSON-LD's
non-strings are blanked first (blankCode, reused for the byline). A page
test shows a FAQPage's JSON-LD reads Ready to paste as done.

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

* fix(content): pass the nudge whether the member can edit the author

Its to-do text names who can complete the profile when they can't.

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

* test(content): give Before you publish's quality read whether the member can edit the author

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

* chore(content): type the agent run's claimed_at

#1400 adds the column to 00249.

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

* fix(content): write the content byline in the brand's language, under the lead's own H1

The byline line Add byline to content puts in the page is written in the
brand's language (brands.language): "Yazar: Ayşe Yılmaz", "Por Ana Silva",
"Vom Acme-Team", from a small table for English, Turkish, German, French,
Spanish, Portuguese, Italian, Dutch and Swedish; any other language gets the
name alone, or the brand's. Before you publish quotes the line as it goes
out. withByline puts it after the end tag of the lead's own H1, counted with
comments and code blanked, so an empty H1 above the title or one in a
comment or a script no longer takes it.

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

* test(content): wait for Before you publish to move focus to Continue to export

The dialog focuses its button after it opens; checking at once failed now
and then under load.

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

* docs(content): say the byline follows the page's language

With #1411 below it, the editor reads the draft's Language rule first.

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

* fix(content): type the H1 list the byline counts in

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]>
gkhngyk added a commit that referenced this pull request Oct 23, 2026
…card (Next step basket) (#1428)

* feat(billing): show this period's AI usage on the Billing page

The workspace's one AI budget (Improve, the Content Editor's AI and the
Action Center's task writer) had no meter: the first sign of it was an
"AI usage is used up" error. Migration 00242 records what each AI call
was for (prompt_improve_usage.feature, backfilled) and sums the period's
spend by feature (ai_usage_by_feature). GET /api/billing/ai-usage
returns the shares of the plan's budget, and the Billing page shows the
share used, when it resets and what used it, with Agent Chat noted as
running on the workspace's own key.

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

* fix(billing): hold an AI call's share of the budget before it runs

The workspace's AI budget was checked by reading the period's spend; the
call's cost was written once the model answered. Calls running at once
(two tabs, a teammate, an Action Center sweep) all read the same spend
and all ran past the budget. 00243's reserve_ai_usage takes a
per-organization lock, reads the spend with the calls in flight, and
holds the call's estimated cost; reserveAiBudget turns the hold into the
real cost or releases it. Improve, the brief rebuild, Apply rules with
Agent, Start Agent and the Action Center task writer use it in place of
enforceImproveQuota, which goes.

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

* fix(billing): charge a schema miss and hold the org's recent median cost

Review fixes:
- Apply rules with Agent and Start Agent charge an answer the provider
  billed but that missed the schema (NoObjectGeneratedError), as Improve,
  the brief and the task writer do; before, the hold was let go and the
  call ran free.
- A call holds the org's median cost over its last 20 calls this period,
  never less than the model's typical cost, so calls in flight pass the
  budget by far less.

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

* feat(content): rewrite a whole page to its rules as one suggestion

Apply rules with Agent makes at most 8 small edits a run, which can't
bring a long page to its Length (about 2% a run on prod). The Content
Agent can now rewrite the whole page in one background call, left as ONE
suggestion (kind 'page', migration 00247) to compare and accept or reject:
- POST /api/content-drafts/:draftId/rewrite, through Start Agent's claim,
  budget hold and background run;
- passages AI quotes today, tables, images, quotes and HTML blocks go to
  the model as [[KEEP n]] lines and come back as they were; a rewrite that
  drops one fails the run;
- one H1, only the page's own links and the ones offered, the editor's
  tags; the page as it was is kept on the suggestion (before_html).

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

* fix(content): describe a rewrite's kept blocks and count them toward Length

Review fixes:
- Kept blocks are described under the page (a quoted passage's words, a
  table's rows, an image's alt) and their text counts toward Length, so a
  rewrite aims at the whole page's length; with Length off it keeps the
  page's own. A kept H1 stays first, and the page's language is kept.
- The answer is taken out of a code fence, text left at its root goes in
  paragraphs, and an answer in Markdown fails the run.
- The page's own links stay exactly as written (query and anchor too).
- Kept blocks go back untouched (an empty table cell stays), only the
  page's first H1 counts as its title, a page that writes "[[KEEP" gets
  markers of its own, and a page that is only kept blocks isn't sent.

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

* feat(content): rewrite the page to its rules from the Rules tab, and compare it

The Rules tab opens with the agent's two ways to meet its rules: Apply
rules with Agent (small edits, up to 8 a run) and Rewrite the page to
these rules (the whole page as one change). The rewrite is recommended,
with a one-line reason, when the page is more than 30% off its Length or
4 rules or more are open.

A rewritten page comes back as one suggestion with its own bar over the
page: the characters before and after and the agent's reason, Compare
(the page and the rewrite side by side), Accept (History keeps the page
first), Reject, and Undo. A page that changed since the agent read it
isn't written over. The page waits for the rewrite with its own steps,
and a failed rewrite's Try again rewrites again.

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

* fix(content): compare a rewrite by its words and run one agent at a time

Review fixes:
- A page is compared with the one the agent read by its words, with a
  space between blocks, so stored line breaks and lists don't read as a
  change (Accept and Undo were refused on imported pages).
- One agent run at a time from the page; a rewrite never starts before
  the locked passages are read, and sends the editor's own locked keys.
- Accept holds the page still from the start and checks it again before
  putting the rewrite in; Undo puts the page back as it was (two H1s too),
  and the bar waits while the HTML view is open.
- No rewrite advice for an empty page or one too long to send whole; the
  rewrite mark survives a reload; the waiting view says the rewrite waits
  in the editor; Compare's links don't navigate.

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

* feat(content): show the Content Agent as a card over the page

Content Editor v1.1, part 1 (CE-025, CE-026, §4): the agent row and the
rewrite bar become one card above the toolbar, in three states:
- waiting: "Content Agent has {n} suggestions for you", what they change
  and the rules they gain ("Rules 5 → 6 of 13"), with Review (scrolls to
  the first suggestion and marks it), Reject all and Accept all; a page
  rewritten shows its characters, with Compare;
- all reviewed: what was accepted and the rules met and still open, with
  Undo all and Run Agent;
- working: while Apply rules with Agent runs.
The tile moves a little (a soft ring, a blink, a spark; a sweep and a
breath while working), never a rotating ring, and not at all with reduced
motion. The card wraps on a narrow page; Accept all and Run Agent are the
primary buttons.

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

* fix(content): agent card review fixes

- Run Agent on the card keeps to one agent run at a time and says why it
  waits; Apply rules never starts beside another run or before the locked
  passages are read.
- Ghost buttons show their hover on the card's grey; the tile and its
  count are hidden from screen readers (the title says it) and the count
  is darker for contrast; "+N more" comes from en.json, the reason's first
  letter is upper-cased in the page's locale.
- Review picks the first open suggestion in the page's order and focuses
  it; the sweep shows on the light tile in dark mode; the spark is slower
  once all are reviewed; without motion the working line is a faint full
  line; "0 still open" isn't said.
- globals.css keeps its own lines; only the motion block is added.

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

* feat(content): put brief and rules under one Instructions tab with a split Run Agent

Content Editor v1.1 part 2 (CE-028–CE-031): the side panel's tabs become
Instructions · Sources · Live page. Instructions holds Brief | Rules, with
the rules still open on the tab and the segment. Each segment opens with a
status card: Rules has one split Run Agent ▾ (Fix open rules, or Rewrite
the whole page, which renames it "Rewrite page") in place of the two rule
buttons; Brief has Run Agent while empty and Rebuild brief once written.
Why the agent can't run is written under the card, and each card's ⓘ tip
opens below it. The brief shows "Not set yet" and its Length in characters
and about as many words; the toolbar counter adds the page's words.

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

* fix(content): instructions tab review fixes

- Run Agent's choice is worked out once and falls back to Fix without a
  rewrite; once a rewrite starts, the button is back on Fix.
- ▾'s choices are menu radio items; Fix is off when only rules the agent
  can't fix are open, and the card says what to do instead.
- The reason line under the card stays mounted for screen readers; Rewrite
  from brief writes its reason too; the tab's count is read out.
- Brief | Rules switch with the arrow keys, one tab stop.
- An edited brief's rebuild question sits under the card; a brief without
  H2s says to rebuild it; an empty brief shows no origin line.
- Plural copy for the open suggestions and the counter's words; rule names
  joined by the formatter; Run Agent's tip leaves ▾ out without a rewrite.

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

* feat(content): show the data the Content Agent writes from

Content Editor v1.1 part 3 (CE-032, CE-034): under each Run Agent card,
"Uses your data: 1 prompt · 21 fan-outs · 20 cited pages · 10 Search
Console queries · Edit sources", counted as the Sources tab keeps them, so
turning one off lowers it at once. The Sources tab carries its count, and
its top says "N sources in use" and when the Content Agent last wrote from
them (its latest suggestions or the brief it built). A first visit's note
at the top of Instructions says the agent writes from the person's data;
closing it is kept in their own user metadata.

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

* fix(content): data note review fixes

- "Last used by Content Agent" also counts the agent writing the page
  (agent_state_at: Start with Agent, Rewrite from brief on a new page),
  not a run that failed; a value that isn't a date is skipped.
- The latest batch's time is its first suggestion's, not a sort per render.
- Tests: the Brief segment's line, no line while the sources can't be read,
  the tab's count, the note showing again after a failed write, and a
  suggestion read with its createdAt.

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

* feat(content): have the Content Agent write from the kept sources and name them

Content Editor v1.1, CE-033 (server): Fix open rules, Start with Agent and
Rewrite the whole page read the sources the Sources tab keeps, numbered
S1, S2… (content-sources.js). Each suggestion keeps the sources it names
and the words each supports (content_draft_suggestions.sources and
source_marks, 00248); a page rewritten whole keeps its sources.

No number without a source: the model reads a source by its words only, so
a number the agent adds must be the page's, the brand's, the brief's, the
rules', today's, or in a source's own words (then marked to it). A
suggestion with any other number is not kept; a page written whole gets a
placeholder in its place. Source numbers written into the words are taken
out.

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

* feat(content): show what each agent suggestion was written from

Content Editor v1.1, CE-033 (web) and the rest of CE-034: under each
suggestion, "Based on" chips name the sources it used (number, kind, name;
the Sources tab's details on hover), and a small number marks the words
each supports. A click on either opens Sources on that row, scrolled to
and ringed for a moment, once. The agent card adds "built from N of your
sources · See sources". Fix open rules sends the kept sources, and the
first-visit note says every change shows the sources it used.

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

* feat(content): write the Content Agent's runs step by step and stop them

Content Editor v1.1, CE-027/035 (server): each Content Agent run (Fix open
rules, Start with Agent, Rewrite the whole page, the brief) is written in
content_agent_runs (00249) with its steps named by the data it reads
("Reading 20 cited pages", "Matching 21 fan-outs", "Writing 3 changes") as
it reaches them. POST /api/content-drafts/:id/stop marks the run stopped
and aborts its model call; the run checks before it keeps anything, so a
stopped run changes nothing (no suggestions, page, brief or History).

A run that can't be written still runs; runs a stopped server left are
closed when the next starts, and Stop ignores them. Background runs are
written before Start answers, so Stop finds them at once.

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

* fix(content): let go of a background draft when its run is stopped

Stop also clears the draft's 'writing' state at once: a background run lets
go once it sees the stop, but one no server holds any more never would, and
the waiting page would wait out the 10 minutes.

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

* feat(content): show the content agent's steps while it works, and stop it (CE-027, CE-035)

The agent card, the brief and the waiting page show the run's real steps
(content_agent_runs, read from the browser every second) and a Stop button
that ends the run through the API proxy, leaving the page as it was. A dashed
decoration under the H1 says where Fix is drafting, and the agent's dots
replace every spinner on its buttons.

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

* feat(content): show the cited pages' length next to the brief's Length (CE-030)

When the brief is rebuilt, the server reads the first few cited pages kept
in Sources (only addresses AI answers cited for the brand, never the draft's
own page), counts their main text as the Rules tab counts length, and saves
the median as brief.citedLength. The Brief tab says "From the rules · cited
pages average N characters"; with fewer than two pages read it stays "From
the rules". textLength moves to page-content.js to avoid an import cycle.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): read a failed rewrite from the draft, and only the latest batch's rows

The editor reads content_drafts.agent_run, so a failed rewrite is tried again
as one on every device (the localStorage mark is gone). Fix open rules' new
409 'writing' says the agent is already writing. getDraftSuggestions finds
the latest batch first and reads only its rows, and Compare's links can't
take focus.

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

* fix(content): say in the agent card why Run Agent won't run

The card's Run Agent writes its reason in the card's second line (amber, tied
to the button by aria-describedby) instead of a hover title, and is turned
off when the only rules left open are ones the agent doesn't fix (one H1),
as the Rules card does.

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

* chore(content): keep AddSourceInput as Prettier formats it

A merge brought in a line formatted by another Prettier version; this puts
back main's formatting, so format:check passes.

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

* fix(content): recommend no Run Agent choice that is turned off

With only One H1 open and no rewrite advice, ▾ no longer shows the disabled
Fix as Recommended.

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

* fix(content): match an added figure by its unit, and read none from dates, addresses or words

A claim (a %, a ×, a scale, a currency) is known only with the same unit or
sign, so a fan-out's "crm for 50 users" no longer sources "50%". Today adds
only its year. A cited page's address is no words of its own. The brand's
name and industry are known, digits stuck to a letter ("B2B", "H2") are no
figure, and a source number written into a reason is taken out.

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

* feat(content): name the agent's steps by the work the server does

Short names for what each run does (CE-027/035): Fix and a rewrite read the
rules, gather the sources (numbered, so a number can be checked), write, and
check what they wrote (a number needs a source, a link must be allowed, a
locked passage stays). The brief gathers, writes the outline and matches
fan-outs. "Reading 20 cited pages" is gone: the agent sees their addresses,
not their content.

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

* fix(content): name the Rules tab's button as it reads now in a test and two lines

A test from main still pressed "Apply rules with Agent", and two messages
still named it; the button is Run Agent, its default Fix open rules.

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

* fix(content): charge a call Stop aborted, end only a run's own claim, and stop the run named

- A Stop that aborts a model call already sent keeps its hold on the AI
  budget as its cost (reserveAiBudget's keep()), since the provider bills
  it; a run stopped before its call sends nothing (runCall).
- A background run ends only the claim it still holds (agent_state_at), so
  one stopped from another server never clears a newer run's.
- A run closes only runs a stopped server left (older than RUN_STALE_MS),
  and /stop takes an optional runId, so another tab's run goes on.

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

* feat(content): show the steps by their new names, and stop the run the editor shows

The step chips read the server's short names (Reading 4 rules, Gathering 52
sources, Writing changes, Checking sources). Stop sends the run's id, so
another tab's run goes on. The waiting page keeps the run's last steps and
reads the draft as soon as its run ends, and a hidden tab reads the run every
AGENT_POLL_MS, then at once when it shows again.

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

* test(content): read the hook's run from what it renders

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

* fix(content): call the cited-page figure the median it is, and stop its reads with the run

The Brief's Length now says "a typical cited page has N characters (median of
M)". A Stop settles the cited-page read on nothing at once: the run's signal
ends each page read (fetchPage takes a signal beside its timeout), so a fast
model answer followed by a Stop never waits on them.

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

* fix(content): show loading without a spinning ring anywhere in Content

Every Loader2 spinner in Content (the editor, Library, Plan, the content
page and its dialogs and menus, the webhook settings) is now LoadingDots:
three dots that bounce in turn, in the text's color, still with reduced
motion, as the Content Editor brief asks ("no spinning ring anywhere"). The
agent's WorkingDots are built on it.

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

* feat(content): read the draft's Readability and show it in Instructions › Quality (CE-036, CE-039)

Quality spec Phase 1, behind NEXT_PUBLIC_CONTENT_QUALITY_PHASE (off unset):
- readability.ts: seven checks read from the draft in the browser, no AI
  cost — average sentence 15–20 words, none over 35, reading level by the
  language's formula (Flesch, Ateşman, Amstad, Kandel–Moles,
  Fernández-Huerta; else sentence and word length), answer first, short
  paragraphs, a heading every 200–300 words, passive voice and jargon
  (English). A check a language can't be read for is left out and the
  score rescaled to 100.
- Instructions gets a Quality segment: the score with its band (80+
  Strong, 60–79 Can improve, under 60 Needs work), "Ansvisor estimates
  based on Google's published quality signals. Not a Google score.", and
  what would raise it, the biggest gain first, with Show.
- The header gets a "Quality {score}" chip that opens it.

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

* fix(content): read Readability from the page's own blocks, and show a passage by its block

- A quote's and a list item's paragraphs are read apart (the editor's HTML
  has no space between tags) and a nested list once; sentence length is
  measured on running text, a list's points aside, and a page of short
  sentences is asked to join some.
- Fernández-Huerta subtracts words per sentence (the corrected form).
- Answer first skips an empty line, fails without an H1, and reads an H1's
  subject without its question and common words.
- Abbreviations don't end a sentence; "-ted" keeps its syllable, French
  "-ent" is no silent ending, Turkish â î û are vowels; "is indeed" isn't
  passive, jargon is read in all its forms, and Show goes to what falls short.
- Show finds the passage's block in the page (never a suggestion's card)
  and marks it with a decoration; the band is read out with the chip and
  the segment's badge.

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

* fix(content): count a passive sentence that says not or never in Readability

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

* feat(content): add Settings › Authors, the real people a page is by (CE-037)

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

* fix(content): let whoever added an author edit it, link only yourself, and renumber to 00251

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

* feat(content): name the page's author in the editor's header and a Page info strip outside the page (CE-038)

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

* fix(content): keep the Page info strip right under the H1, count authors' pages only in Settings

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

* fix(content): draw the Page info strip as the mockup's one line, with the author's face and title at the brand

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

* feat(content): score E-E-A-T from the page's author and Trust from the agent's sourced claims in Quality (CE-039)

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

* fix(content): score only checks that can fail: no Trust and no author schema until they read the page

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

* fix(content): say only what an author's profile is missing in Quality

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

* feat(content): read a draft's links once a day for Trust: working or broken, and their page's date

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

* fix(content): read only a saved draft's links, a few at a time and within a budget, and date pages by their own entity

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

* feat(content): score Trust from the page's sourced figures, fresh sources and working links (CE-039)

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

* fix(content): reserve link reads up front, say which links are never read, and date an article before its page

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

* fix(content): compare links as the draft saves them, count each link and sentence once, and read prices and sizes as no figures

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

* feat(audit): read a brand's site trust: About, Contact, editorial policy, Organization schema and author pages (CE-043)

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

* fix(audit): read site trust in parallel and once per brand, tell a page from the home page, and re-read a partial read soon

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

* feat(audit): show Site trust n/5 in Site Audit, and count it in Quality's Trust (CE-043)

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

* fix(audit): scroll to Site trust from Quality, keep it per brand, say when checking again fails, and count it only beside the page's own Trust

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

* fix(audit): give the Site trust card its own key beside the auto-run notice

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

* feat(content): list what only you can do in Quality, and nudge the next one (CE-040)

Your to-dos in Instructions › Quality: picking the page's author (or adding
one) and completing their profile move out of the suggestions, with a box
the checks tick and E-E-A-T's gain. A dark "Next for you" pill names the
first open one when the agent's run ends (not a failed or stopped one),
when the last open suggestion is accepted (Accept all, one by one, or the
page rewrite) and on Mark ready, once per moment and to-do in the session;
Later hides it. Its words go to a status kept on the page for screen
readers.

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

* feat(content): check the page before it's marked ready, with its JSON-LD to paste (CE-041)

Before you publish opens on Mark ready once Quality is live: a warning
only when Trust is under 60 (the check that raises it most, and to about
what), a note while the page's links are still being read, what the CMS
does for the page (author, visible dates, schema), and for an article an
Article JSON-LD from the title, author, brand, its image and today's date
(Person with sameAs, or the brand's Organization; no author while the
authors aren't read; a live page keeps its published date) with Copy
JSON-LD. Fix first goes to Quality and puts the caret at the passage.
Mark ready anyway is logged with the page's Trust and the check named
(00255 content_draft_ready_log: members add rows as themselves for a
ready draft, three columns only). useLinkChecks also says how many reads
may still come.

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

* feat(content): keep the Content Agent from inventing people and quotes (CE-044)

Every person's name and quoted sentence the agent writes is looked up in
what it was given: the page, the brand, the brief, the rules, the
person's data (Sources) and Settings › Authors. One that isn't becomes a
placeholder ("[name of a real person]", "[quote from a real person, with
its source]"): in Fix open rules' and the first optimize's suggestions,
read in their words as written before they are cleaned; in a page
written whole; and in a rewrite before what it kept goes back, so the
page's own passages are never touched.

A name is read where a person is plainly meant: an honorific, a role
("CEO Jane Doe", "Jane Doe, head of sales", "Jane Doe (CEO)"), or speech
("Jane Doe said", "according to Jane Doe", "Ayşe Yılmaz'a göre"); a
known author stays with the words before it, and a heading is read for
quotes and speech only. A quote is two words or more in quotation marks
next to speech, four or more anywhere, or a blockquote or <q> (its cite
read for the name), across the bold and the links in a line. One reading
per word keeps long text fast.

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

* feat(content): list the placeholders the agent left as the first to-do (CE-044)

Your to-dos in Quality now opens with "Fill {n} placeholders" while the
page has words in square brackets (what the agent leaves where it had no
real name, quote or number), with Show on the first. The Next for you
nudge names it too ("Show now"). Only the person can fill them; an export
never ships one (CE-057).

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

* feat(content): export the page ready to paste, with its page fields (CE-057)

Export, once Quality is live, asks where the page goes: Webflow,
WordPress, Shopify or Google Docs (copied as rich text to paste in; the
CMSs' H1 left out for their title field), Word or Markdown (downloaded),
or HTML. It shows the page as it was when it opened.

No export carries a placeholder. Fill now selects the first (in the HTML
view's text too, or says it is in an HTML block); Export without them
leaves out the sentences they are in, read as a reader would ("1.5",
"e.g." and "acme.com" end none), one outside a line, in alt text or in
JSON-LD alone. One in the title or a heading is filled first. Copy HTML
sends a page with one to Export too.

It lists what it checks (clean HTML or the HTML blocks' own code, the
links that answer or couldn't be read, the images' alt text) and the
page fields, read from the page as it goes out (its title, first
paragraph, live address or title as a slug, author, first image), each
with Copy. Word gets them as a table on page 1, Markdown as front matter
(with the date, the title not again as an H1), HTML in its head.

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

* fix(content): count a link the site refused as unread, and the title's placeholder once

Trust's link reads say "unknown" when a site refused the read or timed
out (a bot wall, a 403): Export no longer counts such a link as read, so
it never says the links answer for one that wasn't. A title that is the
page's H1 has its placeholders counted with the page, not twice.

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

* feat(content): check the page before Export, with a Ready to paste row (CE-057)

Before you publish now opens on Export too (§7), then goes on to Export
with Continue to export; its Trust warning says the page can be exported
anyway, and nothing is logged. On Mark ready and on Export alike, a last
row reads Ready to paste: no placeholders, every image with alt text,
every link working; what is still open is named ("2 placeholders still
open · 1 image has no alt text"), and links that weren't read are said
to be unchecked, never to work. It is read from the page as it is when
the dialog opens.

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

* feat(content): let a brand add the byline to its exported content (CE-057)

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

* fix(content): keep the loading dots visible with reduced motion

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

* fix(content): check author profile links in the table, unlink a removed member and revoke anon

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

* fix(content): let a Stop go only of the claim the stopped run holds

A Stop that named a Fix or brief run cleared agent_state whatever the run
was, so a Start or Rewrite on the same draft went on without its claim.
Each run now carries the claim it holds (content_agent_runs.claimed_at,
00249), stopDraftRun answers it, and the route clears agent_state only
where agent_state_at is still that claim.

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

* fix(content): say in the Remove dialog that the author's pages go back to the team byline

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

* fix(content): date a page over the read cap from its start, and count a private-address link as broken

fetchPage gets an opt-in truncate that resolves with the first maxBytes
instead of refusing the page, and the link check uses it, so a large
article page still gives its date and stays working. A link the fetch
refuses as a private or local address reads as broken, since no reader
of the published page can open it; a non-standard port stays unknown.

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

* fix(content): offer Edit author in Quality only to who can edit that author, and say who can otherwise

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

* fix(content): read discounts, materials and short forms as no figures, and score Trust only with a figure or a dated source

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

* fix(audit): read a bot wall as unsure, read a walled home page through Scrape.do once a day, and look for author pages at the usual addresses

A 401/403/429, or a 200 challenge page, now leaves the read incomplete
instead of failing About, Contact, Editorial or Organization schema for a
day (looksBlocked from site-pages.js). A walled home page goes through
Scrape.do, unrendered, at most once a day per brand (site_trust.scraped_at),
and a pass it read stands for that day while the wall hides the page.
An author the page list has no page for is looked for at /author/<slug>
and /authors/<slug> (a few authors per read), with the probes' guards and
their name in the title or H1. readSiteTrust returns complete, so the web
can tell a partial read from a fix to make.

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

* fix(audit): hold Check again until the read can change, say when the site didn't answer, and say Site trust counts in Quality

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

* fix(content): leave a placeholder title out of the JSON-LD headline, and say why

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

* feat(content): recommend the next step from the header and the agent card (Next step basket)

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

* chore(content): move Show's doc comment back onto showInPage

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

* fix(content): read Readability in the draft's language, and split its sentences where they end

- Japanese, Chinese and Thai, written without spaces between words, get no
  score: Quality says "Readability isn't read for this language yet"
  instead of asking for more paragraphs. Sentences also end after 。!?,
  । and ؟, and a Hindi word keeps its vowel signs, so Hindi is read by its
  own sentences and words.
- The language is the draft's Language rule when it is on, else the
  brand's; every brand language's name is read ("Portuguese", "Brazilian
  Portuguese", "日本語"…).
- A sentence doesn't end before a lower-case word, nor at a German or
  Turkish ordinal ("am 3. Oktober") or a language's common abbreviations
  ("z. B.", "p. ex.", "örn."); one before a number only ("No. 5") counts
  there. A full stop before a closing quote or bracket ends one.
- Show goes to the first copy of a passage, and a second Show within the
  moment keeps its mark for the full time.
- Passive voice reads common irregular participles (sent, found, held…).

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

* fix(content): know a name only as whole words, read a bare name only with a verb said of people, and run on without the authors

isKnown matched names as substrings of what the agent was given, so
"Dr. Sarah Chen" passed on a page with "kitchen" and "Mr. Doe" on one
with "does". Both sides are now compared as whole words. A name without
an honorific or role is read only with said, told, explained, recalled,
admitted, insisted or argued (and German sagte, Turkish söyledi), so
"Google Ads recommends" or "according to Google Analytics" no longer
become name placeholders. authorWords logs a failed read (content_authors
not there yet) and reads as no author words instead of failing the run.

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

* fix(content): read the page for export in a document of its own, and JSON-LD by its strings

Export reads the page in a document of its own, so nothing in it loads or
runs. A JSON-LD is read by its string values: its arrays are no placeholders,
and Export without them clears the strings and keeps it valid JSON. In a
title or a heading only the agent's own placeholder forms hold the export,
so "Best CRM tools [2026 Update]" goes out as written. A live page's
Markdown front matter gets lastmod instead of date, and the draftHtmlDocument
comment is back on its function.

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

* fix(content): offer Edit author on the profile to-do only to who can edit the author

#1414's review fix moved here: the to-dos replaced E-E-A-T's suggestions,
so the to-do now carries the rule (whoever added the author, the author
themself or an admin) and tells anyone else who can.

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

* refactor(content): read the title's placeholder with the shared pattern

#1420 kept its own copy while placeholders.ts wasn't below it; now it is.

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

* test(content): expect the dated source line's corrected plural

#1416's review fix reads "1 of 1 dated source is over 24 months old".

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

* fix(content): read Ready to paste once per change, and fill in the HTML view only where it counts

Ready to paste is read in a useMemo while Before you publish is open, not
on every render. A link still being read is told from one no read is coming
for (a refused read, one past the limit, one in an HTML block). The title's
placeholders count once when any heading or the page's first line reads as
it, H1 or not. In the HTML view, Fill now searches only where the count
reads: tags (but alt and title), styles, other scripts and a JSON-LD's
non-strings are blanked first (blankCode, reused for the byline). A page
test shows a FAQPage's JSON-LD reads Ready to paste as done.

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

* fix(content): pass the nudge whether the member can edit the author

Its to-do text names who can complete the profile when they can't.

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

* test(content): give Before you publish's quality read whether the member can edit the author

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

* chore(content): type the agent run's claimed_at

#1400 adds the column to 00249.

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

* fix(content): write the content byline in the brand's language, under the lead's own H1

The byline line Add byline to content puts in the page is written in the
brand's language (brands.language): "Yazar: Ayşe Yılmaz", "Por Ana Silva",
"Vom Acme-Team", from a small table for English, Turkish, German, French,
Spanish, Portuguese, Italian, Dutch and Swedish; any other language gets the
name alone, or the brand's. Before you publish quotes the line as it goes
out. withByline puts it after the end tag of the lead's own H1, counted with
comments and code blanked, so an empty H1 above the title or one in a
comment or a script no longer takes it.

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

* test(content): wait for Before you publish to move focus to Continue to export

The dialog focuses its button after it opens; checking at once failed now
and then under load.

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

* docs(content): say the byline follows the page's language

With #1411 below it, the editor reads the draft's Language rule first.

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

* fix(content): type the H1 list the byline counts in

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

* fix(content): keep focus where it went when the basket closes, and hold a skip until every read is in

Review fixes for the Next step basket:
- focus goes back to the Next button only from inside the basket or from
  nowhere (Base UI's own rule); after Skip, the new step's button takes it
  and the step is read out
- stale skips are dropped only once the sources, the site's trust and the
  link reads are in
- an empty page is read past the block its title comes from
- Before you publish and Mark ready are held as the header's Mark ready is
- Rewrite page sits beside Fix open rules where the Rules tab recommends it,
  and "If you see…" takes its count from REWRITE_OPEN_RULES

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]>
gkhngyk pushed a commit that referenced this pull request Oct 24, 2026
…abelled on hover and focus (Next step basket, part 2) (#1429)

* feat(billing): show this period's AI usage on the Billing page

The workspace's one AI budget (Improve, the Content Editor's AI and the
Action Center's task writer) had no meter: the first sign of it was an
"AI usage is used up" error. Migration 00242 records what each AI call
was for (prompt_improve_usage.feature, backfilled) and sums the period's
spend by feature (ai_usage_by_feature). GET /api/billing/ai-usage
returns the shares of the plan's budget, and the Billing page shows the
share used, when it resets and what used it, with Agent Chat noted as
running on the workspace's own key.

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

* fix(billing): hold an AI call's share of the budget before it runs

The workspace's AI budget was checked by reading the period's spend; the
call's cost was written once the model answered. Calls running at once
(two tabs, a teammate, an Action Center sweep) all read the same spend
and all ran past the budget. 00243's reserve_ai_usage takes a
per-organization lock, reads the spend with the calls in flight, and
holds the call's estimated cost; reserveAiBudget turns the hold into the
real cost or releases it. Improve, the brief rebuild, Apply rules with
Agent, Start Agent and the Action Center task writer use it in place of
enforceImproveQuota, which goes.

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

* fix(billing): charge a schema miss and hold the org's recent median cost

Review fixes:
- Apply rules with Agent and Start Agent charge an answer the provider
  billed but that missed the schema (NoObjectGeneratedError), as Improve,
  the brief and the task writer do; before, the hold was let go and the
  call ran free.
- A call holds the org's median cost over its last 20 calls this period,
  never less than the model's typical cost, so calls in flight pass the
  budget by far less.

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

* feat(content): rewrite a whole page to its rules as one suggestion

Apply rules with Agent makes at most 8 small edits a run, which can't
bring a long page to its Length (about 2% a run on prod). The Content
Agent can now rewrite the whole page in one background call, left as ONE
suggestion (kind 'page', migration 00247) to compare and accept or reject:
- POST /api/content-drafts/:draftId/rewrite, through Start Agent's claim,
  budget hold and background run;
- passages AI quotes today, tables, images, quotes and HTML blocks go to
  the model as [[KEEP n]] lines and come back as they were; a rewrite that
  drops one fails the run;
- one H1, only the page's own links and the ones offered, the editor's
  tags; the page as it was is kept on the suggestion (before_html).

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

* fix(content): describe a rewrite's kept blocks and count them toward Length

Review fixes:
- Kept blocks are described under the page (a quoted passage's words, a
  table's rows, an image's alt) and their text counts toward Length, so a
  rewrite aims at the whole page's length; with Length off it keeps the
  page's own. A kept H1 stays first, and the page's language is kept.
- The answer is taken out of a code fence, text left at its root goes in
  paragraphs, and an answer in Markdown fails the run.
- The page's own links stay exactly as written (query and anchor too).
- Kept blocks go back untouched (an empty table cell stays), only the
  page's first H1 counts as its title, a page that writes "[[KEEP" gets
  markers of its own, and a page that is only kept blocks isn't sent.

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

* feat(content): rewrite the page to its rules from the Rules tab, and compare it

The Rules tab opens with the agent's two ways to meet its rules: Apply
rules with Agent (small edits, up to 8 a run) and Rewrite the page to
these rules (the whole page as one change). The rewrite is recommended,
with a one-line reason, when the page is more than 30% off its Length or
4 rules or more are open.

A rewritten page comes back as one suggestion with its own bar over the
page: the characters before and after and the agent's reason, Compare
(the page and the rewrite side by side), Accept (History keeps the page
first), Reject, and Undo. A page that changed since the agent read it
isn't written over. The page waits for the rewrite with its own steps,
and a failed rewrite's Try again rewrites again.

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

* fix(content): compare a rewrite by its words and run one agent at a time

Review fixes:
- A page is compared with the one the agent read by its words, with a
  space between blocks, so stored line breaks and lists don't read as a
  change (Accept and Undo were refused on imported pages).
- One agent run at a time from the page; a rewrite never starts before
  the locked passages are read, and sends the editor's own locked keys.
- Accept holds the page still from the start and checks it again before
  putting the rewrite in; Undo puts the page back as it was (two H1s too),
  and the bar waits while the HTML view is open.
- No rewrite advice for an empty page or one too long to send whole; the
  rewrite mark survives a reload; the waiting view says the rewrite waits
  in the editor; Compare's links don't navigate.

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

* feat(content): show the Content Agent as a card over the page

Content Editor v1.1, part 1 (CE-025, CE-026, §4): the agent row and the
rewrite bar become one card above the toolbar, in three states:
- waiting: "Content Agent has {n} suggestions for you", what they change
  and the rules they gain ("Rules 5 → 6 of 13"), with Review (scrolls to
  the first suggestion and marks it), Reject all and Accept all; a page
  rewritten shows its characters, with Compare;
- all reviewed: what was accepted and the rules met and still open, with
  Undo all and Run Agent;
- working: while Apply rules with Agent runs.
The tile moves a little (a soft ring, a blink, a spark; a sweep and a
breath while working), never a rotating ring, and not at all with reduced
motion. The card wraps on a narrow page; Accept all and Run Agent are the
primary buttons.

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

* fix(content): agent card review fixes

- Run Agent on the card keeps to one agent run at a time and says why it
  waits; Apply rules never starts beside another run or before the locked
  passages are read.
- Ghost buttons show their hover on the card's grey; the tile and its
  count are hidden from screen readers (the title says it) and the count
  is darker for contrast; "+N more" comes from en.json, the reason's first
  letter is upper-cased in the page's locale.
- Review picks the first open suggestion in the page's order and focuses
  it; the sweep shows on the light tile in dark mode; the spark is slower
  once all are reviewed; without motion the working line is a faint full
  line; "0 still open" isn't said.
- globals.css keeps its own lines; only the motion block is added.

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

* feat(content): put brief and rules under one Instructions tab with a split Run Agent

Content Editor v1.1 part 2 (CE-028–CE-031): the side panel's tabs become
Instructions · Sources · Live page. Instructions holds Brief | Rules, with
the rules still open on the tab and the segment. Each segment opens with a
status card: Rules has one split Run Agent ▾ (Fix open rules, or Rewrite
the whole page, which renames it "Rewrite page") in place of the two rule
buttons; Brief has Run Agent while empty and Rebuild brief once written.
Why the agent can't run is written under the card, and each card's ⓘ tip
opens below it. The brief shows "Not set yet" and its Length in characters
and about as many words; the toolbar counter adds the page's words.

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

* fix(content): instructions tab review fixes

- Run Agent's choice is worked out once and falls back to Fix without a
  rewrite; once a rewrite starts, the button is back on Fix.
- ▾'s choices are menu radio items; Fix is off when only rules the agent
  can't fix are open, and the card says what to do instead.
- The reason line under the card stays mounted for screen readers; Rewrite
  from brief writes its reason too; the tab's count is read out.
- Brief | Rules switch with the arrow keys, one tab stop.
- An edited brief's rebuild question sits under the card; a brief without
  H2s says to rebuild it; an empty brief shows no origin line.
- Plural copy for the open suggestions and the counter's words; rule names
  joined by the formatter; Run Agent's tip leaves ▾ out without a rewrite.

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

* feat(content): show the data the Content Agent writes from

Content Editor v1.1 part 3 (CE-032, CE-034): under each Run Agent card,
"Uses your data: 1 prompt · 21 fan-outs · 20 cited pages · 10 Search
Console queries · Edit sources", counted as the Sources tab keeps them, so
turning one off lowers it at once. The Sources tab carries its count, and
its top says "N sources in use" and when the Content Agent last wrote from
them (its latest suggestions or the brief it built). A first visit's note
at the top of Instructions says the agent writes from the person's data;
closing it is kept in their own user metadata.

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

* fix(content): data note review fixes

- "Last used by Content Agent" also counts the agent writing the page
  (agent_state_at: Start with Agent, Rewrite from brief on a new page),
  not a run that failed; a value that isn't a date is skipped.
- The latest batch's time is its first suggestion's, not a sort per render.
- Tests: the Brief segment's line, no line while the sources can't be read,
  the tab's count, the note showing again after a failed write, and a
  suggestion read with its createdAt.

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

* feat(content): have the Content Agent write from the kept sources and name them

Content Editor v1.1, CE-033 (server): Fix open rules, Start with Agent and
Rewrite the whole page read the sources the Sources tab keeps, numbered
S1, S2… (content-sources.js). Each suggestion keeps the sources it names
and the words each supports (content_draft_suggestions.sources and
source_marks, 00248); a page rewritten whole keeps its sources.

No number without a source: the model reads a source by its words only, so
a number the agent adds must be the page's, the brand's, the brief's, the
rules', today's, or in a source's own words (then marked to it). A
suggestion with any other number is not kept; a page written whole gets a
placeholder in its place. Source numbers written into the words are taken
out.

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

* feat(content): show what each agent suggestion was written from

Content Editor v1.1, CE-033 (web) and the rest of CE-034: under each
suggestion, "Based on" chips name the sources it used (number, kind, name;
the Sources tab's details on hover), and a small number marks the words
each supports. A click on either opens Sources on that row, scrolled to
and ringed for a moment, once. The agent card adds "built from N of your
sources · See sources". Fix open rules sends the kept sources, and the
first-visit note says every change shows the sources it used.

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

* feat(content): write the Content Agent's runs step by step and stop them

Content Editor v1.1, CE-027/035 (server): each Content Agent run (Fix open
rules, Start with Agent, Rewrite the whole page, the brief) is written in
content_agent_runs (00249) with its steps named by the data it reads
("Reading 20 cited pages", "Matching 21 fan-outs", "Writing 3 changes") as
it reaches them. POST /api/content-drafts/:id/stop marks the run stopped
and aborts its model call; the run checks before it keeps anything, so a
stopped run changes nothing (no suggestions, page, brief or History).

A run that can't be written still runs; runs a stopped server left are
closed when the next starts, and Stop ignores them. Background runs are
written before Start answers, so Stop finds them at once.

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

* fix(content): let go of a background draft when its run is stopped

Stop also clears the draft's 'writing' state at once: a background run lets
go once it sees the stop, but one no server holds any more never would, and
the waiting page would wait out the 10 minutes.

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

* feat(content): show the content agent's steps while it works, and stop it (CE-027, CE-035)

The agent card, the brief and the waiting page show the run's real steps
(content_agent_runs, read from the browser every second) and a Stop button
that ends the run through the API proxy, leaving the page as it was. A dashed
decoration under the H1 says where Fix is drafting, and the agent's dots
replace every spinner on its buttons.

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

* feat(content): show the cited pages' length next to the brief's Length (CE-030)

When the brief is rebuilt, the server reads the first few cited pages kept
in Sources (only addresses AI answers cited for the brand, never the draft's
own page), counts their main text as the Rules tab counts length, and saves
the median as brief.citedLength. The Brief tab says "From the rules · cited
pages average N characters"; with fewer than two pages read it stays "From
the rules". textLength moves to page-content.js to avoid an import cycle.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): read a failed rewrite from the draft, and only the latest batch's rows

The editor reads content_drafts.agent_run, so a failed rewrite is tried again
as one on every device (the localStorage mark is gone). Fix open rules' new
409 'writing' says the agent is already writing. getDraftSuggestions finds
the latest batch first and reads only its rows, and Compare's links can't
take focus.

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

* fix(content): say in the agent card why Run Agent won't run

The card's Run Agent writes its reason in the card's second line (amber, tied
to the button by aria-describedby) instead of a hover title, and is turned
off when the only rules left open are ones the agent doesn't fix (one H1),
as the Rules card does.

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

* chore(content): keep AddSourceInput as Prettier formats it

A merge brought in a line formatted by another Prettier version; this puts
back main's formatting, so format:check passes.

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

* fix(content): recommend no Run Agent choice that is turned off

With only One H1 open and no rewrite advice, ▾ no longer shows the disabled
Fix as Recommended.

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

* fix(content): match an added figure by its unit, and read none from dates, addresses or words

A claim (a %, a ×, a scale, a currency) is known only with the same unit or
sign, so a fan-out's "crm for 50 users" no longer sources "50%". Today adds
only its year. A cited page's address is no words of its own. The brand's
name and industry are known, digits stuck to a letter ("B2B", "H2") are no
figure, and a source number written into a reason is taken out.

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

* feat(content): name the agent's steps by the work the server does

Short names for what each run does (CE-027/035): Fix and a rewrite read the
rules, gather the sources (numbered, so a number can be checked), write, and
check what they wrote (a number needs a source, a link must be allowed, a
locked passage stays). The brief gathers, writes the outline and matches
fan-outs. "Reading 20 cited pages" is gone: the agent sees their addresses,
not their content.

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

* fix(content): name the Rules tab's button as it reads now in a test and two lines

A test from main still pressed "Apply rules with Agent", and two messages
still named it; the button is Run Agent, its default Fix open rules.

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

* fix(content): charge a call Stop aborted, end only a run's own claim, and stop the run named

- A Stop that aborts a model call already sent keeps its hold on the AI
  budget as its cost (reserveAiBudget's keep()), since the provider bills
  it; a run stopped before its call sends nothing (runCall).
- A background run ends only the claim it still holds (agent_state_at), so
  one stopped from another server never clears a newer run's.
- A run closes only runs a stopped server left (older than RUN_STALE_MS),
  and /stop takes an optional runId, so another tab's run goes on.

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

* feat(content): show the steps by their new names, and stop the run the editor shows

The step chips read the server's short names (Reading 4 rules, Gathering 52
sources, Writing changes, Checking sources). Stop sends the run's id, so
another tab's run goes on. The waiting page keeps the run's last steps and
reads the draft as soon as its run ends, and a hidden tab reads the run every
AGENT_POLL_MS, then at once when it shows again.

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

* test(content): read the hook's run from what it renders

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

* fix(content): call the cited-page figure the median it is, and stop its reads with the run

The Brief's Length now says "a typical cited page has N characters (median of
M)". A Stop settles the cited-page read on nothing at once: the run's signal
ends each page read (fetchPage takes a signal beside its timeout), so a fast
model answer followed by a Stop never waits on them.

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

* fix(content): show loading without a spinning ring anywhere in Content

Every Loader2 spinner in Content (the editor, Library, Plan, the content
page and its dialogs and menus, the webhook settings) is now LoadingDots:
three dots that bounce in turn, in the text's color, still with reduced
motion, as the Content Editor brief asks ("no spinning ring anywhere"). The
agent's WorkingDots are built on it.

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

* feat(content): read the draft's Readability and show it in Instructions › Quality (CE-036, CE-039)

Quality spec Phase 1, behind NEXT_PUBLIC_CONTENT_QUALITY_PHASE (off unset):
- readability.ts: seven checks read from the draft in the browser, no AI
  cost — average sentence 15–20 words, none over 35, reading level by the
  language's formula (Flesch, Ateşman, Amstad, Kandel–Moles,
  Fernández-Huerta; else sentence and word length), answer first, short
  paragraphs, a heading every 200–300 words, passive voice and jargon
  (English). A check a language can't be read for is left out and the
  score rescaled to 100.
- Instructions gets a Quality segment: the score with its band (80+
  Strong, 60–79 Can improve, under 60 Needs work), "Ansvisor estimates
  based on Google's published quality signals. Not a Google score.", and
  what would raise it, the biggest gain first, with Show.
- The header gets a "Quality {score}" chip that opens it.

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

* fix(content): read Readability from the page's own blocks, and show a passage by its block

- A quote's and a list item's paragraphs are read apart (the editor's HTML
  has no space between tags) and a nested list once; sentence length is
  measured on running text, a list's points aside, and a page of short
  sentences is asked to join some.
- Fernández-Huerta subtracts words per sentence (the corrected form).
- Answer first skips an empty line, fails without an H1, and reads an H1's
  subject without its question and common words.
- Abbreviations don't end a sentence; "-ted" keeps its syllable, French
  "-ent" is no silent ending, Turkish â î û are vowels; "is indeed" isn't
  passive, jargon is read in all its forms, and Show goes to what falls short.
- Show finds the passage's block in the page (never a suggestion's card)
  and marks it with a decoration; the band is read out with the chip and
  the segment's badge.

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

* fix(content): count a passive sentence that says not or never in Readability

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

* feat(content): add Settings › Authors, the real people a page is by (CE-037)

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

* fix(content): let whoever added an author edit it, link only yourself, and renumber to 00251

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

* feat(content): name the page's author in the editor's header and a Page info strip outside the page (CE-038)

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

* fix(content): keep the Page info strip right under the H1, count authors' pages only in Settings

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

* fix(content): draw the Page info strip as the mockup's one line, with the author's face and title at the brand

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

* feat(content): score E-E-A-T from the page's author and Trust from the agent's sourced claims in Quality (CE-039)

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

* fix(content): score only checks that can fail: no Trust and no author schema until they read the page

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

* fix(content): say only what an author's profile is missing in Quality

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

* feat(content): read a draft's links once a day for Trust: working or broken, and their page's date

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

* fix(content): read only a saved draft's links, a few at a time and within a budget, and date pages by their own entity

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

* feat(content): score Trust from the page's sourced figures, fresh sources and working links (CE-039)

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

* fix(content): reserve link reads up front, say which links are never read, and date an article before its page

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

* fix(content): compare links as the draft saves them, count each link and sentence once, and read prices and sizes as no figures

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

* feat(audit): read a brand's site trust: About, Contact, editorial policy, Organization schema and author pages (CE-043)

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

* fix(audit): read site trust in parallel and once per brand, tell a page from the home page, and re-read a partial read soon

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

* feat(audit): show Site trust n/5 in Site Audit, and count it in Quality's Trust (CE-043)

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

* fix(audit): scroll to Site trust from Quality, keep it per brand, say when checking again fails, and count it only beside the page's own Trust

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

* fix(audit): give the Site trust card its own key beside the auto-run notice

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

* feat(content): list what only you can do in Quality, and nudge the next one (CE-040)

Your to-dos in Instructions › Quality: picking the page's author (or adding
one) and completing their profile move out of the suggestions, with a box
the checks tick and E-E-A-T's gain. A dark "Next for you" pill names the
first open one when the agent's run ends (not a failed or stopped one),
when the last open suggestion is accepted (Accept all, one by one, or the
page rewrite) and on Mark ready, once per moment and to-do in the session;
Later hides it. Its words go to a status kept on the page for screen
readers.

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

* feat(content): check the page before it's marked ready, with its JSON-LD to paste (CE-041)

Before you publish opens on Mark ready once Quality is live: a warning
only when Trust is under 60 (the check that raises it most, and to about
what), a note while the page's links are still being read, what the CMS
does for the page (author, visible dates, schema), and for an article an
Article JSON-LD from the title, author, brand, its image and today's date
(Person with sameAs, or the brand's Organization; no author while the
authors aren't read; a live page keeps its published date) with Copy
JSON-LD. Fix first goes to Quality and puts the caret at the passage.
Mark ready anyway is logged with the page's Trust and the check named
(00255 content_draft_ready_log: members add rows as themselves for a
ready draft, three columns only). useLinkChecks also says how many reads
may still come.

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

* feat(content): keep the Content Agent from inventing people and quotes (CE-044)

Every person's name and quoted sentence the agent writes is looked up in
what it was given: the page, the brand, the brief, the rules, the
person's data (Sources) and Settings › Authors. One that isn't becomes a
placeholder ("[name of a real person]", "[quote from a real person, with
its source]"): in Fix open rules' and the first optimize's suggestions,
read in their words as written before they are cleaned; in a page
written whole; and in a rewrite before what it kept goes back, so the
page's own passages are never touched.

A name is read where a person is plainly meant: an honorific, a role
("CEO Jane Doe", "Jane Doe, head of sales", "Jane Doe (CEO)"), or speech
("Jane Doe said", "according to Jane Doe", "Ayşe Yılmaz'a göre"); a
known author stays with the words before it, and a heading is read for
quotes and speech only. A quote is two words or more in quotation marks
next to speech, four or more anywhere, or a blockquote or <q> (its cite
read for the name), across the bold and the links in a line. One reading
per word keeps long text fast.

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

* feat(content): list the placeholders the agent left as the first to-do (CE-044)

Your to-dos in Quality now opens with "Fill {n} placeholders" while the
page has words in square brackets (what the agent leaves where it had no
real name, quote or number), with Show on the first. The Next for you
nudge names it too ("Show now"). Only the person can fill them; an export
never ships one (CE-057).

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

* feat(content): export the page ready to paste, with its page fields (CE-057)

Export, once Quality is live, asks where the page goes: Webflow,
WordPress, Shopify or Google Docs (copied as rich text to paste in; the
CMSs' H1 left out for their title field), Word or Markdown (downloaded),
or HTML. It shows the page as it was when it opened.

No export carries a placeholder. Fill now selects the first (in the HTML
view's text too, or says it is in an HTML block); Export without them
leaves out the sentences they are in, read as a reader would ("1.5",
"e.g." and "acme.com" end none), one outside a line, in alt text or in
JSON-LD alone. One in the title or a heading is filled first. Copy HTML
sends a page with one to Export too.

It lists what it checks (clean HTML or the HTML blocks' own code, the
links that answer or couldn't be read, the images' alt text) and the
page fields, read from the page as it goes out (its title, first
paragraph, live address or title as a slug, author, first image), each
with Copy. Word gets them as a table on page 1, Markdown as front matter
(with the date, the title not again as an H1), HTML in its head.

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

* fix(content): count a link the site refused as unread, and the title's placeholder once

Trust's link reads say "unknown" when a site refused the read or timed
out (a bot wall, a 403): Export no longer counts such a link as read, so
it never says the links answer for one that wasn't. A title that is the
page's H1 has its placeholders counted with the page, not twice.

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

* feat(content): check the page before Export, with a Ready to paste row (CE-057)

Before you publish now opens on Export too (§7), then goes on to Export
with Continue to export; its Trust warning says the page can be exported
anyway, and nothing is logged. On Mark ready and on Export alike, a last
row reads Ready to paste: no placeholders, every image with alt text,
every link working; what is still open is named ("2 placeholders still
open · 1 image has no alt text"), and links that weren't read are said
to be unchecked, never to work. It is read from the page as it is when
the dialog opens.

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

* feat(content): let a brand add the byline to its exported content (CE-057)

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

* fix(content): keep the loading dots visible with reduced motion

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

* fix(content): check author profile links in the table, unlink a removed member and revoke anon

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

* fix(content): let a Stop go only of the claim the stopped run holds

A Stop that named a Fix or brief run cleared agent_state whatever the run
was, so a Start or Rewrite on the same draft went on without its claim.
Each run now carries the claim it holds (content_agent_runs.claimed_at,
00249), stopDraftRun answers it, and the route clears agent_state only
where agent_state_at is still that claim.

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

* fix(content): say in the Remove dialog that the author's pages go back to the team byline

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

* fix(content): date a page over the read cap from its start, and count a private-address link as broken

fetchPage gets an opt-in truncate that resolves with the first maxBytes
instead of refusing the page, and the link check uses it, so a large
article page still gives its date and stays working. A link the fetch
refuses as a private or local address reads as broken, since no reader
of the published page can open it; a non-standard port stays unknown.

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

* fix(content): offer Edit author in Quality only to who can edit that author, and say who can otherwise

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

* fix(content): read discounts, materials and short forms as no figures, and score Trust only with a figure or a dated source

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

* fix(audit): read a bot wall as unsure, read a walled home page through Scrape.do once a day, and look for author pages at the usual addresses

A 401/403/429, or a 200 challenge page, now leaves the read incomplete
instead of failing About, Contact, Editorial or Organization schema for a
day (looksBlocked from site-pages.js). A walled home page goes through
Scrape.do, unrendered, at most once a day per brand (site_trust.scraped_at),
and a pass it read stands for that day while the wall hides the page.
An author the page list has no page for is looked for at /author/<slug>
and /authors/<slug> (a few authors per read), with the probes' guards and
their name in the title or H1. readSiteTrust returns complete, so the web
can tell a partial read from a fix to make.

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

* fix(audit): hold Check again until the read can change, say when the site didn't answer, and say Site trust counts in Quality

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

* fix(content): leave a placeholder title out of the JSON-LD headline, and say why

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

* feat(content): recommend the next step from the header and the agent card (Next step basket)

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

* chore(content): move Show's doc comment back onto showInPage

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

* fix(content): read Readability in the draft's language, and split its sentences where they end

- Japanese, Chinese and Thai, written without spaces between words, get no
  score: Quality says "Readability isn't read for this language yet"
  instead of asking for more paragraphs. Sentences also end after 。!?,
  । and ؟, and a Hindi word keeps its vowel signs, so Hindi is read by its
  own sentences and words.
- The language is the draft's Language rule when it is on, else the
  brand's; every brand language's name is read ("Portuguese", "Brazilian
  Portuguese", "日本語"…).
- A sentence doesn't end before a lower-case word, nor at a German or
  Turkish ordinal ("am 3. Oktober") or a language's common abbreviations
  ("z. B.", "p. ex.", "örn."); one before a number only ("No. 5") counts
  there. A full stop before a closing quote or bracket ends one.
- Show goes to the first copy of a passage, and a second Show within the
  moment keeps its mark for the full time.
- Passive voice reads common irregular participles (sent, found, held…).

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

* fix(content): know a name only as whole words, read a bare name only with a verb said of people, and run on without the authors

isKnown matched names as substrings of what the agent was given, so
"Dr. Sarah Chen" passed on a page with "kitchen" and "Mr. Doe" on one
with "does". Both sides are now compared as whole words. A name without
an honorific or role is read only with said, told, explained, recalled,
admitted, insisted or argued (and German sagte, Turkish söyledi), so
"Google Ads recommends" or "according to Google Analytics" no longer
become name placeholders. authorWords logs a failed read (content_authors
not there yet) and reads as no author words instead of failing the run.

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

* fix(content): read the page for export in a document of its own, and JSON-LD by its strings

Export reads the page in a document of its own, so nothing in it loads or
runs. A JSON-LD is read by its string values: its arrays are no placeholders,
and Export without them clears the strings and keeps it valid JSON. In a
title or a heading only the agent's own placeholder forms hold the export,
so "Best CRM tools [2026 Update]" goes out as written. A live page's
Markdown front matter gets lastmod instead of date, and the draftHtmlDocument
comment is back on its function.

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

* fix(content): offer Edit author on the profile to-do only to who can edit the author

#1414's review fix moved here: the to-dos replaced E-E-A-T's suggestions,
so the to-do now carries the rule (whoever added the author, the author
themself or an admin) and tells anyone else who can.

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

* refactor(content): read the title's placeholder with the shared pattern

#1420 kept its own copy while placeholders.ts wasn't below it; now it is.

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

* test(content): expect the dated source line's corrected plural

#1416's review fix reads "1 of 1 dated source is over 24 months old".

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

* fix(content): read Ready to paste once per change, and fill in the HTML view only where it counts

Ready to paste is read in a useMemo while Before you publish is open, not
on every render. A link still being read is told from one no read is coming
for (a refused read, one past the limit, one in an HTML block). The title's
placeholders count once when any heading or the page's first line reads as
it, H1 or not. In the HTML view, Fill now searches only where the count
reads: tags (but alt and title), styles, other scripts and a JSON-LD's
non-strings are blanked first (blankCode, reused for the byline). A page
test shows a FAQPage's JSON-LD reads Ready to paste as done.

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

* fix(content): pass the nudge whether the member can edit the author

Its to-do text names who can complete the profile when they can't.

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

* test(content): give Before you publish's quality read whether the member can edit the author

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

* chore(content): type the agent run's claimed_at

#1400 adds the column to 00249.

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

* fix(content): write the content byline in the brand's language, under the lead's own H1

The byline line Add byline to content puts in the page is written in the
brand's language (brands.language): "Yazar: Ayşe Yılmaz", "Por Ana Silva",
"Vom Acme-Team", from a small table for English, Turkish, German, French,
Spanish, Portuguese, Italian, Dutch and Swedish; any other language gets the
name alone, or the brand's. Before you publish quotes the line as it goes
out. withByline puts it after the end tag of the lead's own H1, counted with
comments and code blanked, so an empty H1 above the title or one in a
comment or a script no longer takes it.

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

* test(content): wait for Before you publish to move focus to Continue to export

The dialog focuses its button after it opens; checking at once failed now
and then under load.

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

* docs(content): say the byline follows the page's language

With #1411 below it, the editor reads the draft's Language rule first.

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

* fix(content): type the H1 list the byline counts in

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

* fix(content): keep focus where it went when the basket closes, and hold a skip until every read is in

Review fixes for the Next step basket:
- focus goes back to the Next button only from inside the basket or from
  nowhere (Base UI's own rule); after Skip, the new step's button takes it
  and the step is read out
- stale skips are dropped only once the sources, the site's trust and the
  link reads are in
- an empty page is read past the block its title comes from
- Before you publish and Mark ready are held as the header's Mark ready is
- Rewrite page sits beside Fix open rules where the Rules tab recommends it,
  and "If you see…" takes its count from REWRITE_OPEN_RULES

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

* feat(content): fit the editor header to its width, its icon buttons labelled on hover and focus (Next step basket, part 2)

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

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 24, 2026
…d agent buttons once it's used up (AI usage display, part 3b) (#1433)

* feat(billing): show this period's AI usage on the Billing page

The workspace's one AI budget (Improve, the Content Editor's AI and the
Action Center's task writer) had no meter: the first sign of it was an
"AI usage is used up" error. Migration 00242 records what each AI call
was for (prompt_improve_usage.feature, backfilled) and sums the period's
spend by feature (ai_usage_by_feature). GET /api/billing/ai-usage
returns the shares of the plan's budget, and the Billing page shows the
share used, when it resets and what used it, with Agent Chat noted as
running on the workspace's own key.

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

* fix(billing): hold an AI call's share of the budget before it runs

The workspace's AI budget was checked by reading the period's spend; the
call's cost was written once the model answered. Calls running at once
(two tabs, a teammate, an Action Center sweep) all read the same spend
and all ran past the budget. 00243's reserve_ai_usage takes a
per-organization lock, reads the spend with the calls in flight, and
holds the call's estimated cost; reserveAiBudget turns the hold into the
real cost or releases it. Improve, the brief rebuild, Apply rules with
Agent, Start Agent and the Action Center task writer use it in place of
enforceImproveQuota, which goes.

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

* fix(billing): charge a schema miss and hold the org's recent median cost

Review fixes:
- Apply rules with Agent and Start Agent charge an answer the provider
  billed but that missed the schema (NoObjectGeneratedError), as Improve,
  the brief and the task writer do; before, the hold was let go and the
  call ran free.
- A call holds the org's median cost over its last 20 calls this period,
  never less than the model's typical cost, so calls in flight pass the
  budget by far less.

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

* feat(content): rewrite a whole page to its rules as one suggestion

Apply rules with Agent makes at most 8 small edits a run, which can't
bring a long page to its Length (about 2% a run on prod). The Content
Agent can now rewrite the whole page in one background call, left as ONE
suggestion (kind 'page', migration 00247) to compare and accept or reject:
- POST /api/content-drafts/:draftId/rewrite, through Start Agent's claim,
  budget hold and background run;
- passages AI quotes today, tables, images, quotes and HTML blocks go to
  the model as [[KEEP n]] lines and come back as they were; a rewrite that
  drops one fails the run;
- one H1, only the page's own links and the ones offered, the editor's
  tags; the page as it was is kept on the suggestion (before_html).

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

* fix(content): describe a rewrite's kept blocks and count them toward Length

Review fixes:
- Kept blocks are described under the page (a quoted passage's words, a
  table's rows, an image's alt) and their text counts toward Length, so a
  rewrite aims at the whole page's length; with Length off it keeps the
  page's own. A kept H1 stays first, and the page's language is kept.
- The answer is taken out of a code fence, text left at its root goes in
  paragraphs, and an answer in Markdown fails the run.
- The page's own links stay exactly as written (query and anchor too).
- Kept blocks go back untouched (an empty table cell stays), only the
  page's first H1 counts as its title, a page that writes "[[KEEP" gets
  markers of its own, and a page that is only kept blocks isn't sent.

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

* feat(content): rewrite the page to its rules from the Rules tab, and compare it

The Rules tab opens with the agent's two ways to meet its rules: Apply
rules with Agent (small edits, up to 8 a run) and Rewrite the page to
these rules (the whole page as one change). The rewrite is recommended,
with a one-line reason, when the page is more than 30% off its Length or
4 rules or more are open.

A rewritten page comes back as one suggestion with its own bar over the
page: the characters before and after and the agent's reason, Compare
(the page and the rewrite side by side), Accept (History keeps the page
first), Reject, and Undo. A page that changed since the agent read it
isn't written over. The page waits for the rewrite with its own steps,
and a failed rewrite's Try again rewrites again.

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

* fix(content): compare a rewrite by its words and run one agent at a time

Review fixes:
- A page is compared with the one the agent read by its words, with a
  space between blocks, so stored line breaks and lists don't read as a
  change (Accept and Undo were refused on imported pages).
- One agent run at a time from the page; a rewrite never starts before
  the locked passages are read, and sends the editor's own locked keys.
- Accept holds the page still from the start and checks it again before
  putting the rewrite in; Undo puts the page back as it was (two H1s too),
  and the bar waits while the HTML view is open.
- No rewrite advice for an empty page or one too long to send whole; the
  rewrite mark survives a reload; the waiting view says the rewrite waits
  in the editor; Compare's links don't navigate.

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

* feat(content): show the Content Agent as a card over the page

Content Editor v1.1, part 1 (CE-025, CE-026, §4): the agent row and the
rewrite bar become one card above the toolbar, in three states:
- waiting: "Content Agent has {n} suggestions for you", what they change
  and the rules they gain ("Rules 5 → 6 of 13"), with Review (scrolls to
  the first suggestion and marks it), Reject all and Accept all; a page
  rewritten shows its characters, with Compare;
- all reviewed: what was accepted and the rules met and still open, with
  Undo all and Run Agent;
- working: while Apply rules with Agent runs.
The tile moves a little (a soft ring, a blink, a spark; a sweep and a
breath while working), never a rotating ring, and not at all with reduced
motion. The card wraps on a narrow page; Accept all and Run Agent are the
primary buttons.

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

* fix(content): agent card review fixes

- Run Agent on the card keeps to one agent run at a time and says why it
  waits; Apply rules never starts beside another run or before the locked
  passages are read.
- Ghost buttons show their hover on the card's grey; the tile and its
  count are hidden from screen readers (the title says it) and the count
  is darker for contrast; "+N more" comes from en.json, the reason's first
  letter is upper-cased in the page's locale.
- Review picks the first open suggestion in the page's order and focuses
  it; the sweep shows on the light tile in dark mode; the spark is slower
  once all are reviewed; without motion the working line is a faint full
  line; "0 still open" isn't said.
- globals.css keeps its own lines; only the motion block is added.

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

* feat(content): put brief and rules under one Instructions tab with a split Run Agent

Content Editor v1.1 part 2 (CE-028–CE-031): the side panel's tabs become
Instructions · Sources · Live page. Instructions holds Brief | Rules, with
the rules still open on the tab and the segment. Each segment opens with a
status card: Rules has one split Run Agent ▾ (Fix open rules, or Rewrite
the whole page, which renames it "Rewrite page") in place of the two rule
buttons; Brief has Run Agent while empty and Rebuild brief once written.
Why the agent can't run is written under the card, and each card's ⓘ tip
opens below it. The brief shows "Not set yet" and its Length in characters
and about as many words; the toolbar counter adds the page's words.

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

* fix(content): instructions tab review fixes

- Run Agent's choice is worked out once and falls back to Fix without a
  rewrite; once a rewrite starts, the button is back on Fix.
- ▾'s choices are menu radio items; Fix is off when only rules the agent
  can't fix are open, and the card says what to do instead.
- The reason line under the card stays mounted for screen readers; Rewrite
  from brief writes its reason too; the tab's count is read out.
- Brief | Rules switch with the arrow keys, one tab stop.
- An edited brief's rebuild question sits under the card; a brief without
  H2s says to rebuild it; an empty brief shows no origin line.
- Plural copy for the open suggestions and the counter's words; rule names
  joined by the formatter; Run Agent's tip leaves ▾ out without a rewrite.

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

* feat(content): show the data the Content Agent writes from

Content Editor v1.1 part 3 (CE-032, CE-034): under each Run Agent card,
"Uses your data: 1 prompt · 21 fan-outs · 20 cited pages · 10 Search
Console queries · Edit sources", counted as the Sources tab keeps them, so
turning one off lowers it at once. The Sources tab carries its count, and
its top says "N sources in use" and when the Content Agent last wrote from
them (its latest suggestions or the brief it built). A first visit's note
at the top of Instructions says the agent writes from the person's data;
closing it is kept in their own user metadata.

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

* fix(content): data note review fixes

- "Last used by Content Agent" also counts the agent writing the page
  (agent_state_at: Start with Agent, Rewrite from brief on a new page),
  not a run that failed; a value that isn't a date is skipped.
- The latest batch's time is its first suggestion's, not a sort per render.
- Tests: the Brief segment's line, no line while the sources can't be read,
  the tab's count, the note showing again after a failed write, and a
  suggestion read with its createdAt.

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

* feat(content): have the Content Agent write from the kept sources and name them

Content Editor v1.1, CE-033 (server): Fix open rules, Start with Agent and
Rewrite the whole page read the sources the Sources tab keeps, numbered
S1, S2… (content-sources.js). Each suggestion keeps the sources it names
and the words each supports (content_draft_suggestions.sources and
source_marks, 00248); a page rewritten whole keeps its sources.

No number without a source: the model reads a source by its words only, so
a number the agent adds must be the page's, the brand's, the brief's, the
rules', today's, or in a source's own words (then marked to it). A
suggestion with any other number is not kept; a page written whole gets a
placeholder in its place. Source numbers written into the words are taken
out.

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

* feat(content): show what each agent suggestion was written from

Content Editor v1.1, CE-033 (web) and the rest of CE-034: under each
suggestion, "Based on" chips name the sources it used (number, kind, name;
the Sources tab's details on hover), and a small number marks the words
each supports. A click on either opens Sources on that row, scrolled to
and ringed for a moment, once. The agent card adds "built from N of your
sources · See sources". Fix open rules sends the kept sources, and the
first-visit note says every change shows the sources it used.

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

* feat(content): write the Content Agent's runs step by step and stop them

Content Editor v1.1, CE-027/035 (server): each Content Agent run (Fix open
rules, Start with Agent, Rewrite the whole page, the brief) is written in
content_agent_runs (00249) with its steps named by the data it reads
("Reading 20 cited pages", "Matching 21 fan-outs", "Writing 3 changes") as
it reaches them. POST /api/content-drafts/:id/stop marks the run stopped
and aborts its model call; the run checks before it keeps anything, so a
stopped run changes nothing (no suggestions, page, brief or History).

A run that can't be written still runs; runs a stopped server left are
closed when the next starts, and Stop ignores them. Background runs are
written before Start answers, so Stop finds them at once.

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

* fix(content): let go of a background draft when its run is stopped

Stop also clears the draft's 'writing' state at once: a background run lets
go once it sees the stop, but one no server holds any more never would, and
the waiting page would wait out the 10 minutes.

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

* feat(content): show the content agent's steps while it works, and stop it (CE-027, CE-035)

The agent card, the brief and the waiting page show the run's real steps
(content_agent_runs, read from the browser every second) and a Stop button
that ends the run through the API proxy, leaving the page as it was. A dashed
decoration under the H1 says where Fix is drafting, and the agent's dots
replace every spinner on its buttons.

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

* feat(content): show the cited pages' length next to the brief's Length (CE-030)

When the brief is rebuilt, the server reads the first few cited pages kept
in Sources (only addresses AI answers cited for the brand, never the draft's
own page), counts their main text as the Rules tab counts length, and saves
the median as brief.citedLength. The Brief tab says "From the rules · cited
pages average N characters"; with fewer than two pages read it stays "From
the rules". textLength moves to page-content.js to avoid an import cycle.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): read a failed rewrite from the draft, and only the latest batch's rows

The editor reads content_drafts.agent_run, so a failed rewrite is tried again
as one on every device (the localStorage mark is gone). Fix open rules' new
409 'writing' says the agent is already writing. getDraftSuggestions finds
the latest batch first and reads only its rows, and Compare's links can't
take focus.

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

* fix(content): say in the agent card why Run Agent won't run

The card's Run Agent writes its reason in the card's second line (amber, tied
to the button by aria-describedby) instead of a hover title, and is turned
off when the only rules left open are ones the agent doesn't fix (one H1),
as the Rules card does.

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

* chore(content): keep AddSourceInput as Prettier formats it

A merge brought in a line formatted by another Prettier version; this puts
back main's formatting, so format:check passes.

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

* fix(content): recommend no Run Agent choice that is turned off

With only One H1 open and no rewrite advice, ▾ no longer shows the disabled
Fix as Recommended.

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

* fix(content): match an added figure by its unit, and read none from dates, addresses or words

A claim (a %, a ×, a scale, a currency) is known only with the same unit or
sign, so a fan-out's "crm for 50 users" no longer sources "50%". Today adds
only its year. A cited page's address is no words of its own. The brand's
name and industry are known, digits stuck to a letter ("B2B", "H2") are no
figure, and a source number written into a reason is taken out.

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

* feat(content): name the agent's steps by the work the server does

Short names for what each run does (CE-027/035): Fix and a rewrite read the
rules, gather the sources (numbered, so a number can be checked), write, and
check what they wrote (a number needs a source, a link must be allowed, a
locked passage stays). The brief gathers, writes the outline and matches
fan-outs. "Reading 20 cited pages" is gone: the agent sees their addresses,
not their content.

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

* fix(content): name the Rules tab's button as it reads now in a test and two lines

A test from main still pressed "Apply rules with Agent", and two messages
still named it; the button is Run Agent, its default Fix open rules.

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

* fix(content): charge a call Stop aborted, end only a run's own claim, and stop the run named

- A Stop that aborts a model call already sent keeps its hold on the AI
  budget as its cost (reserveAiBudget's keep()), since the provider bills
  it; a run stopped before its call sends nothing (runCall).
- A background run ends only the claim it still holds (agent_state_at), so
  one stopped from another server never clears a newer run's.
- A run closes only runs a stopped server left (older than RUN_STALE_MS),
  and /stop takes an optional runId, so another tab's run goes on.

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

* feat(content): show the steps by their new names, and stop the run the editor shows

The step chips read the server's short names (Reading 4 rules, Gathering 52
sources, Writing changes, Checking sources). Stop sends the run's id, so
another tab's run goes on. The waiting page keeps the run's last steps and
reads the draft as soon as its run ends, and a hidden tab reads the run every
AGENT_POLL_MS, then at once when it shows again.

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

* test(content): read the hook's run from what it renders

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

* fix(content): call the cited-page figure the median it is, and stop its reads with the run

The Brief's Length now says "a typical cited page has N characters (median of
M)". A Stop settles the cited-page read on nothing at once: the run's signal
ends each page read (fetchPage takes a signal beside its timeout), so a fast
model answer followed by a Stop never waits on them.

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

* fix(content): show loading without a spinning ring anywhere in Content

Every Loader2 spinner in Content (the editor, Library, Plan, the content
page and its dialogs and menus, the webhook settings) is now LoadingDots:
three dots that bounce in turn, in the text's color, still with reduced
motion, as the Content Editor brief asks ("no spinning ring anywhere"). The
agent's WorkingDots are built on it.

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

* feat(content): read the draft's Readability and show it in Instructions › Quality (CE-036, CE-039)

Quality spec Phase 1, behind NEXT_PUBLIC_CONTENT_QUALITY_PHASE (off unset):
- readability.ts: seven checks read from the draft in the browser, no AI
  cost — average sentence 15–20 words, none over 35, reading level by the
  language's formula (Flesch, Ateşman, Amstad, Kandel–Moles,
  Fernández-Huerta; else sentence and word length), answer first, short
  paragraphs, a heading every 200–300 words, passive voice and jargon
  (English). A check a language can't be read for is left out and the
  score rescaled to 100.
- Instructions gets a Quality segment: the score with its band (80+
  Strong, 60–79 Can improve, under 60 Needs work), "Ansvisor estimates
  based on Google's published quality signals. Not a Google score.", and
  what would raise it, the biggest gain first, with Show.
- The header gets a "Quality {score}" chip that opens it.

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

* fix(content): read Readability from the page's own blocks, and show a passage by its block

- A quote's and a list item's paragraphs are read apart (the editor's HTML
  has no space between tags) and a nested list once; sentence length is
  measured on running text, a list's points aside, and a page of short
  sentences is asked to join some.
- Fernández-Huerta subtracts words per sentence (the corrected form).
- Answer first skips an empty line, fails without an H1, and reads an H1's
  subject without its question and common words.
- Abbreviations don't end a sentence; "-ted" keeps its syllable, French
  "-ent" is no silent ending, Turkish â î û are vowels; "is indeed" isn't
  passive, jargon is read in all its forms, and Show goes to what falls short.
- Show finds the passage's block in the page (never a suggestion's card)
  and marks it with a decoration; the band is read out with the chip and
  the segment's badge.

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

* fix(content): count a passive sentence that says not or never in Readability

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

* feat(content): add Settings › Authors, the real people a page is by (CE-037)

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

* fix(content): let whoever added an author edit it, link only yourself, and renumber to 00251

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

* feat(content): name the page's author in the editor's header and a Page info strip outside the page (CE-038)

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

* fix(content): keep the Page info strip right under the H1, count authors' pages only in Settings

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

* fix(content): draw the Page info strip as the mockup's one line, with the author's face and title at the brand

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

* feat(content): score E-E-A-T from the page's author and Trust from the agent's sourced claims in Quality (CE-039)

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

* fix(content): score only checks that can fail: no Trust and no author schema until they read the page

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

* fix(content): say only what an author's profile is missing in Quality

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

* feat(content): read a draft's links once a day for Trust: working or broken, and their page's date

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

* fix(content): read only a saved draft's links, a few at a time and within a budget, and date pages by their own entity

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

* feat(content): score Trust from the page's sourced figures, fresh sources and working links (CE-039)

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

* fix(content): reserve link reads up front, say which links are never read, and date an article before its page

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

* fix(content): compare links as the draft saves them, count each link and sentence once, and read prices and sizes as no figures

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

* feat(audit): read a brand's site trust: About, Contact, editorial policy, Organization schema and author pages (CE-043)

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

* fix(audit): read site trust in parallel and once per brand, tell a page from the home page, and re-read a partial read soon

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

* feat(audit): show Site trust n/5 in Site Audit, and count it in Quality's Trust (CE-043)

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

* fix(audit): scroll to Site trust from Quality, keep it per brand, say when checking again fails, and count it only beside the page's own Trust

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

* fix(audit): give the Site trust card its own key beside the auto-run notice

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

* feat(content): list what only you can do in Quality, and nudge the next one (CE-040)

Your to-dos in Instructions › Quality: picking the page's author (or adding
one) and completing their profile move out of the suggestions, with a box
the checks tick and E-E-A-T's gain. A dark "Next for you" pill names the
first open one when the agent's run ends (not a failed or stopped one),
when the last open suggestion is accepted (Accept all, one by one, or the
page rewrite) and on Mark ready, once per moment and to-do in the session;
Later hides it. Its words go to a status kept on the page for screen
readers.

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

* feat(content): check the page before it's marked ready, with its JSON-LD to paste (CE-041)

Before you publish opens on Mark ready once Quality is live: a warning
only when Trust is under 60 (the check that raises it most, and to about
what), a note while the page's links are still being read, what the CMS
does for the page (author, visible dates, schema), and for an article an
Article JSON-LD from the title, author, brand, its image and today's date
(Person with sameAs, or the brand's Organization; no author while the
authors aren't read; a live page keeps its published date) with Copy
JSON-LD. Fix first goes to Quality and puts the caret at the passage.
Mark ready anyway is logged with the page's Trust and the check named
(00255 content_draft_ready_log: members add rows as themselves for a
ready draft, three columns only). useLinkChecks also says how many reads
may still come.

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

* feat(content): keep the Content Agent from inventing people and quotes (CE-044)

Every person's name and quoted sentence the agent writes is looked up in
what it was given: the page, the brand, the brief, the rules, the
person's data (Sources) and Settings › Authors. One that isn't becomes a
placeholder ("[name of a real person]", "[quote from a real person, with
its source]"): in Fix open rules' and the first optimize's suggestions,
read in their words as written before they are cleaned; in a page
written whole; and in a rewrite before what it kept goes back, so the
page's own passages are never touched.

A name is read where a person is plainly meant: an honorific, a role
("CEO Jane Doe", "Jane Doe, head of sales", "Jane Doe (CEO)"), or speech
("Jane Doe said", "according to Jane Doe", "Ayşe Yılmaz'a göre"); a
known author stays with the words before it, and a heading is read for
quotes and speech only. A quote is two words or more in quotation marks
next to speech, four or more anywhere, or a blockquote or <q> (its cite
read for the name), across the bold and the links in a line. One reading
per word keeps long text fast.

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

* feat(content): list the placeholders the agent left as the first to-do (CE-044)

Your to-dos in Quality now opens with "Fill {n} placeholders" while the
page has words in square brackets (what the agent leaves where it had no
real name, quote or number), with Show on the first. The Next for you
nudge names it too ("Show now"). Only the person can fill them; an export
never ships one (CE-057).

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

* feat(content): export the page ready to paste, with its page fields (CE-057)

Export, once Quality is live, asks where the page goes: Webflow,
WordPress, Shopify or Google Docs (copied as rich text to paste in; the
CMSs' H1 left out for their title field), Word or Markdown (downloaded),
or HTML. It shows the page as it was when it opened.

No export carries a placeholder. Fill now selects the first (in the HTML
view's text too, or says it is in an HTML block); Export without them
leaves out the sentences they are in, read as a reader would ("1.5",
"e.g." and "acme.com" end none), one outside a line, in alt text or in
JSON-LD alone. One in the title or a heading is filled first. Copy HTML
sends a page with one to Export too.

It lists what it checks (clean HTML or the HTML blocks' own code, the
links that answer or couldn't be read, the images' alt text) and the
page fields, read from the page as it goes out (its title, first
paragraph, live address or title as a slug, author, first image), each
with Copy. Word gets them as a table on page 1, Markdown as front matter
(with the date, the title not again as an H1), HTML in its head.

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

* fix(content): count a link the site refused as unread, and the title's placeholder once

Trust's link reads say "unknown" when a site refused the read or timed
out (a bot wall, a 403): Export no longer counts such a link as read, so
it never says the links answer for one that wasn't. A title that is the
page's H1 has its placeholders counted with the page, not twice.

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

* feat(content): check the page before Export, with a Ready to paste row (CE-057)

Before you publish now opens on Export too (§7), then goes on to Export
with Continue to export; its Trust warning says the page can be exported
anyway, and nothing is logged. On Mark ready and on Export alike, a last
row reads Ready to paste: no placeholders, every image with alt text,
every link working; what is still open is named ("2 placeholders still
open · 1 image has no alt text"), and links that weren't read are said
to be unchecked, never to work. It is read from the page as it is when
the dialog opens.

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

* feat(content): let a brand add the byline to its exported content (CE-057)

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

* fix(content): keep the loading dots visible with reduced motion

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

* fix(content): check author profile links in the table, unlink a removed member and revoke anon

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

* fix(content): let a Stop go only of the claim the stopped run holds

A Stop that named a Fix or brief run cleared agent_state whatever the run
was, so a Start or Rewrite on the same draft went on without its claim.
Each run now carries the claim it holds (content_agent_runs.claimed_at,
00249), stopDraftRun answers it, and the route clears agent_state only
where agent_state_at is still that claim.

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

* fix(content): say in the Remove dialog that the author's pages go back to the team byline

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

* fix(content): date a page over the read cap from its start, and count a private-address link as broken

fetchPage gets an opt-in truncate that resolves with the first maxBytes
instead of refusing the page, and the link check uses it, so a large
article page still gives its date and stays working. A link the fetch
refuses as a private or local address reads as broken, since no reader
of the published page can open it; a non-standard port stays unknown.

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

* fix(content): offer Edit author in Quality only to who can edit that author, and say who can otherwise

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

* fix(content): read discounts, materials and short forms as no figures, and score Trust only with a figure or a dated source

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

* fix(audit): read a bot wall as unsure, read a walled home page through Scrape.do once a day, and look for author pages at the usual addresses

A 401/403/429, or a 200 challenge page, now leaves the read incomplete
instead of failing About, Contact, Editorial or Organization schema for a
day (looksBlocked from site-pages.js). A walled home page goes through
Scrape.do, unrendered, at most once a day per brand (site_trust.scraped_at),
and a pass it read stands for that day while the wall hides the page.
An author the page list has no page for is looked for at /author/<slug>
and /authors/<slug> (a few authors per read), with the probes' guards and
their name in the title or H1. readSiteTrust returns complete, so the web
can tell a partial read from a fix to make.

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

* fix(audit): hold Check again until the read can change, say when the site didn't answer, and say Site trust counts in Quality

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

* fix(content): leave a placeholder title out of the JSON-LD headline, and say why

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

* feat(content): recommend the next step from the header and the agent card (Next step basket)

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

* chore(content): move Show's doc comment back onto showInPage

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

* fix(content): read Readability in the draft's language, and split its sentences where they end

- Japanese, Chinese and Thai, written without spaces between words, get no
  score: Quality says "Readability isn't read for this language yet"
  instead of asking for more paragraphs. Sentences also end after 。!?,
  । and ؟, and a Hindi word keeps its vowel signs, so Hindi is read by its
  own sentences and words.
- The language is the draft's Language rule when it is on, else the
  brand's; every brand language's name is read ("Portuguese", "Brazilian
  Portuguese", "日本語"…).
- A sentence doesn't end before a lower-case word, nor at a German or
  Turkish ordinal ("am 3. Oktober") or a language's common abbreviations
  ("z. B.", "p. ex.", "örn."); one before a number only ("No. 5") counts
  there. A full stop before a closing quote or bracket ends one.
- Show goes to the first copy of a passage, and a second Show within the
  moment keeps its mark for the full time.
- Passive voice reads common irregular participles (sent, found, held…).

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

* fix(content): know a name only as whole words, read a bare name only with a verb said of people, and run on without the authors

isKnown matched names as substrings of what the agent was given, so
"Dr. Sarah Chen" passed on a page with "kitchen" and "Mr. Doe" on one
with "does". Both sides are now compared as whole words. A name without
an honorific or role is read only with said, told, explained, recalled,
admitted, insisted or argued (and German sagte, Turkish söyledi), so
"Google Ads recommends" or "according to Google Analytics" no longer
become name placeholders. authorWords logs a failed read (content_authors
not there yet) and reads as no author words instead of failing the run.

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

* fix(content): read the page for export in a document of its own, and JSON-LD by its strings

Export reads the page in a document of its own, so nothing in it loads or
runs. A JSON-LD is read by its string values: its arrays are no placeholders,
and Export without them clears the strings and keeps it valid JSON. In a
title or a heading only the agent's own placeholder forms hold the export,
so "Best CRM tools [2026 Update]" goes out as written. A live page's
Markdown front matter gets lastmod instead of date, and the draftHtmlDocument
comment is back on its function.

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

* fix(content): offer Edit author on the profile to-do only to who can edit the author

#1414's review fix moved here: the to-dos replaced E-E-A-T's suggestions,
so the to-do now carries the rule (whoever added the author, the author
themself or an admin) and tells anyone else who can.

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

* refactor(content): read the title's placeholder with the shared pattern

#1420 kept its own copy while placeholders.ts wasn't below it; now it is.

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

* test(content): expect the dated source line's corrected plural

#1416's review fix reads "1 of 1 dated source is over 24 months old".

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

* fix(content): read Ready to paste once per change, and fill in the HTML view only where it counts

Ready to paste is read in a useMemo while Before you publish is open, not
on every render. A link still being read is told from one no read is coming
for (a refused read, one past the limit, one in an HTML block). The title's
placeholders count once when any heading or the page's first line reads as
it, H1 or not. In the HTML view, Fill now searches only where the count
reads: tags (but alt and title), styles, other scripts and a JSON-LD's
non-strings are blanked first (blankCode, reused for the byline). A page
test shows a FAQPage's JSON-LD reads Ready to paste as done.

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

* fix(content): pass the nudge whether the member can edit the author

Its to-do text names who can complete the profile when they can't.

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

* test(content): give Before you publish's quality read whether the member can edit the author

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

* chore(content): type the agent run's claimed_at

#1400 adds the column to 00249.

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

* fix(content): write the content byline in the brand's language, under the lead's own H1

The byline line Add byline to content puts in the page is written in the
brand's language (brands.language): "Yazar: Ayşe Yılmaz", "Por Ana Silva",
"Vom Acme-Team", from a small table for English, Turkish, German, French,
Spanish, Portuguese, Italian, Dutch and Swedish; any other language gets the
name alone, or the brand's. Before you publish quotes the line as it goes
out. withByline puts it after the end tag of the lead's own H1, counted with
comments and code blanked, so an empty H1 above the title or one in a
comment or a script no longer takes it.

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

* test(content): wait for Before you publish to move focus to Continue to export

The dialog focuses its button after it opens; checking at once failed now
and then under load.

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

* docs(content): say the byline follows the page's language

With #1411 below it, the editor reads the draft's Language rule first.

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

* fix(content): type the H1 list the byline counts in

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

* fix(content): keep focus where it went when the basket closes, and hold a skip until every read is in

Review fixes for the Next step basket:
- focus goes back to the Next button only from inside the basket or from
  nowhere (Base UI's own rule); after Skip, the new step's button takes it
  and the step is read out
- stale skips are dropped only once the sources, the site's trust and the
  link reads are in
- an empty page is read past the block its title comes from
- Before you publish and Mark ready are held as the header's Mark ready is
- Rewrite page sits beside Fix open rules where the Rules tab recommends it,
  and "If you see…" takes its count from REWRITE_OPEN_RULES

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

* feat(content): fit the editor header to its width, its icon buttons labelled on hover and focus (Next step basket, part 2)

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

* feat(billing): show the month's AI usage at the top right of the main pages (AI usage display, part 1)

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

* feat(billing): warn under each page's header from 80% of the month's AI usage, and once it's used up (AI usage display, part 2)

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

* feat(content): show the month's AI usage in the editor header and hold agent buttons once it's used up (AI usage display, part 3b)

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]>
gkhngyk pushed a commit that referenced this pull request Oct 24, 2026
… the editor header (Send to CMS #1331, part 2: web) (#1438)

* feat(billing): show this period's AI usage on the Billing page

The workspace's one AI budget (Improve, the Content Editor's AI and the
Action Center's task writer) had no meter: the first sign of it was an
"AI usage is used up" error. Migration 00242 records what each AI call
was for (prompt_improve_usage.feature, backfilled) and sums the period's
spend by feature (ai_usage_by_feature). GET /api/billing/ai-usage
returns the shares of the plan's budget, and the Billing page shows the
share used, when it resets and what used it, with Agent Chat noted as
running on the workspace's own key.

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

* fix(billing): hold an AI call's share of the budget before it runs

The workspace's AI budget was checked by reading the period's spend; the
call's cost was written once the model answered. Calls running at once
(two tabs, a teammate, an Action Center sweep) all read the same spend
and all ran past the budget. 00243's reserve_ai_usage takes a
per-organization lock, reads the spend with the calls in flight, and
holds the call's estimated cost; reserveAiBudget turns the hold into the
real cost or releases it. Improve, the brief rebuild, Apply rules with
Agent, Start Agent and the Action Center task writer use it in place of
enforceImproveQuota, which goes.

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

* fix(billing): charge a schema miss and hold the org's recent median cost

Review fixes:
- Apply rules with Agent and Start Agent charge an answer the provider
  billed but that missed the schema (NoObjectGeneratedError), as Improve,
  the brief and the task writer do; before, the hold was let go and the
  call ran free.
- A call holds the org's median cost over its last 20 calls this period,
  never less than the model's typical cost, so calls in flight pass the
  budget by far less.

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

* feat(content): rewrite a whole page to its rules as one suggestion

Apply rules with Agent makes at most 8 small edits a run, which can't
bring a long page to its Length (about 2% a run on prod). The Content
Agent can now rewrite the whole page in one background call, left as ONE
suggestion (kind 'page', migration 00247) to compare and accept or reject:
- POST /api/content-drafts/:draftId/rewrite, through Start Agent's claim,
  budget hold and background run;
- passages AI quotes today, tables, images, quotes and HTML blocks go to
  the model as [[KEEP n]] lines and come back as they were; a rewrite that
  drops one fails the run;
- one H1, only the page's own links and the ones offered, the editor's
  tags; the page as it was is kept on the suggestion (before_html).

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

* fix(content): describe a rewrite's kept blocks and count them toward Length

Review fixes:
- Kept blocks are described under the page (a quoted passage's words, a
  table's rows, an image's alt) and their text counts toward Length, so a
  rewrite aims at the whole page's length; with Length off it keeps the
  page's own. A kept H1 stays first, and the page's language is kept.
- The answer is taken out of a code fence, text left at its root goes in
  paragraphs, and an answer in Markdown fails the run.
- The page's own links stay exactly as written (query and anchor too).
- Kept blocks go back untouched (an empty table cell stays), only the
  page's first H1 counts as its title, a page that writes "[[KEEP" gets
  markers of its own, and a page that is only kept blocks isn't sent.

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

* feat(content): rewrite the page to its rules from the Rules tab, and compare it

The Rules tab opens with the agent's two ways to meet its rules: Apply
rules with Agent (small edits, up to 8 a run) and Rewrite the page to
these rules (the whole page as one change). The rewrite is recommended,
with a one-line reason, when the page is more than 30% off its Length or
4 rules or more are open.

A rewritten page comes back as one suggestion with its own bar over the
page: the characters before and after and the agent's reason, Compare
(the page and the rewrite side by side), Accept (History keeps the page
first), Reject, and Undo. A page that changed since the agent read it
isn't written over. The page waits for the rewrite with its own steps,
and a failed rewrite's Try again rewrites again.

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

* fix(content): compare a rewrite by its words and run one agent at a time

Review fixes:
- A page is compared with the one the agent read by its words, with a
  space between blocks, so stored line breaks and lists don't read as a
  change (Accept and Undo were refused on imported pages).
- One agent run at a time from the page; a rewrite never starts before
  the locked passages are read, and sends the editor's own locked keys.
- Accept holds the page still from the start and checks it again before
  putting the rewrite in; Undo puts the page back as it was (two H1s too),
  and the bar waits while the HTML view is open.
- No rewrite advice for an empty page or one too long to send whole; the
  rewrite mark survives a reload; the waiting view says the rewrite waits
  in the editor; Compare's links don't navigate.

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

* feat(content): show the Content Agent as a card over the page

Content Editor v1.1, part 1 (CE-025, CE-026, §4): the agent row and the
rewrite bar become one card above the toolbar, in three states:
- waiting: "Content Agent has {n} suggestions for you", what they change
  and the rules they gain ("Rules 5 → 6 of 13"), with Review (scrolls to
  the first suggestion and marks it), Reject all and Accept all; a page
  rewritten shows its characters, with Compare;
- all reviewed: what was accepted and the rules met and still open, with
  Undo all and Run Agent;
- working: while Apply rules with Agent runs.
The tile moves a little (a soft ring, a blink, a spark; a sweep and a
breath while working), never a rotating ring, and not at all with reduced
motion. The card wraps on a narrow page; Accept all and Run Agent are the
primary buttons.

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

* fix(content): agent card review fixes

- Run Agent on the card keeps to one agent run at a time and says why it
  waits; Apply rules never starts beside another run or before the locked
  passages are read.
- Ghost buttons show their hover on the card's grey; the tile and its
  count are hidden from screen readers (the title says it) and the count
  is darker for contrast; "+N more" comes from en.json, the reason's first
  letter is upper-cased in the page's locale.
- Review picks the first open suggestion in the page's order and focuses
  it; the sweep shows on the light tile in dark mode; the spark is slower
  once all are reviewed; without motion the working line is a faint full
  line; "0 still open" isn't said.
- globals.css keeps its own lines; only the motion block is added.

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

* feat(content): put brief and rules under one Instructions tab with a split Run Agent

Content Editor v1.1 part 2 (CE-028–CE-031): the side panel's tabs become
Instructions · Sources · Live page. Instructions holds Brief | Rules, with
the rules still open on the tab and the segment. Each segment opens with a
status card: Rules has one split Run Agent ▾ (Fix open rules, or Rewrite
the whole page, which renames it "Rewrite page") in place of the two rule
buttons; Brief has Run Agent while empty and Rebuild brief once written.
Why the agent can't run is written under the card, and each card's ⓘ tip
opens below it. The brief shows "Not set yet" and its Length in characters
and about as many words; the toolbar counter adds the page's words.

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

* fix(content): instructions tab review fixes

- Run Agent's choice is worked out once and falls back to Fix without a
  rewrite; once a rewrite starts, the button is back on Fix.
- ▾'s choices are menu radio items; Fix is off when only rules the agent
  can't fix are open, and the card says what to do instead.
- The reason line under the card stays mounted for screen readers; Rewrite
  from brief writes its reason too; the tab's count is read out.
- Brief | Rules switch with the arrow keys, one tab stop.
- An edited brief's rebuild question sits under the card; a brief without
  H2s says to rebuild it; an empty brief shows no origin line.
- Plural copy for the open suggestions and the counter's words; rule names
  joined by the formatter; Run Agent's tip leaves ▾ out without a rewrite.

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

* feat(content): show the data the Content Agent writes from

Content Editor v1.1 part 3 (CE-032, CE-034): under each Run Agent card,
"Uses your data: 1 prompt · 21 fan-outs · 20 cited pages · 10 Search
Console queries · Edit sources", counted as the Sources tab keeps them, so
turning one off lowers it at once. The Sources tab carries its count, and
its top says "N sources in use" and when the Content Agent last wrote from
them (its latest suggestions or the brief it built). A first visit's note
at the top of Instructions says the agent writes from the person's data;
closing it is kept in their own user metadata.

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

* fix(content): data note review fixes

- "Last used by Content Agent" also counts the agent writing the page
  (agent_state_at: Start with Agent, Rewrite from brief on a new page),
  not a run that failed; a value that isn't a date is skipped.
- The latest batch's time is its first suggestion's, not a sort per render.
- Tests: the Brief segment's line, no line while the sources can't be read,
  the tab's count, the note showing again after a failed write, and a
  suggestion read with its createdAt.

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

* feat(content): have the Content Agent write from the kept sources and name them

Content Editor v1.1, CE-033 (server): Fix open rules, Start with Agent and
Rewrite the whole page read the sources the Sources tab keeps, numbered
S1, S2… (content-sources.js). Each suggestion keeps the sources it names
and the words each supports (content_draft_suggestions.sources and
source_marks, 00248); a page rewritten whole keeps its sources.

No number without a source: the model reads a source by its words only, so
a number the agent adds must be the page's, the brand's, the brief's, the
rules', today's, or in a source's own words (then marked to it). A
suggestion with any other number is not kept; a page written whole gets a
placeholder in its place. Source numbers written into the words are taken
out.

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

* feat(content): show what each agent suggestion was written from

Content Editor v1.1, CE-033 (web) and the rest of CE-034: under each
suggestion, "Based on" chips name the sources it used (number, kind, name;
the Sources tab's details on hover), and a small number marks the words
each supports. A click on either opens Sources on that row, scrolled to
and ringed for a moment, once. The agent card adds "built from N of your
sources · See sources". Fix open rules sends the kept sources, and the
first-visit note says every change shows the sources it used.

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

* feat(content): write the Content Agent's runs step by step and stop them

Content Editor v1.1, CE-027/035 (server): each Content Agent run (Fix open
rules, Start with Agent, Rewrite the whole page, the brief) is written in
content_agent_runs (00249) with its steps named by the data it reads
("Reading 20 cited pages", "Matching 21 fan-outs", "Writing 3 changes") as
it reaches them. POST /api/content-drafts/:id/stop marks the run stopped
and aborts its model call; the run checks before it keeps anything, so a
stopped run changes nothing (no suggestions, page, brief or History).

A run that can't be written still runs; runs a stopped server left are
closed when the next starts, and Stop ignores them. Background runs are
written before Start answers, so Stop finds them at once.

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

* fix(content): let go of a background draft when its run is stopped

Stop also clears the draft's 'writing' state at once: a background run lets
go once it sees the stop, but one no server holds any more never would, and
the waiting page would wait out the 10 minutes.

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

* feat(content): show the content agent's steps while it works, and stop it (CE-027, CE-035)

The agent card, the brief and the waiting page show the run's real steps
(content_agent_runs, read from the browser every second) and a Stop button
that ends the run through the API proxy, leaving the page as it was. A dashed
decoration under the H1 says where Fix is drafting, and the agent's dots
replace every spinner on its buttons.

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

* feat(content): show the cited pages' length next to the brief's Length (CE-030)

When the brief is rebuilt, the server reads the first few cited pages kept
in Sources (only addresses AI answers cited for the brand, never the draft's
own page), counts their main text as the Rules tab counts length, and saves
the median as brief.citedLength. The Brief tab says "From the rules · cited
pages average N characters"; with fewer than two pages read it stays "From
the rules". textLength moves to page-content.js to avoid an import cycle.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): read a failed rewrite from the draft, and only the latest batch's rows

The editor reads content_drafts.agent_run, so a failed rewrite is tried again
as one on every device (the localStorage mark is gone). Fix open rules' new
409 'writing' says the agent is already writing. getDraftSuggestions finds
the latest batch first and reads only its rows, and Compare's links can't
take focus.

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

* fix(content): say in the agent card why Run Agent won't run

The card's Run Agent writes its reason in the card's second line (amber, tied
to the button by aria-describedby) instead of a hover title, and is turned
off when the only rules left open are ones the agent doesn't fix (one H1),
as the Rules card does.

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

* chore(content): keep AddSourceInput as Prettier formats it

A merge brought in a line formatted by another Prettier version; this puts
back main's formatting, so format:check passes.

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

* fix(content): recommend no Run Agent choice that is turned off

With only One H1 open and no rewrite advice, ▾ no longer shows the disabled
Fix as Recommended.

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

* fix(content): match an added figure by its unit, and read none from dates, addresses or words

A claim (a %, a ×, a scale, a currency) is known only with the same unit or
sign, so a fan-out's "crm for 50 users" no longer sources "50%". Today adds
only its year. A cited page's address is no words of its own. The brand's
name and industry are known, digits stuck to a letter ("B2B", "H2") are no
figure, and a source number written into a reason is taken out.

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

* feat(content): name the agent's steps by the work the server does

Short names for what each run does (CE-027/035): Fix and a rewrite read the
rules, gather the sources (numbered, so a number can be checked), write, and
check what they wrote (a number needs a source, a link must be allowed, a
locked passage stays). The brief gathers, writes the outline and matches
fan-outs. "Reading 20 cited pages" is gone: the agent sees their addresses,
not their content.

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

* fix(content): name the Rules tab's button as it reads now in a test and two lines

A test from main still pressed "Apply rules with Agent", and two messages
still named it; the button is Run Agent, its default Fix open rules.

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

* fix(content): charge a call Stop aborted, end only a run's own claim, and stop the run named

- A Stop that aborts a model call already sent keeps its hold on the AI
  budget as its cost (reserveAiBudget's keep()), since the provider bills
  it; a run stopped before its call sends nothing (runCall).
- A background run ends only the claim it still holds (agent_state_at), so
  one stopped from another server never clears a newer run's.
- A run closes only runs a stopped server left (older than RUN_STALE_MS),
  and /stop takes an optional runId, so another tab's run goes on.

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

* feat(content): show the steps by their new names, and stop the run the editor shows

The step chips read the server's short names (Reading 4 rules, Gathering 52
sources, Writing changes, Checking sources). Stop sends the run's id, so
another tab's run goes on. The waiting page keeps the run's last steps and
reads the draft as soon as its run ends, and a hidden tab reads the run every
AGENT_POLL_MS, then at once when it shows again.

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

* test(content): read the hook's run from what it renders

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

* fix(content): call the cited-page figure the median it is, and stop its reads with the run

The Brief's Length now says "a typical cited page has N characters (median of
M)". A Stop settles the cited-page read on nothing at once: the run's signal
ends each page read (fetchPage takes a signal beside its timeout), so a fast
model answer followed by a Stop never waits on them.

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

* fix(content): show loading without a spinning ring anywhere in Content

Every Loader2 spinner in Content (the editor, Library, Plan, the content
page and its dialogs and menus, the webhook settings) is now LoadingDots:
three dots that bounce in turn, in the text's color, still with reduced
motion, as the Content Editor brief asks ("no spinning ring anywhere"). The
agent's WorkingDots are built on it.

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

* feat(content): read the draft's Readability and show it in Instructions › Quality (CE-036, CE-039)

Quality spec Phase 1, behind NEXT_PUBLIC_CONTENT_QUALITY_PHASE (off unset):
- readability.ts: seven checks read from the draft in the browser, no AI
  cost — average sentence 15–20 words, none over 35, reading level by the
  language's formula (Flesch, Ateşman, Amstad, Kandel–Moles,
  Fernández-Huerta; else sentence and word length), answer first, short
  paragraphs, a heading every 200–300 words, passive voice and jargon
  (English). A check a language can't be read for is left out and the
  score rescaled to 100.
- Instructions gets a Quality segment: the score with its band (80+
  Strong, 60–79 Can improve, under 60 Needs work), "Ansvisor estimates
  based on Google's published quality signals. Not a Google score.", and
  what would raise it, the biggest gain first, with Show.
- The header gets a "Quality {score}" chip that opens it.

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

* fix(content): read Readability from the page's own blocks, and show a passage by its block

- A quote's and a list item's paragraphs are read apart (the editor's HTML
  has no space between tags) and a nested list once; sentence length is
  measured on running text, a list's points aside, and a page of short
  sentences is asked to join some.
- Fernández-Huerta subtracts words per sentence (the corrected form).
- Answer first skips an empty line, fails without an H1, and reads an H1's
  subject without its question and common words.
- Abbreviations don't end a sentence; "-ted" keeps its syllable, French
  "-ent" is no silent ending, Turkish â î û are vowels; "is indeed" isn't
  passive, jargon is read in all its forms, and Show goes to what falls short.
- Show finds the passage's block in the page (never a suggestion's card)
  and marks it with a decoration; the band is read out with the chip and
  the segment's badge.

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

* fix(content): count a passive sentence that says not or never in Readability

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

* feat(content): add Settings › Authors, the real people a page is by (CE-037)

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

* fix(content): let whoever added an author edit it, link only yourself, and renumber to 00251

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

* feat(content): name the page's author in the editor's header and a Page info strip outside the page (CE-038)

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

* fix(content): keep the Page info strip right under the H1, count authors' pages only in Settings

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

* fix(content): draw the Page info strip as the mockup's one line, with the author's face and title at the brand

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

* feat(content): score E-E-A-T from the page's author and Trust from the agent's sourced claims in Quality (CE-039)

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

* fix(content): score only checks that can fail: no Trust and no author schema until they read the page

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

* fix(content): say only what an author's profile is missing in Quality

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

* feat(content): read a draft's links once a day for Trust: working or broken, and their page's date

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

* fix(content): read only a saved draft's links, a few at a time and within a budget, and date pages by their own entity

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

* feat(content): score Trust from the page's sourced figures, fresh sources and working links (CE-039)

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

* fix(content): reserve link reads up front, say which links are never read, and date an article before its page

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

* fix(content): compare links as the draft saves them, count each link and sentence once, and read prices and sizes as no figures

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

* feat(audit): read a brand's site trust: About, Contact, editorial policy, Organization schema and author pages (CE-043)

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

* fix(audit): read site trust in parallel and once per brand, tell a page from the home page, and re-read a partial read soon

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

* feat(audit): show Site trust n/5 in Site Audit, and count it in Quality's Trust (CE-043)

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

* fix(audit): scroll to Site trust from Quality, keep it per brand, say when checking again fails, and count it only beside the page's own Trust

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

* fix(audit): give the Site trust card its own key beside the auto-run notice

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

* feat(content): list what only you can do in Quality, and nudge the next one (CE-040)

Your to-dos in Instructions › Quality: picking the page's author (or adding
one) and completing their profile move out of the suggestions, with a box
the checks tick and E-E-A-T's gain. A dark "Next for you" pill names the
first open one when the agent's run ends (not a failed or stopped one),
when the last open suggestion is accepted (Accept all, one by one, or the
page rewrite) and on Mark ready, once per moment and to-do in the session;
Later hides it. Its words go to a status kept on the page for screen
readers.

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

* feat(content): check the page before it's marked ready, with its JSON-LD to paste (CE-041)

Before you publish opens on Mark ready once Quality is live: a warning
only when Trust is under 60 (the check that raises it most, and to about
what), a note while the page's links are still being read, what the CMS
does for the page (author, visible dates, schema), and for an article an
Article JSON-LD from the title, author, brand, its image and today's date
(Person with sameAs, or the brand's Organization; no author while the
authors aren't read; a live page keeps its published date) with Copy
JSON-LD. Fix first goes to Quality and puts the caret at the passage.
Mark ready anyway is logged with the page's Trust and the check named
(00255 content_draft_ready_log: members add rows as themselves for a
ready draft, three columns only). useLinkChecks also says how many reads
may still come.

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

* feat(content): keep the Content Agent from inventing people and quotes (CE-044)

Every person's name and quoted sentence the agent writes is looked up in
what it was given: the page, the brand, the brief, the rules, the
person's data (Sources) and Settings › Authors. One that isn't becomes a
placeholder ("[name of a real person]", "[quote from a real person, with
its source]"): in Fix open rules' and the first optimize's suggestions,
read in their words as written before they are cleaned; in a page
written whole; and in a rewrite before what it kept goes back, so the
page's own passages are never touched.

A name is read where a person is plainly meant: an honorific, a role
("CEO Jane Doe", "Jane Doe, head of sales", "Jane Doe (CEO)"), or speech
("Jane Doe said", "according to Jane Doe", "Ayşe Yılmaz'a göre"); a
known author stays with the words before it, and a heading is read for
quotes and speech only. A quote is two words or more in quotation marks
next to speech, four or more anywhere, or a blockquote or <q> (its cite
read for the name), across the bold and the links in a line. One reading
per word keeps long text fast.

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

* feat(content): list the placeholders the agent left as the first to-do (CE-044)

Your to-dos in Quality now opens with "Fill {n} placeholders" while the
page has words in square brackets (what the agent leaves where it had no
real name, quote or number), with Show on the first. The Next for you
nudge names it too ("Show now"). Only the person can fill them; an export
never ships one (CE-057).

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

* feat(content): export the page ready to paste, with its page fields (CE-057)

Export, once Quality is live, asks where the page goes: Webflow,
WordPress, Shopify or Google Docs (copied as rich text to paste in; the
CMSs' H1 left out for their title field), Word or Markdown (downloaded),
or HTML. It shows the page as it was when it opened.

No export carries a placeholder. Fill now selects the first (in the HTML
view's text too, or says it is in an HTML block); Export without them
leaves out the sentences they are in, read as a reader would ("1.5",
"e.g." and "acme.com" end none), one outside a line, in alt text or in
JSON-LD alone. One in the title or a heading is filled first. Copy HTML
sends a page with one to Export too.

It lists what it checks (clean HTML or the HTML blocks' own code, the
links that answer or couldn't be read, the images' alt text) and the
page fields, read from the page as it goes out (its title, first
paragraph, live address or title as a slug, author, first image), each
with Copy. Word gets them as a table on page 1, Markdown as front matter
(with the date, the title not again as an H1), HTML in its head.

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

* fix(content): count a link the site refused as unread, and the title's placeholder once

Trust's link reads say "unknown" when a site refused the read or timed
out (a bot wall, a 403): Export no longer counts such a link as read, so
it never says the links answer for one that wasn't. A title that is the
page's H1 has its placeholders counted with the page, not twice.

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

* feat(content): check the page before Export, with a Ready to paste row (CE-057)

Before you publish now opens on Export too (§7), then goes on to Export
with Continue to export; its Trust warning says the page can be exported
anyway, and nothing is logged. On Mark ready and on Export alike, a last
row reads Ready to paste: no placeholders, every image with alt text,
every link working; what is still open is named ("2 placeholders still
open · 1 image has no alt text"), and links that weren't read are said
to be unchecked, never to work. It is read from the page as it is when
the dialog opens.

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

* feat(content): let a brand add the byline to its exported content (CE-057)

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

* fix(content): keep the loading dots visible with reduced motion

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

* fix(content): check author profile links in the table, unlink a removed member and revoke anon

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

* fix(content): let a Stop go only of the claim the stopped run holds

A Stop that named a Fix or brief run cleared agent_state whatever the run
was, so a Start or Rewrite on the same draft went on without its claim.
Each run now carries the claim it holds (content_agent_runs.claimed_at,
00249), stopDraftRun answers it, and the route clears agent_state only
where agent_state_at is still that claim.

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

* fix(content): say in the Remove dialog that the author's pages go back to the team byline

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

* fix(content): date a page over the read cap from its start, and count a private-address link as broken

fetchPage gets an opt-in truncate that resolves with the first maxBytes
instead of refusing the page, and the link check uses it, so a large
article page still gives its date and stays working. A link the fetch
refuses as a private or local address reads as broken, since no reader
of the published page can open it; a non-standard port stays unknown.

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

* fix(content): offer Edit author in Quality only to who can edit that author, and say who can otherwise

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

* fix(content): read discounts, materials and short forms as no figures, and score Trust only with a figure or a dated source

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

* fix(audit): read a bot wall as unsure, read a walled home page through Scrape.do once a day, and look for author pages at the usual addresses

A 401/403/429, or a 200 challenge page, now leaves the read incomplete
instead of failing About, Contact, Editorial or Organization schema for a
day (looksBlocked from site-pages.js). A walled home page goes through
Scrape.do, unrendered, at most once a day per brand (site_trust.scraped_at),
and a pass it read stands for that day while the wall hides the page.
An author the page list has no page for is looked for at /author/<slug>
and /authors/<slug> (a few authors per read), with the probes' guards and
their name in the title or H1. readSiteTrust returns complete, so the web
can tell a partial read from a fix to make.

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

* fix(audit): hold Check again until the read can change, say when the site didn't answer, and say Site trust counts in Quality

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

* fix(content): leave a placeholder title out of the JSON-LD headline, and say why

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

* feat(content): recommend the next step from the header and the agent card (Next step basket)

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

* chore(content): move Show's doc comment back onto showInPage

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

* fix(content): read Readability in the draft's language, and split its sentences where they end

- Japanese, Chinese and Thai, written without spaces between words, get no
  score: Quality says "Readability isn't read for this language yet"
  instead of asking for more paragraphs. Sentences also end after 。!?,
  । and ؟, and a Hindi word keeps its vowel signs, so Hindi is read by its
  own sentences and words.
- The language is the draft's Language rule when it is on, else the
  brand's; every brand language's name is read ("Portuguese", "Brazilian
  Portuguese", "日本語"…).
- A sentence doesn't end before a lower-case word, nor at a German or
  Turkish ordinal ("am 3. Oktober") or a language's common abbreviations
  ("z. B.", "p. ex.", "örn."); one before a number only ("No. 5") counts
  there. A full stop before a closing quote or bracket ends one.
- Show goes to the first copy of a passage, and a second Show within the
  moment keeps its mark for the full time.
- Passive voice reads common irregular participles (sent, found, held…).

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

* fix(content): know a name only as whole words, read a bare name only with a verb said of people, and run on without the authors

isKnown matched names as substrings of what the agent was given, so
"Dr. Sarah Chen" passed on a page with "kitchen" and "Mr. Doe" on one
with "does". Both sides are now compared as whole words. A name without
an honorific or role is read only with said, told, explained, recalled,
admitted, insisted or argued (and German sagte, Turkish söyledi), so
"Google Ads recommends" or "according to Google Analytics" no longer
become name placeholders. authorWords logs a failed read (content_authors
not there yet) and reads as no author words instead of failing the run.

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

* fix(content): read the page for export in a document of its own, and JSON-LD by its strings

Export reads the page in a document of its own, so nothing in it loads or
runs. A JSON-LD is read by its string values: its arrays are no placeholders,
and Export without them clears the strings and keeps it valid JSON. In a
title or a heading only the agent's own placeholder forms hold the export,
so "Best CRM tools [2026 Update]" goes out as written. A live page's
Markdown front matter gets lastmod instead of date, and the draftHtmlDocument
comment is back on its function.

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

* fix(content): offer Edit author on the profile to-do only to who can edit the author

#1414's review fix moved here: the to-dos replaced E-E-A-T's suggestions,
so the to-do now carries the rule (whoever added the author, the author
themself or an admin) and tells anyone else who can.

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

* refactor(content): read the title's placeholder with the shared pattern

#1420 kept its own copy while placeholders.ts wasn't below it; now it is.

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

* test(content): expect the dated source line's corrected plural

#1416's review fix reads "1 of 1 dated source is over 24 months old".

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

* fix(content): read Ready to paste once per change, and fill in the HTML view only where it counts

Ready to paste is read in a useMemo while Before you publish is open, not
on every render. A link still being read is told from one no read is coming
for (a refused read, one past the limit, one in an HTML block). The title's
placeholders count once when any heading or the page's first line reads as
it, H1 or not. In the HTML view, Fill now searches only where the count
reads: tags (but alt and title), styles, other scripts and a JSON-LD's
non-strings are blanked first (blankCode, reused for the byline). A page
test shows a FAQPage's JSON-LD reads Ready to paste as done.

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

* fix(content): pass the nudge whether the member can edit the author

Its to-do text names who can complete the profile when they can't.

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

* test(content): give Before you publish's quality read whether the member can edit the author

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

* chore(content): type the agent run's claimed_at

#1400 adds the column to 00249.

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

* fix(content): write the content byline in the brand's language, under the lead's own H1

The byline line Add byline to content puts in the page is written in the
brand's language (brands.language): "Yazar: Ayşe Yılmaz", "Por Ana Silva",
"Vom Acme-Team", from a small table for English, Turkish, German, French,
Spanish, Portuguese, Italian, Dutch and Swedish; any other language gets the
name alone, or the brand's. Before you publish quotes the line as it goes
out. withByline puts it after the end tag of the lead's own H1, counted with
comments and code blanked, so an empty H1 above the title or one in a
comment or a script no longer takes it.

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

* test(content): wait for Before you publish to move focus to Continue to export

The dialog focuses its button after it opens; checking at once failed now
and then under load.

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

* docs(content): say the byline follows the page's language

With #1411 below it, the editor reads the draft's Language rule first.

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

* fix(content): type the H1 list the byline counts in

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

* fix(content): keep focus where it went when the basket closes, and hold a skip until every read is in

Review fixes for the Next step basket:
- focus goes back to the Next button only from inside the basket or from
  nowhere (Base UI's own rule); after Skip, the new step's button takes it
  and the step is read out
- stale skips are dropped only once the sources, the site's trust and the
  link reads are in
- an empty page is read past the block its title comes from
- Before you publish and Mark ready are held as the header's Mark ready is
- Rewrite page sits beside Fix open rules where the Rules tab recommends it,
  and "If you see…" takes its count from REWRITE_OPEN_RULES

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

* feat(content): fit the editor header to its width, its icon buttons labelled on hover and focus (Next step basket, part 2)

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

* feat(billing): show the month's AI usage at the top right of the main pages (AI usage display, part 1)

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

* feat(billing): warn under each page's header from 80% of the month's AI usage, and once it's used up (AI usage display, part 2)

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

* feat(content): show the month's AI usage in the editor header and hold agent buttons once it's used up (AI usage display, part 3b)

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

* feat(content): send a Content Editor page to the brand's webhook from the editor header (Send to CMS #1331, part 2: web)

- Send to CMS in the editor header, for admins and managers, through
  Before you publish while Quality is on; the dialog fills slug, meta
  title and meta description from the page (or what the draft kept),
  holds the send while placeholders are open or the page is empty, and
  says the server's reasons in plain words
- the page goes as Export makes it ready: publishable HTML without its
  H1, with the brand's byline line, its author and an https featured image
- Webhook Settings gets the opt-in "Content page sent" event
- a long title's slug is cut at a word, as it now becomes the page's
  address in the CMS

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

* fix(content): save the page before it is sent, and hold Send until its last send is read

- openSend settles autosave first; a page it can't save isn't sent (send.unsaved toast)
- the Send dialog holds Send with Try again when the kept slug and meta can't be read
- the meta title prefill is cut at a word near 60 characters
- types: content_draft_deliveries.external_id (00262)

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

* test(content): close the Send dialog at each test's end, and click the page's own text outside the basket

The basket test clicked a button added to the document after the basket
opened, which Base UI takes for another app's: with the Send to CMS tests
before it, it failed one run in three.

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

* fix(content): hold Send for unapplied HTML and a second click, and keep the kept slug per field

- HTML edited in the HTML view and not applied asks to be applied first
- the header's Send waits while the page saves (one click), and is off
  while the page can't save (conflict, too large), as Mark ready is
- the dialog keeps what the draft kept in each field the person hasn't
  changed, the slug above all; Try again stays in place while it reads
- the meta title prefill cuts at any space, never inside an emoji, without
  the punctuation the cut leaves

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

* fix(content): end the basket's focus test without an unhandled error, and give a 2xx send's failure its reason

- the test clicks the page's text: ProseMirror reads the click's place
  with elementFromPoint, which jsdom lacks; it's stubbed for that test
- a send the webhook took (2xx) that the workflow then called back failed
  shows the workflow's reason, not "The webhook answered 200"

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

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 24, 2026
…each row's last send (Send to CMS #1331, part 3a: Library row) (#1439)

* feat(billing): show this period's AI usage on the Billing page

The workspace's one AI budget (Improve, the Content Editor's AI and the
Action Center's task writer) had no meter: the first sign of it was an
"AI usage is used up" error. Migration 00242 records what each AI call
was for (prompt_improve_usage.feature, backfilled) and sums the period's
spend by feature (ai_usage_by_feature). GET /api/billing/ai-usage
returns the shares of the plan's budget, and the Billing page shows the
share used, when it resets and what used it, with Agent Chat noted as
running on the workspace's own key.

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

* fix(billing): hold an AI call's share of the budget before it runs

The workspace's AI budget was checked by reading the period's spend; the
call's cost was written once the model answered. Calls running at once
(two tabs, a teammate, an Action Center sweep) all read the same spend
and all ran past the budget. 00243's reserve_ai_usage takes a
per-organization lock, reads the spend with the calls in flight, and
holds the call's estimated cost; reserveAiBudget turns the hold into the
real cost or releases it. Improve, the brief rebuild, Apply rules with
Agent, Start Agent and the Action Center task writer use it in place of
enforceImproveQuota, which goes.

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

* fix(billing): charge a schema miss and hold the org's recent median cost

Review fixes:
- Apply rules with Agent and Start Agent charge an answer the provider
  billed but that missed the schema (NoObjectGeneratedError), as Improve,
  the brief and the task writer do; before, the hold was let go and the
  call ran free.
- A call holds the org's median cost over its last 20 calls this period,
  never less than the model's typical cost, so calls in flight pass the
  budget by far less.

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

* feat(content): rewrite a whole page to its rules as one suggestion

Apply rules with Agent makes at most 8 small edits a run, which can't
bring a long page to its Length (about 2% a run on prod). The Content
Agent can now rewrite the whole page in one background call, left as ONE
suggestion (kind 'page', migration 00247) to compare and accept or reject:
- POST /api/content-drafts/:draftId/rewrite, through Start Agent's claim,
  budget hold and background run;
- passages AI quotes today, tables, images, quotes and HTML blocks go to
  the model as [[KEEP n]] lines and come back as they were; a rewrite that
  drops one fails the run;
- one H1, only the page's own links and the ones offered, the editor's
  tags; the page as it was is kept on the suggestion (before_html).

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

* fix(content): describe a rewrite's kept blocks and count them toward Length

Review fixes:
- Kept blocks are described under the page (a quoted passage's words, a
  table's rows, an image's alt) and their text counts toward Length, so a
  rewrite aims at the whole page's length; with Length off it keeps the
  page's own. A kept H1 stays first, and the page's language is kept.
- The answer is taken out of a code fence, text left at its root goes in
  paragraphs, and an answer in Markdown fails the run.
- The page's own links stay exactly as written (query and anchor too).
- Kept blocks go back untouched (an empty table cell stays), only the
  page's first H1 counts as its title, a page that writes "[[KEEP" gets
  markers of its own, and a page that is only kept blocks isn't sent.

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

* feat(content): rewrite the page to its rules from the Rules tab, and compare it

The Rules tab opens with the agent's two ways to meet its rules: Apply
rules with Agent (small edits, up to 8 a run) and Rewrite the page to
these rules (the whole page as one change). The rewrite is recommended,
with a one-line reason, when the page is more than 30% off its Length or
4 rules or more are open.

A rewritten page comes back as one suggestion with its own bar over the
page: the characters before and after and the agent's reason, Compare
(the page and the rewrite side by side), Accept (History keeps the page
first), Reject, and Undo. A page that changed since the agent read it
isn't written over. The page waits for the rewrite with its own steps,
and a failed rewrite's Try again rewrites again.

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

* fix(content): compare a rewrite by its words and run one agent at a time

Review fixes:
- A page is compared with the one the agent read by its words, with a
  space between blocks, so stored line breaks and lists don't read as a
  change (Accept and Undo were refused on imported pages).
- One agent run at a time from the page; a rewrite never starts before
  the locked passages are read, and sends the editor's own locked keys.
- Accept holds the page still from the start and checks it again before
  putting the rewrite in; Undo puts the page back as it was (two H1s too),
  and the bar waits while the HTML view is open.
- No rewrite advice for an empty page or one too long to send whole; the
  rewrite mark survives a reload; the waiting view says the rewrite waits
  in the editor; Compare's links don't navigate.

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

* feat(content): show the Content Agent as a card over the page

Content Editor v1.1, part 1 (CE-025, CE-026, §4): the agent row and the
rewrite bar become one card above the toolbar, in three states:
- waiting: "Content Agent has {n} suggestions for you", what they change
  and the rules they gain ("Rules 5 → 6 of 13"), with Review (scrolls to
  the first suggestion and marks it), Reject all and Accept all; a page
  rewritten shows its characters, with Compare;
- all reviewed: what was accepted and the rules met and still open, with
  Undo all and Run Agent;
- working: while Apply rules with Agent runs.
The tile moves a little (a soft ring, a blink, a spark; a sweep and a
breath while working), never a rotating ring, and not at all with reduced
motion. The card wraps on a narrow page; Accept all and Run Agent are the
primary buttons.

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

* fix(content): agent card review fixes

- Run Agent on the card keeps to one agent run at a time and says why it
  waits; Apply rules never starts beside another run or before the locked
  passages are read.
- Ghost buttons show their hover on the card's grey; the tile and its
  count are hidden from screen readers (the title says it) and the count
  is darker for contrast; "+N more" comes from en.json, the reason's first
  letter is upper-cased in the page's locale.
- Review picks the first open suggestion in the page's order and focuses
  it; the sweep shows on the light tile in dark mode; the spark is slower
  once all are reviewed; without motion the working line is a faint full
  line; "0 still open" isn't said.
- globals.css keeps its own lines; only the motion block is added.

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

* feat(content): put brief and rules under one Instructions tab with a split Run Agent

Content Editor v1.1 part 2 (CE-028–CE-031): the side panel's tabs become
Instructions · Sources · Live page. Instructions holds Brief | Rules, with
the rules still open on the tab and the segment. Each segment opens with a
status card: Rules has one split Run Agent ▾ (Fix open rules, or Rewrite
the whole page, which renames it "Rewrite page") in place of the two rule
buttons; Brief has Run Agent while empty and Rebuild brief once written.
Why the agent can't run is written under the card, and each card's ⓘ tip
opens below it. The brief shows "Not set yet" and its Length in characters
and about as many words; the toolbar counter adds the page's words.

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

* fix(content): instructions tab review fixes

- Run Agent's choice is worked out once and falls back to Fix without a
  rewrite; once a rewrite starts, the button is back on Fix.
- ▾'s choices are menu radio items; Fix is off when only rules the agent
  can't fix are open, and the card says what to do instead.
- The reason line under the card stays mounted for screen readers; Rewrite
  from brief writes its reason too; the tab's count is read out.
- Brief | Rules switch with the arrow keys, one tab stop.
- An edited brief's rebuild question sits under the card; a brief without
  H2s says to rebuild it; an empty brief shows no origin line.
- Plural copy for the open suggestions and the counter's words; rule names
  joined by the formatter; Run Agent's tip leaves ▾ out without a rewrite.

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

* feat(content): show the data the Content Agent writes from

Content Editor v1.1 part 3 (CE-032, CE-034): under each Run Agent card,
"Uses your data: 1 prompt · 21 fan-outs · 20 cited pages · 10 Search
Console queries · Edit sources", counted as the Sources tab keeps them, so
turning one off lowers it at once. The Sources tab carries its count, and
its top says "N sources in use" and when the Content Agent last wrote from
them (its latest suggestions or the brief it built). A first visit's note
at the top of Instructions says the agent writes from the person's data;
closing it is kept in their own user metadata.

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

* fix(content): data note review fixes

- "Last used by Content Agent" also counts the agent writing the page
  (agent_state_at: Start with Agent, Rewrite from brief on a new page),
  not a run that failed; a value that isn't a date is skipped.
- The latest batch's time is its first suggestion's, not a sort per render.
- Tests: the Brief segment's line, no line while the sources can't be read,
  the tab's count, the note showing again after a failed write, and a
  suggestion read with its createdAt.

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

* feat(content): have the Content Agent write from the kept sources and name them

Content Editor v1.1, CE-033 (server): Fix open rules, Start with Agent and
Rewrite the whole page read the sources the Sources tab keeps, numbered
S1, S2… (content-sources.js). Each suggestion keeps the sources it names
and the words each supports (content_draft_suggestions.sources and
source_marks, 00248); a page rewritten whole keeps its sources.

No number without a source: the model reads a source by its words only, so
a number the agent adds must be the page's, the brand's, the brief's, the
rules', today's, or in a source's own words (then marked to it). A
suggestion with any other number is not kept; a page written whole gets a
placeholder in its place. Source numbers written into the words are taken
out.

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

* feat(content): show what each agent suggestion was written from

Content Editor v1.1, CE-033 (web) and the rest of CE-034: under each
suggestion, "Based on" chips name the sources it used (number, kind, name;
the Sources tab's details on hover), and a small number marks the words
each supports. A click on either opens Sources on that row, scrolled to
and ringed for a moment, once. The agent card adds "built from N of your
sources · See sources". Fix open rules sends the kept sources, and the
first-visit note says every change shows the sources it used.

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

* feat(content): write the Content Agent's runs step by step and stop them

Content Editor v1.1, CE-027/035 (server): each Content Agent run (Fix open
rules, Start with Agent, Rewrite the whole page, the brief) is written in
content_agent_runs (00249) with its steps named by the data it reads
("Reading 20 cited pages", "Matching 21 fan-outs", "Writing 3 changes") as
it reaches them. POST /api/content-drafts/:id/stop marks the run stopped
and aborts its model call; the run checks before it keeps anything, so a
stopped run changes nothing (no suggestions, page, brief or History).

A run that can't be written still runs; runs a stopped server left are
closed when the next starts, and Stop ignores them. Background runs are
written before Start answers, so Stop finds them at once.

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

* fix(content): let go of a background draft when its run is stopped

Stop also clears the draft's 'writing' state at once: a background run lets
go once it sees the stop, but one no server holds any more never would, and
the waiting page would wait out the 10 minutes.

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

* feat(content): show the content agent's steps while it works, and stop it (CE-027, CE-035)

The agent card, the brief and the waiting page show the run's real steps
(content_agent_runs, read from the browser every second) and a Stop button
that ends the run through the API proxy, leaving the page as it was. A dashed
decoration under the H1 says where Fix is drafting, and the agent's dots
replace every spinner on its buttons.

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

* feat(content): show the cited pages' length next to the brief's Length (CE-030)

When the brief is rebuilt, the server reads the first few cited pages kept
in Sources (only addresses AI answers cited for the brand, never the draft's
own page), counts their main text as the Rules tab counts length, and saves
the median as brief.citedLength. The Brief tab says "From the rules · cited
pages average N characters"; with fewer than two pages read it stays "From
the rules". textLength moves to page-content.js to avoid an import cycle.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

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

* fix(content): read a failed rewrite from the draft, and only the latest batch's rows

The editor reads content_drafts.agent_run, so a failed rewrite is tried again
as one on every device (the localStorage mark is gone). Fix open rules' new
409 'writing' says the agent is already writing. getDraftSuggestions finds
the latest batch first and reads only its rows, and Compare's links can't
take focus.

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

* fix(content): say in the agent card why Run Agent won't run

The card's Run Agent writes its reason in the card's second line (amber, tied
to the button by aria-describedby) instead of a hover title, and is turned
off when the only rules left open are ones the agent doesn't fix (one H1),
as the Rules card does.

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

* chore(content): keep AddSourceInput as Prettier formats it

A merge brought in a line formatted by another Prettier version; this puts
back main's formatting, so format:check passes.

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

* fix(content): recommend no Run Agent choice that is turned off

With only One H1 open and no rewrite advice, ▾ no longer shows the disabled
Fix as Recommended.

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

* fix(content): match an added figure by its unit, and read none from dates, addresses or words

A claim (a %, a ×, a scale, a currency) is known only with the same unit or
sign, so a fan-out's "crm for 50 users" no longer sources "50%". Today adds
only its year. A cited page's address is no words of its own. The brand's
name and industry are known, digits stuck to a letter ("B2B", "H2") are no
figure, and a source number written into a reason is taken out.

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

* feat(content): name the agent's steps by the work the server does

Short names for what each run does (CE-027/035): Fix and a rewrite read the
rules, gather the sources (numbered, so a number can be checked), write, and
check what they wrote (a number needs a source, a link must be allowed, a
locked passage stays). The brief gathers, writes the outline and matches
fan-outs. "Reading 20 cited pages" is gone: the agent sees their addresses,
not their content.

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

* fix(content): name the Rules tab's button as it reads now in a test and two lines

A test from main still pressed "Apply rules with Agent", and two messages
still named it; the button is Run Agent, its default Fix open rules.

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

* fix(content): charge a call Stop aborted, end only a run's own claim, and stop the run named

- A Stop that aborts a model call already sent keeps its hold on the AI
  budget as its cost (reserveAiBudget's keep()), since the provider bills
  it; a run stopped before its call sends nothing (runCall).
- A background run ends only the claim it still holds (agent_state_at), so
  one stopped from another server never clears a newer run's.
- A run closes only runs a stopped server left (older than RUN_STALE_MS),
  and /stop takes an optional runId, so another tab's run goes on.

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

* feat(content): show the steps by their new names, and stop the run the editor shows

The step chips read the server's short names (Reading 4 rules, Gathering 52
sources, Writing changes, Checking sources). Stop sends the run's id, so
another tab's run goes on. The waiting page keeps the run's last steps and
reads the draft as soon as its run ends, and a hidden tab reads the run every
AGENT_POLL_MS, then at once when it shows again.

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

* test(content): read the hook's run from what it renders

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

* fix(content): call the cited-page figure the median it is, and stop its reads with the run

The Brief's Length now says "a typical cited page has N characters (median of
M)". A Stop settles the cited-page read on nothing at once: the run's signal
ends each page read (fetchPage takes a signal beside its timeout), so a fast
model answer followed by a Stop never waits on them.

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

* fix(content): show loading without a spinning ring anywhere in Content

Every Loader2 spinner in Content (the editor, Library, Plan, the content
page and its dialogs and menus, the webhook settings) is now LoadingDots:
three dots that bounce in turn, in the text's color, still with reduced
motion, as the Content Editor brief asks ("no spinning ring anywhere"). The
agent's WorkingDots are built on it.

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

* feat(content): read the draft's Readability and show it in Instructions › Quality (CE-036, CE-039)

Quality spec Phase 1, behind NEXT_PUBLIC_CONTENT_QUALITY_PHASE (off unset):
- readability.ts: seven checks read from the draft in the browser, no AI
  cost — average sentence 15–20 words, none over 35, reading level by the
  language's formula (Flesch, Ateşman, Amstad, Kandel–Moles,
  Fernández-Huerta; else sentence and word length), answer first, short
  paragraphs, a heading every 200–300 words, passive voice and jargon
  (English). A check a language can't be read for is left out and the
  score rescaled to 100.
- Instructions gets a Quality segment: the score with its band (80+
  Strong, 60–79 Can improve, under 60 Needs work), "Ansvisor estimates
  based on Google's published quality signals. Not a Google score.", and
  what would raise it, the biggest gain first, with Show.
- The header gets a "Quality {score}" chip that opens it.

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

* fix(content): read Readability from the page's own blocks, and show a passage by its block

- A quote's and a list item's paragraphs are read apart (the editor's HTML
  has no space between tags) and a nested list once; sentence length is
  measured on running text, a list's points aside, and a page of short
  sentences is asked to join some.
- Fernández-Huerta subtracts words per sentence (the corrected form).
- Answer first skips an empty line, fails without an H1, and reads an H1's
  subject without its question and common words.
- Abbreviations don't end a sentence; "-ted" keeps its syllable, French
  "-ent" is no silent ending, Turkish â î û are vowels; "is indeed" isn't
  passive, jargon is read in all its forms, and Show goes to what falls short.
- Show finds the passage's block in the page (never a suggestion's card)
  and marks it with a decoration; the band is read out with the chip and
  the segment's badge.

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

* fix(content): count a passive sentence that says not or never in Readability

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

* feat(content): add Settings › Authors, the real people a page is by (CE-037)

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

* fix(content): let whoever added an author edit it, link only yourself, and renumber to 00251

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

* feat(content): name the page's author in the editor's header and a Page info strip outside the page (CE-038)

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

* fix(content): keep the Page info strip right under the H1, count authors' pages only in Settings

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

* fix(content): draw the Page info strip as the mockup's one line, with the author's face and title at the brand

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

* feat(content): score E-E-A-T from the page's author and Trust from the agent's sourced claims in Quality (CE-039)

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

* fix(content): score only checks that can fail: no Trust and no author schema until they read the page

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

* fix(content): say only what an author's profile is missing in Quality

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

* feat(content): read a draft's links once a day for Trust: working or broken, and their page's date

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

* fix(content): read only a saved draft's links, a few at a time and within a budget, and date pages by their own entity

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

* feat(content): score Trust from the page's sourced figures, fresh sources and working links (CE-039)

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

* fix(content): reserve link reads up front, say which links are never read, and date an article before its page

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

* fix(content): compare links as the draft saves them, count each link and sentence once, and read prices and sizes as no figures

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

* feat(audit): read a brand's site trust: About, Contact, editorial policy, Organization schema and author pages (CE-043)

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

* fix(audit): read site trust in parallel and once per brand, tell a page from the home page, and re-read a partial read soon

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

* feat(audit): show Site trust n/5 in Site Audit, and count it in Quality's Trust (CE-043)

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

* fix(audit): scroll to Site trust from Quality, keep it per brand, say when checking again fails, and count it only beside the page's own Trust

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

* fix(audit): give the Site trust card its own key beside the auto-run notice

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

* feat(content): list what only you can do in Quality, and nudge the next one (CE-040)

Your to-dos in Instructions › Quality: picking the page's author (or adding
one) and completing their profile move out of the suggestions, with a box
the checks tick and E-E-A-T's gain. A dark "Next for you" pill names the
first open one when the agent's run ends (not a failed or stopped one),
when the last open suggestion is accepted (Accept all, one by one, or the
page rewrite) and on Mark ready, once per moment and to-do in the session;
Later hides it. Its words go to a status kept on the page for screen
readers.

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

* feat(content): check the page before it's marked ready, with its JSON-LD to paste (CE-041)

Before you publish opens on Mark ready once Quality is live: a warning
only when Trust is under 60 (the check that raises it most, and to about
what), a note while the page's links are still being read, what the CMS
does for the page (author, visible dates, schema), and for an article an
Article JSON-LD from the title, author, brand, its image and today's date
(Person with sameAs, or the brand's Organization; no author while the
authors aren't read; a live page keeps its published date) with Copy
JSON-LD. Fix first goes to Quality and puts the caret at the passage.
Mark ready anyway is logged with the page's Trust and the check named
(00255 content_draft_ready_log: members add rows as themselves for a
ready draft, three columns only). useLinkChecks also says how many reads
may still come.

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

* feat(content): keep the Content Agent from inventing people and quotes (CE-044)

Every person's name and quoted sentence the agent writes is looked up in
what it was given: the page, the brand, the brief, the rules, the
person's data (Sources) and Settings › Authors. One that isn't becomes a
placeholder ("[name of a real person]", "[quote from a real person, with
its source]"): in Fix open rules' and the first optimize's suggestions,
read in their words as written before they are cleaned; in a page
written whole; and in a rewrite before what it kept goes back, so the
page's own passages are never touched.

A name is read where a person is plainly meant: an honorific, a role
("CEO Jane Doe", "Jane Doe, head of sales", "Jane Doe (CEO)"), or speech
("Jane Doe said", "according to Jane Doe", "Ayşe Yılmaz'a göre"); a
known author stays with the words before it, and a heading is read for
quotes and speech only. A quote is two words or more in quotation marks
next to speech, four or more anywhere, or a blockquote or <q> (its cite
read for the name), across the bold and the links in a line. One reading
per word keeps long text fast.

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

* feat(content): list the placeholders the agent left as the first to-do (CE-044)

Your to-dos in Quality now opens with "Fill {n} placeholders" while the
page has words in square brackets (what the agent leaves where it had no
real name, quote or number), with Show on the first. The Next for you
nudge names it too ("Show now"). Only the person can fill them; an export
never ships one (CE-057).

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

* feat(content): export the page ready to paste, with its page fields (CE-057)

Export, once Quality is live, asks where the page goes: Webflow,
WordPress, Shopify or Google Docs (copied as rich text to paste in; the
CMSs' H1 left out for their title field), Word or Markdown (downloaded),
or HTML. It shows the page as it was when it opened.

No export carries a placeholder. Fill now selects the first (in the HTML
view's text too, or says it is in an HTML block); Export without them
leaves out the sentences they are in, read as a reader would ("1.5",
"e.g." and "acme.com" end none), one outside a line, in alt text or in
JSON-LD alone. One in the title or a heading is filled first. Copy HTML
sends a page with one to Export too.

It lists what it checks (clean HTML or the HTML blocks' own code, the
links that answer or couldn't be read, the images' alt text) and the
page fields, read from the page as it goes out (its title, first
paragraph, live address or title as a slug, author, first image), each
with Copy. Word gets them as a table on page 1, Markdown as front matter
(with the date, the title not again as an H1), HTML in its head.

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

* fix(content): count a link the site refused as unread, and the title's placeholder once

Trust's link reads say "unknown" when a site refused the read or timed
out (a bot wall, a 403): Export no longer counts such a link as read, so
it never says the links answer for one that wasn't. A title that is the
page's H1 has its placeholders counted with the page, not twice.

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

* feat(content): check the page before Export, with a Ready to paste row (CE-057)

Before you publish now opens on Export too (§7), then goes on to Export
with Continue to export; its Trust warning says the page can be exported
anyway, and nothing is logged. On Mark ready and on Export alike, a last
row reads Ready to paste: no placeholders, every image with alt text,
every link working; what is still open is named ("2 placeholders still
open · 1 image has no alt text"), and links that weren't read are said
to be unchecked, never to work. It is read from the page as it is when
the dialog opens.

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

* feat(content): let a brand add the byline to its exported content (CE-057)

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

* fix(content): keep the loading dots visible with reduced motion

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

* fix(content): check author profile links in the table, unlink a removed member and revoke anon

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

* fix(content): let a Stop go only of the claim the stopped run holds

A Stop that named a Fix or brief run cleared agent_state whatever the run
was, so a Start or Rewrite on the same draft went on without its claim.
Each run now carries the claim it holds (content_agent_runs.claimed_at,
00249), stopDraftRun answers it, and the route clears agent_state only
where agent_state_at is still that claim.

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

* fix(content): say in the Remove dialog that the author's pages go back to the team byline

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

* fix(content): date a page over the read cap from its start, and count a private-address link as broken

fetchPage gets an opt-in truncate that resolves with the first maxBytes
instead of refusing the page, and the link check uses it, so a large
article page still gives its date and stays working. A link the fetch
refuses as a private or local address reads as broken, since no reader
of the published page can open it; a non-standard port stays unknown.

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

* fix(content): offer Edit author in Quality only to who can edit that author, and say who can otherwise

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

* fix(content): read discounts, materials and short forms as no figures, and score Trust only with a figure or a dated source

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

* fix(audit): read a bot wall as unsure, read a walled home page through Scrape.do once a day, and look for author pages at the usual addresses

A 401/403/429, or a 200 challenge page, now leaves the read incomplete
instead of failing About, Contact, Editorial or Organization schema for a
day (looksBlocked from site-pages.js). A walled home page goes through
Scrape.do, unrendered, at most once a day per brand (site_trust.scraped_at),
and a pass it read stands for that day while the wall hides the page.
An author the page list has no page for is looked for at /author/<slug>
and /authors/<slug> (a few authors per read), with the probes' guards and
their name in the title or H1. readSiteTrust returns complete, so the web
can tell a partial read from a fix to make.

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

* fix(audit): hold Check again until the read can change, say when the site didn't answer, and say Site trust counts in Quality

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

* fix(content): leave a placeholder title out of the JSON-LD headline, and say why

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

* feat(content): recommend the next step from the header and the agent card (Next step basket)

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

* chore(content): move Show's doc comment back onto showInPage

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

* fix(content): read Readability in the draft's language, and split its sentences where they end

- Japanese, Chinese and Thai, written without spaces between words, get no
  score: Quality says "Readability isn't read for this language yet"
  instead of asking for more paragraphs. Sentences also end after 。!?,
  । and ؟, and a Hindi word keeps its vowel signs, so Hindi is read by its
  own sentences and words.
- The language is the draft's Language rule when it is on, else the
  brand's; every brand language's name is read ("Portuguese", "Brazilian
  Portuguese", "日本語"…).
- A sentence doesn't end before a lower-case word, nor at a German or
  Turkish ordinal ("am 3. Oktober") or a language's common abbreviations
  ("z. B.", "p. ex.", "örn."); one before a number only ("No. 5") counts
  there. A full stop before a closing quote or bracket ends one.
- Show goes to the first copy of a passage, and a second Show within the
  moment keeps its mark for the full time.
- Passive voice reads common irregular participles (sent, found, held…).

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

* fix(content): know a name only as whole words, read a bare name only with a verb said of people, and run on without the authors

isKnown matched names as substrings of what the agent was given, so
"Dr. Sarah Chen" passed on a page with "kitchen" and "Mr. Doe" on one
with "does". Both sides are now compared as whole words. A name without
an honorific or role is read only with said, told, explained, recalled,
admitted, insisted or argued (and German sagte, Turkish söyledi), so
"Google Ads recommends" or "according to Google Analytics" no longer
become name placeholders. authorWords logs a failed read (content_authors
not there yet) and reads as no author words instead of failing the run.

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

* fix(content): read the page for export in a document of its own, and JSON-LD by its strings

Export reads the page in a document of its own, so nothing in it loads or
runs. A JSON-LD is read by its string values: its arrays are no placeholders,
and Export without them clears the strings and keeps it valid JSON. In a
title or a heading only the agent's own placeholder forms hold the export,
so "Best CRM tools [2026 Update]" goes out as written. A live page's
Markdown front matter gets lastmod instead of date, and the draftHtmlDocument
comment is back on its function.

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

* fix(content): offer Edit author on the profile to-do only to who can edit the author

#1414's review fix moved here: the to-dos replaced E-E-A-T's suggestions,
so the to-do now carries the rule (whoever added the author, the author
themself or an admin) and tells anyone else who can.

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

* refactor(content): read the title's placeholder with the shared pattern

#1420 kept its own copy while placeholders.ts wasn't below it; now it is.

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

* test(content): expect the dated source line's corrected plural

#1416's review fix reads "1 of 1 dated source is over 24 months old".

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

* fix(content): read Ready to paste once per change, and fill in the HTML view only where it counts

Ready to paste is read in a useMemo while Before you publish is open, not
on every render. A link still being read is told from one no read is coming
for (a refused read, one past the limit, one in an HTML block). The title's
placeholders count once when any heading or the page's first line reads as
it, H1 or not. In the HTML view, Fill now searches only where the count
reads: tags (but alt and title), styles, other scripts and a JSON-LD's
non-strings are blanked first (blankCode, reused for the byline). A page
test shows a FAQPage's JSON-LD reads Ready to paste as done.

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

* fix(content): pass the nudge whether the member can edit the author

Its to-do text names who can complete the profile when they can't.

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

* test(content): give Before you publish's quality read whether the member can edit the author

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

* chore(content): type the agent run's claimed_at

#1400 adds the column to 00249.

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

* fix(content): write the content byline in the brand's language, under the lead's own H1

The byline line Add byline to content puts in the page is written in the
brand's language (brands.language): "Yazar: Ayşe Yılmaz", "Por Ana Silva",
"Vom Acme-Team", from a small table for English, Turkish, German, French,
Spanish, Portuguese, Italian, Dutch and Swedish; any other language gets the
name alone, or the brand's. Before you publish quotes the line as it goes
out. withByline puts it after the end tag of the lead's own H1, counted with
comments and code blanked, so an empty H1 above the title or one in a
comment or a script no longer takes it.

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

* test(content): wait for Before you publish to move focus to Continue to export

The dialog focuses its button after it opens; checking at once failed now
and then under load.

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

* docs(content): say the byline follows the page's language

With #1411 below it, the editor reads the draft's Language rule first.

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

* fix(content): type the H1 list the byline counts in

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

* fix(content): keep focus where it went when the basket closes, and hold a skip until every read is in

Review fixes for the Next step basket:
- focus goes back to the Next button only from inside the basket or from
  nowhere (Base UI's own rule); after Skip, the new step's button takes it
  and the step is read out
- stale skips are dropped only once the sources, the site's trust and the
  link reads are in
- an empty page is read past the block its title comes from
- Before you publish and Mark ready are held as the header's Mark ready is
- Rewrite page sits beside Fix open rules where the Rules tab recommends it,
  and "If you see…" takes its count from REWRITE_OPEN_RULES

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

* feat(content): fit the editor header to its width, its icon buttons labelled on hover and focus (Next step basket, part 2)

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

* feat(billing): show the month's AI usage at the top right of the main pages (AI usage display, part 1)

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

* feat(billing): warn under each page's header from 80% of the month's AI usage, and once it's used up (AI usage display, part 2)

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

* feat(content): show the month's AI usage in the editor header and hold agent buttons once it's used up (AI usage display, part 3b)

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

* feat(content): send a Content Editor page to the brand's webhook from the editor header (Send to CMS #1331, part 2: web)

- Send to CMS in the editor header, for admins and managers, through
  Before you publish while Quality is on; the dialog fills slug, meta
  title and meta description from the page (or what the draft kept),
  holds the send while placeholders are open or the page is empty, and
  says the server's reasons in plain words
- the page goes as Export makes it ready: publishable HTML without its
  H1, with the brand's byline line, its author and an https featured image
- Webhook Settings gets the opt-in "Content page sent" event
- a long title's slug is cut at a word, as it now becomes the page's
  address in the CMS

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

* feat(content): send a Library page to the CMS from its row, and show each row's last send (Send to CMS #1331, part 3a: Library row)

- the row menu's Send to CMS (admins and managers) opens the editor's
  Send dialog on the stored page, made ready as the editor makes it:
  publishable HTML, its author and the brand's byline line once Quality
  is live; Fill now opens the editor
- beside each row's status, its last send: sending, sent, failed (with
  the webhook's answer) or published (a link to the live page)
- the Send dialog moves to components/content, now that two pages use it
- getContentDraftPages also gives each page's author and its own Language

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

* fix(content): no Send to CMS on archived Library rows, and keep the draft's brand for its send

- archived drafts aren't sent (the server sends only drafts not
  archived), so their row menu doesn't offer it
- the dialog sends to the brand the row's page was read for, should
  the brand switch meanwhile
- the dialog's and the row's Published time is the publish time
- the published mark is blue like the Published badge, and its link
  says it opens the live page in a new tab

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

* fix(content): save the page before it is sent, and hold Send until its last send is read

- openSend settles autosave first; a page it can't save isn't sent (send.unsaved toast)
- the Send dialog holds Send with Try again when the kept slug and meta can't be read
- the meta title prefill is cut at a word near 60 characters
- types: content_draft_deliveries.external_id (00262)

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

* test(content): close the Send dialog at each test's end, and click the page's own text outside the basket

The basket test clicked a button added to the document after the basket
opened, which Base UI takes for another app's: with the Send to CMS tests
before it, it failed one run in three.

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

* fix(content): read each Library page's last send from content_draft_last_deliveries, and a stale queued one as interrupted

- one row a draft (00262's function, distinct on draft_id), so a page sent
  many times keeps its mark past PostgREST's 1,000 rows
- a send still queued after 15 minutes reads as "Not sent: interrupted":
  the Library neither waits on it nor says it is still going

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

* fix(content): hold Send for unapplied HTML and a second click, and keep the kept slug per field

- HTML edited in the HTML view and not applied asks to be applied first
- the header's Send waits while the page saves (one click), and is off
  while the page can't save (conflict, too large), as Mark ready is
- the dialog keeps what the draft kept in each field the person hasn't
  changed, the slug above all; Try again stays in place while it reads
- the meta title prefill cuts at any space, never inside an emoji, without
  the punctuation the cut leaves

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

* fix(content): read a send left queued as interrupted in the editor too, as the Library does

One helper (lastSend) reads both the Library's marks and the Send dialog's
last send, so the two never disagree; its type sits where generation puts it.

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

* fix(content): end the basket's focus test without an unhandled error, and give a 2xx send's failure its reason

- the test clicks the page's text: ProseMirror reads the click's place
  with elementFromPoint, which jsdom lacks; it's stubbed for that test
- a send the webhook took (2xx) that the workflow then called back failed
  shows the workflow's reason, not "The webhook answered 200"

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

* fix(content): give a 2xx send's failure its reason in the Library, and read a send as interrupted after 30 minutes

- a send the webhook took (2xx) that the workflow then called back failed
  shows the workflow's reason on hover, not "The webhook answered 200"
- INTERRUPTED_AFTER_MS follows 00262: 30 minutes, as a batch with webhooks
  timing out can run about 20

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

* test(content): the Library's last-send mark gives a 2xx failure's reason, not the 200

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]>
gkhngyk added a commit that referenced this pull request Oct 24, 2026
…(Send to CMS #1331, part 3b: bulk) (#1440)

* feat(billing): show this period's AI usage on the Billing page

The workspace's one AI budget (Improve, the Content Editor's AI and the
Action Center's task writer) had no meter: the first sign of it was an
"AI usage is used up" error. Migration 00242 records what each AI call
was for (prompt_improve_usage.feature, backfilled) and sums the period's
spend by feature (ai_usage_by_feature). GET /api/billing/ai-usage
returns the shares of the plan's budget, and the Billing page shows the
share used, when it resets and what used it, with Agent Chat noted as
running on the workspace's own key.

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

* fix(billing): hold an AI call's share of the budget before it runs

The workspace's AI budget was checked by reading the period's spend; the
call's cost was written once the model answered. Calls running at once
(two tabs, a teammate, an Action Center sweep) all read the same spend
and all ran past the budget. 00243's reserve_ai_usage takes a
per-organization lock, reads the spend with the calls in flight, and
holds the call's estimated cost; reserveAiBudget turns the hold into the
real cost or releases it. Improve, the brief rebuild, Apply rules with
Agent, Start Agent and the Action Center task writer use it in place of
enforceImproveQuota, which goes.

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

* fix(billing): charge a schema miss and hold the org's recent median cost

Review fixes:
- Apply rules with Agent and Start Agent charge an answer the provider
  billed but that missed the schema (NoObjectGeneratedError), as Improve,
  the brief and the task writer do; before, the hold was let go and the
  call ran free.
- A call holds the org's median cost over its last 20 calls this period,
  never less than the model's typical cost, so calls in flight pass the
  budget by far less.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): rewrite a whole page to its rules as one suggestion

Apply rules with Agent makes at most 8 small edits a run, which can't
bring a long page to its Length (about 2% a run on prod). The Content
Agent can now rewrite the whole page in one background call, left as ONE
suggestion (kind 'page', migration 00247) to compare and accept or reject:
- POST /api/content-drafts/:draftId/rewrite, through Start Agent's claim,
  budget hold and background run;
- passages AI quotes today, tables, images, quotes and HTML blocks go to
  the model as [[KEEP n]] lines and come back as they were; a rewrite that
  drops one fails the run;
- one H1, only the page's own links and the ones offered, the editor's
  tags; the page as it was is kept on the suggestion (before_html).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): describe a rewrite's kept blocks and count them toward Length

Review fixes:
- Kept blocks are described under the page (a quoted passage's words, a
  table's rows, an image's alt) and their text counts toward Length, so a
  rewrite aims at the whole page's length; with Length off it keeps the
  page's own. A kept H1 stays first, and the page's language is kept.
- The answer is taken out of a code fence, text left at its root goes in
  paragraphs, and an answer in Markdown fails the run.
- The page's own links stay exactly as written (query and anchor too).
- Kept blocks go back untouched (an empty table cell stays), only the
  page's first H1 counts as its title, a page that writes "[[KEEP" gets
  markers of its own, and a page that is only kept blocks isn't sent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): rewrite the page to its rules from the Rules tab, and compare it

The Rules tab opens with the agent's two ways to meet its rules: Apply
rules with Agent (small edits, up to 8 a run) and Rewrite the page to
these rules (the whole page as one change). The rewrite is recommended,
with a one-line reason, when the page is more than 30% off its Length or
4 rules or more are open.

A rewritten page comes back as one suggestion with its own bar over the
page: the characters before and after and the agent's reason, Compare
(the page and the rewrite side by side), Accept (History keeps the page
first), Reject, and Undo. A page that changed since the agent read it
isn't written over. The page waits for the rewrite with its own steps,
and a failed rewrite's Try again rewrites again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): compare a rewrite by its words and run one agent at a time

Review fixes:
- A page is compared with the one the agent read by its words, with a
  space between blocks, so stored line breaks and lists don't read as a
  change (Accept and Undo were refused on imported pages).
- One agent run at a time from the page; a rewrite never starts before
  the locked passages are read, and sends the editor's own locked keys.
- Accept holds the page still from the start and checks it again before
  putting the rewrite in; Undo puts the page back as it was (two H1s too),
  and the bar waits while the HTML view is open.
- No rewrite advice for an empty page or one too long to send whole; the
  rewrite mark survives a reload; the waiting view says the rewrite waits
  in the editor; Compare's links don't navigate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): show the Content Agent as a card over the page

Content Editor v1.1, part 1 (CE-025, CE-026, §4): the agent row and the
rewrite bar become one card above the toolbar, in three states:
- waiting: "Content Agent has {n} suggestions for you", what they change
  and the rules they gain ("Rules 5 → 6 of 13"), with Review (scrolls to
  the first suggestion and marks it), Reject all and Accept all; a page
  rewritten shows its characters, with Compare;
- all reviewed: what was accepted and the rules met and still open, with
  Undo all and Run Agent;
- working: while Apply rules with Agent runs.
The tile moves a little (a soft ring, a blink, a spark; a sweep and a
breath while working), never a rotating ring, and not at all with reduced
motion. The card wraps on a narrow page; Accept all and Run Agent are the
primary buttons.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): agent card review fixes

- Run Agent on the card keeps to one agent run at a time and says why it
  waits; Apply rules never starts beside another run or before the locked
  passages are read.
- Ghost buttons show their hover on the card's grey; the tile and its
  count are hidden from screen readers (the title says it) and the count
  is darker for contrast; "+N more" comes from en.json, the reason's first
  letter is upper-cased in the page's locale.
- Review picks the first open suggestion in the page's order and focuses
  it; the sweep shows on the light tile in dark mode; the spark is slower
  once all are reviewed; without motion the working line is a faint full
  line; "0 still open" isn't said.
- globals.css keeps its own lines; only the motion block is added.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): put brief and rules under one Instructions tab with a split Run Agent

Content Editor v1.1 part 2 (CE-028–CE-031): the side panel's tabs become
Instructions · Sources · Live page. Instructions holds Brief | Rules, with
the rules still open on the tab and the segment. Each segment opens with a
status card: Rules has one split Run Agent ▾ (Fix open rules, or Rewrite
the whole page, which renames it "Rewrite page") in place of the two rule
buttons; Brief has Run Agent while empty and Rebuild brief once written.
Why the agent can't run is written under the card, and each card's ⓘ tip
opens below it. The brief shows "Not set yet" and its Length in characters
and about as many words; the toolbar counter adds the page's words.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): instructions tab review fixes

- Run Agent's choice is worked out once and falls back to Fix without a
  rewrite; once a rewrite starts, the button is back on Fix.
- ▾'s choices are menu radio items; Fix is off when only rules the agent
  can't fix are open, and the card says what to do instead.
- The reason line under the card stays mounted for screen readers; Rewrite
  from brief writes its reason too; the tab's count is read out.
- Brief | Rules switch with the arrow keys, one tab stop.
- An edited brief's rebuild question sits under the card; a brief without
  H2s says to rebuild it; an empty brief shows no origin line.
- Plural copy for the open suggestions and the counter's words; rule names
  joined by the formatter; Run Agent's tip leaves ▾ out without a rewrite.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): show the data the Content Agent writes from

Content Editor v1.1 part 3 (CE-032, CE-034): under each Run Agent card,
"Uses your data: 1 prompt · 21 fan-outs · 20 cited pages · 10 Search
Console queries · Edit sources", counted as the Sources tab keeps them, so
turning one off lowers it at once. The Sources tab carries its count, and
its top says "N sources in use" and when the Content Agent last wrote from
them (its latest suggestions or the brief it built). A first visit's note
at the top of Instructions says the agent writes from the person's data;
closing it is kept in their own user metadata.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): data note review fixes

- "Last used by Content Agent" also counts the agent writing the page
  (agent_state_at: Start with Agent, Rewrite from brief on a new page),
  not a run that failed; a value that isn't a date is skipped.
- The latest batch's time is its first suggestion's, not a sort per render.
- Tests: the Brief segment's line, no line while the sources can't be read,
  the tab's count, the note showing again after a failed write, and a
  suggestion read with its createdAt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): have the Content Agent write from the kept sources and name them

Content Editor v1.1, CE-033 (server): Fix open rules, Start with Agent and
Rewrite the whole page read the sources the Sources tab keeps, numbered
S1, S2… (content-sources.js). Each suggestion keeps the sources it names
and the words each supports (content_draft_suggestions.sources and
source_marks, 00248); a page rewritten whole keeps its sources.

No number without a source: the model reads a source by its words only, so
a number the agent adds must be the page's, the brand's, the brief's, the
rules', today's, or in a source's own words (then marked to it). A
suggestion with any other number is not kept; a page written whole gets a
placeholder in its place. Source numbers written into the words are taken
out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): show what each agent suggestion was written from

Content Editor v1.1, CE-033 (web) and the rest of CE-034: under each
suggestion, "Based on" chips name the sources it used (number, kind, name;
the Sources tab's details on hover), and a small number marks the words
each supports. A click on either opens Sources on that row, scrolled to
and ringed for a moment, once. The agent card adds "built from N of your
sources · See sources". Fix open rules sends the kept sources, and the
first-visit note says every change shows the sources it used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): write the Content Agent's runs step by step and stop them

Content Editor v1.1, CE-027/035 (server): each Content Agent run (Fix open
rules, Start with Agent, Rewrite the whole page, the brief) is written in
content_agent_runs (00249) with its steps named by the data it reads
("Reading 20 cited pages", "Matching 21 fan-outs", "Writing 3 changes") as
it reaches them. POST /api/content-drafts/:id/stop marks the run stopped
and aborts its model call; the run checks before it keeps anything, so a
stopped run changes nothing (no suggestions, page, brief or History).

A run that can't be written still runs; runs a stopped server left are
closed when the next starts, and Stop ignores them. Background runs are
written before Start answers, so Stop finds them at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): let go of a background draft when its run is stopped

Stop also clears the draft's 'writing' state at once: a background run lets
go once it sees the stop, but one no server holds any more never would, and
the waiting page would wait out the 10 minutes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): show the content agent's steps while it works, and stop it (CE-027, CE-035)

The agent card, the brief and the waiting page show the run's real steps
(content_agent_runs, read from the browser every second) and a Stop button
that ends the run through the API proxy, leaving the page as it was. A dashed
decoration under the H1 says where Fix is drafting, and the agent's dots
replace every spinner on its buttons.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): show the cited pages' length next to the brief's Length (CE-030)

When the brief is rebuilt, the server reads the first few cited pages kept
in Sources (only addresses AI answers cited for the brand, never the draft's
own page), counts their main text as the Rules tab counts length, and saves
the median as brief.citedLength. The Brief tab says "From the rules · cited
pages average N characters"; with fewer than two pages read it stays "From
the rules". textLength moves to page-content.js to avoid an import cycle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): record which run holds a draft, and keep Fix off it while it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): read a failed rewrite from the draft, and only the latest batch's rows

The editor reads content_drafts.agent_run, so a failed rewrite is tried again
as one on every device (the localStorage mark is gone). Fix open rules' new
409 'writing' says the agent is already writing. getDraftSuggestions finds
the latest batch first and reads only its rows, and Compare's links can't
take focus.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): say in the agent card why Run Agent won't run

The card's Run Agent writes its reason in the card's second line (amber, tied
to the button by aria-describedby) instead of a hover title, and is turned
off when the only rules left open are ones the agent doesn't fix (one H1),
as the Rules card does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(content): keep AddSourceInput as Prettier formats it

A merge brought in a line formatted by another Prettier version; this puts
back main's formatting, so format:check passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): recommend no Run Agent choice that is turned off

With only One H1 open and no rewrite advice, ▾ no longer shows the disabled
Fix as Recommended.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): match an added figure by its unit, and read none from dates, addresses or words

A claim (a %, a ×, a scale, a currency) is known only with the same unit or
sign, so a fan-out's "crm for 50 users" no longer sources "50%". Today adds
only its year. A cited page's address is no words of its own. The brand's
name and industry are known, digits stuck to a letter ("B2B", "H2") are no
figure, and a source number written into a reason is taken out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): name the agent's steps by the work the server does

Short names for what each run does (CE-027/035): Fix and a rewrite read the
rules, gather the sources (numbered, so a number can be checked), write, and
check what they wrote (a number needs a source, a link must be allowed, a
locked passage stays). The brief gathers, writes the outline and matches
fan-outs. "Reading 20 cited pages" is gone: the agent sees their addresses,
not their content.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): name the Rules tab's button as it reads now in a test and two lines

A test from main still pressed "Apply rules with Agent", and two messages
still named it; the button is Run Agent, its default Fix open rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): charge a call Stop aborted, end only a run's own claim, and stop the run named

- A Stop that aborts a model call already sent keeps its hold on the AI
  budget as its cost (reserveAiBudget's keep()), since the provider bills
  it; a run stopped before its call sends nothing (runCall).
- A background run ends only the claim it still holds (agent_state_at), so
  one stopped from another server never clears a newer run's.
- A run closes only runs a stopped server left (older than RUN_STALE_MS),
  and /stop takes an optional runId, so another tab's run goes on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): show the steps by their new names, and stop the run the editor shows

The step chips read the server's short names (Reading 4 rules, Gathering 52
sources, Writing changes, Checking sources). Stop sends the run's id, so
another tab's run goes on. The waiting page keeps the run's last steps and
reads the draft as soon as its run ends, and a hidden tab reads the run every
AGENT_POLL_MS, then at once when it shows again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(content): read the hook's run from what it renders

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): call the cited-page figure the median it is, and stop its reads with the run

The Brief's Length now says "a typical cited page has N characters (median of
M)". A Stop settles the cited-page read on nothing at once: the run's signal
ends each page read (fetchPage takes a signal beside its timeout), so a fast
model answer followed by a Stop never waits on them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): show loading without a spinning ring anywhere in Content

Every Loader2 spinner in Content (the editor, Library, Plan, the content
page and its dialogs and menus, the webhook settings) is now LoadingDots:
three dots that bounce in turn, in the text's color, still with reduced
motion, as the Content Editor brief asks ("no spinning ring anywhere"). The
agent's WorkingDots are built on it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): read the draft's Readability and show it in Instructions › Quality (CE-036, CE-039)

Quality spec Phase 1, behind NEXT_PUBLIC_CONTENT_QUALITY_PHASE (off unset):
- readability.ts: seven checks read from the draft in the browser, no AI
  cost — average sentence 15–20 words, none over 35, reading level by the
  language's formula (Flesch, Ateşman, Amstad, Kandel–Moles,
  Fernández-Huerta; else sentence and word length), answer first, short
  paragraphs, a heading every 200–300 words, passive voice and jargon
  (English). A check a language can't be read for is left out and the
  score rescaled to 100.
- Instructions gets a Quality segment: the score with its band (80+
  Strong, 60–79 Can improve, under 60 Needs work), "Ansvisor estimates
  based on Google's published quality signals. Not a Google score.", and
  what would raise it, the biggest gain first, with Show.
- The header gets a "Quality {score}" chip that opens it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): read Readability from the page's own blocks, and show a passage by its block

- A quote's and a list item's paragraphs are read apart (the editor's HTML
  has no space between tags) and a nested list once; sentence length is
  measured on running text, a list's points aside, and a page of short
  sentences is asked to join some.
- Fernández-Huerta subtracts words per sentence (the corrected form).
- Answer first skips an empty line, fails without an H1, and reads an H1's
  subject without its question and common words.
- Abbreviations don't end a sentence; "-ted" keeps its syllable, French
  "-ent" is no silent ending, Turkish â î û are vowels; "is indeed" isn't
  passive, jargon is read in all its forms, and Show goes to what falls short.
- Show finds the passage's block in the page (never a suggestion's card)
  and marks it with a decoration; the band is read out with the chip and
  the segment's badge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): count a passive sentence that says not or never in Readability

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): add Settings › Authors, the real people a page is by (CE-037)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): let whoever added an author edit it, link only yourself, and renumber to 00251

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): name the page's author in the editor's header and a Page info strip outside the page (CE-038)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): keep the Page info strip right under the H1, count authors' pages only in Settings

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): draw the Page info strip as the mockup's one line, with the author's face and title at the brand

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): score E-E-A-T from the page's author and Trust from the agent's sourced claims in Quality (CE-039)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): score only checks that can fail: no Trust and no author schema until they read the page

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): say only what an author's profile is missing in Quality

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): read a draft's links once a day for Trust: working or broken, and their page's date

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): read only a saved draft's links, a few at a time and within a budget, and date pages by their own entity

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): score Trust from the page's sourced figures, fresh sources and working links (CE-039)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): reserve link reads up front, say which links are never read, and date an article before its page

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): compare links as the draft saves them, count each link and sentence once, and read prices and sizes as no figures

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(audit): read a brand's site trust: About, Contact, editorial policy, Organization schema and author pages (CE-043)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(audit): read site trust in parallel and once per brand, tell a page from the home page, and re-read a partial read soon

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(audit): show Site trust n/5 in Site Audit, and count it in Quality's Trust (CE-043)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(audit): scroll to Site trust from Quality, keep it per brand, say when checking again fails, and count it only beside the page's own Trust

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(audit): give the Site trust card its own key beside the auto-run notice

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): list what only you can do in Quality, and nudge the next one (CE-040)

Your to-dos in Instructions › Quality: picking the page's author (or adding
one) and completing their profile move out of the suggestions, with a box
the checks tick and E-E-A-T's gain. A dark "Next for you" pill names the
first open one when the agent's run ends (not a failed or stopped one),
when the last open suggestion is accepted (Accept all, one by one, or the
page rewrite) and on Mark ready, once per moment and to-do in the session;
Later hides it. Its words go to a status kept on the page for screen
readers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): check the page before it's marked ready, with its JSON-LD to paste (CE-041)

Before you publish opens on Mark ready once Quality is live: a warning
only when Trust is under 60 (the check that raises it most, and to about
what), a note while the page's links are still being read, what the CMS
does for the page (author, visible dates, schema), and for an article an
Article JSON-LD from the title, author, brand, its image and today's date
(Person with sameAs, or the brand's Organization; no author while the
authors aren't read; a live page keeps its published date) with Copy
JSON-LD. Fix first goes to Quality and puts the caret at the passage.
Mark ready anyway is logged with the page's Trust and the check named
(00255 content_draft_ready_log: members add rows as themselves for a
ready draft, three columns only). useLinkChecks also says how many reads
may still come.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): keep the Content Agent from inventing people and quotes (CE-044)

Every person's name and quoted sentence the agent writes is looked up in
what it was given: the page, the brand, the brief, the rules, the
person's data (Sources) and Settings › Authors. One that isn't becomes a
placeholder ("[name of a real person]", "[quote from a real person, with
its source]"): in Fix open rules' and the first optimize's suggestions,
read in their words as written before they are cleaned; in a page
written whole; and in a rewrite before what it kept goes back, so the
page's own passages are never touched.

A name is read where a person is plainly meant: an honorific, a role
("CEO Jane Doe", "Jane Doe, head of sales", "Jane Doe (CEO)"), or speech
("Jane Doe said", "according to Jane Doe", "Ayşe Yılmaz'a göre"); a
known author stays with the words before it, and a heading is read for
quotes and speech only. A quote is two words or more in quotation marks
next to speech, four or more anywhere, or a blockquote or <q> (its cite
read for the name), across the bold and the links in a line. One reading
per word keeps long text fast.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): list the placeholders the agent left as the first to-do (CE-044)

Your to-dos in Quality now opens with "Fill {n} placeholders" while the
page has words in square brackets (what the agent leaves where it had no
real name, quote or number), with Show on the first. The Next for you
nudge names it too ("Show now"). Only the person can fill them; an export
never ships one (CE-057).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): export the page ready to paste, with its page fields (CE-057)

Export, once Quality is live, asks where the page goes: Webflow,
WordPress, Shopify or Google Docs (copied as rich text to paste in; the
CMSs' H1 left out for their title field), Word or Markdown (downloaded),
or HTML. It shows the page as it was when it opened.

No export carries a placeholder. Fill now selects the first (in the HTML
view's text too, or says it is in an HTML block); Export without them
leaves out the sentences they are in, read as a reader would ("1.5",
"e.g." and "acme.com" end none), one outside a line, in alt text or in
JSON-LD alone. One in the title or a heading is filled first. Copy HTML
sends a page with one to Export too.

It lists what it checks (clean HTML or the HTML blocks' own code, the
links that answer or couldn't be read, the images' alt text) and the
page fields, read from the page as it goes out (its title, first
paragraph, live address or title as a slug, author, first image), each
with Copy. Word gets them as a table on page 1, Markdown as front matter
(with the date, the title not again as an H1), HTML in its head.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): count a link the site refused as unread, and the title's placeholder once

Trust's link reads say "unknown" when a site refused the read or timed
out (a bot wall, a 403): Export no longer counts such a link as read, so
it never says the links answer for one that wasn't. A title that is the
page's H1 has its placeholders counted with the page, not twice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): check the page before Export, with a Ready to paste row (CE-057)

Before you publish now opens on Export too (§7), then goes on to Export
with Continue to export; its Trust warning says the page can be exported
anyway, and nothing is logged. On Mark ready and on Export alike, a last
row reads Ready to paste: no placeholders, every image with alt text,
every link working; what is still open is named ("2 placeholders still
open · 1 image has no alt text"), and links that weren't read are said
to be unchecked, never to work. It is read from the page as it is when
the dialog opens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): let a brand add the byline to its exported content (CE-057)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): keep the loading dots visible with reduced motion

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): check author profile links in the table, unlink a removed member and revoke anon

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): let a Stop go only of the claim the stopped run holds

A Stop that named a Fix or brief run cleared agent_state whatever the run
was, so a Start or Rewrite on the same draft went on without its claim.
Each run now carries the claim it holds (content_agent_runs.claimed_at,
00249), stopDraftRun answers it, and the route clears agent_state only
where agent_state_at is still that claim.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): say in the Remove dialog that the author's pages go back to the team byline

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): date a page over the read cap from its start, and count a private-address link as broken

fetchPage gets an opt-in truncate that resolves with the first maxBytes
instead of refusing the page, and the link check uses it, so a large
article page still gives its date and stays working. A link the fetch
refuses as a private or local address reads as broken, since no reader
of the published page can open it; a non-standard port stays unknown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): offer Edit author in Quality only to who can edit that author, and say who can otherwise

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): read discounts, materials and short forms as no figures, and score Trust only with a figure or a dated source

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(audit): read a bot wall as unsure, read a walled home page through Scrape.do once a day, and look for author pages at the usual addresses

A 401/403/429, or a 200 challenge page, now leaves the read incomplete
instead of failing About, Contact, Editorial or Organization schema for a
day (looksBlocked from site-pages.js). A walled home page goes through
Scrape.do, unrendered, at most once a day per brand (site_trust.scraped_at),
and a pass it read stands for that day while the wall hides the page.
An author the page list has no page for is looked for at /author/<slug>
and /authors/<slug> (a few authors per read), with the probes' guards and
their name in the title or H1. readSiteTrust returns complete, so the web
can tell a partial read from a fix to make.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(audit): hold Check again until the read can change, say when the site didn't answer, and say Site trust counts in Quality

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): leave a placeholder title out of the JSON-LD headline, and say why

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): recommend the next step from the header and the agent card (Next step basket)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(content): move Show's doc comment back onto showInPage

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): read Readability in the draft's language, and split its sentences where they end

- Japanese, Chinese and Thai, written without spaces between words, get no
  score: Quality says "Readability isn't read for this language yet"
  instead of asking for more paragraphs. Sentences also end after 。!?,
  । and ؟, and a Hindi word keeps its vowel signs, so Hindi is read by its
  own sentences and words.
- The language is the draft's Language rule when it is on, else the
  brand's; every brand language's name is read ("Portuguese", "Brazilian
  Portuguese", "日本語"…).
- A sentence doesn't end before a lower-case word, nor at a German or
  Turkish ordinal ("am 3. Oktober") or a language's common abbreviations
  ("z. B.", "p. ex.", "örn."); one before a number only ("No. 5") counts
  there. A full stop before a closing quote or bracket ends one.
- Show goes to the first copy of a passage, and a second Show within the
  moment keeps its mark for the full time.
- Passive voice reads common irregular participles (sent, found, held…).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): know a name only as whole words, read a bare name only with a verb said of people, and run on without the authors

isKnown matched names as substrings of what the agent was given, so
"Dr. Sarah Chen" passed on a page with "kitchen" and "Mr. Doe" on one
with "does". Both sides are now compared as whole words. A name without
an honorific or role is read only with said, told, explained, recalled,
admitted, insisted or argued (and German sagte, Turkish söyledi), so
"Google Ads recommends" or "according to Google Analytics" no longer
become name placeholders. authorWords logs a failed read (content_authors
not there yet) and reads as no author words instead of failing the run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): read the page for export in a document of its own, and JSON-LD by its strings

Export reads the page in a document of its own, so nothing in it loads or
runs. A JSON-LD is read by its string values: its arrays are no placeholders,
and Export without them clears the strings and keeps it valid JSON. In a
title or a heading only the agent's own placeholder forms hold the export,
so "Best CRM tools [2026 Update]" goes out as written. A live page's
Markdown front matter gets lastmod instead of date, and the draftHtmlDocument
comment is back on its function.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): offer Edit author on the profile to-do only to who can edit the author

#1414's review fix moved here: the to-dos replaced E-E-A-T's suggestions,
so the to-do now carries the rule (whoever added the author, the author
themself or an admin) and tells anyone else who can.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(content): read the title's placeholder with the shared pattern

#1420 kept its own copy while placeholders.ts wasn't below it; now it is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(content): expect the dated source line's corrected plural

#1416's review fix reads "1 of 1 dated source is over 24 months old".

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): read Ready to paste once per change, and fill in the HTML view only where it counts

Ready to paste is read in a useMemo while Before you publish is open, not
on every render. A link still being read is told from one no read is coming
for (a refused read, one past the limit, one in an HTML block). The title's
placeholders count once when any heading or the page's first line reads as
it, H1 or not. In the HTML view, Fill now searches only where the count
reads: tags (but alt and title), styles, other scripts and a JSON-LD's
non-strings are blanked first (blankCode, reused for the byline). A page
test shows a FAQPage's JSON-LD reads Ready to paste as done.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): pass the nudge whether the member can edit the author

Its to-do text names who can complete the profile when they can't.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(content): give Before you publish's quality read whether the member can edit the author

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(content): type the agent run's claimed_at

#1400 adds the column to 00249.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): write the content byline in the brand's language, under the lead's own H1

The byline line Add byline to content puts in the page is written in the
brand's language (brands.language): "Yazar: Ayşe Yılmaz", "Por Ana Silva",
"Vom Acme-Team", from a small table for English, Turkish, German, French,
Spanish, Portuguese, Italian, Dutch and Swedish; any other language gets the
name alone, or the brand's. Before you publish quotes the line as it goes
out. withByline puts it after the end tag of the lead's own H1, counted with
comments and code blanked, so an empty H1 above the title or one in a
comment or a script no longer takes it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(content): wait for Before you publish to move focus to Continue to export

The dialog focuses its button after it opens; checking at once failed now
and then under load.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(content): say the byline follows the page's language

With #1411 below it, the editor reads the draft's Language rule first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): type the H1 list the byline counts in

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): keep focus where it went when the basket closes, and hold a skip until every read is in

Review fixes for the Next step basket:
- focus goes back to the Next button only from inside the basket or from
  nowhere (Base UI's own rule); after Skip, the new step's button takes it
  and the step is read out
- stale skips are dropped only once the sources, the site's trust and the
  link reads are in
- an empty page is read past the block its title comes from
- Before you publish and Mark ready are held as the header's Mark ready is
- Rewrite page sits beside Fix open rules where the Rules tab recommends it,
  and "If you see…" takes its count from REWRITE_OPEN_RULES

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): fit the editor header to its width, its icon buttons labelled on hover and focus (Next step basket, part 2)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(billing): show the month's AI usage at the top right of the main pages (AI usage display, part 1)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(billing): warn under each page's header from 80% of the month's AI usage, and once it's used up (AI usage display, part 2)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): show the month's AI usage in the editor header and hold agent buttons once it's used up (AI usage display, part 3b)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): send a Content Editor page to the brand's webhook from the editor header (Send to CMS #1331, part 2: web)

- Send to CMS in the editor header, for admins and managers, through
  Before you publish while Quality is on; the dialog fills slug, meta
  title and meta description from the page (or what the draft kept),
  holds the send while placeholders are open or the page is empty, and
  says the server's reasons in plain words
- the page goes as Export makes it ready: publishable HTML without its
  H1, with the brand's byline line, its author and an https featured image
- Webhook Settings gets the opt-in "Content page sent" event
- a long title's slug is cut at a word, as it now becomes the page's
  address in the CMS

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): send a Library page to the CMS from its row, and show each row's last send (Send to CMS #1331, part 3a: Library row)

- the row menu's Send to CMS (admins and managers) opens the editor's
  Send dialog on the stored page, made ready as the editor makes it:
  publishable HTML, its author and the brand's byline line once Quality
  is live; Fill now opens the editor
- beside each row's status, its last send: sending, sent, failed (with
  the webhook's answer) or published (a link to the live page)
- the Send dialog moves to components/content, now that two pages use it
- getContentDraftPages also gives each page's author and its own Language

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): no Send to CMS on archived Library rows, and keep the draft's brand for its send

- archived drafts aren't sent (the server sends only drafts not
  archived), so their row menu doesn't offer it
- the dialog sends to the brand the row's page was read for, should
  the brand switch meanwhile
- the dialog's and the row's Published time is the publish time
- the published mark is blue like the Published badge, and its link
  says it opens the live page in a new tab

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(content): send the Library's selected pages to the CMS together (Send to CMS #1331, part 3b: bulk)

- admins and managers pick Library rows (not under Archived) and send up
  to 25 at once from the bar above the table
- the dialog lists each page as ready, or why it can't go (no title,
  nothing to publish, placeholders, over a million characters, no slug),
  with the slug and meta of its last send, else the page's
- the pages go in as few requests as the API's proxy takes (by bytes),
  then the dialog reads their sends until they have gone (three minutes
  at most) and says how it went; a refused request names its page
- while a page is on its way, the Library reads its row's send again
- slug and meta that can't be read hold the send: a page sent before
  would land in the CMS twice with the page's own slug
- the row send reads its page the same way (readCmsSources)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): save the page before it is sent, and hold Send until its last send is read

- openSend settles autosave first; a page it can't save isn't sent (send.unsaved toast)
- the Send dialog holds Send with Try again when the kept slug and meta can't be read
- the meta title prefill is cut at a word near 60 characters
- types: content_draft_deliveries.external_id (00262)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(content): close the Send dialog at each test's end, and click the page's own text outside the basket

The basket test clicked a button added to the document after the basket
opened, which Base UI takes for another app's: with the Send to CMS tests
before it, it failed one run in three.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): post a bulk send's next request once the last one's pages have gone

Pages too long for one request went as two sends side by side; #1331 sends
one page at a time. The dialog now waits for the last request's queued
pages (reading them every 2 s, for up to 3 minutes) before posting the next.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): read each Library page's last send from content_draft_last_deliveries, and a stale queued one as interrupted

- one row a draft (00262's function, distinct on draft_id), so a page sent
  many times keeps its mark past PostgREST's 1,000 rows
- a send still queued after 15 minutes reads as "Not sent: interrupted":
  the Library neither waits on it nor says it is still going

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): hold Send for unapplied HTML and a second click, and keep the kept slug per field

- HTML edited in the HTML view and not applied asks to be applied first
- the header's Send waits while the page saves (one click), and is off
  while the page can't save (conflict, too large), as Mark ready is
- the dialog keeps what the draft kept in each field the person hasn't
  changed, the slug above all; Try again stays in place while it reads
- the meta title prefill cuts at any space, never inside an emoji, without
  the punctuation the cut leaves

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): read a send left queued as interrupted in the editor too, as the Library does

One helper (lastSend) reads both the Library's marks and the Send dialog's
last send, so the two never disagree; its type sits where generation puts it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): wait for a bulk request's pages as long as the server does, showing what went meanwhile

- the next request waits up to 15 minutes (00262's interrupted limit), not
  3; past it, the rest aren't posted beside the pages still going, and the
  dialog says how many weren't sent
- while it waits, the dialog shows what went and "Waiting" for the rest,
  and can be closed (the rest still go); a failed read is read again
- once the day's sends are used up, no more requests are posted

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(content): read kept fields and sends by ids again in the client test's mock

The #1439 merge took the table reads by ids out of the mock along with
readCmsStatuses' old read; readKeptFields and readDeliveries still use them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): end the basket's focus test without an unhandled error, and give a 2xx send's failure its reason

- the test clicks the page's text: ProseMirror reads the click's place
  with elementFromPoint, which jsdom lacks; it's stubbed for that test
- a send the webhook took (2xx) that the workflow then called back failed
  shows the workflow's reason, not "The webhook answered 200"

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): give a 2xx send's failure its reason in the Library, and read a send as interrupted after 30 minutes

- a send the webhook took (2xx) that the workflow then called back failed
  shows the workflow's reason on hover, not "The webhook answered 200"
- INTERRUPTED_AFTER_MS follows 00262: 30 minutes, as a batch with webhooks
  timing out can run about 20

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): stop a bulk send's later requests when its dialog closes, and give a 2xx send's failure its reason

- closed (or left) while a request waits for the last one's pages, the
  dialog posts no more, and a toast says how many pages didn't go: else
  they went up to half an hour later with nothing showing it
- the wait follows 00262's 30 minutes
- a page its webhook took (2xx) that its workflow then called back failed
  reads Failed, the reason on hover

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(content): the Library's last-send mark gives a 2xx failure's reason, not the 200

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(content): stop a closed bulk send before each later request, a one-page one's too

The close was read only during the wait for queued pages: a one-page
request (sent at once, never queued) or a read in flight let the next
request go. It's read before each request after the first too.

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