Skip to content

fix(frontend): give the workflow editor its own container, not the document's first - #8607

Closed
yangzhang75 wants to merge 1 commit into
apache:mainfrom
yangzhang75:fix/8606-editor-container
Closed

yangzhang75 wants to merge 1 commit into
apache:mainfrom
yangzhang75:fix/8606-editor-container

Conversation

@yangzhang75

@yangzhang75 yangzhang75 commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

WorkflowEditorComponent found the element it builds its JointJS paper into with a document-wide lookup:

this.editor = document.getElementById("workflow-editor")!;
this.editorWrapper = document.getElementById("workflow-editor-wrapper")!;

Those ids come from this component's own template, so every instance of it renders elements carrying them. The lookup does not return this instance's container; it returns whichever is first in document order. Three places mount this component -- the operator canvas, the Form View's workflow preview, and the Hub's read-only preview -- so "only one is ever in the page" was an assumption, not a fact.

It resolves both from its own host now (ElementRef, which was already injected and otherwise unused). The two ! assertions are also honest for the first time: the divs are this component's own template with no structural directive above them, so they cannot be missing, whereas the document lookup genuinely could return null.

What this was reaching for. el for the paper is the visible one, but fifteen places read these two fields, and every one of them was acting on the wrong element whenever a second instance existed: setDimensions from the other view's wrapper, classList.add("hide-operator-status") on the other view's div, a ResizeObserver watching it, fromEvent(this.editor, "mousemove") bound to it, and the centring in handleCenterEvent measuring it.

Before

After

Measured in a browser on that branch, at the moment the canvas comes back from the Form View:

   two in the document, the lookup returns index 0 (the departing view's)
   before:  #workflow-editor 1399x1000   svg=false   cells=0
   after:   #workflow-editor 1399x1000   svg=true    cells=1

This is not reachable on main as it stands: every route that mounts a second editor does so after a full page load, so the instances never coexist and the first match is always the right one. Verified on a local instance running plain main (957b6c965), where the same steps keep the canvas live and the lookup only ever sees one container. It becomes reachable the moment two coexist, which is what #8581 does by routing between a workflow's two views.

The canvas was left with an empty container: nothing to pan, nothing to click, while the graph itself was untouched -- the Form View's preview went on showing it, including a run in progress, right up to the switch.

Any related issues, documentation, discussions?

Closes #8606.

Found while browser-testing #8581, which is blocked on this: with the switch routed and this unfixed, coming back to the canvas from a Form View whose preview has been opened leaves it blank.

Two more document-wide lookups of the same id are deliberately left alone, since neither leaves a stuck state and both want their own reasoning: MiniMapComponent.updateNavigator reads it to place the navigator rectangle (self-corrects on the next pointer event) and ReportGenerationService reads it to snapshot the canvas. Both are noted in #8606.

Changing the ids to classes, which is the other half of the story (two elements sharing an id in one document is invalid HTML), is not done here: it reaches into the component's SCSS and those two other readers, and this fix is worth having on its own.

How was this PR tested?

workflow-editor.component.spec: a second editor created while a decoy #workflow-editor sits earlier in the document still builds its paper in its own container, and the decoy stays empty. This reproduces the defect deterministically without any routing, so it fails on main today.

Deletion-checked: restoring the document-wide lookup turns exactly that one named test red (1 failed, 117 passed).

Verified end to end in a real browser as well, on the #8581 branch where the defect is reachable: switch to the Form View, expand its workflow preview, switch back, and the canvas comes back live rather than blank. No run is needed; watching a run in the preview simply makes it certain, because that is when a reader expands the preview.

Full frontend suite: 224 files, 6119 passed, 1 skipped (pre-existing), 0 failed. ng build --configuration=production (AOT), eslint and prettier --check on both changed files: clean.

Was this PR authored or co-authored using generative AI tooling?

Yes. Generated-by: Claude Code (Claude Opus 5, Anthropic). Co-authored with Claude; the author reviewed the change line by line and reproduced both the failure and the fix in a running instance before submission.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FVvP3ttj22f9LB4p9u2anY

…cument's first

Found in the browser: switching to the Form View and back left the canvas
blank -- nothing to pan, nothing to click -- while the graph itself was
fine, as the Form View's preview went on showing it running.

`WorkflowEditorComponent` found its container with
`document.getElementById("workflow-editor")`, and both views render that
same hardcoded id: the canvas's editor and the Form View's preview are
the same component. While the switch was a full page load the two could
never coexist, so the lookup was always right. Routing between the views
overlaps them for a tick -- the arriving view runs `ngAfterViewInit`
while the departing one is still in the DOM -- and a document-wide
lookup then returns the departing view's container, first in document
order. The paper was built into a div about to be removed, and the
arriving canvas kept an empty one.

Measured in a real browser, at the moment the canvas comes back:

  [GETBYID] workflow-editor: 2 in document, returned index 0
  before: #workflow-editor 1399x1000, svg=false, cells=0
  after:  #workflow-editor 1399x1000, svg=true,  cells=1

It resolves both elements from its own host now. No run is needed to
reproduce; expanding the Form View's preview once is enough, which is
why watching a run there made it certain.

Deletion-checked: restoring the document-wide lookup turns exactly the
new named test red.

Full frontend suite: 224 files, 6150 passed, 1 skipped, 0 failed. AOT
build, eslint and prettier clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FVvP3ttj22f9LB4p9u2anY
@github-actions github-actions Bot added fix frontend Changes related to the frontend GUI labels Sep 19, 2026
@Yicong-Huang Yicong-Huang added release/v1.3 back porting to release/v1.3 release/v1.2 back porting to release/v1.2 labels Sep 19, 2026
@github-actions
github-actions Bot requested review from mengw15 and xuang7 September 19, 2026 03:14
@github-actions

github-actions Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Backport auto-label report

This fix: PR was checked against each actively-supported release branch. A release/* label nominates a backport target; the branch's release manager approving this PR is what sends the fix there. The required Backport Approvals check stays red until every label below is approved, so each manager either approves or removes their own label — which is why the labels left on a merged PR are exactly the branches it reached.

Release branch Analysis
release/v1.3 Already labeled — this fix is queued to backport here. @mengw15 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other.
release/v1.2 Already labeled — this fix is queued to backport here. @xuang7 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other.

Auto-label run.

@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @PG1204
    You can notify them by mentioning @PG1204 in a comment.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.78%. Comparing base (d118784) to head (a0eb568).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8607   +/-   ##
=========================================
  Coverage     92.78%   92.78%           
  Complexity     4899     4899           
=========================================
  Files          1236     1236           
  Lines         52120    52144   +24     
  Branches       6405     6409    +4     
=========================================
+ Hits          48357    48381   +24     
  Misses         2186     2186           
  Partials       1577     1577           
Flag Coverage Δ *Carryforward flag
access-control-service 71.78% <ø> (ø) Carriedforward from d118784
agent-service 99.32% <ø> (ø) Carriedforward from d118784
amber 88.61% <ø> (ø) Carriedforward from d118784
computing-unit-managing-service 55.20% <ø> (ø) Carriedforward from d118784
config-service 87.37% <ø> (ø) Carriedforward from d118784
file-service 81.53% <ø> (ø) Carriedforward from d118784
frontend 96.58% <100.00%> (+<0.01%) ⬆️
notebook-migration-service 83.73% <ø> (ø) Carriedforward from d118784
pyamber 98.48% <ø> (ø) Carriedforward from d118784
workflow-compiling-service 74.09% <ø> (ø) Carriedforward from d118784

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yangzhang75

Copy link
Copy Markdown
Contributor Author

Closing: the fix belongs in #8581 rather than beside it.

The defect is older than #8581 (the lookup predates the core/new-gui relocation), but the symptom is #8581's: routing between a workflow's two views is what puts two editors in the page at once. A #8581 without this fix would merge a blank canvas into main and rely on this PR landing first, which nothing enforces. Carrying it there instead means main is never broken whatever order things land in, and 2 files / +32/-2 does not meaningfully add to that PR's review surface.

The commit is unchanged, now the third on #8581's branch. #8606 stays open for the two other document-wide lookups of the same id, which #8581 does not need.

@yangzhang75
yangzhang75 deleted the fix/8606-editor-container branch September 19, 2026 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix frontend Changes related to the frontend GUI release/v1.2 back porting to release/v1.2 release/v1.3 back porting to release/v1.3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The workflow editor takes its container from the document, so a second instance leaves the canvas blank

3 participants