PG1204 opened a new pull request, #8552:
URL: https://github.com/apache/texera/pull/8552

   ### What changes were proposed in this PR?
   
   Third sub-task of the heat-map umbrella #5772. Today the heat-map is 
session-only: a refresh drops the Layers > Performance toggle and the 
statistics that color the canvas, so the workflow has to be re-run just to look 
at it again.
   
   Before this PR:
   
   
https://github.com/user-attachments/assets/3a29a5b1-5e7f-4d7a-9e62-05efdb47d6f1
   
   After this PR:
   
   
https://github.com/user-attachments/assets/a2506966-dbd5-4c93-8304-cb950d9a2771
   
   ```
   Before:  refresh -> session state cleared -> overlay off, canvas blank
   After:   refresh -> toggle + view restored -> last run's stats re-fetched -> 
canvas repainted
   ```
   
   Two halves, both frontend-only.
   
   **1. Overlay state.** `heatmap-overlay-persistence.ts` keeps `{ view: 
HeatmapView | null }` in localStorage via the existing `localSetObject` / 
`localGetObject`. `MenuComponent` saves on toggle and on view change, and 
restores in `ngOnInit`. Only the Performance layer persists — Grid / Regions / 
Workers stay session-only. A corrupted or foreign value reads as off.
   
   **2. Statistics.** `HeatmapStatsRestoreService` composes existing client 
APIs:
   
   ```
   wid -> retrieveWorkflowExecutions        -> latest completed run
       -> retrieveWorkflowRuntimeStatistics -> latest snapshot per operator
       -> WorkflowStatusService.setExternalStatus
   ```
   
   `runtime-statistics-mapper.ts` does the shape conversion, including status 
code -> `OperatorState`; Failed and Killed have no `OperatorState` member, so 
they fall back to `Uninitialized` rather than a wrong state. Port-level metrics 
are not persisted, so restored port labels read 0.
   
   `WorkflowStatusService` gains `setExternalStatus`. The websocket handler's 
body moves into a private `ingestRuntimeStatus` that both paths share, so live 
and restored updates emit identically. `performanceMetricsSubject` is already a 
`BehaviorSubject`, so the restore fetch cannot race the overlay's own init.
   
   Restoring is best-effort and entirely gated inside the service:
   
   | Skips when | Why |
   | --- | --- |
   | Overlay not persisted on | A localStorage read, so non-users issue no 
request at all |
   | No `wid` (unsaved workflow) | Nothing to fetch |
   | Execution in progress | The live stream wins |
   | No executions, or no statistics | Nothing to restore |
   | HTTP error | Must never block workspace entry |
   
   ### Any related issues, documentation, discussions?
   
   Closes #5775. Part of umbrella #5772. RFC #5216.
   
   Reviewer note: #5775 refers to `setExternalStatus` as already existing from 
#5773. It is not on `main` and this PR adds it.
   
   ### How was this PR tested?
   
   <!-- TODO: before/after GIF of the refresh -->
   
   Manual, Chrome: run a workflow to completion, Layers > Performance on, pick 
**I/O imbalance**, reload: toggle, view and colors all come back with no 
re-run. Switch to **Time / row** and reload: the ranking inverts and survives. 
Uncheck and reload: stays off. `localStorage.clear()` and reload: back to 
default.
   
   ```
   cd frontend && ng test --watch=false \
     --include "**/heatmap-overlay-persistence.spec.ts" \
     --include "**/runtime-statistics-mapper.spec.ts" \
     --include "**/heatmap-stats-restore.service.spec.ts" \
     --include "**/workflow-status.service.spec.ts" \
     --include "**/menu.component.spec.ts" \
     --include "**/workspace.component.spec.ts"
   ```
   
   | Spec | Tests | New |
   | --- | --- | --- |
   | `heatmap-overlay-persistence.spec.ts` | 4 | 4 |
   | `runtime-statistics-mapper.spec.ts` | 7 | 7 |
   | `heatmap-stats-restore.service.spec.ts` | 10 | 10 |
   | `workflow-status.service.spec.ts` | 13 | 2 |
   | `menu.component.spec.ts` | 118 | 6 |
   | `workspace.component.spec.ts` | 26 | 0 |
   
   29 new tests, 178 passing, covering the negative paths: corrupted stored 
value, unsaved workflow, live execution, zero executions, a run that never 
completed, an empty payload, and an HTTP error from either fetch.
   
   `tsc --noEmit` (strict), `eslint ./src` and Prettier are clean.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   This PR was co-authored by Claude, in compliance with ASF.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to