Copilot commented on code in PR #8581:
URL: https://github.com/apache/texera/pull/8581#discussion_r4066597946


##########
frontend/src/app/workspace/service/workflow-graph/model/workflow-action.service.ts:
##########
@@ -629,6 +629,42 @@ export class WorkflowActionService {
     this.texeraGraph.destroyYModel();
   }
 
+  /**
+   * Whether this page already holds `workflowId` open: the shared document is 
in that workflow's
+   * co-editing room, so the graph, the undo history and the room membership 
are the live ones.
+   *
+   * The operator canvas and the Form View are two views of one open workflow 
and hand the session
+   * over between them rather than each building its own. The arriving view 
asks this before
+   * loading: seeding a second document for the same workflow would leave the 
room and rejoin it,
+   * which is what used to leave a ghost of yourself in the co-editor list.
+   *
+   * A workflow that was open and has since been left does not answer true 
here, and the reason is
+   * worth stating because it is not local: `destroyYModel` destroys the 
document but keeps the
+   * object, `wid` and all. What clears it is `clearWorkflow` going on to 
`reloadWorkflow(undefined)`,
+   * which seeds a fresh model with no `wid`. Were that to stop happening, a 
canvas re-entered from
+   * the dashboard would attach to a destroyed document instead of loading. 
Pinned by a test.
+   */
+  public hasWorkflowOpen(workflowId: number): boolean {
+    return this.texeraGraph.sharedModel.wid === workflowId;

Review Comment:
   A workflow created on the blank canvas never satisfies this check after its 
first save. `reloadWorkflow(undefined)` creates `SharedModel` without a `wid` 
(a random room), while autosave and `saveThenOpenFormView` only update workflow 
metadata with the assigned ID. The canvas therefore preserves the session for 
`/workflow/42/form`, but the Form View sees `hasWorkflowOpen(42) === false`, 
destroys that live document, reloads the graph, and loses the preserved 
undo/session state. Recognize the newly assigned metadata ID (or move the 
shared model to the assigned workflow room when saving), and add a 
create-then-switch regression test.



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