Skip to content

feat(content): recommend the next step from the header and the agent card (Next step basket) - #1428

Merged
gkhngyk merged 180 commits into
ansvisor:mainfrom
cihan-gyk:feature/next-step-basket
Oct 23, 2026
Merged

gkhngyk merged 180 commits into
ansvisor:mainfrom
cihan-gyk:feature/next-step-basket

Conversation

@cihan-gyk

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

Copy link
Copy Markdown
Collaborator

Summary

Content Editor Next step basket (Drive spec CONTENT-EDITOR-next-step-spec.md, approved 2026-10-23), part 1 of 2. Behind NEXT_PUBLIC_CONTENT_QUALITY_PHASE, since it reads Quality's Trust and to-dos; with the flag off, nothing changes.

Stacked on #1427 (→ #1426 → … → #1411). Web only, no migration.

The editor has many agent buttons: Build brief, Rewrite from brief, Run Agent ▾, Quality, Before you publish, Mark ready. The basket says which one to use now. It removes nothing: every button stays where it is, and the Instructions panel (Brief / Rules / Quality) doesn't change.

One step at a time (lib/content/next-step.ts, rules only, no AI call). The first match wins:

State Step Button Other
No brief (Create) Plan the page Build brief
Empty page Write the first draft / Bring in your page Write with Agent I'll write it
Length more than 30% off (rewriteAdvice) Shorten to your Length (or Bring it up to it) Rewrite page Fix open rules
Open rules a Fix run can close Fix open rules Fix open rules Rewrite page, where the Rules tab recommends a rewrite
Trust under 60, or a to-do only the person can do Add proof and author Pick author / Add author / Show to-dos
All of the above done Check and mark ready Before you publish
Marked ready / published Ready to publish Export
  • Each step's reason comes from the page: "19,203 characters against a Length of 8,000…", "3 rules are still open…", "Trust is 54, under 60. Only you can do this first: pick the page's author."
  • Fix open rules counts only what a run can close. A setting only the person fills ("Who it's for" on feature pages) and Length are left out. Length has its own step once it's far off, and a page a little off isn't sent round Fix again and again.
  • Nothing on an empty page asks for agent work but writing it. After "I'll write it", the step stays the person's own until the page has words.
  • Skip passes a step on this draft, in this browser, until its state changes. That means a different set of open rules, long turning to short, Trust passing 60 or a to-do done; typing a word doesn't bring it back. A skip whose state has changed is dropped, so it never comes back to life.
  • The path: five steps, done ones ticked and struck through, skipped ones marked.
  • "If you see…": up to two lines that match the page now, each with its button. None repeats the step's own button.

Where it shows

  • Header: "Next · {step}" with small progress bars, before the save state. Below xl it's "Next" with the bars, as §3b asks at 1024 px. A click opens the basket as a popover (components/ui/popover.tsx, a base-ui wrapper like dropdown-menu.tsx); Esc or a second click closes it.
    • On a new page (Create, no brief, empty) it opens by itself, without taking focus.
    • It folds once the brief is built. Skip doesn't fold it.
    • A button that moves on to the page (a menu, a tab, the to-dos) keeps focus there. Closed otherwise, focus goes back to the button.
  • Agent card: once nothing is left to decide, "Next: {button}" takes Run Agent's place, with All steps to open the basket. Its reason shows in the card when it can't run (suggestions to decide, another run).
  • While the agent runs, the basket shows the run's steps and Stop instead of a step.
  • Build brief opens Instructions › Brief and builds it there, once per click (also when an effect runs twice in development). When a build can't start, it says why.

