Repository navigation
feat(content): rewrite the page from its brief with the Content Agent - #1351
Merged
Merged
Conversation
The Brief tab builds and edits a brief, but nothing wrote the page from it. Under the brief, Rewrite from brief (a new page) or Suggest changes from brief (a live page) hands the draft to the agent after a confirm. It uses the editor's own start (as Try again does), so the brief, the sources kept and the rules in effect go with it, and the editor waits for the agent. It is offered while the page is a draft or in review, and waits while suggestions are open. The API now writes a draft in review too (a page the agent wrote, written again), never one marked ready or published. The page it replaces is kept in History first, as before. The failed banner and the Library's agent badge show on a draft in review as well. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
|
@gkhngyk this is Rewrite from brief from the editor feedback. One server change to check: |
7 of 12 tasks
This was referenced Oct 22, 2026
gkhngyk
approved these changes
Oct 22, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good. Two small follow-ups.
_draft-editor.tsx:729: Rewrite from brief isn't blocked while Fix open rules (Apply rules with Agent after #1346) is running.- On a live page, the writer's model call is metered and then dropped:
content-writer.js:446lets go, because the fix's batch came in during the run. - On a new page, the rewrite replaces the page that the fix's batch points at, so its suggestions can't be applied.
- Fix: add
fixing ? t('suggestions.fixing') : nulltoblocked, and disable the rules button whilestarting.
- On a live page, the writer's model call is metered and then dropped:
web/messages/en.json:3506(and:3358):not_draftnow means "marked ready or published". "This draft is no longer a draft" reads wrong next to a draft in review. For example: "This page is marked ready or published, so the agent didn't start."
Checked, and fine:
- Route.
POST /writeis unchanged: guid ids,assertBrandAccess(brandId, req.user.id), the draft'sbrand_idchecked against the brand (404), then its status. The claim stays atomic onstatus in (draft, in_review)andagent_state, and so does the finish (openOnly). A draft marked ready during the run keeps its page. - Cost. It goes the same way as Start's Agent:
enforceImproveQuotabefore the claim,recordUsageafter the call, and one run per organization (org_writing). The page is kept in History (agent_before) before it's written over. - Prompt injection. The brief and the page go to
generateObjectwith a schema and no tools, so there is no tool call to hijack. A new page's text is escaped (renderPage). An inserted block goes throughcleanInsertHtml, which keeps allow-listed tags and strips every attribute, so no links. A person reviews both. This PR adds nothing new to the prompt.
Merge notes
- Merges cleanly on main and with #1346, #1347, #1348, #1349, #1350 and #1353. No migration.
- With #1349: this PR's new test expects
'Content Agent is writing this page'(page.test.tsx:1449). #1349 renames it to'Content Agent is working on this page', so whichever lands second updates it. - The server change has to be deployed for the button to work on a draft in review. Until then, the API refuses it with
not_draft. Deploy the server with, or before, the web.
Tested on top of main together with #1353, #1347, #1348, #1350 and #1351: web and server tests, tsc, lint and Prettier pass.
cihan-gyk
added a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Oct 22, 2026
…keep the timer from screen readers Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk
pushed a commit
that referenced
this pull request
Oct 22, 2026
…step (#1349) * feat(content): open the editor on the Content Agent at work, step by step Start offers the agent first (Agent · Me · Team; Me stays the default, as the agent's run is metered). Picking the agent opens the editor at once instead of a toast to click. While the agent writes, the editor shows its steps as Chat shows its tools: the reading and the rules done, the writing (or the suggestions on a live page) under way with the time it has taken, and the review to come. Past two minutes it says the wait is longer than usual. The draft carries agent_state_at as agentSince for the timer. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): read the wait's new title in #1351's test, and keep the timer from screen readers Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
8 of 12 tasks
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
Content Editor feedback item 12. The Brief tab could build and edit a brief, but nothing wrote the page from it.
retryAgent→startAgent). So the brief, sources and rules in effect go with it, and the editor shows the agent at work.not_draft.content-writer.jsnow acceptsOPEN_STATUSES = ['draft', 'in_review']for the check, the claim and the run's finish (openOnly, which wasdraftOnly).agent_before), as before.What the agent writes from (
buildWritePrompt): the brand, the page type and length, the brief (the draft's own, else the opportunity's), the tracked prompts, fan-outs, Search Console queries, the pages AI cites (to beat, never copy), the rules and the writer's own rules, and on a live page its passages, with the quoted ones locked.Related issue
Content Editor feedback round (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
content_drafts.briefon a dev draft).Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run:
yarn test(2634 pass, with new Brief tab and editor tests) andyarn build;npm run format,npm run lintandnpm test(2029 pass, with a new test for writing a draft in review).Checked in the browser in light and dark, on a dev draft given a brief (removed after). The agent itself wasn't run.
🤖 Generated with Claude Code