Skip to content

Commit 1a216cd

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 b96c1fe commit 1a216cd

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
@@ -2518,9 +2518,9 @@ describe("WorkflowFormComponent", () => {
25182518
});
25192519

25202520
// An update to a result the form already shows reaches the frame in place (the frame redraws on
2521-
// its operator's updates); the form only re-limits the shown set and re-fits. It used to keep a
2522-
// per-operator version here as well, to key the frame on, which nothing needs.
2523-
it("re-limits the shown results and re-fits on a result update, and rebuilds nothing", () => {
2521+
// its operator's updates); the form only re-limits the shown set and re-fits. That the frame is
2522+
// still the same one afterwards is asserted on the rendered page (workflow-form.rendered.spec).
2523+
it("re-limits the shown results and re-fits on a result update", () => {
25242524
vi.useFakeTimers();
25252525
build(formViewWorkflow).ngOnInit();
25262526
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
@@ -890,6 +890,40 @@ describe("WorkflowFormComponent (rendered template)", () => {
890890
expect(names().map(e => e.getAttribute("aria-current"))).toEqual(["false", "true"]);
891891
});
892892

893+
// What the result-update subscription claims: an update for a chart already on the page reaches
894+
// the frame that is there, it does not get the frame rebuilt. A per-result key meant to do that
895+
// used to sit on the frame; this is the assertion that would fail if one came back.
896+
it("keeps the same chart frame across that step's result updates", () => {
897+
const updates = new Subject<Record<string, unknown>>();
898+
const wrs: any = TestBed.inject(WorkflowResultService);
899+
wrs.getResultUpdateStream = () => updates.asObservable();
900+
wrs.hasNonEmptyResult = () => true;
901+
// A snapshot with a picture takes the visualisation branch. The frame's template is blanked
902+
// above, so what is instantiated is the component instance alone, with no iframe to run.
903+
wrs.getResultService = () => ({ getCurrentResultSnapshot: () => [{ "html-content": "<div>chart</div>" }] });
904+
// An update re-reads the shown set from the graph (refreshShownResults), so op-1 has to be a
905+
// step that is on it: with no downstream link it is a final step, shown by default.
906+
const actions: any = TestBed.inject(WorkflowActionService);
907+
const graph = actions.getTexeraGraph();
908+
graph.getAllOperators = () => [{ operatorID: "op-1" }];
909+
actions.getTexeraGraph = () => graph;
910+
fixture.detectChanges();
911+
finishLoad();
912+
vi.spyOn(fixture.componentInstance as any, "fitVisualisations").mockImplementation(() => {});
913+
914+
const frame = () => fixture.debugElement.query(By.directive(VisualizationFrameContentComponent));
915+
const first = frame();
916+
expect(first).not.toBeNull();
917+
918+
updates.next({ "op-1": {} });
919+
fixture.detectChanges();
920+
updates.next({ "op-1": {} });
921+
fixture.detectChanges();
922+
923+
expect(frame().componentInstance).toBe(first.componentInstance);
924+
expect(frame().nativeElement).toBe(first.nativeElement);
925+
});
926+
893927
it("mounts the step panel from the start, hidden until a step is selected", () => {
894928
fixture.detectChanges();
895929
finishLoad();

0 commit comments

Comments
 (0)