Copilot commented on code in PR #5271:
URL: https://github.com/apache/texera/pull/5271#discussion_r3693473160
##########
frontend/src/app/workspace/service/jupyter-panel/jupyter-panel.service.ts:
##########
@@ -209,19 +210,70 @@ export class JupyterPanelService {
if (!this.enabled) return;
if (panelName === "JupyterNotebookPanel") {
this.jupyterNotebookPanelVisible.next(true);
+ // Opening the panel means the current workflow has an associated
notebook, so
+ // surface the toolbar "expand" button (jupyterNotebookExists$) right
away. Needed
+ // after an in-place import where the wid does not change and init()
does not re-run
+ // to detect the notebook.
+ this.jupyterNotebookExists.next(true);
}
}
- // Close the Jupyter Notebook panel
- public closeJupyterNotebookPanel(): void {
+ // Delete the current workflow's stored notebook from the backend, then hide
the
+ // panel and clear all local notebook state. This is the user-initiated
action
+ // behind the panel's delete button, and is distinct from the workflow-switch
+ // cleanup (hideAndClearLocalState), which must never touch the backend.
+ public deleteJupyterNotebook(): void {
if (!this.enabled) return;
+ const wid = this.workflowActionService.getWorkflow().wid;
+ if (wid === undefined) {
+ // Unsaved workflow: nothing persisted, so just reset local state.
+ this.hideAndClearLocalState();
+ this.jupyterNotebookExists.next(false);
+ this.clearHighlights();
+ return;
+ }
Review Comment:
`deleteJupyterNotebook()` treats only `wid === undefined` as “unsaved”, but
the workspace default workflow uses `wid: 0` (see DEFAULT_WORKFLOW). Calling
the backend delete with `wid = 0` can 500 or delete the wrong record. Treat
`wid === 0` the same as undefined and only reset local state in that case.
--
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]