Repository navigation
fix(workflow-form): redraw a result's chart in place, and drop the key that was meant to rebuild it - #9021
fix(workflow-form): redraw a result's chart in place, and drop the key that was meant to rebuild it#9021yangzhang75 wants to merge 3 commits into
Conversation
Automated Reviewer SuggestionsBased on the
|
Backport auto-label reportThis
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9021 +/- ##
============================================
+ Coverage 91.60% 91.63% +0.02%
+ Complexity 5038 5037 -1
============================================
Files 1283 1288 +5
Lines 57004 56961 -43
Branches 7419 7436 +17
============================================
- Hits 52221 52198 -23
+ Misses 2915 2903 -12
+ Partials 1868 1860 -8
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
The test name claims “rebuilds nothing”, but the assertions only verifyrefreshShownResultscalls… · New This comment encodes a lot of implementation assumptions and measured behavior (backend emission… · New Using multiple sequential.pipe(...)calls makes it easier to accidentally reintroduce the… · New
What changed in this PR
Fixes a latent redraw ordering issue in visualization frames and removes the unused “result version key” mechanism from the Form View chart frames.
Changes:
- Reorders RxJS operators in
VisualizationFrameContentComponentso per-operator filtering happens beforeauditTime, preventing missed redraws. - Removes per-operator
resultVersion/resultKey/trackByKeylogic and simplifies the Form View template to render the visualization frame directly. - Updates/adjusts unit tests to cover the redraw ordering case and remove the now-obsolete keying behavior.
| File | Description |
|---|---|
| frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts | Removes result-version keying logic and updates result-update handling/comments. |
| frontend/src/app/workspace/component/workflow-form/workflow-form.component.html | Drops the *ngFor keyed frame workaround and renders the visualization panel content directly. |
| frontend/src/app/workspace/component/workflow-form/workflow-form.component.spec.ts | Removes tests for the deleted keying API and refocuses result-update assertions. |
| frontend/src/app/workspace/component/visualization-panel-content/visualization-frame-content.component.ts | Filters result-update events before throttling to avoid losing pending redraws. |
| frontend/src/app/workspace/component/visualization-panel-content/visualization-frame-content.component.spec.ts | Adds coverage for the “interleaving operator update” redraw-loss scenario. |
Review effort: Lite
…and tidy the subscription (review) Copilot on apache#9021: the unit test's "rebuilds nothing" was only a name, so the rendered spec now holds the frame's component instance and host element across two updates for its step and checks both are the same objects afterwards; the frame's three .pipe() calls are one pipe, so the filter-before-audit order is visible in one place; and the result-update comment is cut to the invariant, with the measurements left on apache#8759. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FVvP3ttj22f9LB4p9u2anY
0b43bf1 to
1a216cd
Compare
…and tidy the subscription (review) Copilot on apache#9021: the unit test's "rebuilds nothing" was only a name, so the rendered spec now holds the frame's component instance and host element across two updates for its step and checks both are the same objects afterwards; the frame's three .pipe() calls are one pipe, so the filter-before-audit order is visible in one place; and the result-update comment is cut to the invariant, with the measurements left on apache#8759. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FVvP3ttj22f9LB4p9u2anY
…y that was meant to rebuild it The visualization frame audited before it filtered. An update event carries only the operators whose result changed, so a window that closed on another operator's event was handed that event by the filter and dropped, taking this operator's pending redraw with it: the last update of a run could leave the previous picture showing for good. Filter first. The canvas result panel uses the same frame and gains the same reliability. The Form View keyed each chart frame by a per-operator version, bumped on every result update, meaning to rebuild the frame rather than reuse it. It could not do that. Every visualisation operator takes its whole input before it draws (`process_table`, single-snapshot output), so the update that carries a picture is the one that mounts the frame, and a second one never arrives; measured on a run, the chart's operator sees two updates, one picture and one frame, with the key and without it. A re-run replaces the snapshot inside the operator's result service, which lives until the page is left, so there is no new frame to key on there either. The machinery never fired, so it goes. No visible change: this fixes a latent ordering bug and removes code that cannot run. Closes apache#8759 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FVvP3ttj22f9LB4p9u2anY
…and tidy the subscription (review) Copilot on apache#9021: the unit test's "rebuilds nothing" was only a name, so the rendered spec now holds the frame's component instance and host element across two updates for its step and checks both are the same objects afterwards; the frame's three .pipe() calls are one pipe, so the filter-before-audit order is visible in one place; and the result-update comment is cut to the invariant, with the measurements left on apache#8759. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FVvP3ttj22f9LB4p9u2anY
1a216cd to
ff0fc31
Compare
| .pipe(untilDestroyed(this)) | ||
| .pipe( | ||
| filter(rec => this.operatorId !== undefined && rec[this.operatorId] !== undefined), | ||
| auditTime(VisualizationFrameContentComponent.UPDATE_INTERVAL_MS), |
There was a problem hiding this comment.
With the key gone, a quick re-run shows the old chart for 2 more seconds. Results are first polled 2 s after the run starts, so a run that finishes sooner sends a single update, already carrying the new picture. Nothing clears the previous result, so the frame is still mounted and waits out this window. On main the key redraws it at once.
I ran this with the real result service: the new picture appears immediately on main, and after 2 s here. Drawing on the first update (throttleTime with leading and trailing) fixes it and still keeps the same frame.
There was a problem hiding this comment.
Confirmed and changed: throttleTime(UPDATE_INTERVAL_MS, asyncScheduler, { leading: true, trailing: true }), filter still first. The first update redraws at once, updates inside the window coalesce into one trailing redraw of whatever is current then, and a window nothing arrived in draws nothing more. The spec has the quick re-run case (first update after mounting redraws immediately), the coalescing, and the cross-operator case re-done with a pending second update so it still catches the order; each of leading, trailing and filter-before-throttle turns a named test red when flipped. The pinned result window mounts the same frame, so it gains the immediate first redraw too (7e91fc7).
| // A result update re-limits what the form shows and re-fits the visualisations. The chart | ||
| // frame is left alone: it redraws in place on its own operator's updates. The per-operator | ||
| // version that used to key the frame here never produced a second frame -- a visualisation | ||
| // operator draws once, from its whole input -- so it is gone; the measurements are on #8759. |
There was a problem hiding this comment.
This isn't true for every visualisation: HTML Visualizer and URL Visualizer output one row per input row, so a slow source sends several updates with a picture. On main each one rebuilds the frame, which is the flicker in #8759, and this PR does fix it. Also, there are no measurements on #8759. Could you correct this comment, the one in the template, and the description?
There was a problem hiding this comment.
You're right, and thanks for the measurement. The pie chart I counted on is a single-snapshot case and does not generalise: a row-per-row visualiser sends an update per batch, the key fired on each, and that rebuild was the flicker. Corrected here, in the template comment and in the description, which now says what the key did and what this PR fixes; the sentence pointing at measurements on #8759 is gone (7e91fc7).
…t the key did Review fixes on apache#9021 (mengw15). The frame redrew on its operator's updates through auditTime, which held the first redraw for the whole interval: with the frame no longer rebuilt, a re-run that finished inside the interval sent one update, already carrying the new picture, and the mounted frame showed the old one for 2 s. It throttles with a leading and a trailing edge now, so the first update redraws at once and the rest coalesce into one redraw per window. The comments on the form (and the PR description) claimed the removed key never fired; it fired on every update of a visualiser that outputs a row per input row, and each rebuild was the flicker of apache#8759 -- corrected. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FVvP3ttj22f9LB4p9u2anY


What changes were proposed in this PR?
Closes #8759. Part of the Form View feature (#8011); from the #8439 refinements (the result-frame item, raised in the #8441 review and deferred there).
Two things about the chart frame a result card shows.
The Form View rebuilt the frame on every result update. Each chart frame was keyed on a per-operator version, bumped on every emission of the result-update stream, so that a changed result would rebuild the frame rather than reuse it (the frame reads its content once, at creation). A visualiser that outputs a row per input row -- HTML Visualizer, URL Visualizer -- sends several updates with a picture over a slow source, and each one rebuilt the frame: the flicker #8759 describes. The key, the map behind it and the
*ngForthat carried it go; the frame stays, and redraws in place on its own operator's updates. A re-run does not need the key either: it replaces the snapshot inside the operator's result service, which lives until the page is left, and a result that is cleared takes the frame down throughvizHasContent.The frame redraws on the first update, and at most once per interval after.
VisualizationFrameContentComponentredrew on the result-update stream throughauditTime(2 s), which holds every redraw, the first included, until the interval has elapsed. With the frame no longer rebuilt that showed: a re-run that finishes inside the interval sends a single update, already carrying the new picture, and the mounted frame showed the old one for the whole 2 s (mengw15, measured against the real result service; on main the key redrew it at once). The frame now throttles with a leading and a trailing edge: the first update redraws at once, and further updates inside the window coalesce into one redraw when it closes, with whatever picture is current then. The filter for the frame's own operator also runs ahead of the throttle: an update event carries only the operators whose result changed, so with the throttle first a window that closed on another operator's event handed the filter that event, which dropped it, and this operator's pending redraw was lost -- the last update of a run could leave the previous picture showing for good. The canvas's pinned result window mounts the same frame and gains the same immediate first redraw.Any related issues, documentation, discussions?
Closes #8759, which came out of the #8441 review (where the key was introduced, with the Copilot threads about it left open for this fix). Part of #8439 and the Form View feature #8011.
The issue's "expected" -- bump the key only for a genuinely new result, and handle
clearResults-- is not what this does: with the frame redrawing in place there is nothing left for a key to do.clearResults()runs when a workspace is torn down and when a computing unit is switched, not during a run.Worth knowing, not changed here: the backend emits an update only for an operator whose tuple count changed, so a single-row visualiser that replaces its HTML at the same count produces no event at all, on the canvas and the form alike. That is a separate gap and a follow-up candidate.
How was this PR tested?
Unit tests (vitest). The frame's spec: the first update after mounting redraws at once; updates inside the interval are held to one trailing redraw, of the latest picture, and a window nothing arrived in draws nothing more; a redraw pending for this operator survives a later emission for another operator (this operator's update, a second one inside the window, another operator's event, the window closing -- and the picture that lands is this operator's latest), which is the case the old order lost; the ignore-other-operators and no-operator tests still pass. The form's spec: a result update re-limits the shown results and re-fits the visualisations and rebuilds nothing; the rendered spec pins that the chart frame is the same instance and element across that step's result updates, which is the assertion a returning key would fail. Deletion-checked: the leading edge, the trailing edge and the filter-before-throttle order each turn a named test red; so does a key on the frame.
eslint, prettier and the production (AOT) build pass; the full frontend suite passes.
Was this PR authored or co-authored using generative AI tooling?
Yes. Generated-by: Claude Code (Anthropic). Co-authored with Claude, reviewed line by line by the author before submission.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FVvP3ttj22f9LB4p9u2anY