@@ -11,7 +11,6 @@ import type * as Platform from '../../core/platform/platform.js';
1111import * as Root from '../../core/root/root.js' ;
1212import * as SDK from '../../core/sdk/sdk.js' ;
1313import * as Protocol from '../../generated/protocol.js' ;
14- import * as Persistence from '../../models/persistence/persistence.js' ;
1514import * as Workspace from '../../models/workspace/workspace.js' ;
1615import * as Buttons from '../../ui/components/buttons/buttons.js' ;
1716import * as UI from '../../ui/legacy/legacy.js' ;
@@ -40,7 +39,6 @@ import {
4039 NetworkAgent ,
4140 RequestContext ,
4241} from './agents/NetworkAgent.js' ;
43- import { PatchAgent } from './agents/PatchAgent.js' ;
4442import { CallTreeContext , PerformanceAgent } from './agents/PerformanceAgent.js' ;
4543import { InsightContext , PerformanceInsightsAgent } from './agents/PerformanceInsightsAgent.js' ;
4644import { NodeContext , StylingAgent , StylingAgentWithFunctionCalling } from './agents/StylingAgent.js' ;
@@ -56,6 +54,7 @@ import {
5654 State as ChatViewState ,
5755 type Step
5856} from './components/ChatView.js' ;
57+ import { isAiAssistancePatchingEnabled } from './PatchWidget.js' ;
5958
6059const { html} = Lit ;
6160
@@ -441,11 +440,7 @@ export class AiAssistancePanel extends UI.Panel.Panel {
441440 accountImage ?: string ,
442441 accountFullName ?: string ,
443442 } ;
444- #project?: Workspace . Workspace . Project ;
445- #patchSuggestion?: string ;
446- #patchSuggestionLoading?: boolean ;
447443 #imageInput = '' ;
448- #workspace = Workspace . Workspace . WorkspaceImpl . instance ( ) ;
449444
450445 constructor ( private view : View = defaultView , { aidaClient, aidaAvailability, syncInfo} : {
451446 aidaClient : Host . AidaClient . AidaClient ,
@@ -468,36 +463,6 @@ export class AiAssistancePanel extends UI.Panel.Panel {
468463 this . #historicalConversations = AiHistoryStorage . instance ( ) . getHistory ( ) . map ( item => {
469464 return new Conversation ( item . type , item . history , item . id , true ) ;
470465 } ) ;
471-
472- this . #selectProject( ) ;
473- }
474-
475- #selectProject( ) : void {
476- if ( isAiAssistancePatchingEnabled ( ) ) {
477- // TODO: this is temporary code that should be replaced with
478- // workflow selection flow. For now it picks the first Workspace
479- // project that is not Snippets.
480- const projects = this . #workspace. projectsForType ( Workspace . Workspace . projectTypes . FileSystem ) ;
481- this . #project = undefined ;
482- for ( const project of projects ) {
483- // This is for TypeScript to narrow the types. projectsForType()
484- // probably only returns instances of
485- // Persistence.FileSystemWorkspaceBinding.FileSystem.
486- if ( ! ( project instanceof Persistence . FileSystemWorkspaceBinding . FileSystem ) ) {
487- continue ;
488- }
489- if ( project . fileSystem ( ) . type ( ) !== Persistence . PlatformFileSystem . PlatformFileSystemType . WORKSPACE_PROJECT ) {
490- continue ;
491- }
492- this . #project = project ;
493- this . requestUpdate ( ) ;
494- break ;
495- }
496- }
497- }
498-
499- #onProjectAddedOrRemoved( ) : void {
500- this . #selectProject( ) ;
501466 }
502467
503468 #getChatUiState( ) : ChatViewState {
@@ -702,16 +667,6 @@ export class AiAssistancePanel extends UI.Panel.Panel {
702667 SDK . TargetManager . TargetManager . instance ( ) . addModelListener (
703668 SDK . DOMModel . DOMModel , SDK . DOMModel . Events . AttrRemoved , this . #handleDOMNodeAttrChange, this ) ;
704669 Host . userMetrics . actionTaken ( Host . UserMetrics . Action . AiAssistancePanelOpened ) ;
705-
706- if ( isAiAssistancePatchingEnabled ( ) ) {
707- this . #workspace. addEventListener ( Workspace . Workspace . Events . ProjectAdded , this . #onProjectAddedOrRemoved, this ) ;
708- this . #workspace. addEventListener ( Workspace . Workspace . Events . ProjectRemoved , this . #onProjectAddedOrRemoved, this ) ;
709-
710- // @ts -expect-error temporary global function for local testing.
711- window . aiAssistanceTestPatchPrompt = async ( changeSummary : string ) => {
712- return await this . #applyPatch( changeSummary ) ;
713- } ;
714- }
715670 }
716671
717672 override willHide ( ) : void {
@@ -748,12 +703,6 @@ export class AiAssistancePanel extends UI.Panel.Panel {
748703 this . #handleDOMNodeAttrChange,
749704 this ,
750705 ) ;
751-
752- if ( isAiAssistancePatchingEnabled ( ) ) {
753- this . #workspace. removeEventListener ( Workspace . Workspace . Events . ProjectAdded , this . #onProjectAddedOrRemoved, this ) ;
754- this . #workspace. removeEventListener (
755- Workspace . Workspace . Events . ProjectRemoved , this . #onProjectAddedOrRemoved, this ) ;
756- }
757706 }
758707
759708 #handleAidaAvailabilityChange = async ( ) : Promise < void > => {
@@ -849,15 +798,12 @@ export class AiAssistancePanel extends UI.Panel.Panel {
849798 conversationType : this . #conversation?. type ,
850799 isReadOnly : this . #conversation?. isReadOnly ?? false ,
851800 changeSummary : this . #getChangeSummary( ) ,
852- patchSuggestion : this . #patchSuggestion,
853- patchSuggestionLoading : this . #patchSuggestionLoading,
854801 inspectElementToggled : this . #toggleSearchElementAction. toggled ( ) ,
855802 userInfo : this . #userInfo,
856803 canShowFeedbackForm : this . #serverSideLoggingEnabled,
857804 multimodalInputEnabled :
858805 isAiAssistanceMultimodalInputEnabled ( ) && this . #conversation?. type === ConversationType . STYLING ,
859806 imageInput : this . #imageInput,
860- projectName : this . #project?. displayName ( ) ?? '' ,
861807 isDeleteHistoryButtonVisible : Boolean ( this . #conversation && ! this . #conversation. isEmpty ) ,
862808 isTextInputDisabled : this . #isTextInputDisabled( ) ,
863809 emptyStateSuggestions : this . #conversation ? getEmptyStateSuggestions ( this . #conversation. type ) : [ ] ,
@@ -885,7 +831,6 @@ export class AiAssistancePanel extends UI.Panel.Panel {
885831 onTakeScreenshot : isAiAssistanceMultimodalInputEnabled ( ) ? this . #handleTakeScreenshot. bind ( this ) : undefined ,
886832 onRemoveImageInput : isAiAssistanceMultimodalInputEnabled ( ) ? this . #handleRemoveImageInput. bind ( this ) :
887833 undefined ,
888- onApplyToWorkspace : this . #onApplyToWorkspace. bind ( this )
889834 } ,
890835 this . #viewOutput, this . contentElement ) ;
891836 }
@@ -1263,36 +1208,6 @@ export class AiAssistancePanel extends UI.Panel.Panel {
12631208 UI . ARIAUtils . alert ( lockedString ( UIStringsNotTranslate . answerReady ) ) ;
12641209 }
12651210
1266- async #onApplyToWorkspace( ) : Promise < void > {
1267- if ( ! isAiAssistancePatchingEnabled ( ) ) {
1268- return ;
1269- }
1270- const changeSummary = this . #getChangeSummary( ) ;
1271- if ( ! changeSummary ) {
1272- throw new Error ( 'Change summary does not exist' ) ;
1273- }
1274-
1275- this . #patchSuggestionLoading = true ;
1276- this . requestUpdate ( ) ;
1277- const response = await this . #applyPatch( changeSummary ) ;
1278- this . #patchSuggestion = response ?. type === ResponseType . ANSWER ? response . text : 'Could not update files' ;
1279- this . #patchSuggestionLoading = false ;
1280- this . requestUpdate ( ) ;
1281- }
1282-
1283- async #applyPatch( changeSummary : string ) : Promise < ResponseData | undefined > {
1284- if ( ! this . #project) {
1285- throw new Error ( 'Project does not exist' ) ;
1286- }
1287- const agent = new PatchAgent ( {
1288- aidaClient : this . #aidaClient,
1289- serverSideLoggingEnabled : this . #serverSideLoggingEnabled,
1290- project : this . #project,
1291- } ) ;
1292- const responses = await Array . fromAsync ( agent . applyChanges ( changeSummary ) ) ;
1293- return responses . at ( - 1 ) ;
1294- }
1295-
12961211 async *
12971212 #saveResponsesToCurrentConversation( items : AsyncIterable < ResponseData , void , void > ) :
12981213 AsyncGenerator < ResponseData , void , void > {
@@ -1487,11 +1402,6 @@ function isAiAssistanceMultimodalInputEnabled(): boolean {
14871402 return Boolean ( hostConfig . devToolsFreestyler ?. multimodal ) ;
14881403}
14891404
1490- function isAiAssistancePatchingEnabled ( ) : boolean {
1491- const { hostConfig} = Root . Runtime ;
1492- return Boolean ( hostConfig . devToolsFreestyler ?. patching ) ;
1493- }
1494-
14951405function isAiAssistanceServerSideLoggingEnabled ( ) : boolean {
14961406 const { hostConfig} = Root . Runtime ;
14971407 return ! hostConfig . aidaAvailability ?. disallowLogging ;
0 commit comments