@@ -263,7 +263,11 @@ const UIStringsNotTranslate = {
263263 /**
264264 *@description Text displayed for showing change summary view.
265265 */
266- changeSummary : 'Change summary' ,
266+ changeSummary : 'Changes summary' ,
267+ /**
268+ *@description Button text for staging changes to workspace.
269+ */
270+ applyToWorkspace : 'Apply to workspace' ,
267271} ;
268272
269273const str_ = i18n . i18n . registerUIStrings ( 'panels/ai_assistance/components/ChatView.ts' , UIStrings ) ;
@@ -336,7 +340,7 @@ export interface Props {
336340 patchSuggestion ?: string ;
337341 patchSuggestionLoading ?: boolean ;
338342 projectName ?: string ;
339- onStageToWorkspace ?: ( ) => void ;
343+ onApplyToWorkspace ?: ( ) => void ;
340344}
341345
342346export class ChatView extends HTMLElement {
@@ -710,11 +714,16 @@ export class ChatView extends HTMLElement {
710714 userInfo : this . #props. userInfo ,
711715 markdownRenderer : this . #markdownRenderer,
712716 agentType : this . #props. agentType ,
717+ changeSummary : this . #props. changeSummary ,
718+ patchSuggestion : this . #props. patchSuggestion ,
719+ patchSuggestionLoading : this . #props. patchSuggestionLoading ,
720+ projectName : this . #props. projectName ,
713721 getUnavailableAidaAvailabilityContents : this . #getUnavailableAidaAvailabilityContents,
714722 onSuggestionClick : this . #handleSuggestionClick,
715723 onFeedbackSubmit : this . #props. onFeedbackSubmit ,
716724 onLastAnswerMarkdownViewRef : this . #handleLastAnswerMarkdownViewRef,
717725 onMessageContainerRef : this . #handleMessageContainerRef,
726+ onApplyToWorkspace : this . #props. onApplyToWorkspace ,
718727 } ) }
719728 ${ this . #props. isReadOnly
720729 ? renderReadOnlySection ( {
@@ -730,7 +739,6 @@ export class ChatView extends HTMLElement {
730739 selectedContext : this . #props. selectedContext ,
731740 inspectElementToggled : this . #props. inspectElementToggled ,
732741 agentType : this . #props. agentType ,
733- changeSummary : this . #props. changeSummary ,
734742 onContextClick : this . #props. onContextClick ,
735743 onInspectElementClick : this . #props. onInspectElementClick ,
736744 onSubmit : this . #handleSubmit,
@@ -767,47 +775,47 @@ function renderChangeSummary({
767775 patchSuggestion,
768776 patchSuggestionLoading,
769777 projectName,
770- onStageToWorkspace ,
778+ onApplyToWorkspace ,
771779} : {
772- changeSummary ? : string ,
780+ changeSummary : string ,
773781 patchSuggestion ?: string ,
774782 patchSuggestionLoading ?: boolean ,
775783 projectName ?: string ,
776- onStageToWorkspace ?: ( ) => void ,
784+ onApplyToWorkspace ?: ( ) => void ,
777785} ) : Lit . LitTemplate {
778- if ( ! changeSummary ) {
779- return Lit . nothing ;
780- }
781-
786+ // clang-format off
782787 return html `< details class ="change-summary ">
783788 < summary >
784- < devtools-icon class ="difference-icon " .name =${ 'difference ' }
789+ < devtools-icon class ="difference-icon " .name =${ 'pen-spark ' }
785790 > </ devtools-icon >
786791 < span class ="header-text ">
787792 ${ lockedString ( UIStringsNotTranslate . changeSummary ) }
788793 </ span >
789794 < devtools-icon
790795 class ="arrow "
791- .name =${ 'chevron-up ' }
796+ .name =${ 'chevron-down ' }
792797 > </ devtools-icon >
793798 </ summary >
794799 < devtools-code-block
795800 .code =${ changeSummary }
796801 .codeLang =${ 'css' }
797- .displayNotice=${ false }
802+ .displayNotice=${ true }
798803 > </ devtools-code-block >
799- < div class ="patch-tmp-message ">
800- ${ ( patchSuggestion ? '\nI suggest changing these files\n' + patchSuggestion : '' ) }
801- </ div >
802- < div class ="workspace ">
803- < devtools-button
804- @click =${ onStageToWorkspace }
805- .jslogContext =${ 'stage-to-workspace' }
806- .variant=${ Buttons . Button . Variant . PRIMARY } > ${
807- ! patchSuggestionLoading ? 'Stage to workspace' : 'Loading...' } </ devtools-button >
808- < div > Selected folder: ${ projectName } </ div >
809- </ div >
804+ < div class ="workspace ">
805+ < devtools-button
806+ class ='apply-to-workspace '
807+ @click =${ onApplyToWorkspace }
808+ .jslogContext =${ 'stage-to-workspace' }
809+ .variant=${ Buttons . Button . Variant . OUTLINED } >
810+ ${ ! patchSuggestionLoading ? lockedString ( UIStringsNotTranslate . applyToWorkspace ) : 'Loading...' }
811+ </ devtools-button >
812+ < div > Selected folder: ${ projectName } </ div >
813+ </ div >
814+ ${ patchSuggestion ? html `< div class ="patch-tmp-message ">
815+ I suggest changing these files ${ patchSuggestion }
816+ </ div > ` : Lit . nothing }
810817 </ details > ` ;
818+ // clang-format on
811819}
812820
813821function renderTextAsMarkdown ( text : string , markdownRenderer : MarkdownRendererWithCodeBlock , { animate, ref : refFn } : {
@@ -1217,21 +1225,32 @@ function renderMessages({
12171225 canShowFeedbackForm,
12181226 userInfo,
12191227 markdownRenderer,
1228+ changeSummary,
1229+ patchSuggestion,
1230+ patchSuggestionLoading,
1231+ projectName,
12201232 onSuggestionClick,
12211233 onFeedbackSubmit,
12221234 onLastAnswerMarkdownViewRef,
12231235 onMessageContainerRef,
1236+ onApplyToWorkspace,
12241237} : {
12251238 messages : ChatMessage [ ] ,
12261239 isLoading : boolean ,
12271240 isReadOnly : boolean ,
12281241 canShowFeedbackForm : boolean ,
12291242 userInfo : Pick < Host . InspectorFrontendHostAPI . SyncInformation , 'accountImage' | 'accountFullName' > ,
12301243 markdownRenderer : MarkdownRendererWithCodeBlock ,
1231- onSuggestionClick : ( suggestion : string ) => void ,
1232- onFeedbackSubmit : ( rpcId : Host . AidaClient . RpcGlobalId , rate : Host . AidaClient . Rating , feedback ?: string ) => void ,
1233- onLastAnswerMarkdownViewRef : ( el : Element | undefined ) => void ,
1234- onMessageContainerRef : ( el : Element | undefined ) => void ,
1244+ changeSummary ?: string ,
1245+ patchSuggestion ?: string ,
1246+ patchSuggestionLoading ?: boolean ,
1247+ projectName ?: string ,
1248+ onApplyToWorkspace ?: ( ) => void ,
1249+ onSuggestionClick : ( suggestion : string ) => void ,
1250+ onFeedbackSubmit :
1251+ ( rpcId : Host . AidaClient . RpcGlobalId , rate : Host . AidaClient . Rating , feedback ?: string ) => void ,
1252+ onLastAnswerMarkdownViewRef : ( el : Element | undefined ) => void ,
1253+ onMessageContainerRef : ( el : Element | undefined ) => void ,
12351254} ) : Lit . TemplateResult {
12361255 // clang-format off
12371256 return html `
@@ -1250,6 +1269,13 @@ function renderMessages({
12501269 onLastAnswerMarkdownViewRef,
12511270 } ) ,
12521271 ) }
1272+ ${ ( changeSummary && ! isLoading ) ? renderChangeSummary ( {
1273+ changeSummary,
1274+ patchSuggestion,
1275+ patchSuggestionLoading,
1276+ projectName,
1277+ onApplyToWorkspace,
1278+ } ) : Lit . nothing }
12531279 </ div >
12541280 ` ;
12551281 // clang-format on
@@ -1403,18 +1429,13 @@ function renderChatInput({
14031429 selectedContext,
14041430 inspectElementToggled,
14051431 agentType,
1406- changeSummary,
1407- patchSuggestion,
1408- patchSuggestionLoading,
1409- projectName,
14101432 onContextClick,
14111433 onInspectElementClick,
14121434 onSubmit,
14131435 onTextAreaKeyDown,
14141436 onCancel,
14151437 onNewConversation,
14161438 onCancelCrossOriginChat,
1417- onStageToWorkspace,
14181439} : {
14191440 isLoading : boolean ,
14201441 blockedByCrossOrigin : boolean ,
@@ -1424,18 +1445,13 @@ function renderChatInput({
14241445 selectedContext : ConversationContext < unknown > | null ,
14251446 inspectElementToggled : boolean ,
14261447 agentType ?: AgentType ,
1427- changeSummary ?: string ,
1428- patchSuggestion ?: string ,
1429- patchSuggestionLoading ?: boolean ,
1430- projectName ?: string ,
14311448 onContextClick : ( ) => void | Promise < void > ,
14321449 onInspectElementClick : ( ) => void ,
14331450 onSubmit : ( ev : SubmitEvent ) => void ,
14341451 onTextAreaKeyDown : ( ev : KeyboardEvent ) => void ,
14351452 onCancel : ( ev : SubmitEvent ) => void ,
14361453 onNewConversation : ( ) => void ,
14371454 onCancelCrossOriginChat ?: ( ) => void ,
1438- onStageToWorkspace ?: ( ) => void ,
14391455} ) : Lit . LitTemplate {
14401456 if ( ! agentType ) {
14411457 return Lit . nothing ;
@@ -1463,13 +1479,6 @@ function renderChatInput({
14631479 onInspectElementClick,
14641480 } ) }
14651481 </ div >
1466- ${ renderChangeSummary ( {
1467- changeSummary,
1468- patchSuggestion,
1469- patchSuggestionLoading,
1470- projectName,
1471- onStageToWorkspace,
1472- } ) }
14731482 </ div >
14741483 ` : Lit . nothing }
14751484 < div class ="chat-input-container ">
@@ -1599,11 +1608,16 @@ function renderMainContents({
15991608 userInfo,
16001609 markdownRenderer,
16011610 agentType,
1611+ changeSummary,
1612+ patchSuggestion,
1613+ patchSuggestionLoading,
1614+ projectName,
16021615 getUnavailableAidaAvailabilityContents,
16031616 onSuggestionClick,
16041617 onFeedbackSubmit,
16051618 onLastAnswerMarkdownViewRef,
16061619 onMessageContainerRef,
1620+ onApplyToWorkspace,
16071621} : {
16081622 state : State ,
16091623 aidaAvailability : Host . AidaClient . AidaAccessPreconditions ,
@@ -1617,15 +1631,20 @@ function renderMainContents({
16171631 userInfo : Pick < Host . InspectorFrontendHostAPI . SyncInformation , 'accountImage' | 'accountFullName' > ,
16181632 markdownRenderer : MarkdownRendererWithCodeBlock ,
16191633 agentType ?: AgentType ,
1620- getUnavailableAidaAvailabilityContents :
1621- ( aidaAvailability : Exclude <
1622- Host . AidaClient . AidaAccessPreconditions , Host . AidaClient . AidaAccessPreconditions . AVAILABLE > ) =>
1623- Lit . TemplateResult ,
1624- onSuggestionClick : ( suggestion : string ) => void ,
1625- onFeedbackSubmit : ( rpcId : Host . AidaClient . RpcGlobalId , rate : Host . AidaClient . Rating , feedback ?: string ) =>
1626- void ,
1627- onLastAnswerMarkdownViewRef : ( el : Element | undefined ) => void ,
1628- onMessageContainerRef : ( el : Element | undefined ) => void ,
1634+ changeSummary ?: string ,
1635+ patchSuggestion ?: string ,
1636+ patchSuggestionLoading ?: boolean ,
1637+ projectName ?: string ,
1638+ getUnavailableAidaAvailabilityContents :
1639+ ( aidaAvailability : Exclude <
1640+ Host . AidaClient . AidaAccessPreconditions , Host . AidaClient . AidaAccessPreconditions . AVAILABLE > ) =>
1641+ Lit . TemplateResult ,
1642+ onSuggestionClick : ( suggestion : string ) => void ,
1643+ onFeedbackSubmit : ( rpcId : Host . AidaClient . RpcGlobalId , rate : Host . AidaClient . Rating , feedback ?: string ) =>
1644+ void ,
1645+ onLastAnswerMarkdownViewRef : ( el : Element | undefined ) => void ,
1646+ onMessageContainerRef : ( el : Element | undefined ) => void ,
1647+ onApplyToWorkspace ?: ( ) => void ,
16291648} ) : Lit . TemplateResult {
16301649 if ( state === State . CONSENT_VIEW ) {
16311650 return renderDisabledState ( consentViewContents ) ;
@@ -1647,6 +1666,11 @@ function renderMainContents({
16471666 canShowFeedbackForm,
16481667 userInfo,
16491668 markdownRenderer,
1669+ changeSummary,
1670+ patchSuggestion,
1671+ patchSuggestionLoading,
1672+ projectName,
1673+ onApplyToWorkspace,
16501674 onSuggestionClick,
16511675 onFeedbackSubmit,
16521676 onLastAnswerMarkdownViewRef,
0 commit comments