Repository navigation
fix(content): hold the agent card while a restore runs, say what the restore set aside, and open a pre-restore batch's card closed (#1522 follow-ups) - #1536
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]>
…wasn't given or drops a name a passage has Co-Authored-By: Claude Opus 5.5 <[email protected]>
…give claims only to sources the page or its input names, and put a rewrite's as a placeholder (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…editor shows them, and hold the rules chip until its count stands Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aracters as the toolbar counts them, and the run's rule count Co-Authored-By: Claude Opus 5.5 <[email protected]>
…for the brief and catalog before the rules' count, hold the panel's counts with it, and read the shown rewrite's Length by the editor's count (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s open suggestions for the page before, and drop a batch's card once the page no longer has it Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e left open never holds the next run out of sight Co-Authored-By: Claude Opus 5.5 <[email protected]>
…estions when they can't be set aside, and hold History while the agent works or a decision saves (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… a sweep on the step under way, a line on what it does, and the page drawn in Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, true without an outline, and silent on rules or sources read none of; even step spacing; steadier tests (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hich runs as a Fix, with its steps and Stop Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a Start's write doesn't stand in for it; the rewrite prop says what it reads (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t once it's decided too, not only while it's shown Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ents say when it's read and who counts it (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nows it Co-Authored-By: Claude Opus 5.5 <[email protected]>
… a restore runs, set nothing aside for a restore of the page as it is, and read the last restore from content_drafts.restored_at (00289), which every restore that changes the page sets (review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…restored_at the server's (guard_content_draft_server_columns), and say "nothing changed" for the page as it is (review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good.
What I checked:
- Stack. The PR's own change is three commits on #1526's branch: 0981c74, 2214640 and 8ad3c70. Its two merges (6cce798 and a119152) only bring #1526's branch in: re-merging their parents gives the same trees. With its stack it merges cleanly on main as it was before #1514's squash. #1514's squash on main is exactly #1514's head merged there, so it follows the rest of the chain.
- #1522's three follow-ups:
- Nothing else runs during a restore. Done.
- The card's buttons are busy while it runs (
_draft-editor.tsx:3777), and Try again is disabled (:3730). decide,decidePage,fixRules,handOff,startAgentandrewritePagereturn whilerestoringNowis set. That covers the buttons on the page too.- Fix, Hand off, Start, Rewrite page and Next step give "Restoring…" as the reason.
- History already waits while
fixingordecidingis set, so a decision and a restore can't overlap from either side.
- The card's buttons are busy while it runs (
- The toast says what was set aside. Done.
history.restoredis an ICU plural oncount, and this is its only use. The count is what was actually set aside. It's 0 when the set-aside failed and the changes stay on the card, so the toast never claims something that didn't happen. - The card after a reload. Done. It uses a better signal than the one I suggested:
restored_at, written by the restore itself. Arestoreversion isn't kept when the page repeats the latest version.- The card opens closed only when the latest batch is older than
restored_at(:1712-1717). - Open changes still show.
- A batch run after the restore shows as before.
- If the read fails, the card shows as before.
- The card opens closed only when the latest batch is older than
- Nothing else runs during a restore. Done.
- Restoring the page it already is.
content_draft_restorealready left such a draft alone. It now says so (restored: false), so nothing is set aside, the card stays,restored_atdoesn't move, and the toast says nothing changed (:3300-3325). - 00289:
restored_atis nullable, with no default. Adding it only changes the catalog and doesn't rewritecontent_drafts. There's no backfill, so no draft'supdated_atmoves.content_draft_restorematches 00215's version line for line, plusrestored_atandrestored. It keeps the same member check (content_draft_member),search_pathand grants:authenticatedandservice_role, neveranon.guard_content_draft_server_columnsis 00262's version plusrestored_at, on insert and on update. 00262's is the latest; no later migration or open PR redefines it. A member can't set the column through the table. The restore writes it as the function's owner, which the guard lets through, as it does for migrations.- It can run twice safely (
if not exists,create or replace). No other open PR uses 00289.schema.sqlandtypes/supabase.tsmatch it.
- The read.
getLastRestoreAt(content-drafts.ts:1719) reads one column of one row by id, throughcontent_drafts' member policy. It runs in parallel with the batch read when the editor opens. - Before 00289 is applied. The read fails, and the card shows as it does today. The restore returns no
restored, so the editor compares the page itself. Merging before the migration breaks nothing that works today. Applying the migration first is safe too, since the current editor ignores the new field. - Before the API deploy. This is web and a migration only, and it calls no API route. Nothing waits on the deploy.
- Tests:
- Accept all is disabled, and Accept on the page does nothing, while a restore runs;
- Try again is held;
- the toast for one change and for two;
- nothing is set aside when the version is the page as it is;
- the card is closed after a reload for a batch from before the restore;
- the card shows with open changes, for a batch after the restore, and when the read fails;
- the toast when the set-aside fails;
getLastRestoreAt, andrestoredpassed through.
No findings.
# Conflicts: # server/src/lib/content-writer.js
|
Merged #1526 forward (9af7e25), which brings in Checks after the merge:
|
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good.
The new head, 9af7e25, only merges #1526's new head (c149612), and through it main. Re-merging its parents (8ad3c70 and c149612) is clean and gives the commit's tree (2b652fb2), so the merge hides nothing. Its own change against #1526 is the same as in round 31, line for line.
00289 is unchanged since 8ad3c70, and so are schema.sql and types/supabase.ts. None of the other open migrations (00286–00288 and 00290) redefines content_draft_restore or guard_content_draft_server_columns, so the order they're applied in doesn't matter. With its stack, it merges cleanly on main. Round 31's verdict stands.
Summary
Follow-ups from the review of #1522 (restore guard). Stacked on #1526, the tip of the #1514–#1526 chain. This PR's own change is its commits after #1526's branch.
gkhngyk listed three low follow-ups on #1522. All three are here, web only:
Nothing else runs during a restore. History already waited while a decision saved; now the reverse holds too:
busy={deciding || restoring || htmlSource !== null});restoringNowis set.Without this, an Accept all landing during a restore could be saved as accepted, then set aside by the restore, whichever call landed last. A Fix could also read the page from before the restore.
The toast says what was set aside. The open changes are set aside first, and the toast then reads, for example: "Restored “Live page”. The agent’s 4 open changes were for the page before, so they were set aside." With none set aside it reads as before: "…The page before it is in History."
history.restoredis now an ICU plural oncount.After a review of this PR (second commit):
The cards on the page wait during a restore too:
decideanddecidePagereturn while it runs, and the Fix, Hand off, rewrite and Next step reasons say "Restoring…", so their buttons read as held. Try again is held too.Restoring the version the page already is sets nothing aside, leaves the card open, and says "“…” is the page as it is: nothing changed." The server says so:
content_draft_restorenow returnsrestored: false. A database before 00289 doesn't, and then the editor compares the page itself.Migration 00289:
content_drafts.restored_at;content_draft_restore(00215's) to set it each time the page changes, and to return whether it did;guard_content_draft_server_columns(00262's) so a member can't write it, as with the other server columns.getLastRestoreAtreadsrestored_at. A "restore" version can't say when a restore happened: one is kept only when the page differs from the latest version, so a restore right after Mark ready or an Undo all left none.There's no backfill: an update to
content_draftsmoves itsupdated_at(the Library's order, an open editor's save base), and fix(content): restore once, and let the agent's batch go with the page before #1522 hasn't shipped. 00289 is applied on the dev database, andschema.sqlandtypes/supabase.tsare updated. Labelling it needs-migration is for you, @gkhngyk.getLastRestoreAt(draftId)reads the draft'srestored_at(00289), one row through RLS.getDraftSuggestionsis unchanged, so the side panel's "Last used by Content Agent" and the agent's own polling read the batch as before.Related issue
Follow-ups to #1522 (review 2026-10-26). Editor test 2026-10-25, group H.
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/)bash supabase/build-schema.shrun andsupabase/schema.sqlincludedWeb:
yarn test(3,984 passed) andyarn build. 00289 is applied on the dev database.Tests:
getLastRestoreAtreads the latestrestoreversion.Two reviews ran after opening. Their findings are fixed in the later commits (above).
🤖 Generated with Claude Code