Skip to content

Commit 6802960

Browse files
committed
fix: Fix deepnote notebook deserializer
1 parent 4cffc41 commit 6802960

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

src/notebooks/deepnote/deepnoteSerializer.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,15 @@ export class DeepnoteNotebookSerializer implements NotebookSerializer {
188188
* @returns The notebook ID to deserialize, or undefined if none found
189189
*/
190190
findCurrentNotebookId(projectId: string): string | undefined {
191-
// Prefer the active notebook editor when it matches the project
191+
// Check the manager's stored selection first - this is set explicitly when the user
192+
// picks a notebook from the explorer, and must take priority over the active editor
193+
const storedNotebookId = this.notebookManager.getTheSelectedNotebookForAProject(projectId);
194+
195+
if (storedNotebookId) {
196+
return storedNotebookId;
197+
}
198+
199+
// Fallback: prefer the active notebook editor when it matches the project
192200
const activeEditorNotebook = window.activeNotebookEditor?.notebook;
193201

194202
if (
@@ -199,14 +207,7 @@ export class DeepnoteNotebookSerializer implements NotebookSerializer {
199207
return activeEditorNotebook.metadata.deepnoteNotebookId;
200208
}
201209

202-
// Check the manager's stored selection - this should be set when opening from explorer
203-
const storedNotebookId = this.notebookManager.getTheSelectedNotebookForAProject(projectId);
204-
205-
if (storedNotebookId) {
206-
return storedNotebookId;
207-
}
208-
209-
// Fallback: Check if there's an active notebook document for this project
210+
// Last fallback: Check if there's an active notebook document for this project
210211
const openNotebook = workspace.notebookDocuments.find(
211212
(doc) => doc.notebookType === 'deepnote' && doc.metadata?.deepnoteProjectId === projectId
212213
);

0 commit comments

Comments
 (0)