@@ -22,6 +22,7 @@ class WorkspaceV2ToolStateProducer {
2222 this . backButton = document . getElementById ( "workspaceV2BackButton" ) ;
2323 this . loadFixtureButton = document . getElementById ( "workspaceV2LoadFixtureButton" ) ;
2424 this . launchButton = document . getElementById ( "workspaceV2LaunchButton" ) ;
25+ this . createDirectToolsEntryButton = document . getElementById ( "workspaceV2CreateDirectToolsEntryButton" ) ;
2526 this . promoteActiveToolStateButton = document . getElementById ( "workspaceV2PromoteActiveToolStateButton" ) ;
2627 this . openAssetManagerButton = document . getElementById ( "workspaceV2OpenAssetManagerButton" ) ;
2728 this . importJsonNode = document . getElementById ( "workspaceV2ImportJson" ) ;
@@ -79,6 +80,7 @@ class WorkspaceV2ToolStateProducer {
7980 this . clearSavedToolStatesButton = document . getElementById ( "workspaceV2ClearSavedToolStatesButton" ) ;
8081 this . resetClearErrorLogsButton = document . getElementById ( "workspaceV2ResetClearErrorLogsButton" ) ;
8182 this . fullResetButton = document . getElementById ( "workspaceV2FullResetButton" ) ;
83+ this . activeToolStatePublishStatusNode = document . getElementById ( "workspaceV2ActiveToolStatePublishStatus" ) ;
8284 this . statusNode = document . getElementById ( "workspaceV2Status" ) ;
8385 this . importExportStatusNode = null ;
8486 this . importFileDialogPending = false ;
@@ -102,6 +104,9 @@ class WorkspaceV2ToolStateProducer {
102104 this . launchButton . addEventListener ( "click" , ( ) => {
103105 this . createToolStateAndLaunch ( ) ;
104106 } ) ;
107+ this . createDirectToolsEntryButton . addEventListener ( "click" , ( ) => {
108+ this . createDirectToolsEntry ( ) ;
109+ } ) ;
105110 this . promoteActiveToolStateButton . addEventListener ( "click" , ( ) => {
106111 this . promoteActiveToolStateToWorkspaceTools ( ) ;
107112 } ) ;
@@ -313,18 +318,20 @@ class WorkspaceV2ToolStateProducer {
313318 if ( ! parsed . value . tools || typeof parsed . value . tools !== "object" || Array . isArray ( parsed . value . tools ) ) {
314319 return [ ] ;
315320 }
316- return Object . keys ( parsed . value . tools ) . sort ( ( left , right ) => left . localeCompare ( right ) ) ;
321+ return Object . keys ( parsed . value . tools )
322+ . filter ( ( toolId ) => toolId !== "workspace-v2" )
323+ . sort ( ( left , right ) => left . localeCompare ( right ) ) ;
317324 }
318325
319326 workspaceToolSummaryEntries ( ) {
320327 const fromTextarea = this . readWorkspaceToolsFromTextarea ( ) ;
321328 if ( fromTextarea . length > 0 ) {
322329 return fromTextarea ;
323330 }
324- const entries = [ "palette-browser" , "workspace-v2" ] ;
331+ const entries = [ "palette-browser" ] ;
325332 const importedToolIds = Object . keys ( this . workspaceImportedToolEntries || { } ) . sort ( ( left , right ) => left . localeCompare ( right ) ) ;
326333 importedToolIds . forEach ( ( toolId ) => {
327- if ( ! entries . includes ( toolId ) ) {
334+ if ( toolId !== "workspace-v2" && ! entries . includes ( toolId ) ) {
328335 entries . push ( toolId ) ;
329336 }
330337 } ) ;
@@ -337,8 +344,8 @@ class WorkspaceV2ToolStateProducer {
337344 }
338345 const entries = this . workspaceToolSummaryEntries ( ) ;
339346 this . workspaceToolsSummaryNode . textContent = entries . length > 0
340- ? `Workspace Tools: ${ entries . join ( ", " ) } `
341- : "Workspace Tools: none" ;
347+ ? entries . join ( ", " )
348+ : "none" ;
342349 }
343350
344351 setImportExportStatus ( message ) {
@@ -349,6 +356,29 @@ class WorkspaceV2ToolStateProducer {
349356 this . statusNode . textContent = message ;
350357 }
351358
359+ activeToolStatePublishStatusText ( ) {
360+ const activeToolState = this . readActiveToolStatePayloadForLibraryActions ( ) ;
361+ if ( ! this . isValidToolStatePayload ( activeToolState ) ) {
362+ return "Active in Workspace only" ;
363+ }
364+ const toolId = typeof activeToolState . toolId === "string" ? activeToolState . toolId . trim ( ) : "" ;
365+ if ( ! toolId || ! Object . prototype . hasOwnProperty . call ( this . workspaceImportedToolEntries , toolId ) ) {
366+ return "Active in Workspace only" ;
367+ }
368+ const publishedPayload = this . workspaceImportedToolEntries [ toolId ] ;
369+ if ( JSON . stringify ( publishedPayload ) !== JSON . stringify ( activeToolState . payloadJson ) ) {
370+ return "Active in Workspace only" ;
371+ }
372+ return `Promoted to tools.${ toolId } ` ;
373+ }
374+
375+ renderActiveToolStatePublishStatus ( ) {
376+ if ( ! this . activeToolStatePublishStatusNode ) {
377+ return ;
378+ }
379+ this . activeToolStatePublishStatusNode . textContent = this . activeToolStatePublishStatusText ( ) ;
380+ }
381+
352382 initializeHiddenImportFileInput ( ) {
353383 if ( ! this . importFileNode ) {
354384 return ;
@@ -1002,6 +1032,8 @@ class WorkspaceV2ToolStateProducer {
10021032 this . renderMergeConflictSummary ( ) ;
10031033 this . openAssetManagerButton . disabled = ! model . assetManagerLaunchReady ;
10041034 this . openAssetManagerButton . textContent = model . assetManagerLaunchLabel ;
1035+ this . renderActiveToolStatePublishStatus ( ) ;
1036+ this . renderWorkspaceToolsSummary ( ) ;
10051037 }
10061038
10071039 refreshWorkspaceToolStateUiStateModel ( actionName = "refresh_load" ) {
@@ -1335,6 +1367,33 @@ class WorkspaceV2ToolStateProducer {
13351367 ) ;
13361368 }
13371369
1370+ createDirectToolsEntry ( ) {
1371+ const selectedToolId = this . ensureSelectedToolStateProducerToolId ( ) ;
1372+ if ( ! selectedToolId ) {
1373+ this . statusNode . textContent = "Direct tools entry blocked. Select a toolState-capable V2 tool first." ;
1374+ return ;
1375+ }
1376+ const activeToolState = this . readActiveToolStatePayloadForLibraryActions ( ) ;
1377+ if ( ! this . isValidToolStatePayload ( activeToolState ) ) {
1378+ this . statusNode . textContent = "Direct tools entry blocked. No active tool state is available." ;
1379+ return ;
1380+ }
1381+ const activeToolId = typeof activeToolState . toolId === "string" ? activeToolState . toolId . trim ( ) : "" ;
1382+ if ( activeToolId !== selectedToolId ) {
1383+ this . statusNode . textContent = `Direct tools entry blocked. Active tool state toolId '${ activeToolId } ' does not match selected tool '${ selectedToolId } '.` ;
1384+ return ;
1385+ }
1386+ const promoted = this . promoteToolStatePayloadToWorkspaceTools (
1387+ activeToolState ,
1388+ "tools.workspace-v2.activeToolState" ,
1389+ `Direct tools entry '${ selectedToolId } '`
1390+ ) ;
1391+ if ( ! promoted ) {
1392+ return ;
1393+ }
1394+ this . statusNode . textContent = `Direct tools entry created at tools.${ selectedToolId } .` ;
1395+ }
1396+
13381397 readToolStatePayloadFromRecentToolStateId ( toolStateId ) {
13391398 if ( typeof toolStateId !== "string" || ! toolStateId . trim ( ) ) {
13401399 return null ;
@@ -1535,6 +1594,7 @@ class WorkspaceV2ToolStateProducer {
15351594 this . currentToolStateSource = sourceLabel ;
15361595 this . updateWorkspaceActivePaletteFromCurrentToolState ( ) ;
15371596 this . refreshPaletteOwnershipUiState ( ) ;
1597+ this . renderActiveToolStatePublishStatus ( ) ;
15381598 }
15391599
15401600 isValidToolStatePayload ( toolStatePayload ) {
@@ -3586,6 +3646,7 @@ class WorkspaceV2ToolStateProducer {
35863646 }
35873647 this . workspaceJsonNode . value = JSON . stringify ( workspaceSchemaDocument , null , 2 ) ;
35883648 this . renderWorkspaceToolsSummary ( ) ;
3649+ this . renderActiveToolStatePublishStatus ( ) ;
35893650 return true ;
35903651 }
35913652
0 commit comments