Skip to content

fix(agent): apply only the latest run mode save - #16753

Merged
christian-byrne merged 2 commits into
Comfy-Org:mainfrom
christian-byrne:fix/agent-run-mode-latest-save
Sep 3, 2026
Merged

christian-byrne merged 2 commits into
Comfy-Org:mainfrom
christian-byrne:fix/agent-run-mode-latest-save

Conversation

@christian-byrne

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #16432. saveRevision only guarded load(); two overlapping save() calls each applied their own PUT response unconditionally, so the store showed whichever response resolved last rather than the latest save. Each save now captures its own revision and applies only when newer than the last applied save. The 404 fallback goes through the same gate, so an earlier success still applies when a later save fails.

Changes

  • agentRunModeStore.ts: per-save revision, appliedSaveRevision gate on both the PUT response and the 404 fallback.
  • agentRunModeStore.test.ts: two cases, "keeps the latest save when an earlier PUT resolves last" (fails on main) and "applies an earlier save when the latest one fails".

Verification

  • pnpm test:unit src/workbench/extensions/agent/stores/agent/agentRunModeStore.test.ts (18 pass; the first new case fails without the store change).
  • vue-tsc --noEmit clean; eslint, oxlint, oxfmt clean on both files.

@github-actions

github-actions Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

🎨 Storybook: 🚧 Building...

🎭 Playwright: ✅ 1914 passed, 0 failed · 1 flaky

📊 Browser Reports
  • chromium: View Report (✅ 1893 / ❌ 0 / ⚠️ 1 / ⏭️ 4)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 18 / ❌ 0 / ⚠️ 0 / ⏭️ 0)

📦 Bundle: 9.68 MB gzip ⚪ 0 B

Details

Summary

  • Raw size: 41 MB baseline 41 MB — ⚪ 0 B
  • Gzip: 9.68 MB baseline 9.68 MB — ⚪ 0 B
  • Brotli: 6.81 MB baseline 6.81 MB — ⚪ 0 B
  • Bundles: 448 current • 448 baseline

Category Glance
Vendor & Third-Party ⚪ 0 B (18.1 MB) · Other ⚪ 0 B (16.4 MB) · Data & Services ⚪ 0 B (3.59 MB) · Graph Workspace ⚪ 0 B (1.43 MB) · Panels & Settings ⚪ 0 B (621 kB) · Utilities & Hooks ⚪ 0 B (560 kB) · + 5 more

App Entry Points — 3.74 kB (baseline 3.74 kB) • ⚪ 0 B

Main entry bundles and manifests

Status: 1 unchanged

Graph Workspace — 1.43 MB (baseline 1.43 MB) • ⚪ 0 B

Graph editor runtime, canvas, workflow orchestration

Status: 3 unchanged

Views & Navigation — 124 kB (baseline 124 kB) • ⚪ 0 B

Top-level views, pages, and routed surfaces

Status: 17 unchanged

Panels & Settings — 621 kB (baseline 621 kB) • ⚪ 0 B

Configuration panels, inspectors, and settings screens

Status: 27 unchanged

User & Accounts — 27.8 kB (baseline 27.8 kB) • ⚪ 0 B

Authentication, profile, and account management bundles

Status: 11 unchanged

Editors & Dialogs — 126 kB (baseline 126 kB) • ⚪ 0 B

Modals, dialogs, drawers, and in-app editors

Status: 8 unchanged

UI Components — 117 kB (baseline 117 kB) • ⚪ 0 B

Reusable component library chunks

Status: 15 unchanged

Data & Services — 3.59 MB (baseline 3.59 MB) • ⚪ 0 B

Stores, services, APIs, and repositories

Status: 16 unchanged

Utilities & Hooks — 560 kB (baseline 560 kB) • ⚪ 0 B

Helpers, composables, and utility bundles

Status: 36 unchanged

Vendor & Third-Party — 18.1 MB (baseline 18.1 MB) • ⚪ 0 B

External libraries and shared vendor chunks

Status: 18 unchanged

Other — 16.4 MB (baseline 16.4 MB) • ⚪ 0 B

Bundles that do not match a named category

Status: 296 unchanged

⚡ Performance

⏳ Performance tests in progress…

@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

Next included review available in 13 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: d1248823-f22a-43ac-a732-3676a295b161

📥 Commits

Reviewing files that changed from the base of the PR and between 24a41cb and 61acab7.

📒 Files selected for processing (1)
  • src/workbench/extensions/agent/stores/agent/agentRunModeStore.test.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: ff436251-1f63-46af-b07f-e657a5e78160

📥 Commits

Reviewing files that changed from the base of the PR and between 86b872d and 24a41cb.

