Skip to content

feat(content): send a Content Editor page to the brand's webhook from the editor header (Send to CMS #1331, part 2: web) - #1438

Merged
gkhngyk merged 191 commits into
ansvisor:mainfrom
cihan-gyk:feature/cms-send-editor
Oct 24, 2026
Merged

gkhngyk merged 191 commits into
ansvisor:mainfrom
cihan-gyk:feature/cms-send-editor

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Send to CMS, part 2 (web): an admin or manager sends a Content Editor page to the brand's webhook from the editor header. Part 1 (#1437) is the server and migration 00262.

Stacked on #1433 (this branch starts from its tip, for the editor header). Its own change is the last commit, 3399e87c.

Editor header: Send to CMS (paper-plane icon after Export)

  • Only admins and managers see it (useUserRole().canManage), matching the server's assertSender.
  • With Quality on, it opens Before you publish in a new send mode. Its below-60 warning says "You can send it to your CMS…", and the button reads Continue to send. With Quality off, it opens the Send dialog directly.

Send dialog (_send-dialog.tsx)

  • Read-only title.
  • Editable fields:
    • Slug, checked as the server checks it;
    • Meta title;
    • Meta description, with a character count.
  • The fields are filled from the page (pageFields), or from what the draft kept from an earlier send. Changes the person has already typed are never overwritten by that read.
  • Send stays disabled while:
    • a placeholder is open (with Fill now);
    • the page has no title, or a title over 300 characters;
    • the page has nothing under its H1, as a new page doesn't;
    • the slug is empty or invalid.
  • It shows where the page went live, or how the last send went.
  • Each server reason gets its own message:
    • no_webhook, webhook_not_subscribed, daily_limit, forbidden, not_found;
    • invalid with the field named;
    • the webhook's HTTP status.
    • Session, workspace and rate-limit failures are read through apiFailure, as other calls do.

What is sent (lib/content/cms-send.ts)

  • The page as Export makes it ready (publishableHtml), without its H1, which the CMS's title field carries.
  • The brand's byline line, when the brand adds it to content.
  • The author, or the team byline.
  • An https featured image with its alt text. Author, alt and image src are kept within the server's limits.
  • The send goes through the /api/aeo proxy with fetch, not a server action: no 1 MB body cap, and it doesn't queue behind the editor's own actions.

Webhook Settings

  • New Content page sent event (content_draft.sent). It is opt-in, like the column default in 00198/00262: a workflow built for opportunities doesn't expect pages.
  • Added to saveWebhookConfig's allowed events.

Slug

  • A long title's slug is now cut at a word, at most 80 characters. Before, it was cut mid-word ("…shipping-d"), and the slug now becomes the page's address in the CMS.

Types: content_drafts gets slug, meta and published columns, and content_draft_deliveries is added.

Deploy order

Merge and deploy this after #1437 and after migration 00262 is applied on prod. If the web goes first:

  • saving a webhook with Content page sent ticked fails on 00198's check constraint;
  • Send answers "Couldn't send the page".

The dialog's read of the new columns is separate from getContentDraft and tolerates them missing, so the editor itself keeps working either way.

Related issue

Part of #1331 (phase 1: webhook). Next:

  • PR C: Library row and bulk send (≤25, with delivery status);
  • PR D: Zapier / Make / n8n docs for the content_draft.sent package.

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. Run the server from feat(content): send Content Editor pages to the brand's webhook as content packages, and take back where they went live (Send to CMS #1331, part 1: server) #1437 with migration 00262 applied, and this branch's web.
  2. Content Opportunities › Webhook Settings: set a webhook URL (on self-hosted, a local listener such as http://127.0.0.1:8099/hook works), tick Content page sent, and save.
  3. Open a Content Editor page as an admin or manager. Click the paper-plane icon (Send to CMS).
    • With NEXT_PUBLIC_CONTENT_QUALITY_PHASE=1, Before you publish opens first; click Continue to send.
  4. Check the dialog:
    • The slug, meta title and meta description come from the page.
    • Type blog/coffee as the slug: a red hint appears and Send is disabled.
    • Clear the slug: it asks for one.
  5. Fix the slug and click Send. A "Sent to your CMS" toast appears, and the webhook receives a content_draft.sent package with the page's HTML minus its H1.
  6. Reopen the dialog: it says "Last sent …" and keeps the slug and meta you sent.
  7. On a new page (an H1 only), the dialog says the page has nothing to send yet.
  8. Untick the event in Webhook Settings and send again: the dialog says to turn it on there.
  9. As an analyst, the button isn't shown.

Checked locally at 1024px, in light and dark. Demo data was restored afterwards: the draft row is byte-identical to its backup, and the temporary webhook config and delivery rows were deleted.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/): 0 errors, 6 existing warnings in files this PR doesn't touch
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run:

  • yarn test: 371 files / 3362 tests pass.
  • yarn build with CI's placeholder env passes.
  • npm run version:check at the root fails as it does on main (docker-compose images at 0.2.0). That is unrelated and untouched here.

The Export dialog test "downloads Word and Markdown … remembers the destination" failed once in a two-file run on a loaded machine. It passed alone and in the full run. It is in a file this PR doesn't change.

🤖 Generated with Claude Code

cihan-gyk and others added 30 commits October 23, 2026 02:24
The workspace's one AI budget (Improve, the Content Editor's AI and the
Action Center's task writer) had no meter: the first sign of it was an
"AI usage is used up" error. Migration 00242 records what each AI call
was for (prompt_improve_usage.feature, backfilled) and sums the period's
spend by feature (ai_usage_by_feature). GET /api/billing/ai-usage
returns the shares of the plan's budget, and the Billing page shows the
share used, when it resets and what used it, with Agent Chat noted as
running on the workspace's own key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The workspace's AI budget was checked by reading the period's spend; the
call's cost was written once the model answered. Calls running at once
(two tabs, a teammate, an Action Center sweep) all read the same spend
and all ran past the budget. 00243's reserve_ai_usage takes a
per-organization lock, reads the spend with the calls in flight, and
holds the call's estimated cost; reserveAiBudget turns the hold into the
real cost or releases it. Improve, the brief rebuild, Apply rules with
Agent, Start Agent and the Action Center task writer use it in place of
enforceImproveQuota, which goes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fixes:
- Apply rules with Agent and Start Agent charge an answer the provider
  billed but that missed the schema (NoObjectGeneratedError), as Improve,
  the brief and the task writer do; before, the hold was let go and the
  call ran free.
- A call holds the org's median cost over its last 20 calls this period,
  never less than the model's typical cost, so calls in flight pass the
  budget by far less.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Apply rules with Agent makes at most 8 small edits a run, which can't
bring a long page to its Length (about 2% a run on prod). The Content
Agent can now rewrite the whole page in one background call, left as ONE
suggestion (kind 'page', migration 00247) to compare and accept or reject:
- POST /api/content-drafts/:draftId/rewrite, through Start Agent's claim,
  budget hold and background run;
- passages AI quotes today, tables, images, quotes and HTML blocks go to
  the model as [[KEEP n]] lines and come back as they were; a rewrite that
  drops one fails the run;
- one H1, only the page's own links and the ones offered, the editor's
  tags; the page as it was is kept on the suggestion (before_html).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Length

Review fixes:
- Kept blocks are described under the page (a quoted passage's words, a
  table's rows, an image's alt) and their text counts toward Length, so a
  rewrite aims at the whole page's length; with Length off it keeps the
  page's own. A kept H1 stays first, and the page's language is kept.
- The answer is taken out of a code fence, text left at its root goes in
  paragraphs, and an answer in Markdown fails the run.
- The page's own links stay exactly as written (query and anchor too).
- Kept blocks go back untouched (an empty table cell stays), only the
  page's first H1 counts as its title, a page that writes "[[KEEP" gets
  markers of its own, and a page that is only kept blocks isn't sent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…compare it

The Rules tab opens with the agent's two ways to meet its rules: Apply
rules with Agent (small edits, up to 8 a run) and Rewrite the page to
these rules (the whole page as one change). The rewrite is recommended,
with a one-line reason, when the page is more than 30% off its Length or
4 rules or more are open.

A rewritten page comes back as one suggestion with its own bar over the
page: the characters before and after and the agent's reason, Compare
(the page and the rewrite side by side), Accept (History keeps the page
first), Reject, and Undo. A page that changed since the agent read it
isn't written over. The page waits for the rewrite with its own steps,
and a failed rewrite's Try again rewrites again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fixes:
- A page is compared with the one the agent read by its words, with a
  space between blocks, so stored line breaks and lists don't read as a
  change (Accept and Undo were refused on imported pages).
- One agent run at a time from the page; a rewrite never starts before
  the locked passages are read, and sends the editor's own locked keys.
- Accept holds the page still from the start and checks it again before
  putting the rewrite in; Undo puts the page back as it was (two H1s too),
  and the bar waits while the HTML view is open.
- No rewrite advice for an empty page or one too long to send whole; the
  rewrite mark survives a reload; the waiting view says the rewrite waits
  in the editor; Compare's links don't navigate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Content Editor v1.1, part 1 (CE-025, CE-026, §4): the agent row and the
rewrite bar become one card above the toolbar, in three states:
- waiting: "Content Agent has {n} suggestions for you", what they change
  and the rules they gain ("Rules 5 → 6 of 13"), with Review (scrolls to
  the first suggestion and marks it), Reject all and Accept all; a page
  rewritten shows its characters, with Compare;
- all reviewed: what was accepted and the rules met and still open, with
  Undo all and Run Agent;
- working: while Apply rules with Agent runs.
The tile moves a little (a soft ring, a blink, a spark; a sweep and a
breath while working), never a rotating ring, and not at all with reduced
motion. The card wraps on a narrow page; Accept all and Run Agent are the
primary buttons.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Run Agent on the card keeps to one agent run at a time and says why it
  waits; Apply rules never starts beside another run or before the locked
  passages are read.
- Ghost buttons show their hover on the card's grey; the tile and its
  count are hidden from screen readers (the title says it) and the count
  is darker for contrast; "+N more" comes from en.json, the reason's first
  letter is upper-cased in the page's locale.
- Review picks the first open suggestion in the page's order and focuses
  it; the sweep shows on the light tile in dark mode; the spark is slower
  once all are reviewed; without motion the working line is a faint full
  line; "0 still open" isn't said.
- globals.css keeps its own lines; only the motion block is added.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…split Run Agent

Content Editor v1.1 part 2 (CE-028–CE-031): the side panel's tabs become
Instructions · Sources · Live page. Instructions holds Brief | Rules, with
the rules still open on the tab and the segment. Each segment opens with a
status card: Rules has one split Run Agent ▾ (Fix open rules, or Rewrite
the whole page, which renames it "Rewrite page") in place of the two rule
buttons; Brief has Run Agent while empty and Rebuild brief once written.
Why the agent can't run is written under the card, and each card's ⓘ tip
opens below it. The brief shows "Not set yet" and its Length in characters
and about as many words; the toolbar counter adds the page's words.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Run Agent's choice is worked out once and falls back to Fix without a
  rewrite; once a rewrite starts, the button is back on Fix.
- ▾'s choices are menu radio items; Fix is off when only rules the agent
  can't fix are open, and the card says what to do instead.
- The reason line under the card stays mounted for screen readers; Rewrite
  from brief writes its reason too; the tab's count is read out.
- Brief | Rules switch with the arrow keys, one tab stop.
- An edited brief's rebuild question sits under the card; a brief without
  H2s says to rebuild it; an empty brief shows no origin line.
- Plural copy for the open suggestions and the counter's words; rule names
  joined by the formatter; Run Agent's tip leaves ▾ out without a rewrite.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Content Editor v1.1 part 3 (CE-032, CE-034): under each Run Agent card,
"Uses your data: 1 prompt · 21 fan-outs · 20 cited pages · 10 Search
Console queries · Edit sources", counted as the Sources tab keeps them, so
turning one off lowers it at once. The Sources tab carries its count, and
its top says "N sources in use" and when the Content Agent last wrote from
them (its latest suggestions or the brief it built). A first visit's note
at the top of Instructions says the agent writes from the person's data;
closing it is kept in their own user metadata.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- "Last used by Content Agent" also counts the agent writing the page
  (agent_state_at: Start with Agent, Rewrite from brief on a new page),
  not a run that failed; a value that isn't a date is skipped.
- The latest batch's time is its first suggestion's, not a sort per render.
- Tests: the Brief segment's line, no line while the sources can't be read,
  the tab's count, the note showing again after a failed write, and a
  suggestion read with its createdAt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… name them

Content Editor v1.1, CE-033 (server): Fix open rules, Start with Agent and
Rewrite the whole page read the sources the Sources tab keeps, numbered
S1, S2… (content-sources.js). Each suggestion keeps the sources it names
and the words each supports (content_draft_suggestions.sources and
source_marks, 00248); a page rewritten whole keeps its sources.

No number without a source: the model reads a source by its words only, so
a number the agent adds must be the page's, the brand's, the brief's, the
rules', today's, or in a source's own words (then marked to it). A
suggestion with any other number is not kept; a page written whole gets a
placeholder in its place. Source numbers written into the words are taken
out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Content Editor v1.1, CE-033 (web) and the rest of CE-034: under each
suggestion, "Based on" chips name the sources it used (number, kind, name;
the Sources tab's details on hover), and a small number marks the words
each supports. A click on either opens Sources on that row, scrolled to
and ringed for a moment, once. The agent card adds "built from N of your
sources · See sources". Fix open rules sends the kept sources, and the
first-visit note says every change shows the sources it used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Content Editor v1.1, CE-027/035 (server): each Content Agent run (Fix open
rules, Start with Agent, Rewrite the whole page, the brief) is written in
content_agent_runs (00249) with its steps named by the data it reads
("Reading 20 cited pages", "Matching 21 fan-outs", "Writing 3 changes") as
it reaches them. POST /api/content-drafts/:id/stop marks the run stopped
and aborts its model call; the run checks before it keeps anything, so a
stopped run changes nothing (no suggestions, page, brief or History).

A run that can't be written still runs; runs a stopped server left are
closed when the next starts, and Stop ignores them. Background runs are
written before Start answers, so Stop finds them at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Stop also clears the draft's 'writing' state at once: a background run lets
go once it sees the stop, but one no server holds any more never would, and
the waiting page would wait out the 10 minutes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…p it (CE-027, CE-035)

The agent card, the brief and the waiting page show the run's real steps
(content_agent_runs, read from the browser every second) and a Stop button
that ends the run through the API proxy, leaving the page as it was. A dashed
decoration under the H1 says where Fix is drafting, and the agent's dots
replace every spinner on its buttons.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…h (CE-030)

When the brief is rebuilt, the server reads the first few cited pages kept
in Sources (only addresses AI answers cited for the brand, never the draft's
own page), counts their main text as the Rules tab counts length, and saves
the median as brief.citedLength. The Brief tab says "From the rules · cited
pages average N characters"; with fewer than two pages read it stays "From
the rules". textLength moves to page-content.js to avoid an import cycle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	server/src/lib/content-writer.js
#	server/src/lib/content-writer.test.js
#	supabase/schema.sql
…le it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…le it writes

content_drafts.agent_run ('write' or 'rewrite', in 00247 and its guard) is
set when Start or a rewrite claims the draft, so every device knows a failed
rewrite from a failed Start. Fix open rules and the MCP suggest call answer
409 'writing' while a run holds the draft, so its answer is never dropped
after it was charged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…st batch's rows

The editor reads content_drafts.agent_run, so a failed rewrite is tried again
as one on every device (the localStorage mark is gone). Fix open rules' new
409 'writing' says the agent is already writing. getDraftSuggestions finds
the latest batch first and reads only its rows, and Compare's links can't
take focus.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The card's Run Agent writes its reason in the card's second line (amber, tied
to the button by aria-describedby) instead of a hover title, and is turned
off when the only rules left open are ones the agent doesn't fix (one H1),
as the Rules card does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
cihan-gyk and others added 10 commits October 23, 2026 23:33
…ld a skip until every read is in

Review fixes for the Next step basket:
- focus goes back to the Next button only from inside the basket or from
  nowhere (Base UI's own rule); after Skip, the new step's button takes it
  and the step is read out
- stale skips are dropped only once the sources, the site's trust and the
  link reads are in
- an empty page is read past the block its title comes from
- Before you publish and Mark ready are held as the header's Mark ready is
- Rewrite page sits beside Fix open rules where the Rules tab recommends it,
  and "If you see…" takes its count from REWRITE_OPEN_RULES

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…abelled on hover and focus (Next step basket, part 2)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… pages (AI usage display, part 1)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…AI usage, and once it's used up (AI usage display, part 2)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d agent buttons once it's used up (AI usage display, part 3b)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the editor header (Send to CMS ansvisor#1331, part 2: web)

- Send to CMS in the editor header, for admins and managers, through
  Before you publish while Quality is on; the dialog fills slug, meta
  title and meta description from the page (or what the draft kept),
  holds the send while placeholders are open or the page is empty, and
  says the server's reasons in plain words
- the page goes as Export makes it ready: publishable HTML without its
  H1, with the brand's byline line, its author and an https featured image
- Webhook Settings gets the opt-in "Content page sent" event
- a long title's slug is cut at a word, as it now becomes the page's
  address in the CMS

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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.

One fix before merge:

  1. Save the page before it is sent. #1331's plan for the editor send says "Before sending, save what's waiting (autosave settle)", and Mark ready already does this (_draft-editor.tsx:1612-1623). Here, openSend (_draft-editor.tsx:1594, reached from the header at :2015 and from Continue to send at :2403) takes the editor's content as it is, whether it's saved or not.

    • A tab in the conflict state, where a teammate or the agent changed the page meanwhile, can still send its own version.
    • The CMS then gets a page Ansvisor doesn't hold, and the callback later marks the stored page, which is different, as Published.

    Fix: make openSend async and await autosave.settle() first. If it throws, show a toast (a new send.unsaved key, like markReadyUnsaved) and don't open the dialog.

Low, can follow:

  1. _send-dialog.tsx:94-104 with cms-send-client.ts:114-116: when the kept slug and meta can't be read, the dialog fills them from the page and enables Send, with no "Last sent" line.

    • For a page sent before under an edited slug, that can create a second post in the CMS. #1440's bulk dialog holds the send in this case for that reason.
    • The deploy order puts 00262 on prod first, so a null here only means a failed read. Hold Send the same way, with Try again.
  2. The decision on #1331 prefills the meta title from the title, "up to ~60 characters". cmsFields (cms-send.ts:46) takes pageFields().metaTitle, which is the whole title (up to 300 characters). Either cut it at a word near 60 in cmsFields (Export's page fields can stay as they are), or note the change on #1331.

Checked against #1437 and fine:

  • The button is shown to admins and managers only, matching the server's assertSender.
  • The title, slug, meta, author and image limits match deliveryPage.
  • The placeholder count runs on the same snapshot that is sent.
  • Each server code has its own message, and so do 401, 403 and 429.

cihan-gyk and others added 4 commits October 24, 2026 11:34
ansvisor#1433 is on main (squash-merged), with ansvisor#1429–ansvisor#1436 and ansvisor#1442/ansvisor#1444; this
branch's own change (Send to CMS part 2) is applied on top.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s last send is read

- openSend settles autosave first; a page it can't save isn't sent (send.unsaved toast)
- the Send dialog holds Send with Try again when the kept slug and meta can't be read
- the meta title prefill is cut at a word near 60 characters
- types: content_draft_deliveries.external_id (00262)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e page's own text outside the basket

The basket test clicked a button added to the document after the basket
opened, which Base UI takes for another app's: with the Send to CMS tests
before it, it failed one run in three.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ep the kept slug per field

- HTML edited in the HTML view and not applied asks to be applied first
- the header's Send waits while the page saves (one click), and is off
  while the page can't save (conflict, too large), as Mark ready is
- the dialog keeps what the draft kept in each field the person hasn't
  changed, the slug above all; Try again stays in place while it reads
- the meta title prefill cuts at any space, never inside an emoji, without
  the punctuation the cut leaves

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Thanks. Fixed in 72049d5, bec616b and 4a036db. upstream/main is merged in (3059ee1), so the conflict is gone.

  1. Save before sending.
    • openSend awaits autosave.settle() first. If the page can't be saved, it shows send.unsaved and doesn't open the dialog, as Mark ready does. Both the header and Before you publish's "Continue to send" go through it.
    • Also from the pre-push review:
      • HTML edited in the HTML view and not applied isn't in autosave, so Send asks for it to be applied first (send.applyHtml).
      • The header button takes one click while the page saves, showing LoadingDots.
      • Like Mark ready, it is off in the conflict and too-large states.
    • Tests cover a conflict (no dialog, no read), an unapplied HTML edit, and a second click.
  2. Unread kept fields.
    • When readDraftCms fails or answers null, the dialog shows an alert with Try again, and Send stays off.
    • Try again stays in place, disabled, while it reads again, so keyboard focus doesn't drop.
    • The kept fields now fill each field the person hasn't touched. Changing the meta description before the read lands no longer drops the kept slug (the second-post risk).
  3. Meta title prefill.
    • cmsFields cuts the page's meta title at the last space within 60 characters. A no-break space counts as a space.
    • With no space past half, it cuts at 60 characters, never inside an emoji.
    • The punctuation a cut leaves (: , –…) is dropped.
    • Export's page fields are unchanged, and a kept meta title is used as it is.

types/supabase.ts has content_draft_deliveries.external_id from #1437's 00262 change.

A test note: with the new Send to CMS tests, the Next step basket test "leaves focus where a click outside the basket put it" failed one run in three. It clicked a button appended to document.body after the popover opened, which Base UI takes for a third-party element. It now clicks the page's own .ProseMirror and passes every run. The Send dialog tests also close their dialog at the end.

Checks: format, lint (no new warnings), typecheck, all 3,377 tests and the build pass.

cihan-gyk added a commit to cihan-gyk/ansvisor that referenced this pull request Oct 24, 2026
…library

ansvisor#1438's branch now has main (ansvisor#1429–ansvisor#1436, ansvisor#1442, ansvisor#1444); this branch's own
changes (Send to CMS part 3a) are applied on top.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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.

All three items are done. One new fix before merge:

  1. The rewritten basket test ends the run with an error. page.test.tsx:3492-3510 ("leaves focus where a click outside the basket put it") now sends mousedown and the other pointer events to .ProseMirror.

    • prosemirror-view's mousedown handler calls posAtCoords, which calls elementFromPoint, and jsdom doesn't have it.
    • Every test passes, but Vitest reports an unhandled error ("Errors 1 error") and yarn test exits 1.
    • It happens with vitest run <this file> -t basket on this branch, and not on main.

    Fix: define document.elementFromPoint (returning null) for this test and remove it afterwards. Or send only events ProseMirror doesn't read coordinates from. Please check that the run ends with no "Errors" line, not only that every test passes.

Low, can follow:

  1. _send-dialog.tsx:150-157: #1437 now returns what a callback said if it landed before the webhook answered.

    • A workflow that calls back failed and then answers 200 comes back as failed, with http_status: 200 and its own reason in error.
    • The dialog then says "The webhook answered 200 and didn't take the page", not the reason.

    Fix: show the status only for a non-2xx answer. Otherwise show webhookFailed with error.

Checked against #1437 as it is now, and fine:

  • The request and response shapes are unchanged.
  • The server reads method, live address, page type and language from the draft's row, so the browser sends none of them.
  • external_id is typed.
  • An interrupted send keeps its own time, and at falls back to created_at for it.
  • Merge commit 3059ee1 carries no changes of its own.

… and give a 2xx send's failure its reason

- the test clicks the page's text: ProseMirror reads the click's place
  with elementFromPoint, which jsdom lacks; it's stubbed for that test
- a send the webhook took (2xx) that the workflow then called back failed
  shows the workflow's reason, not "The webhook answered 200"

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Both items are done in e5f9430.

  1. Basket test error. The test now defines document.elementFromPoint (returning null) and removes it afterwards in a finally. The full yarn test run exits 0 with no "Errors" line (371 files, 3,377 tests). vitest run <file> -t basket ends clean too.
  2. A 2xx answer with a failure. The dialog shows the status only for a non-2xx answer. Otherwise it shows webhookFailed with the workflow's reason from error.

Checks: yarn format, yarn lint, yarn typecheck, yarn test and yarn 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.

All items done. Looks good.

  1. Basket test: document.elementFromPoint is now stubbed for that one test and removed in a finally. No other test is affected.
  2. A 2xx answer with a failure: the dialog shows the status only for a non-2xx answer (_send-dialog.tsx:150-161). Otherwise it shows the workflow's reason from error, and there's a test for it.

Checked against #1437 as it is now (cffb209):

  • The request and response shapes haven't changed.
  • deliver() still hands back a callback's failed together with the webhook's 2xx and the workflow's reason. That's the case the dialog now reads.
  • The callback always writes a reason for failed, so the t('errors.failed') fallback only covers an old row.

@gkhngyk
gkhngyk merged commit 5697552 into ansvisor:main Oct 24, 2026
5 checks passed
gkhngyk added a commit to cihan-gyk/ansvisor that referenced this pull request Oct 24, 2026
Keep ansvisor#1438's useUserRole import and canManage declaration; drop this branch's duplicates.
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