@@ -40,7 +40,7 @@ import {
4040} from './agents/NetworkAgent.js' ;
4141import { PatchAgent , ProjectContext } from './agents/PatchAgent.js' ;
4242import { CallTreeContext , PerformanceAgent } from './agents/PerformanceAgent.js' ;
43- import { NodeContext , StylingAgent } from './agents/StylingAgent.js' ;
43+ import { NodeContext , StylingAgent , StylingAgentWithFunctionCalling } from './agents/StylingAgent.js' ;
4444import aiAssistancePanelStyles from './aiAssistancePanel.css.js' ;
4545import {
4646 AiHistoryStorage ,
@@ -334,6 +334,13 @@ export class AiAssistancePanel extends UI.Panel.Panel {
334334 ...options ,
335335 changeManager : this . #changeManager,
336336 } ) ;
337+ if ( isAiAssistanceStylingWithFunctionCallingEnabled ( ) ) {
338+ agent = new StylingAgentWithFunctionCalling ( {
339+ ...options ,
340+ changeManager : this . #changeManager,
341+ } ) ;
342+ }
343+
337344 break ;
338345 }
339346 case AgentType . NETWORK : {
@@ -939,9 +946,13 @@ export class AiAssistancePanel extends UI.Panel.Panel {
939946 commitStep ( ) ;
940947 break ;
941948 }
949+ case ResponseType . SUGGESTIONS : {
950+ systemMessage . suggestions = data . suggestions ;
951+ break ;
952+ }
942953 case ResponseType . SIDE_EFFECT : {
943954 step . isLoading = false ;
944- step . code = data . code ;
955+ step . code ?? = data . code ;
945956 step . sideEffect = {
946957 onAnswer : data . confirm ,
947958 } ;
@@ -950,8 +961,8 @@ export class AiAssistancePanel extends UI.Panel.Panel {
950961 }
951962 case ResponseType . ACTION : {
952963 step . isLoading = false ;
953- step . code = data . code ;
954- step . output = data . output ;
964+ step . code ?? = data . code ;
965+ step . output ?? = data . output ;
955966 step . canceled = data . canceled ;
956967 if ( isAiAssistanceChangeSummariesEnabled ( ) && this . #currentAgent && ! this . #currentAgent. isHistoryEntry ) {
957968 this . #viewProps. changeSummary = this . #changeManager. formatChanges ( this . #currentAgent. id ) ;
@@ -960,7 +971,7 @@ export class AiAssistancePanel extends UI.Panel.Panel {
960971 break ;
961972 }
962973 case ResponseType . ANSWER : {
963- systemMessage . suggestions = data . suggestions ;
974+ systemMessage . suggestions ?? = data . suggestions ;
964975 systemMessage . answer = data . text ;
965976 systemMessage . rpcId = data . rpcId ;
966977 // When there is an answer without any thinking steps, we don't want to show the thinking step.
@@ -1075,7 +1086,21 @@ function isAiAssistanceServerSideLoggingEnabled(): boolean {
10751086 return localStorage . getItem ( 'aiAssistance_enableServerSideLogging' ) !== 'false' ;
10761087}
10771088
1089+ function setAiAssistanceStylingWithFunctionCalling ( enabled : boolean ) : void {
1090+ if ( enabled ) {
1091+ localStorage . setItem ( 'aiAssistance_stylingFunctionCalling' , 'true' ) ;
1092+ } else {
1093+ localStorage . setItem ( 'aiAssistance_stylingFunctionCalling' , 'false' ) ;
1094+ }
1095+ }
1096+
1097+ function isAiAssistanceStylingWithFunctionCallingEnabled ( ) : boolean {
1098+ return localStorage . getItem ( 'aiAssistance_stylingFunctionCalling' ) === 'true' ;
1099+ }
1100+
10781101// @ts -ignore
10791102globalThis . setAiAssistanceServerSideLoggingEnabled = setAiAssistanceServerSideLoggingEnabled ;
10801103// @ts -ignore
10811104globalThis . setAiAssistanceChangeSummariesEnabled = setAiAssistanceChangeSummariesEnabled ;
1105+ // @ts -ignore
1106+ globalThis . setAiAssistanceStylingWithFunctionCalling = setAiAssistanceStylingWithFunctionCalling ;
0 commit comments