Skip to content

refactor(frontend): avoid redundant validateOperator call in applyOperatorBorder - #5702

Merged
Xiao-zhen-Liu merged 13 commits into
apache:mainfrom
PG1204:refactor/apply-operator-border-reuse-validation
Jun 25, 2026
Merged

refactor(frontend): avoid redundant validateOperator call in applyOperatorBorder#5702
Xiao-zhen-Liu merged 13 commits into
apache:mainfrom
PG1204:refactor/apply-operator-border-reuse-validation

Conversation

@PG1204

@PG1204 PG1204 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

WorkflowEditorComponent.applyOperatorBorder(operatorID)` always recomputes validation as its first step:

const validation = this.validationWorkflowService.validateOperator(operatorID);

This is redundant when the helper is called from the validation-stream subscriber in handleOperatorValidation, the stream's emitted event already carries the Validation result that was just computed by updateValidationState.

This PR:

  • Adds an optional validation?: Validation parameter to applyOperatorBorder. The helper uses it when provided, and falls back to validateOperator(operatorID) otherwise.
  • Updates handleOperatorValidation to pass value.validation from the stream into the helper.
  • Leaves the operator-add stream subscriber unchanged and hence it doesn't have a Validation in hand at that point, so it correctly falls through to the lazy-fetch path.
  • Functionally identical (the stream emits the same Validation that would have been recomputed), purely avoids the duplicate call.

Originally flagged as an optional nit during the PR #5146 review. Attempted in PR #5626 but split out as per the reviewer's request so that PR could stay scoped to test restructuring; this PR completes the follow-up.

Any related issues, documentation, discussions?

Closes #5683
Related: PR #5146 (where the nit was raised), PR #5626 (where this was attempted and split out).

How was this PR tested?

Added one focused unit test in workflow-editor.component.spec.ts inside the existing operator border restoration after navigation describe block: it("uses the Validation passed in instead of recomputing it", ...). The test clears the validateOperator spy after the operator-add validation chain settles, then calls applyOperatorBorder directly with a Validation argument and asserts validateOperator is not called.

Verified locally:

  • tsc --noEmit: clean
  • eslint: clean
  • ng test (jsdom): 26/26 pass in the editor spec (was 25, new test adds one)
  • ng run gui:test-browser: 13/13 pass

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

This PR was co-authored using Claude Code (Anthropic Claude Opus 4.7)

@github-actions github-actions Bot added refactor Refactor the code frontend Changes related to the frontend GUI labels Jun 14, 2026
@codecov-commenter

codecov-commenter commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.40%. Comparing base (d4eb9f7) to head (3f9ffb4).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5702      +/-   ##
============================================
- Coverage     54.54%   54.40%   -0.15%     
+ Complexity     3164     2857     -307     
============================================
  Files          1128     1108      -20     
  Lines         45753    42773    -2980     
  Branches       5008     4605     -403     
============================================
- Hits          24958    23269    -1689     
+ Misses        19362    18149    -1213     
+ Partials       1433     1355      -78     
Flag Coverage Δ *Carryforward flag
access-control-service 69.69% <ø> (-0.97%) ⬇️ Carriedforward from 6433e71
agent-service 34.36% <ø> (ø) Carriedforward from 6433e71
amber 56.17% <ø> (-0.69%) ⬇️ Carriedforward from 6433e71
computing-unit-managing-service 0.28% <ø> (-0.97%) ⬇️ Carriedforward from 6433e71
config-service 54.83% <ø> (+2.41%) ⬆️ Carriedforward from 6433e71
file-service 59.31% <ø> (+1.45%) ⬆️ Carriedforward from 6433e71
frontend 48.39% <100.00%> (+0.47%) ⬆️
notebook-migration-service ?
pyamber 90.20% <ø> (-0.99%) ⬇️ Carriedforward from 6433e71
python 90.76% <ø> (ø) Carriedforward from 6433e71
workflow-compiling-service 57.57% <ø> (+7.57%) ⬆️ Carriedforward from 6433e71

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

@PG1204

PG1204 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

/request-review @Xiao-zhen-Liu

Follow-up for the split-out applyOperatorBorder change: #5626. Includes the test for the "validation passed in" path.

@github-actions
github-actions Bot requested a review from Xiao-zhen-Liu June 14, 2026 00:17
@Yicong-Huang

Copy link
Copy Markdown
Contributor

@Xiao-zhen-Liu do you want to check on this one?

@PG1204

PG1204 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

@Xiao-zhen-Liu do you want to check on this one?

Hi team, any update on this PR?

@chenlica

Copy link
Copy Markdown
Contributor

@Xiao-zhen-Liu Please check this PR.

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

  • No candidates found from git blame history.

@Xiao-zhen-Liu Xiao-zhen-Liu 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.

LGTM — clean split-out of the change from #5626, and good call keeping the lazy fallback (the operator-add path has no Validation in hand, so it can't be removed).

@Xiao-zhen-Liu
Xiao-zhen-Liu added this pull request to the merge queue Jun 25, 2026
Merged via the queue into apache:main with commit 43ca4b2 Jun 25, 2026
18 checks passed
PG1204 added a commit to PG1204/texera that referenced this pull request Jul 14, 2026
…torBorder (apache#6075)

### What changes were proposed in this PR?

Follow-up to apache#5702. `WorkflowEditorComponent.applyOperatorBorder`
decides an operator's border color and has two callers:

- `handleOperatorValidation`: the validation-stream subscriber, which
already had the `Validation` and passed it in.
- The operator-add stream subscriber: which passed no `Validation` and
relied on an optional-parameter fallback that recomputed it inside the
helper.

This PR unifies the two paths so both callers obtain the `Validation`
themselves and pass it in:

- The operator-add subscriber now computes it via
`validationWorkflowService.validateOperator(...)` and passes it,
mirroring the validation-stream caller.
- `applyOperatorBorder`'s `validation` parameter becomes **required**,
and the `?? validateOperator(...)` fallback is removed. The color
decision no longer silently depends on a recompute hidden inside the
helper.

This is a non-functional cleanup and no behavioral change. In
particular, the operator-add subscriber still paints the border
immediately (and restores cached run statistics), preserving the
navigation-reset behavior from apache#3614.

Note on scope: the issue's summary mentions "painted exactly once."
Truly collapsing to a single paint conflicts with the apache#3614 requirement
that borders render immediately on reload without waiting for validation
events, and would need fragile "just-added" state tracking in the
validation handler. This PR implements the safe, behavior-preserving
unification (consistent validation acquisition, fallback removed) rather
than suppressing either paint.

### Any related issues, documentation, discussions?

Part of apache#5726. 
Related: apache#5702 (added the optional parameter; this issue arose from its
review), apache#5146 (introduced `applyOperatorBorder` and the apache#3614
navigation fix).

### How was this PR tested?

Updated `workflow-editor.component.spec.ts`:
- Renamed the "uses the Validation passed in instead of recomputing it"
test to "relies solely on the passed-in Validation (never recomputes
inside the helper)": the old name implied a recompute path that no
longer exists.
- Added "supplies a computed Validation from the operator-add path",
asserting the operator-add subscriber calls `applyOperatorBorder` with a
`Validation` object.
- Existing border-outcome tests (green / gray / red /
invalid-over-cached priority) remain and continue to pass.

Verified locally:
- `tsc --noEmit`: clean
- `prettier --check` / `eslint`: clean
- `ng test` (jsdom): 30/30 pass in the editor spec
- `ng run gui:test-browser`: 13/13 pass

### Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude Opus 4.8 in compliance with ASF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI refactor Refactor the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reuse validation result from the validation stream in applyOperatorBorder

5 participants