Skip to content

feat(content): open the editor on the Content Agent at work, step by step - #1349

Merged
gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:feature/content-agent-flow
Oct 22, 2026
Merged

gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:feature/content-agent-flow

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Content Editor feedback items 1, 2 and 11 (the Start → Agent flow):

  • Agent first. New content's "Who does it" now reads Agent · Me · Team. Me stays the default, since the agent's run is metered from the AI usage.

  • The editor opens at once. Picking the agent used to show a toast you had to click, "Content Agent is drafting · Open draft". Once the agent has started, the dialog now opens the editor on the draft. If it can't start (budget, subscription, another draft being written…), the error toast with Open draft stays as it was, and the editor isn't opened.

    • The agentStarted / agentStartedDescription keys are gone.
  • An agentic waiting screen. The new _agent-writing.tsx replaces the bot icon and line of text. While the draft says writing, it shows the agent's steps, as Chat shows its tools:

    • ✓ the reading (sources and brief, or the live page);
    • ✓ the rules (or, on a live page, the passages AI quotes, set aside);
    • ⟳ the writing, or the suggestions on a live page, with the time it has taken (useNow, from agent_state_at);
    • ○ the review.

    The first two finish within a second of the start, so the model's call is the wait. After 2 minutes, "Usually a minute or two." becomes "Taking longer than usual. If it can't finish within a few minutes, this page says so…". The model call is cut at 3 minutes (CALL_TIMEOUT_MS).

  • ContentDraft.agentSince carries agent_state_at for the timer. The editor sets it too when its own Try again starts the agent.

The next PR fixes item 8 on its own: Fix open rules showing "couldn't run" while the agent was still working.

Related issue

Content Editor feedback round (no issue).

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Go to Content → New content, pick a source and Continue. "Who does it" shows Agent · Me · Team, with Me selected.
  2. Pick Agent and Start the agent. The editor opens on the steps, and "Writing the page" counts up. When the agent finishes, the editor opens on what it wrote (it polls every 5 s, as before).
  3. To see the screen without running the agent, set a draft's agent_state = 'writing' and agent_state_at = now() on a dev DB. With now() - interval '150 seconds' the "longer than usual" note shows. Set both back to null after.
  4. Check light and dark, at 1024px and phone width.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run: yarn test (2631 tests pass) and yarn build. Checked in the browser on a dev draft set to writing (restored after).

🤖 Generated with Claude Code

…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]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk the Start → Agent flow from the Content Editor feedback: Agent is offered first (Me stays the default), the editor opens at once, and while the agent writes it shows the agent's steps with a timer, plus a 'longer than usual' note after 2 minutes. Web only, no migration. It touches the editor's page.tsx and page.test.tsx like #1347/#1348, in other places; whichever lands second, I'll merge main in.

@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, and approved in substance. One step before merge: #1351 is landing now, and its new test expects "Content Agent is writing this page", which this PR changes to "working on this page". Please merge main in and update that expectation.

Optional (a11y): put aria-hidden on the timer inside role="status", so screen readers don't announce it every second.

@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk merged main in (02d9636), then d8a1d70:

Checks: web lint (0 errors), typecheck, 2,722 tests and build pass.

@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. Ready to merge.

Both items from the last review are done in d8a1d70:

  • #1351's test now expects "Content Agent is working on this page" (page.test.tsx:1559). The old title isn't used anywhere on this head.
  • The timer has aria-hidden (_agent-writing.tsx:102), so the role="status" region no longer reads it out every second.

Merge notes

  • Merges cleanly on current main and with #1346. No migration.
  • The merge of main (02d9636) has no changes of its own: it matches a clean re-merge of its parents exactly.
  • The rewrite from #1351 fits the steps: a new page shows the writing steps, and a live page shows the suggestion steps. Both open in review, as the "leave" note says.

Tested on top of main together with #1346, #1349 and #1127: web and server tests, tsc, lint and Prettier pass.

@gkhngyk
gkhngyk merged commit 4e5119a into ansvisor:main Oct 22, 2026
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