Skip to content

fix(designer-v2): prevent false unsaved-changes flag in monitoring view#9360

Merged
rllyy97 merged 1 commit into
mainfrom
rllyy97-fix-monitoring-false-dirty-state
Jul 2, 2026
Merged

fix(designer-v2): prevent false unsaved-changes flag in monitoring view#9360
rllyy97 merged 1 commit into
mainfrom
rllyy97-fix-monitoring-false-dirty-state

Conversation

@rllyy97

@rllyy97 rllyy97 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Commit Type

  • feature - New functionality
  • fix - Bug fix
  • refactor - Code restructuring without behavior change
  • perf - Performance improvement
  • docs - Documentation update
  • test - Test-related changes
  • chore - Maintenance/tooling

Risk Level

  • Low - Minor changes, limited scope
  • Medium - Moderate changes, some user impact
  • High - Major changes, significant user/system impact

What & Why

Fixes #9345.

While viewing run history (read-only / monitoring view), the designer could be falsely marked dirty, producing an intermittent "your unsaved edits will be discarded" prompt when toggling back to the workflow/code view — even though the view is read-only and no edits were made.

Root cause: Monitoring view is read-only, but nothing guarded the isDirty flags against side-effects. A controlled parameter editor re-emitting its value on mount can trigger a parameter-update path that forces isUserAction: trueworkflow.isDirty = true. Because it depends on parameter content and async timing, it reproduces only "sometimes", and the flag then persists so the host navigation guard shows the discard prompt.

Fix: Add monitoringDirtyGuardMiddleware to the designer-v2 store. While designerOptions.readOnly or isMonitoringView is set, it reverts any false → true transition of workflow.isDirty / workflowParameters.isDirty. This is root-cause-agnostic (covers parameter, settings, connection, and any other side-effect path) and preserves genuine pre-existing edits — only false → true transitions are reverted; already-true flags are left untouched.

Scoped to designer-v2 only. Designer v1 is intentionally left unchanged since v2 is replacing v1 in production.

Impact of Change

  • Users: No more spurious "unsaved edits will be discarded" prompt when leaving run history in read-only/monitoring view. Genuine unsaved edits made before entering monitoring are still preserved and still prompt.
  • Developers: New store middleware monitoringDirtyGuardMiddleware in libs/designer-v2/src/lib/core/utils/middleware.ts, wired after storeStateHistoryMiddleware. Follows the existing dispatch-from-middleware pattern.
  • System: Negligible overhead — reads two booleans before/after each action and only dispatches when a guarded false→true transition occurs in read-only/monitoring mode.

Test Plan

  • Unit tests added/updated
  • E2E tests added/updated
  • Manual testing completed
  • Tested in: libs/designer-v2 Vitest suite — 24/24 passing in middleware.spec.ts (7 new tests: reverts false→true when readOnly; reverts when isMonitoringView; reverts both workflow and workflowParameters flags; preserves pre-existing true; no revert when editable; no dispatch when unchanged; transparent pass-through to next). Biome clean on all changed files.

Contributors

@rllyy97

Screenshots/Videos

N/A — behavioral fix, no UI changes.

Copilot AI review requested due to automatic review settings July 2, 2026 14:31
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🤖 AI PR Validation Report

PR Review Results

Thank you for your submission! Here's detailed feedback on your PR title and body compliance:

PR Title

  • Current: fix(designer-v2): prevent false unsaved-changes flag in monitoring view
  • Issue: None.
  • Recommendation: The title is specific, uses a clear type/scope, and accurately describes the behavior change.

Commit Type

  • Properly selected (fix).
  • Only one commit type is checked, which is correct.

⚠️ Risk Level

  • The selected risk level is Low, which matches the label risk:low and the scope of the change.
  • Advised risk level: low (no change needed).

What & Why

  • Current: Well written and specific, with clear root cause and fix description.
  • Issue: None.
  • Recommendation: This section already provides enough context for reviewers.