📒 Files selected for processing (2)
  • src/workbench/extensions/agent/stores/agent/agentRunModeStore.test.ts
  • src/workbench/extensions/agent/stores/agent/agentRunModeStore.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The store now tracks applied save revisions. It ignores stale asynchronous responses, preserves 404 fallback behavior, and propagates other errors. Tests cover late earlier success and latest-save failure scenarios.

Changes

Agent run mode save ordering

Layer / File(s) Summary
Revision-ordered save application and concurrency tests
src/workbench/extensions/agent/stores/agent/agentRunModeStore.ts, src/workbench/extensions/agent/stores/agent/agentRunModeStore.test.ts
The store applies only newer save results, including 404 fallbacks. Tests verify ordering for late earlier success and latest-save failure.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 24a41

Concurrent run mode saves now retain the newest applicable result while allowing an earlier successful save to update local state if a later save fails. No current merge-readiness risk remains.

Suggested reviewers: anupreet-comfy


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
End-To-End Regression Coverage For Fixes ❓ Inconclusive The changed files are available and show changes only under src/, with no browser_tests/ file. The description does not give a concrete reason for omitting an end-to-end regression test. However, … Provide the PR title and actual commit subjects. If either contains bug-fix language, confirm whether the author gave a concrete reason for not adding a Playwright regression test under browser_tests/.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: applying only the latest run mode save.
Description check ✅ Passed The description explains the bug, implementation, tests, and verification results. It omits explicit Review Focus and Screenshots sections, but these omissions are non-critical for this change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Website End-To-End Regression Coverage ✅ Passed Pass. The changed files are under src/workbench/..., not under apps/website/src/ or apps/website/public/. This website-specific check does not apply.
Adr Compliance For Entity/Litegraph Changes ✅ Passed The changed files are under src/workbench/extensions/agent/stores/agent/. No changed file is under src/lib/litegraph/, src/ecs/, or a graph-entity-related path. The check is therefore not applic…
Full details: End-To-End Regression Coverage For Fixes

Explanation

The changed files are available and show changes only under src/, with no browser_tests/ file. The description does not give a concrete reason for omitting an end-to-end regression test. However, the PR title and actual commit subjects are not provided; the available commit summary is not a commit subject. The check requires those signals and says to mark the result inconclusive when commit subjects are unavailable.

Full details: Adr Compliance For Entity/Litegraph Changes

Explanation

The changed files are under src/workbench/extensions/agent/stores/agent/. No changed file is under src/lib/litegraph/, src/ecs/, or a graph-entity-related path. The check is therefore not applicable.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Sep 3, 2026
@codecov

codecov Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main   #16753      +/-   ##
==========================================
+ Coverage   81.04%   82.61%   +1.57%     
==========================================
  Files        2452     2034     -418     
  Lines      125794   118321    -7473     
  Branches    31661    29835    -1826     
==========================================
- Hits       101944    97746    -4198     
+ Misses      23338    20398    -2940     
+ Partials      512      177     -335     
Flag Coverage Δ
e2e 66.70% <ø> (+<0.01%) ⬆️
unit 76.96% <100.00%> (-0.01%) ⬇️
website-unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...extensions/agent/stores/agent/agentRunModeStore.ts 96.96% <100.00%> (+0.19%) ⬆️

... and 425 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@christian-byrne christian-byrne self-assigned this Sep 3, 2026
@christian-byrne christian-byrne added the risk:R1 PR risk grade (advisory shadow check; grader-owned) label Sep 3, 2026

@christian-byrne christian-byrne left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact-head review of 61acab71c36ac7b6d040554437f45054e849ca7e: no blocking findings. The monotonic applied-revision gate handles both successful PUT responses and 404 local fallbacks, while preserving the latest successful save when a newer request fails. The two overlap tests cover the critical reversed-completion and newer-failure schedules; required checks are green on this head.

const savedPreference = await api.putRunMode(next)
const revision = ++saveRevision
const applySaved = (savedPreference: AgentRunModePreference) => {
if (revision <= appliedSaveRevision) return

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comparison is the key ordering invariant: once revision N applies, every response or 404 fallback from revisions ≤ N becomes a no-op. A newer failed request does not advance appliedSaveRevision, so the latest older successful response can still become the visible preference. Verified against both overlap tests at exact head 61acab71c36ac7b6d040554437f45054e849ca7e.

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

Walked the diff and its blast radius against the current head; the one open thread is the author's own note on the ordering invariant, not an objection. Nothing to add.

@christian-byrne
christian-byrne merged commit cdbbcbd into Comfy-Org:main Sep 3, 2026
101 checks passed
@DrJKL DrJKL added agent Comfy Agent product, integration, tests or product documentation agent-test-unit Touches Agent-related unit/component tests or their support labels Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Comfy Agent product, integration, tests or product documentation agent-test-unit Touches Agent-related unit/component tests or their support risk:R1 PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants