Skip to content

[backport cloud/1.56] fix(agent): notify refused promoted writes and refuse before the doc catches up - #21312

Closed
comfy-pr-bot wants to merge 1 commit into
cloud/1.56from
backport-20516-to-cloud-1.56
Closed

comfy-pr-bot wants to merge 1 commit into
cloud/1.56from
backport-20516-to-cloud-1.56

Conversation

@comfy-pr-bot

Copy link
Copy Markdown
Member

Backport of #20516 to cloud/1.56

Automatically created by backport workflow.

…catches up (#20516)

## Summary

A promoted subgraph-host widget write that the agent CRDT minter refuses
now reports telemetry and shows the same rejected-edit toast as a host
rejection. The minter also refuses a promoted write until the follower
document has caught up, unless this tab enqueued the host's `add_node`
into that document. Part of PM-1995, follow-up to #20377.

- **Refusals:** `promotedHostWrite` returns a refusal
(`unpromoted_widget`, `doc_not_synced`, `layout_drift`). `mintSetWidget`
reports each one once per minter, per workflow and host (per widget for
`agent_crdt_promoted_widget_not_promoted`), then calls
`onWidgetWriteRefused`.
- **Toast:** `AgentPanelRoot` routes `onWidgetWriteRefused` to the
follower's existing rejected-op notifier. Local refusals and host
rejections share one throttle per rendered message.
- **Catch-up gate:** the follower answers `mayWritePromotedHost`. It
returns true once `LayoutFollowerBridge.isSubscribeBaselineIntegrated`
holds (an acknowledged subscribe whose integrated seq reaches the ack,
with a readable schema). It also returns true for a host this tab
enqueued an `add_node` for into the same follower document, while that
document does not hold the host yet.
- **Bridge evidence:** the bridge keeps `integratedSeq` per follower
document. A catch-up credits every frame applied since the send, and a
live frame credits only itself when it is contiguous with what is
already integrated. The first frame applied before an ack is checked
when the ack lands, and a frame past ack + 1 is reported as `doc_gap`
and triggers a resubscribe.
- **Known limitations:**
- A promoted edit made between a resubscribe's send and its ack is
refused with a toast, not deferred. Resubscribes include the 30 s stale
probe, a reconnect, a gap resync, and an ack-timeout retry.
- While a subscription is refused, the schema is unreadable, or the
workflow is not minted yet (seq-0 ack), every promoted edit is refused
and toasted.
- The toast copy (`agent.editRejected.widgetWrite`) is the
host-rejection copy.

## Verification

- `vitest run src/workbench/extensions/agent/`: 160 files pass. `pnpm
typecheck`, knip, oxfmt, oxlint, eslint, and the pre-push fallow audit
are clean.
- Bridge tests in `followerSubscription.test.ts` cover:
  - waiting for a catch-up;
  - an already-current resubscribe;
  - live progress that overtakes an ack;
  - repeated, refused, and retried subscribes;
  - a gap resubscribe;
  - a pre-ack frame past the ack reported as a gap;
  - baseline zero;
  - the schema gate;
  - a rejection after an accepted ack;
  - discarding a replayed frame after a resubscribe.
- `useAgentCrdtFollower.humanAddTabSwitch.test.ts` drives the real
follower and checks `mayWritePromotedHost` before and after catch-up,
for a host this tab added, and after `doc_reset`.
`useAgentCrdtFollower.rejectedWidgetWrite.test.ts` checks that a local
refusal and a host rejection share one toast.
- Each new test fails when the behaviour it covers is removed
(mutation-checked).
- No browser check of the toast. The rendered toast is the existing
host-rejection toast; only its trigger is new.

---------

Co-authored-by: Glary-Bot <glary-bot@users.noreply.github.com>
Co-authored-by: Alexander Brown <drjkl@comfy.org>
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle Size

⏳ Size data collection in progress…

⚡ Performance

⚠️ Performance tests failed. Check the CI workflow logs.

🔬 E2E Coverage

⚠️ Coverage collection failed. Check the CI workflow logs.

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 10/18/2026, 10:16:53 PM UTC

Links

🌾 Fallow: ✅ Passed

Fallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened.

No new findings in the changed files.

Reproduce locally
# the base the gate compared against
npx fallow audit --root . --quiet --format json \
  --changed-since 1b0ddf2ef25caee1fb682ca2f08b352475983bdf

Full docs: ADR-DEVEX-LINT-0015

@github-actions
github-actions Bot requested a review from thedatalife October 18, 2026 22:15
@datadog-official

datadog-official Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Pipelines

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 9 Pipeline jobs failed

CI: Dist Telemetry Scan | scan

View in Datadog · View in GitHub Actions

CI: OSS Assets Validation | validate-fonts

View in Datadog · View in GitHub Actions

CI: Performance Report | perf-tests

View in Datadog · View in GitHub Actions

View all 9 failed jobs.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 80c6872 | Docs | View more details | Give us feedback!

@github-actions github-actions Bot added the risk:high PR risk grade (advisory shadow check; grader-owned) label Oct 18, 2026

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

Blocked: the cloud/1.56 backport does not typecheck at this head.

Full context for agent readers

The implementation matches the merged change, but the older target branch exposes two compatibility gaps. The real lint-pr / typecheck job fails in its application typecheck step; the downstream setup, lint, test, and E2E failures are short-circuit fallout.

I left the two actionable defects inline. Please backfill the older-branch fixtures with the new required dependencies and use the toast helper that exists on this branch.

* False until the bound document has caught up, unless this tab already
* sent the root host's `add_node` into the same document.
*/
mayWritePromotedHost(nodeId: NodeId): boolean

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.

Blocking: making these dependencies required breaks the two existing cloud/1.56 fixtures in agentBuiltWidgetInputLink.regression.test.ts at lines 156 and 219. The real typecheck reports TS2739 because both objects omit mayWritePromotedHost and onWidgetWriteRefused. Please backfill those fixtures (or provide compatible defaults) so the target branch builds.

const { submit, follower } = mountFollower()

follower.notifyWidgetWriteRefused()
expect(toastDescriptions()).toEqual([

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.

Blocking: this target branch defines toastDetails(), not toastDescriptions(). Both new assertions here (lines 296 and 301) fail with TS2304. Please use the existing branch helper so this regression test typechecks.

@thedatalife

Copy link
Copy Markdown
Contributor

Closing: production has already advanced past 1.56, so this cloud/1.56 change is no longer needed.

@thedatalife thedatalife closed this Nov 6, 2026
auto-merge was automatically disabled November 6, 2026 16:54

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Backporting a PR onto a release candidate risk:high PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants