@@ -43,21 +43,12 @@ export class DeepnoteExplorerView {
4343 /**
4444 * Shared helper that creates and adds a new notebook to a project
4545 * @param fileUri The URI of the project file
46- * @param projectId The project ID
4746 * @returns Object with notebook ID and name if successful, or null if aborted/failed
4847 */
49- public async createAndAddNotebookToProject (
50- fileUri : Uri ,
51- projectId : string
52- ) : Promise < { id : string ; name : string } | null > {
48+ public async createAndAddNotebookToProject ( fileUri : Uri ) : Promise < { id : string ; name : string } | null > {
5349 // Read the Deepnote project file
5450 const projectData = await readDeepnoteProjectFile ( fileUri ) ;
5551
56- if ( projectData . project . id !== projectId ) {
57- await window . showErrorMessage ( l10n . t ( 'Project ID mismatch' ) ) ;
58- return null ;
59- }
60-
6152 if ( ! projectData ?. project ) {
6253 await window . showErrorMessage ( l10n . t ( 'Invalid Deepnote file format' ) ) ;
6354 return null ;
@@ -84,7 +75,7 @@ export class DeepnoteExplorerView {
8475 projectData . project . notebooks . push ( newNotebook ) ;
8576
8677 // Save and open the new notebook
87- await this . saveProjectAndOpenNotebook ( fileUri , projectData , projectId , newNotebook . id ) ;
78+ await this . saveProjectAndOpenNotebook ( fileUri , projectData , newNotebook . id ) ;
8879
8980 return { id : newNotebook . id , name : notebookName } ;
9081 }
@@ -120,19 +111,7 @@ export class DeepnoteExplorerView {
120111
121112 const existingNames = new Set ( projectData . project . notebooks . map ( ( nb : DeepnoteNotebook ) => nb . name ) ) ;
122113
123- const newName = await window . showInputBox ( {
124- prompt : l10n . t ( 'Enter new notebook name' ) ,
125- value : currentName ,
126- validateInput : ( value ) => {
127- if ( ! value || value . trim ( ) . length === 0 ) {
128- return l10n . t ( 'Notebook name cannot be empty' ) ;
129- }
130- if ( existingNames . has ( value ) ) {
131- return l10n . t ( 'A notebook with this name already exists' ) ;
132- }
133- return null ;
134- }
135- } ) ;
114+ const newName = await this . promptForNotebookName ( currentName , existingNames ) ;
136115
137116 if ( ! newName || newName === currentName ) {
138117 return ;
@@ -482,13 +461,11 @@ export class DeepnoteExplorerView {
482461 * Saves the project data to file and opens the specified notebook
483462 * @param fileUri The URI of the project file
484463 * @param projectData The project data to save
485- * @param projectId The project ID
486464 * @param notebookId The notebook ID to open
487465 */
488466 private async saveProjectAndOpenNotebook (
489467 fileUri : Uri ,
490468 projectData : DeepnoteFile ,
491- projectId : string ,
492469 notebookId : string
493470 ) : Promise < void > {
494471 // Update metadata timestamp
@@ -506,7 +483,7 @@ export class DeepnoteExplorerView {
506483 this . treeDataProvider . refresh ( ) ;
507484
508485 // Open the new notebook
509- this . manager . selectNotebookForProject ( projectId , notebookId ) ;
486+ this . manager . selectNotebookForProject ( projectData . project . id , notebookId ) ;
510487 const notebookUri = fileUri . with ( { query : `notebook=${ notebookId } ` } ) ;
511488 const document = await workspace . openNotebookDocument ( notebookUri ) ;
512489 await window . showNotebookDocument ( document , {
@@ -722,14 +699,6 @@ export class DeepnoteExplorerView {
722699 }
723700
724701 const document = activeEditor . notebook ;
725- const metadata = document . metadata ;
726-
727- // Get project information from notebook metadata
728- const projectId = metadata ?. deepnoteProjectId as string | undefined ;
729- if ( ! projectId ) {
730- await window . showErrorMessage ( l10n . t ( 'Could not determine project ID' ) ) ;
731- return ;
732- }
733702
734703 // Get the file URI (strip query params if present)
735704 let fileUri = document . uri ;
@@ -739,7 +708,7 @@ export class DeepnoteExplorerView {
739708
740709 try {
741710 // Use shared helper to create and add notebook
742- const result = await this . createAndAddNotebookToProject ( fileUri , projectId ) ;
711+ const result = await this . createAndAddNotebookToProject ( fileUri ) ;
743712
744713 if ( result ) {
745714 await window . showInformationMessage ( l10n . t ( 'Created new notebook: {0}' , result . name ) ) ;
@@ -968,14 +937,11 @@ export class DeepnoteExplorerView {
968937 return ;
969938 }
970939
971- const project = treeItem . data as DeepnoteFile ;
972- const projectId = project . project . id ;
973-
974940 try {
975941 const fileUri = Uri . file ( treeItem . context . filePath ) ;
976942
977943 // Use shared helper to create and add notebook
978- const result = await this . createAndAddNotebookToProject ( fileUri , projectId ) ;
944+ const result = await this . createAndAddNotebookToProject ( fileUri ) ;
979945
980946 if ( result ) {
981947 await window . showInformationMessage ( l10n . t ( 'Created new notebook: {0}' , result . name ) ) ;
0 commit comments