@@ -101,7 +101,7 @@ class WorkspaceV2SessionProducer {
101101 this . createSessionAndLaunch ( ) ;
102102 } ) ;
103103 this . importButton . addEventListener ( "click" , ( ) => {
104- this . importWorkspaceSessionJson ( ) ;
104+ this . handleImportWorkspaceSessionJsonClick ( ) ;
105105 } ) ;
106106 this . exportButton . addEventListener ( "click" , ( ) => {
107107 this . exportWorkspaceSessionJson ( ) ;
@@ -214,6 +214,7 @@ class WorkspaceV2SessionProducer {
214214 this . applyDefaultWorkspaceToolSelection ( ) ;
215215 this . registerScrollTextColorRule ( ) ;
216216 this . initializeImportExportSectionStatusNode ( ) ;
217+ this . initializeHiddenImportFileInput ( ) ;
217218 this . decodeSessionParamFromUrl ( ) ;
218219 this . initializeWorkspaceProducerSession ( ) ;
219220 this . refreshPaletteOwnershipStateAndUi ( ) ;
@@ -281,6 +282,37 @@ class WorkspaceV2SessionProducer {
281282 this . statusNode . textContent = message ;
282283 }
283284
285+ initializeHiddenImportFileInput ( ) {
286+ if ( ! this . importFileNode ) {
287+ return ;
288+ }
289+ const importFileLabel = document . querySelector ( 'label[for="workspaceV2ImportFile"]' ) ;
290+ if ( importFileLabel instanceof HTMLElement ) {
291+ importFileLabel . hidden = true ;
292+ importFileLabel . style . display = "none" ;
293+ }
294+ this . importFileNode . type = "file" ;
295+ this . importFileNode . hidden = true ;
296+ this . importFileNode . setAttribute ( "aria-hidden" , "true" ) ;
297+ this . importFileNode . tabIndex = - 1 ;
298+ this . importFileNode . style . display = "none" ;
299+ }
300+
301+ handleImportWorkspaceSessionJsonClick ( ) {
302+ const rawJson = typeof this . workspaceJsonNode . value === "string" ? this . workspaceJsonNode . value . trim ( ) : "" ;
303+ if ( rawJson ) {
304+ this . importWorkspaceSessionJson ( ) ;
305+ return ;
306+ }
307+ this . setImportExportStatus ( "Select a workspace session file to import." ) ;
308+ if ( ! this . importFileNode ) {
309+ this . setImportExportStatus ( "Import error: file picker is unavailable." ) ;
310+ return ;
311+ }
312+ this . importFileNode . value = "" ;
313+ this . importFileNode . click ( ) ;
314+ }
315+
284316 applyDefaultWorkspaceToolSelection ( ) {
285317 if ( ! this . toolSelect ) {
286318 return ;
@@ -3327,10 +3359,10 @@ class WorkspaceV2SessionProducer {
33273359 const reader = new FileReader ( ) ;
33283360 reader . addEventListener ( "load" , ( ) => {
33293361 this . importJsonNode . value = typeof reader . result === "string" ? reader . result : "" ;
3330- this . statusNode . textContent = `Import file loaded: ${ file . name } . Click Import Session JSON to validate and create session.` ;
3362+ this . importWorkspaceSessionJson ( ) ;
33313363 } ) ;
33323364 reader . addEventListener ( "error" , ( ) => {
3333- this . statusNode . textContent = `Import file read failed : ${ file . name } .` ;
3365+ this . setImportExportStatus ( `Import error : ${ file . name } could not be read.` ) ;
33343366 } ) ;
33353367 reader . readAsText ( file ) ;
33363368 }
@@ -3752,7 +3784,7 @@ class WorkspaceV2SessionProducer {
37523784 this . refreshPaletteOwnershipStateAndUi ( ) ;
37533785 this . refreshWorkspaceSessionUiStateModel ( "refresh_load" ) ;
37543786 this . renderDiagnosticsPanel ( ) ;
3755- this . setImportExportStatus ( "Import success " ) ;
3787+ this . setImportExportStatus ( "Workspace session imported. " ) ;
37563788 } catch ( error ) {
37573789 this . setImportExportStatus ( `Import error: ${ error instanceof Error ? error . message : "unknown error" } ` ) ;
37583790 }
0 commit comments