Repository navigation
fix(content): pass Next's third step only by its own run and while the page reads as it did, and show it as passed (#1550 follow-ups) - #1556
Merged
gkhngyk merged 1 commit intoOct 26, 2026
Conversation
…e page reads as it did, drop a failed or stopped run's attempt, and show the step as passed (ansvisor#1550 review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk
approved these changes
Oct 26, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good, with follow-ups.
The #1550 review's six items:
- A Fix on some of the rules, or on the Length step, passes the whole step: Done.
beginThirdTry(kind, { only, at })(_draft-editor.tsx:474-494) notes nothing unless Next's step was Length or Fix open rules when the run was asked for.- A Fix with
onlycounts only whenonlycoversrulesForNext(:479-486). Only Remove AI traces' own Fix passesonly(_rules-tab.tsx:683), so it counts only when AI traces is the last rule left. Run Agent (the Rules tab's and the card's) and Next's button send noonly, so they count. - The attempt notes its step by kind: a rewrite takes
length, a Fix takesfixRules(:488).nextSteppasses each step by its own pass (next-step.ts:323-324). On the Length step, a Fix passes Fix open rules, and Next stays on Rewrite page. - A rewrite reads Next's step before its waits (
stepAsked,:2996,:3039).
- Once passed, the step never comes back: Done.
thirdPassOfkeepsrulesForNextand the Length's state (next-step.ts:204).thirdStepPassesholds a pass while the Length reads the same and, for Fix open rules, every rule open now was open then (:214-223).- The pass is written once the page has been read after the last decision (
_draft-editor.tsx:3274-3287). A pass that no longer holds is dropped (:3290-3303). - Start clears the passes (
:2950): Write with Agent, Rewrite from brief, and Try again after a failed write. So does a restore to another page (:3550).
- A rewrite that fails or is stopped leaves its attempt behind: Mostly done.
- A failed rewrite (
failedRewrite) drops its attempt as the page opens (:3312). - Otherwise the page reads the latest run of the attempt's kind, begun no earlier than a minute before the attempt (
:3318-3333). A run that failed, stopped, or hasstopped_atdrops it.attemptCheckedkeeps any step from passing until that read is in, so a hand-off batch can't pass it first. - Two gaps are left. A run still under way when the page opens, which then fails, keeps its attempt; the PR says so. Follow-up 3 has the other.
- A failed rewrite (
- The pass is kept per browser: Not done. The PR leaves it for later.
- The path calls step 3 done while rules are open: Done.
- There's a new path state,
passed(next-step.ts:114,:353-357). - The step shows muted with its number, not a check, and isn't struck through (
_next-step.tsx:215,:375,:390-392). - Both strings are in
en.json.
- There's a new path state,
- Tests to add: Done.
- The fixture has Length on (400).
- The other cases: the Remove AI traces Fix, a rewrite's page decided after the page reopens, a lost answer whose row says it found nothing, and a restore.
- The rewrite is begun from storage, not by a click, so
stepAskedisn't exercised. - One test doesn't guard what it names (follow-up 4).
What I checked:
- Whether it gets stuck the other way.
- What a pass compares.
- Fix open rules compares the keys of
rulesForNext: rules that are on, open, and that a Fix can close. That leaves out Length, Who it's for unset, One H1, the feed, and rules held by quoted passages. It compares keys, not counts. - Both passes also compare the Length's state,
stepState('length'). That'slongorshortwhen the page is more than 30% off and a rewrite can reach it, else''. It compares the state, not the count.
- Fix open rules compares the keys of
- A typo fix changes neither, so the pass holds. It brings the step back only if it tips a rule over its edge (a sentence one word past the limit, a keyword out of a heading) or crosses the 30% line.
- That's by design: the agent never saw that rule.
- The pass is then dropped for good, as a stale skip is, so undoing the edit doesn't bring it back.
- There's no loop. Each decided run writes a new pass with what's open then, and the step can still be skipped.
- A rejected batch. The pass is written after the page is read again, with the rules from before the run, and it holds.
- A run that found nothing. The same, and it still holds after the page reopens (tested).
- Accepted changes that open a rule (a Fix's added sentence): the page read restarts the wait (
pageHtmlin the deps). So the pass keeps the rule as open, and it doesn't bring the step back. - One case does misfire; see follow-up 1.
- What a pass compares.
- Stored state.
- The key is unchanged:
aeo:next-step-third-try:{draftId}. It now holds{ attempt: { step, kind, at, batch, ended? } | null, passes: { length?: { rules, length }, fixRules?: { rules, length } } }, and it's removed when both are empty. - #1550's
{ batch, ended?, passed? }has nopasses, so it reads as nothing taken. Bad JSON, a plain value, or an attempt withoutstepread the same way. Nothing throws. - So a page #1550 passed today shows Fix open rules once more (the PR says so), and one decided run passes it again.
- A tab still on #1550's build reads the new shape as nothing taken too.
- The key is unchanged:
- What the person sees (only with Quality phase 1 or later, where the basket shows).
- The path line reads "Fix open rules · yours in the Rules tab", "Shorten to your Length · yours in the Rules tab" or "Bring it up to your Length · yours in the Rules tab".
- Screen readers hear "… · taken by Content Agent, what's left is yours in the Rules tab".
- The Next button's bars show the step light, as they do a skipped one.
- After the last decision, Next moves on after about 0.65 s on a reject and about 1 s on an accept, not at once. It takes longer while Quality is still reading the page (links being checked, for example).
- The deploy gap. None.
- The one new read is the latest run of a kind, from the browser:
content_agent_runs, itsstarted_at,stopped_atandoutcome(00249, readable by members, on prod). - The editor already read
draft.agentStateandagentRun. - The API on prod already writes fix and rewrite runs with these columns, so Next behaves the same before and after the API deploy.
- The one new read is the latest run of a kind, from the browser:
- Speed. No regex. The loops run over at most two passes and the open rules' keys.
- Tests.
- The unit tests fail without the change:
thirdPassOfandthirdPassesare new. - These page tests fail without it:
- "moves on once decided": the stored shape and the path's wording;
- the Length step: main passes the Length on a Fix;
- the three dropped attempts and the failed rewrite: main has no read when the page opens, and their stored attempt stays;
- a rule opened since: main's
passedholds for good.
- The Remove AI traces test fails on main, but not without this PR's
onlycheck (follow-up 4). - The lost answer and the restore pass on main as well. They're the cover round 34 asked for.
- I read the tests but didn't run them.
- The unit tests fail without the change:
- Merge.
- One commit (c9c2ee2) on 307670b, which is main (
merge-baseconfirms it).git merge-treewith main gives the head's tree (b6c15317). Web only, no migration. - It merges cleanly with #1553 (tree 68fd0307), which adds tests to other blocks of
page.test.tsx.- #1553's new Fix test clicks Run Agent in the Rules tab. With this PR that notes an attempt, but the test checks only the request, and
localStorageis cleared before each test.
- #1553's new Fix test clicks Run Agent in the Rules tab. With this PR that notes an attempt, but the test checks only the request, and
- One commit (c9c2ee2) on 307670b, which is main (
Follow-ups:
- The Fix open rules pass also drops when the Length's state changes (
next-step.ts:218).pass.length !== lengthapplies to both passes. That can catch the person while they do the part the path just called theirs.- For example, a page far under its Length:
- "Bring it up to your Length": the rewrite is decided, and the page is still short.
- Fix open rules: its changes are decided.
- The person writes two paragraphs, and the page comes within 30%.
- Next goes back to Fix open rules, for the same rules the agent couldn't close.
- The same happens when someone trims a long page by hand. It costs one more run, or a Skip.
- The unit test names the other direction, a Length that drifts far off ("the Length step, and Fix open rules with it"). There the page has changed a lot, and bringing the step back is right.
- Fix:
- Drop the Fix open rules pass on a Length change only when the Length is far off now (
length !== ''). - Clear the pass when a rewrite's page is accepted, as Start does: that's a page written again.
- Drop the Fix open rules pass on a Length change only when the Length is far off now (
- The pass waits for every Quality read, not just the ones it compares (
_draft-editor.tsx:3238-3250,:3275,:3290).nextReadwaits for the authors, the site's trust, the links, the facts and the page's read.- If the authors read fails,
eeatScorestays null (:1101,:1532), andnextReadnever turns true in that visit. - Then a decided run never passes the step: Next stays on Fix open rules, and a second run ends the same way.
- On main the step passed at once, and only dropping stale skips waited for these reads.
- If the authors read fails,
nextReaddoesn't wait for the page's last rewrite (getLastPageRewrite,:2014). That read moves the Length's state throughreach.last.- Say it fails, or lands after the others, on a page whose last rewrite missed its Length.
- Meanwhile a page far over its Length can read
long, and its passes are dropped for good.
- Fix: wait for what
thirdPassOfreads, for both the pass and the stale drop:rulesSettled;citedRead;- a flag set once the last rewrite's read is in (in its
finally).
- When the page opens (
_draft-editor.tsx:3309-3339).- A newer attempt can be dropped. The read drops whatever attempt is current when it lands. Say the person runs Fix in the moment after the page opens, and the earlier run had failed or stopped: the new Fix loses its attempt.
- Fix: drop only the attempt it read:
if (thirdStepNow.current.attempt === attempt) saveThirdTry(null).
- Fix: drop only the attempt it read:
- A Fix that found nothing while the tab was closed is kept, but never marked
ended. It left no batch, so Next stays on Fix open rules until another batch is decided.- Fix: read it as
agentOutcomedoes. Whenkind === 'fix',outcome === 'done'and!run.steps[2]?.count, save{ ...attempt, ended: true }.
- Fix: read it as
- A newer attempt can be dropped. The read drops whatever attempt is current when it lands. Say the person runs Fix in the moment after the page opens, and the earlier run had failed or stopped: the new Fix loses its attempt.
- The Remove AI traces test passes without the
onlycheck (page.test.tsx:6569-6574).- The pass is written 650 ms after the run, and the test checks Next right after the run.
- Fix: add
expect(stored()).toBeNull(). Without the check, the attempt is stored withended: true. Orawait settle()before the last check. - Also, the dropped-attempt cases pair
kind: 'rewrite'withstep: 'fixRules'(:6629-6630), which the editor never writes. Add akind: 'fix'case (a tab closed mid-run), and give the rewritestep: 'length'.
- The pass is kept per browser (round 34's item 4). It's still open, as the PR says.
gkhngyk
pushed a commit
that referenced
this pull request
Oct 27, 2026
…within its Length, wait only for what a pass reads, and read a kept attempt's run by that attempt alone (#1556 review) (#1560) Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-ups from the review of #1550 (merged). #1550 moves the Next step basket past its third step (Length → Rewrite page, or Fix open rules) once the Content Agent has taken it. This narrows when that happens and lets the step come back when the page moves on.
1. Each run passes its own step only, as you put it: a rewrite passes the Length, a Fix passes Fix open rules.
step: 'length' | 'fixRules', from the run's kind), and is noted only while Next's step is the third. A rewrite's step is read when it's asked for, before its waits.onlyunset, or coveringrulesForNext). A Fix of Remove AI traces alone, from the Rules tab, isn't the step.2. A passed step holds only while the page reads as it did (
thirdStepPasses).PAGE_READ_DELAY_MS, then their deferred read), so it keeps the page as it reads after, not before.3. A run that failed or was stopped while the editor was closed leaves no attempt.
failedorstopped, or has astopped_atand no outcome yet (a Stop writes it first), the attempt is dropped.failedRewrite:agentStatefailed on a rewrite run) is dropped at once.4. The path says the step was passed, not done. It shows muted, not struck through, with "· yours in the Rules tab". The screen-reader state reads "taken by Content Agent, what's left is yours in the Rules tab". Both are in
en.json.Storage:
aeo:next-step-third-try:{id}); it now holds{ attempt, passes }.passes) reads as none. A page fix(content): move Next on to the fourth step once the agent has taken the third, with rules still open or the Length off #1550 already passed may show Fix open rules once more; the next decided run passes it again.Left for later (review item 4): the pass is kept per browser. Reading it from the run row, or keeping it on the draft, would carry it across devices and teammates.
Related issue
Follow-up to #1550 (no issue).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
With
NEXT_PUBLIC_CONTENT_QUALITY_PHASE=1, on a draft whose Next step is Fix open rules:Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/): 0 errors; the 6 warnings were already on mainyarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run:
yarn test(427 files, 4,077 tests) andyarn build.Tests:
next-step.test.ts:passed;thirdStepTried's cases.page.test.tsx(a fixture with Length on, at 400, for the Length step):onlycheck);agentState).Pre-push review
A review agent read the change. Fixed from it:
readThirdStep/writeThirdStepwere renamed;🤖 Generated with Claude Code