Not in this PR

  • The cost line ("~2 min · 3% of AI usage"). A share of AI usage needs a per-run estimate (the median of the workspace's recent runs of each kind, spec AI-USAGE §5), which doesn't exist yet. Nothing is shown rather than a made-up number. It comes with the AI usage display work, next in the queue.
  • The header layout of §3b: the title ending in "…", History / Copy HTML / Export as icon buttons, the narrow-width collapse order. That's part 2.
  • The AI usage meter in the header: part of the AI usage display work.

Rewrite page sits beside Fix open rules exactly where the Rules tab recommends a rewrite (rewriteAdvice), and "If you see…" takes its count from REWRITE_OPEN_RULES (matched after review; the spec said 5).

After review (2026-10-23): focus stays where a click into the page put it (Base UI's own rule); after Skip the new step's button takes focus; skips hold until every read is 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.

Pre-push review: 1 high finding, fixed: a setting only the person fills kept "Fix open rules" open forever on feature pages. Also fixed:

  • agent steps on an empty page after "I'll write it";
  • Skip signatures too fine, and skips coming back to life;
  • Skip folding the auto-opened basket;
  • a double brief build in development;
  • Rewrite page offered where it can't run;
  • focus after Esc;
  • copy (Trust's 60 from TRUST_GATE, the published state, "→" / "·" in en.json);
  • tips repeating the main button;
  • the page read only while Quality is on.

Related issue

Drive spec Content Editor › Next step basket. No GitHub issue.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation

How to test

  1. Set NEXT_PUBLIC_CONTENT_QUALITY_PHASE=1 and create a new page (Content › New content › Create).
  2. The basket opens by itself on Plan the page. Build brief opens Instructions › Brief and builds it, and the basket folds; the header now reads "Next · Write the first draft".
  3. Open the basket, then I'll write it: the caret goes to the end of the page, and the basket stays on writing until the page has words.
  4. On a page far off its Length, the step is Shorten to your Length with Rewrite page and Fix open rules. Skip moves on until the page turns from too long to too short, or the rules change.
  5. Accept or reject an agent batch: the card offers "Next: …" and All steps.
  6. With Trust under 60, or the author not picked, the step is Add proof and author; Pick author opens the header's author menu.
  7. Mark ready: the basket says Ready to publish with Export.
  8. Flag off: no Next button, and the card's Run Agent is as before.

Checked locally at 1024 px in light and dark, on a temporary demo draft (removed afterwards).

Checklist

  • web/: yarn format:check, yarn lint (0 errors; 6 existing warnings elsewhere), yarn typecheck, yarn test (356 files, 3,190 tests) and yarn build pass. Two small fixes from the browser check came after that run (the path's third step on an empty page, a doubled "skipped" for screen readers); for those, the affected tests, yarn typecheck and yarn lint ran again and pass
  • Tests:
    • next-step.test.ts: the mockup's three states; Rewrite page beside Fix where the Rules tab recommends it; proof; check and ready; Skip until its state changes; skips dropped; an empty page after "I'll write it"; rulesForNext
    • _next-step.test.tsx: the button, the reason, buttons, Skip, the path, tips, the blocked reason, no Skip on the last step, published, the run with Stop, wordsUnderTitle
    • _agent-card.test.tsx: Next in Run Agent's place, All steps, the reason when blocked, nothing while suggestions wait
    • page.test.tsx: opens by itself without focus, Build brief, folds after; Skip kept on reopen; stays open on Skip; "I'll write it"; flag off
  • 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]>

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

A few fixes before merge:

  1. (medium) A click into the page while the basket is open moves focus to the Next button.

    • finalFocus is a function (_next-step.tsx:193-197). Base UI only leaves focus where the person moved it when finalFocus is a boolean (the default). When the function returns true, Base UI focuses the trigger once the popup unmounts, wherever focus is by then.
    • So with the basket open, a click into the editor closes it, and about 100 ms later the caret leaves the page for the Next button. This is most likely with the basket that opens by itself on a new page. What the person types next is lost, and Space opens the basket again. A click on the Brief tab's Build button does the same.
    • The opposite happens for the step's own buttons. act sets acted for every action (:169-173), so Fix open rules, Rewrite page, Write with Agent, Build brief and Show to-dos close the basket and leave focus on the body, although nothing else took it.
    • After Skip, the new step isn't announced: focus stays on Skip, and the step block isn't a live region.

    Fix:

    • Return true from finalFocus only when focus is still inside the popup, or on the body, at close. That is Base UI's own rule, which the function form turns off. Then acted isn't needed: a dialog, the author menu or the editor already holds focus by the time the popup unmounts.
    • After Skip, focus the new step's first button, or mark the step block aria-live="polite".
    • Add a page test: open the basket, focus the editor, press outside, and expect focus to stay in the editor.
  2. (medium) Skip is lost on reopen for Fix open rules and for Add proof and author.

    • nextRead (_draft-editor.tsx:1615) waits for the brief, My rules and the authors. It doesn't wait for the sources or for Trust's reads.
    • Until getDraftSources lands, the rules are checked with no fan-outs and no brand or competitor domains. The fan-out rules then read as "no fan-outs" (info, not open), so openRules is a different set.
    • Trust is null until the brand domains are in. After that it moves as the site's trust and each link read land, so trustLow can flip during load.
    • The effect at :1618-1627 drops any skip whose state differs at that moment and writes that to localStorage. When the sources land, the skipped step is back.
    • The same happens after reloadSources(), which sets the sources to null while prompts are added.
    • The page test reopens only a skipped Plan, which reads the brief alone.

    Fix:

    • Drop stale skips only once every read the step states use is in: reads.sources !== null, and with Quality the site's trust read (it needs a "read" flag, as null now means both "loading" and "none") and !linksPending.
    • Add a page test that skips Fix open rules with a fan-out rule open, then reopens with getDraftSources resolving after the other reads. The skip should hold.
  3. (low) An empty page with anything above its H1 counts as written.

    • wordsUnderTitle (_next-step.tsx:54-60) drops the first element only when it is an H1.
    • Two cases leave the title in the text: an empty paragraph above it (Enter at the top of a new page), or an image first.
    • The page then counts as written, and the basket moves on to Fix open rules or Length. That is agent work an empty page shouldn't get.
    • Fix: drop the block the title is read from, as draftTitleFromDoc picks it: the first H1 with words, else the first heading, else the first block with words. Add <p></p><h1>Pour-over</h1><p></p> to its test.
  4. (low) Before you publish isn't held when Mark ready is.

    • The header's Mark ready is disabled while marking, on a save conflict, and when the page is too large to save (_draft-editor.tsx:1833-1838).
    • nextBlocked returns null for beforePublish and markReady (:1645-1658). So the basket and the card's "Next: Before you publish" open the checklist anyway, and Mark ready then fails with "The page has changes that aren't saved".
    • Fix: hold those two actions under the same conditions in nextBlocked, with a reason line.

On the question in the body (4 or 5 open rules): I'd match them.

  • At 4 open rules, the Rules tab recommends a rewrite, while the basket offers Fix open rules alone and shows "1 to 4 rules open → Fix open rules".
  • The two also count different sets. rewriteAdvice counts Length and an unset Who it's for; rulesForNext leaves them out.
  • Whichever number stays, pass it into tips.someRules (en.json:4210) rather than writing "1 to 4" in the copy.

Checked and fine:

  • No AI call on its own:
    • The basket opening by itself and the stale-skip effect only set state.
    • Build brief runs only from a click. It goes through the side panel's rebuild(), the Brief tab's metered path, once per request: the ref is keyed on tabRequest.n and onBuildStarted clears the flag, so a panel opened later doesn't build.
    • The other buttons call the runs that already exist, and each shows its own blocked reason.
  • Rules:
    • The order matches the table.
    • Fix counts leave out Length and an unset Who it's for.
    • Rewrite page is offered only where rewrite advice exists, so never on a page too long to send.
    • After "I'll write it", an empty page stays the person's.
    • Marked ready and published both end on Export.
  • While a run is under way:
    • The basket shows the run's steps and Stop.
    • Buttons that start runs are held, with the "decide first" or "another run" reason. Tips are hidden.
    • After the run, the step is read from the current state: Fix open rules waits on the suggestions with its reason.
  • Re-render cost:
    • On a keystroke the editor runs rewriteAdvice, rulesForNext and nextStep over the rule list, which is cheap.
    • Quality, Trust and the to-dos are the existing reads.
    • Emptiness is parsed once per typing pause (pageHtml), in an inert <template>.
    • The popup isn't mounted while closed.
  • Flag off:
    • There is no Next button, and the card gets next = null, so Run Agent and its reason are as before.
    • The page isn't parsed.
  • Accessibility:
    • The popup is labelled by its title.
    • The path is an <ol> with aria-current="step", a state per step and "Step n of total" for screen readers.
    • The card's Next button is described by its blocked reason.
  • i18n: every new string is in en.json, with correct plurals.
  • Tests: they cover the rules, Skip, dropped skips, the empty page after "I'll write it", the card's Next, the run with Stop, and the flag off.

Merge state: one commit on #1427's head, with no merge commits. Against main it conflicts in the same files as #1427 and adds no conflicts of its own. Web only, no migration.

cihan-gyk and others added 7 commits October 23, 2026 23:29
…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]>
With ansvisor#1411 below it, the editor reads the draft's Language rule first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ld 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]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk Fixed:

  1. Focus on close. The finalFocus function is gone, so Base UI's own rule applies again. I first tried your suggested function, returning true only from inside the popup or the body. In the browser that still sent focus to Next: the check ran at the outside press, before the click had moved focus into the page. With the default:
    • A click into the page keeps the caret in the editor, and typing goes to the page. I checked this in the browser on the basket that opens by itself and on one opened with a click.
    • The step's buttons now return focus to Next unless what they open takes it: the author menu, a dialog, a tab.
    • After Skip, the new step's first button takes focus, and the step block is aria-live="polite". Tested.
    • jsdom doesn't move focus late the way Base UI does in the browser, so the page test for the outside click passes on the old code too. The browser check is the real proof here.
  2. Skips on reopen. Stale skips are dropped only once every read the step states use is in: the brief, the sources (reads.sources !== null, so also during reloadSources()), My rules, and with Quality the authors, the site's trust and the link reads (linksPending === 0).
    • The site's trust has a "read" flag now, since null meant both "loading" and "none".
    • A page test skips Fix open rules with fanoutH2 open, reopens with getDraftSources resolving last, and the skip holds.
  3. Empty page. wordsUnderTitle drops the block the title is read from, as draftTitleFromDoc picks it: the first H1 with words, else the first heading, else the first block with words. Tests cover <p></p><h1>Pour-over</h1><p></p>, an image first, an H2 title and a one-line page.
  4. Before you publish / Mark ready are held under the same conditions as the header's Mark ready, with a reason line: marking, a save conflict, too large to save.

4 or 5: matched with the Rules tab.

  • Rewrite page sits beside Fix open rules exactly where rewriteAdvice recommends it.
  • "If you see…" takes its count from REWRITE_OPEN_RULES ("1 to 3 rules open"), and shows only where no rewrite is recommended.

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

Looks good. All items done (c6f9957).

  1. Focus on close: finalFocus is gone, so Base UI's own rule applies: focus goes back to Next only from inside the basket or from the body. The page test clicks a button outside and focus stays there. After Skip, the new step's first button takes focus, and the step block is aria-live="polite".
  2. Skips on reopen: nextRead now waits for reads.sources, and with Quality for the site's trust read (siteTrustRead, set on failure too) and linksPending === 0. The page test resolves getDraftSources last and the skip holds.
  3. Empty page: wordsUnderTitle drops the block the title is read from, as draftTitleFromDoc picks it. The empty line and image cases are tested.
  4. Held actions: Before you publish and Mark ready are held while marking, on a save conflict and when the page is too large, with a reason line.
  5. Open rules: Rewrite page sits beside Fix open rules wherever rewriteAdvice recommends it, and the tip's count comes from REWRITE_OPEN_RULES.

For a follow-up (low, fine to merge without them):

  1. After Skip, a held next step leaves focus on the body. When the new step's button is disabled (for example Before you publish while marking), primaryRef.current?.focus() does nothing, and the Skip button may be gone. Fall back to the step title, or to the popup.
  2. The "1 to 3 rules open" tip can show with more rules open. rewriteAdvice also returns null for a page longer than REWRITE_MAX_CHARS, so such a page with, say, six open rules gets the "1 to 3" line (next-step.ts:280). Count the open rules there as well: s.openRules.length < REWRITE_OPEN_RULES.

Merge state: merges cleanly on main. Web only, no migration.

@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 23, 2026
@gkhngyk
gkhngyk merged commit 02fa6db into ansvisor:main Oct 23, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants