Repository navigation
fix(content): check the agent's changes and a page rewrite against the rules before they're accepted - #1519
Merged
Conversation
…adings' answers and what the last rewrite came to, and offer a Length it can reach Co-Authored-By: Claude Opus 5.5 <[email protected]>
… for, keep its numbers on the row (00285), and read the floor's sections closer (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and count the last rewrite only within its Length's band and the same kept text (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… one more pass Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er to rewrite the cited passages too when they hold the Length out of reach Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e back, release an unused hold, keep a cited-too miss as evidence, and offer it only when cited passages hold the Length (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he agent and Next step move on, and count open rules as the Rules tab does Co-Authored-By: Claude Opus 5.5 <[email protected]>
…es read the page, keep the Length's own words, and wait for the passages before dropping skips (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ion, not the next step, and say how many placeholders it leaves to fill Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aphs, and read a rewrite's once, not on every key (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y why a run left nothing, and show a failed last run on the card Co-Authored-By: Claude Opus 5.5 <[email protected]>
… id and kind, not by clocks, and clear a failed last run once another starts (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e rules before they're accepted, and say which rule met now one would break Co-Authored-By: Claude Opus 5.5 <[email protected]>
…age as it is now, and count a rewrite's Length as its own line reads it (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
7 of 12 tasks
gkhngyk
approved these changes
Oct 26, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good.
What I checked:
- Stack. The PR's own change is its two commits on #1518 (945f984, b17fb3f), with no merge commit. With the stack, it merges cleanly on main.
- Web only. There is no API change and no migration, so it works as soon as it's merged, whatever API prod runs.
- The same check as the Rules tab.
checkHtmlruns the draft's own rules with the same context (rules,ctxinuseDraftRules) on another page. Only the page it reads differs.- "Now" is checked in the same pass, from the editor's doc:
getHTMLFromFragmentis whatgetHTMLserializes, with the editor's character count. - So both sides are read alike, and a change just accepted counts as part of the page.
- As Accept takes them.
- Each change goes into a copy through
acceptInto, which Accept itself uses. - The whole batch goes through
redoDecision, which accepts the changes in order on one transaction and updates each status as it goes, asdecidedoes. So two changes on one passage both go in. - Stale changes, locked ones and ones that grow a heading too long are left out of both, as Accept leaves them out.
- Each change goes into a copy through
- A rewrite.
- Its Length is read as its "Length missed" line reads it (
pageTextLength,pageCharacters), and Length isn't named a second time. - The API has already cleaned its HTML to the editor's blocks (
cleanPageHtml).readPagereads a list item with or without its paragraph alike. So the raw HTML reads as the page it becomes.
- Its Length is read as its "Length missed" line reads it (
- Nothing is dropped or held back.
- It only adds words to the agent card and the cards in the page; Accept and Accept all work as before.
- Only rules that are on and met now can be named, never an off rule or one the page can't say.
- With no open change it returns at once, so a page without a batch pays nothing.
- Cards in the page. The label shows on open cards only, and the card is drawn again when it changes, since the label is part of its key.
Low, follow-up:
_draft-editor.tsx:1709-1758: with a batch open, each recompute reads the page up to ten times (now, each of up to eight changes, then all of them).- Each read is a full HTML serialization, a DOMParser read and every rule, and it runs inside the render.
- It runs again after each pause in typing (
pageHtml) and after each decision. On a long page, a person typing beside open suggestions can feel it. useDraftRuleskeeps its own check a beat behind typing withuseDeferredValue. Do the same here: passuseDeferredValue(pageHtml)into the memo's deps, so this runs in an interruptible render and never holds up the keyboard.
Merged
7 of 12 tasks
This was referenced Oct 26, 2026
fix(content): one count for the rules and for a rewrite's characters, as the editor shows them
#1521
Merged
Merged
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
Stacked on #1518. The PR's own changes are its last two commits.
In the live editor test (2026-10-25), fixing one rule broke another:
The card's "Rules 9 → 10 of 14" was only an estimate, from the rules each change said it fixed.
The agent's open result is checked against the rules before it's accepted (
_draft-editor.tsx,ruleEffects).redoDecision, one after another, so two changes on one passage both go in), or a whole page rewritten. Each goes into a copy of the page and is checked as the page is (checkHtml, new onuseDraftRules: the same rules and context, another page).pageTextLength), and isn't named again as broken.Nothing is dropped automatically: the person sees what a change would do and decides.
Related issue
Editor test findings 2026-10-25 (group C, part 1).
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
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/): 0 errors; the 6 warnings are in files this PR doesn't touchyarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Web:
yarn testandyarn build. A pre-push review ran; its findings are the last commit. The browser check is in the next batched local test session.🤖 Generated with Claude Code