The GitHub Actions job "Required Checks" on 
texera.git/gh-readonly-queue/main/pr-9367-52093b446b2c659c4fb626ae9e6d18b02deca7b1
 has failed.
Run started by GitHub user xuang7 (triggered by xuang7).

Head commit for run:
bde1f7d88b0ca95ec9678e17529cca4a54bf9911 / Tanishq Gandhi 
<[email protected]>
fix(frontend): drop a version preview left open when leaving the workspace 
(#9367)

### What changes were proposed in this PR?

A version preview could outlive the workflow it was opened in.
Previewing a version turns off autosave and stores the open workflow so
the ← arrow can put it back. That state lives in root services, and only
← or "Restore this version" reset it. Browser Back is the only other way
out of a preview, and it left the state in place. So the next workflow
opened was stuck in preview mode:
- its edits weren't saved;
- pressing ← loaded the first workflow's graph into it;
- that graph was then saved over it.

When the workspace is left, `WorkspaceComponent.ngOnDestroy` now calls a
new `WorkflowVersionService.discardOpenVersionDisplay()`. If a preview
is still open, that method:
- drops the stored workflow;
- turns autosave back on;
- clears the preview flag.

It runs after `clearWorkflow()`, so the clear itself still happens with
autosave off. Handing the workflow to its own Form View is not leaving,
so the preview is kept there.

The graph is deliberately not reloaded on the way out. Doing what ← does
at that point empties the closing workflow's co-editing document: the
reload's deletions reach the room, but its re-added operators are
rendered asynchronously and the document is destroyed first.

| Before | After |
|---|---|
| <img width="1440" height="900" alt="before-2-b-stuck-in-preview"
src="https://github.com/user-attachments/assets/2f7139d4-30d0-40a6-914c-77b2a8ef2483";
/> B opens stuck in A's preview | <img width="1440" height="900"
alt="after-1-b-opens-normally"
src="https://github.com/user-attachments/assets/235082fc-400b-444f-aa6e-b2c2ab46b281";
/> B opens normally |
| <img width="1440" height="900" alt="before-4-b-overwritten"
src="https://github.com/user-attachments/assets/7c285d4a-9ce5-459e-b85f-8d9eb944bf70";
/> B reopened shows A's operators, saved into B | <img width="1440"
height="900" alt="after-2-b-keeps-its-content"
src="https://github.com/user-attachments/assets/5d2d1d2a-9625-4ac7-87c3-a505ebb0a0a2";
/> B keeps its own operator |

### Any related issues, documentation, discussions?

Closes #9354.

### How was this PR tested?

- New `WorkflowVersionService` tests:
- `discardOpenVersionDisplay` ends an open preview (it resets the temp
workflow, turns autosave on and clears the flag and selected version)
without reloading the graph;
  - it does nothing when no preview is open.
- New `WorkspaceComponent` test: leaving the workspace discards the
preview after `clearWorkflow()`. The Form View hand-over test now also
checks that the preview is kept.
- With the fix removed, the two new behaviour tests fail.
`workflow-version.service` and `workspace.component` specs pass (70
tests). Prettier and eslint are clean.
- Manually on a local stack, following the issue's steps:
  - B opens normally;
  - an edit to B is saved;
  - a new session shows B's own content;
  - A keeps its content with no extra versions;
  - the ← arrow still closes a preview and the next edit saves to A.

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

Generated-by: Claude Code (Claude Opus 5.5)

---------

Co-authored-by: Xuan Gu <[email protected]>

Report URL: https://github.com/apache/texera/actions/runs/43808033318

With regards,
GitHub Actions via GitBox

Reply via email to