@@ -373,7 +373,9 @@ function renderHostedAgentDeployment() {
373373 const link = document . getElementById ( "testPlaygroundLink" ) ;
374374 const description = document . getElementById ( "deployDescription" ) ;
375375 if ( ! link && ! description ) return ;
376- const deployment = state . hostedAgentDeployment ;
376+ const deployment = state . hostedAgents . creatingNew
377+ ? emptyHostedAgentDeployment ( )
378+ : state . hostedAgentDeployment ;
377379 const descriptionText = hostedAgentDeploymentDescription ( deployment ) ;
378380 if ( description ) {
379381 description . textContent = descriptionText ;
@@ -532,15 +534,17 @@ async function loadHostedAgents(force) {
532534 return st ;
533535}
534536
535- function beginNewHostedAgent ( ) {
536- closeHostedAgentMenu ( ) ;
537+ function showNewAgent ( prompt = "" ) {
538+ const nextPrompt = String ( prompt || "" ) . trim ( ) ;
539+ if ( nextPrompt ) {
540+ state . init . idea = "" ;
541+ setInitPreviewPrompt ( nextPrompt ) ;
542+ }
537543 state . hostedAgents . creatingNew = true ;
538544 state . init . open = true ;
539545 state . folds . resources = false ;
540546 state . folds . deploy = false ;
541- renderHostedAgentPicker ( ) ;
542- renderInit ( ) ;
543- renderFolds ( ) ;
547+ render ( ) ;
544548}
545549
546550async function selectHostedAgent ( agentName ) {
@@ -563,6 +567,7 @@ async function selectHostedAgent(agentName) {
563567 }
564568 renderHostedAgentPicker ( ) ;
565569 if ( agentName === previous ) {
570+ renderHostedAgentDeployment ( ) ;
566571 toast ( "Agent: " + agentName ) ;
567572 return ;
568573 }
@@ -744,10 +749,7 @@ function setInitPreviewPrompt(text) {
744749
745750function setInitUserPrompt ( prompt ) {
746751 if ( ! prompt || ! prompt . trim ( ) ) return ;
747- state . init . idea = "" ;
748- state . init . open = true ;
749- setInitPreviewPrompt ( prompt . trim ( ) ) ;
750- renderInit ( ) ;
752+ showNewAgent ( prompt ) ;
751753 toast ( "Task added \u2713" ) ;
752754}
753755
@@ -1913,7 +1915,7 @@ root.addEventListener("click", async (e) => {
19131915 return ;
19141916 }
19151917 if ( e . target . closest ( "#newHostedAgentBtn" ) ) {
1916- beginNewHostedAgent ( ) ;
1918+ showNewAgent ( ) ;
19171919 return ;
19181920 }
19191921 if ( e . target . closest ( "#hostedAgentTrigger" ) ) {
@@ -1971,7 +1973,12 @@ root.addEventListener("click", async (e) => {
19711973 return ;
19721974 }
19731975 if ( e . target . closest ( "#inspectBtn" ) ) {
1974- launchInspector ( e . target . closest ( "#inspectBtn" ) ) ;
1976+ if ( state . hostedAgents . creatingNew ) {
1977+ toast ( "Select an existing agent to inspect locally." ) ;
1978+ } else {
1979+ launchInspector ( e . target . closest ( "#inspectBtn" ) ) ;
1980+ }
1981+ return ;
19751982 }
19761983} ) ;
19771984
@@ -2089,6 +2096,7 @@ root.addEventListener("input", (e) => {
20892096
20902097// ------------------------------------------------------- Init + live updates
20912098async function init ( ) {
2099+ let initialCreatePrompt = "" ;
20922100 const [ stateResult , projectInitResult ] = await Promise . allSettled ( [
20932101 getJSON ( "/api/state" ) ,
20942102 getJSON ( "/api/project-init" ) ,
@@ -2098,8 +2106,7 @@ async function init() {
20982106 const s = stateResult . value ;
20992107 if ( s . agentName ) state . agentName = s . agentName ;
21002108 if ( s . initPrompt ) {
2101- state . init . promptText = s . initPrompt ;
2102- state . init . promptDirty = true ;
2109+ initialCreatePrompt = s . initPrompt ;
21032110 }
21042111 if ( s . selection ) state . selection = normalizeSelection ( s . selection ) ;
21052112 if ( s . model ) state . model = s . model ;
@@ -2121,7 +2128,8 @@ async function init() {
21212128 }
21222129 }
21232130 }
2124- render ( ) ;
2131+ if ( initialCreatePrompt ) showNewAgent ( initialCreatePrompt ) ;
2132+ else render ( ) ;
21252133
21262134 // Project init normally supplies the agent list from the workspace scan it
21272135 // already performed. If it did not, start the fallback fetch immediately
0 commit comments