Impact of Change

  • Impact is clearly described for users, developers, and system behavior.
  • Recommendation:
    • Users: No changes needed.
    • Developers: No changes needed.
    • System: No changes needed.

Test Plan

  • Unit tests were added/updated in the diff, and the PR body correctly reflects that.
  • The presence of middleware.spec.ts updates satisfies the test plan requirement.

Contributors

  • @rllyy97 is listed.
  • No issues found.

Screenshots/Videos

  • N/A is appropriate because this is a behavioral fix with no UI changes.

Summary Table

Section Status Recommendation
Title None
Commit Type None
Risk Level None
What & Why None
Impact of Change None
Test Plan None
Contributors None
Screenshots/Videos None

This PR passes. The submitted risk level matches the label and the body is well-formed.


Last updated: Thu, 02 Jul 2026 16:47:41 GMT

Copilot AI 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.

Pull request overview

Fixes an intermittent “unsaved edits will be discarded” prompt that could appear after viewing run history (monitoring/read-only) by preventing false isDirty transitions from persisting in the designer Redux state. This aligns with the designer’s contract that monitoring view is read-only and should not create new unsaved-change signals.

Changes:

  • Added monitoringDirtyGuardMiddleware to revert workflow.isDirty / workflowParameters.isDirty when they transition false → true during read-only or monitoring mode.
  • Wired the new middleware into the designer store middleware chain.
  • Added unit tests covering guarded dirty-flag transitions in read-only/monitoring scenarios.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
libs/designer/src/lib/core/utils/middleware.ts Adds a Redux middleware that detects and reverts false-positive dirty-flag transitions in read-only/monitoring mode.
libs/designer/src/lib/core/utils/test/middleware.spec.ts Adds unit tests validating the new middleware’s behavior.
libs/designer/src/lib/core/store.ts Registers the new middleware in the store configuration.

Comment thread libs/designer/src/lib/core/utils/middleware.ts
Comment thread libs/designer/src/lib/core/utils/__test__/middleware.spec.ts Outdated
@rllyy97 rllyy97 force-pushed the rllyy97-fix-monitoring-false-dirty-state branch from ebe18b5 to d131397 Compare July 2, 2026 14:42
@rllyy97 rllyy97 changed the title fix(designer): prevent false unsaved-changes flag in monitoring view fix(designer-v2): prevent false unsaved-changes flag in monitoring view Jul 2, 2026
While viewing run history (read-only/monitoring view) the workflow could be
falsely marked dirty by side-effects (e.g. a controlled parameter editor
re-emitting its value on mount), producing an intermittent 'unsaved edits will
be discarded' prompt when toggling back to the workflow/code view even though no
edits were made.

Add monitoringDirtyGuardMiddleware to the designer-v2 store: while
designerOptions.readOnly or isMonitoringView is set, revert any
workflow/workflowParameters isDirty false->true transition. Pre-existing dirty
state is preserved (only false->true transitions are reverted).

Also short-circuit storeStateHistoryMiddleware in read-only/monitoring view so
undoable side-effect dispatches (e.g. updateParameterAndDependencies.pending) do
not grow undo history or perform compression work for edits the user cannot make.

Fixes #9345

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rllyy97 rllyy97 force-pushed the rllyy97-fix-monitoring-false-dirty-state branch from d131397 to 294e1d6 Compare July 2, 2026 14:49
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

📊 Coverage Check

The following changed files need attention:

⚠️ libs/designer-v2/src/lib/core/store.ts - 40% covered (needs improvement)

Please add tests for the uncovered files before merging.

@rllyy97 rllyy97 added the risk:low Low risk change with minimal impact label Jul 2, 2026
@rllyy97 rllyy97 merged commit 3515b57 into main Jul 2, 2026
42 of 43 checks passed
@rllyy97 rllyy97 deleted the rllyy97-fix-monitoring-false-dirty-state branch July 2, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-validated risk:low Low risk change with minimal impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

While viewing run history sometimes I cant toggle back to workflow and it says I have workflow changes

3 participants