Skip to content

fix(frontend): clean up websocket state when returning to the dashboard (#5565) [release/v1.2 backport] - #5609

Merged
xuang7 merged 1 commit into
apache:release/v1.2from
kunwp1:backport/5565-websocket-cleanup-dashboard-v1.2
Jun 10, 2026
Merged

xuang7 merged 1 commit into
apache:release/v1.2from
kunwp1:backport/5565-websocket-cleanup-dashboard-v1.2

Conversation

@kunwp1

@kunwp1 kunwp1 commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Backport of #5565 ("fix(frontend): clean up websocket state when returning to the dashboard") to release/v1.2.

Applies as a clean git cherry-pick -x of the merged squash commit ad10b7f2b — no conflicts and no prerequisite chain (unlike the #5280 backport in #5602). Frontend-only: 14 files changed, 391 insertions, 2 deletions, identical to the original.

For the full change description see #5565. In brief: websocket-derived front-end state (the connection, plus execution status, console output, and results built from its events) lives in singletons outside the workspace and was never torn down when returning to the dashboard or switching computing units, so stale state carried over. This tears that state down in WorkspaceComponent.ngOnDestroy() and clears it again on a computing-unit switch.

Any related issues, documentation, discussions?

Backports #5565 (which closes #3120 on main). Related: #3093.

How was this PR tested?

This is a backport with no changes beyond the single cherry-picked commit, so it relies on the existing tests carried over from #5565 (added *.spec.ts cases across computing-unit-status, workspace.component, execute-workflow, workflow-console, workflow-result, result-panel, and workflow-websocket).

Backport fidelity was verified locally: after the cherry-pick, every file touched by #5565 is byte-identical to its state on main at the merged commit (ad10b7f2b), and release/v1.2 had no independent changes to any of those files.

Full compile and unit-test runs are left to CI.

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

Generated-by: Claude Code (Claude Opus 4.8)

…rd (apache#5565)

### What changes were proposed in this PR?

Websocket-derived front-end state (the connection itself, plus the
execution status, console output, and results built from its events)
lives in singletons outside the workspace. It was never torn down in two
cases, so stale state carried over:

1. **Returning to the dashboard** and re-entering a workflow reused the
previous socket. The connection-tracking fields (`currentConnectedWid` /
`currentConnectedCuid`) also survived, so the reconnect guard saw them
unchanged, skipped reconnecting, and reused the stale socket. (apache#3120 —
the case apache#3093 did not cover.)
2. **Switching computing units** inside the workspace left the previous
unit's console, results, and execution status on screen.

This PR clears that state at both points.

**Workspace exit**: `WorkspaceComponent.ngOnDestroy()` now tears
everything down:

| Call *(new)* | Resets |
| --- | --- |
| `ComputingUnitStatusService.disconnect()` | closes the socket, clears
operator status, stops the unit poll, resets the connection-tracking
fields and the selected unit |
| `ExecuteWorkflowService.resetExecutionAndWorkers()` | execution status
and worker assignments |
| `WorkflowConsoleService.clearConsoleMessages()` | console output |
| `WorkflowResultService.clearResults()` | result caches and table stats
|

**Unit switch**: `ComputingUnitStatusService` emits a reset signal when
it reconnects to a different unit, and `WorkspaceComponent` clears the
same execution / console / result state in response. As a result,
switching units now discards the previous unit's results and console
instead of leaving them on screen.

The remaining websocket-event consumers need no teardown:
`OperatorReuseCacheStatusService` is stateless, and
`udf-debug.service`'s state lives in the `TexeraGraph`, already reset by
`clearWorkflow()`.

### Any related issues, documentation, discussions?

Closes apache#3120. Related: apache#3093 (earlier partial fix for the in-canvas
socket re-open).

### How was this PR tested?

Test with this workflow
[Untitled workflow
(14).json](https://github.com/user-attachments/files/28696700/Untitled.workflow.14.json)

https://github.com/user-attachments/assets/060fe1ac-39cf-45e5-b423-5aa27fe17aed

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

Generated-by: Claude Code (Claude Opus 4.8)

---------

Co-authored-by: Xinyuan Lin <[email protected]>
(cherry picked from commit ad10b7f)
@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Jun 10, 2026
@kunwp1 kunwp1 added the release/v1.2 back porting to release/v1.2 label Jun 10, 2026
@kunwp1
kunwp1 requested a review from xuang7 June 10, 2026 20:08
@kunwp1

kunwp1 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

/request-review @xuang7

@codecov-commenter

codecov-commenter commented Jun 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.58%. Comparing base (1f84101) to head (0340f18).

Additional details and impacted files
@@                Coverage Diff                 @@
##             release/v1.2    #5609      +/-   ##
==================================================
+ Coverage           51.44%   51.58%   +0.14%     
  Complexity           2445     2445              
==================================================
  Files                1065     1065              
  Lines               41184    41226      +42     
  Branches             4413     4415       +2     
==================================================
+ Hits                21186    21266      +80     
+ Misses              18757    18714      -43     
- Partials             1241     1246       +5     
Flag Coverage Δ *Carryforward flag
access-control-service 64.61% <ø> (ø) Carriedforward from 1f84101
agent-service 33.76% <ø> (ø) Carriedforward from 1f84101
amber 51.97% <ø> (ø) Carriedforward from 1f84101
computing-unit-managing-service 1.65% <ø> (ø) Carriedforward from 1f84101
config-service 55.38% <ø> (ø) Carriedforward from 1f84101
file-service 38.21% <ø> (ø) Carriedforward from 1f84101
frontend 46.20% <100.00%> (+0.34%) ⬆️
pyamber 90.72% <ø> (ø) Carriedforward from 1f84101
python 90.75% <ø> (ø) Carriedforward from 1f84101
workflow-compiling-service 58.69% <ø> (ø) Carriedforward from 1f84101

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

@xuang7 xuang7 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!

@xuang7
xuang7 merged commit 911eb2f into apache:release/v1.2 Jun 10, 2026
39 of 43 checks passed
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 release/v1.2 back porting to release/v1.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants