Skip to content

Commit 0b43bf1

Browse files
yangzhang75claude
andcommitted
fix(workflow-form): assert the chart frame survives a result update, 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 <[email protected]> Claude-Session: https://claude.ai/code/session_01FVvP3ttj22f9LB4p9u2anY
1 parent ba632b2 commit 0b43bf1

4 files changed

Lines changed: 46 additions & 17 deletions

File tree

‎frontend/src/app/workspace/component/visualization-panel-content/visualization-frame-content.component.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ export class VisualizationFrameContentComponent implements AfterContentInit {
5252
// re-draw was lost -- the last update of a run showed the previous picture for good.
5353
this.workflowResultService
5454
.getResultUpdateStream()
55-
.pipe(filter(rec => this.operatorId !== undefined && rec[this.operatorId] !== undefined))
56-
.pipe(auditTime(VisualizationFrameContentComponent.UPDATE_INTERVAL_MS))
57-
.pipe(untilDestroyed(this))
55+
.pipe(
56+
filter(rec => this.operatorId !== undefined && rec[this.operatorId] !== undefined),
57+
auditTime(VisualizationFrameContentComponent.UPDATE_INTERVAL_MS),
58+
untilDestroyed(this)
59+
)
5860
.subscribe(() => {
5961
this.drawChart();
6062
});

‎frontend/src/app/workspace/component/workflow-form/workflow-form.component.spec.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,9 +2514,9 @@ describe("WorkflowFormComponent", () => {
25142514
});
25152515

25162516
// An update to a result the form already shows reaches the frame in place (the frame redraws on
2517-
// its operator's updates); the form only re-limits the shown set and re-fits. It used to keep a
2518-
// per-operator version here as well, to key the frame on, which nothing needs.
2519-
it("re-limits the shown results and re-fits on a result update, and rebuilds nothing", () => {
2517+
// its operator's updates); the form only re-limits the shown set and re-fits. That the frame is
2518+
// still the same one afterwards is asserted on the rendered page (workflow-form.rendered.spec).
2519+
it("re-limits the shown results and re-fits on a result update", () => {
25202520
vi.useFakeTimers();
25212521
build(formViewWorkflow).ngOnInit();
25222522
const refresh = vi.spyOn(component as any, "refreshShownResults");

‎frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,17 +363,10 @@ export class WorkflowFormComponent implements OnInit, OnDestroy {
363363
.pipe(untilDestroyed(this))
364364
.subscribe(() => this.syncSelectionFromHighlight());
365365

366-
// A result update re-limits what the form shows to the currently-viewed set and re-fits the
367-
// visualisations. The chart frame itself is left alone: it redraws in place on its own
368-
// operator's updates (see the visualization frame, at most once per two seconds), and an
369-
// operator's result service lives until the page is left -- a re-run replaces the snapshot
370-
// inside it, nothing clears it -- so there is never a new frame to build mid-session.
371-
// This used to bump a per-operator version that keyed the frame, meaning to rebuild it rather
372-
// than reuse it. It could not do that: every visualisation operator takes its whole input
373-
// before it draws (`process_table`, single-snapshot output), so the one update that carries a
374-
// picture is also the one that mounts the frame, and a second one never comes. Measured on a
375-
// run: two updates for the chart's operator, one picture, one frame -- with the key and
376-
// without it. Dead machinery, so it goes.
366+
// A result update re-limits what the form shows and re-fits the visualisations. The chart
367+
// frame is left alone: it redraws in place on its own operator's updates. The per-operator
368+
// version that used to key the frame here never produced a second frame -- a visualisation
369+
// operator draws once, from its whole input -- so it is gone; the measurements are on #8759.
377370
this.workflowResultService
378371
.getResultUpdateStream()
379372
.pipe(untilDestroyed(this))

‎frontend/src/app/workspace/component/workflow-form/workflow-form.rendered.spec.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,40 @@ describe("WorkflowFormComponent (rendered template)", () => {
815815
expect(el(".result .result-body")).not.toBeNull();
816816
});
817817

818+
// What the result-update subscription claims: an update for a chart already on the page reaches
819+
// the frame that is there, it does not get the frame rebuilt. A per-result key meant to do that
820+
// used to sit on the frame; this is the assertion that would fail if one came back.
821+
it("keeps the same chart frame across that step's result updates", () => {
822+
const updates = new Subject<Record<string, unknown>>();
823+
const wrs: any = TestBed.inject(WorkflowResultService);
824+
wrs.getResultUpdateStream = () => updates.asObservable();
825+
wrs.hasNonEmptyResult = () => true;
826+
// A snapshot with a picture takes the visualisation branch. The frame's template is blanked
827+
// above, so what is instantiated is the component instance alone, with no iframe to run.
828+
wrs.getResultService = () => ({ getCurrentResultSnapshot: () => [{ "html-content": "<div>chart</div>" }] });
829+
// An update re-reads the shown set from the graph (refreshShownResults), so op-1 has to be a
830+
// step that is on it: with no downstream link it is a final step, shown by default.
831+
const actions: any = TestBed.inject(WorkflowActionService);
832+
const graph = actions.getTexeraGraph();
833+
graph.getAllOperators = () => [{ operatorID: "op-1" }];
834+
actions.getTexeraGraph = () => graph;
835+
fixture.detectChanges();
836+
finishLoad();
837+
vi.spyOn(fixture.componentInstance as any, "fitVisualisations").mockImplementation(() => {});
838+
839+
const frame = () => fixture.debugElement.query(By.directive(VisualizationFrameContentComponent));
840+
const first = frame();
841+
expect(first).not.toBeNull();
842+
843+
updates.next({ "op-1": {} });
844+
fixture.detectChanges();
845+
updates.next({ "op-1": {} });
846+
fixture.detectChanges();
847+
848+
expect(frame().componentInstance).toBe(first.componentInstance);
849+
expect(frame().nativeElement).toBe(first.nativeElement);
850+
});
851+
818852
it("mounts the step panel from the start, hidden until a step is selected", () => {
819853
fixture.detectChanges();
820854
finishLoad();

0 commit comments

Comments
 (0)