@@ -36,6 +36,7 @@ 7. DO NOT include the placeholder summary when the commands contains no placehol
3636 """ ;
3737
3838 private int _turnsLeft ;
39+ private CopilotResponse _copilotResponse ;
3940
4041 private readonly string _instructions ;
4142 private readonly StringBuilder _buffer ;
@@ -120,36 +121,36 @@ public async Task<bool> ChatAsync(string input, IShell shell)
120121 try
121122 {
122123 string query = $ "{ input } \n \n ---\n \n { _instructions } ";
123- CopilotResponse copilotResponse = await host . RunWithSpinnerAsync (
124+ _copilotResponse = await host . RunWithSpinnerAsync (
124125 status : "Thinking ..." ,
125126 spinnerKind : SpinnerKind . Processing ,
126127 func : async context => await _chatSession . GetChatResponseAsync ( query , context , token )
127128 ) . ConfigureAwait ( false ) ;
128129
129- if ( copilotResponse is null )
130+ if ( _copilotResponse is null )
130131 {
131132 // User cancelled the operation.
132133 return true ;
133134 }
134135
135- if ( copilotResponse . ChunkReader is null )
136+ if ( _copilotResponse . ChunkReader is null )
136137 {
137138 ArgPlaceholder ? . DataRetriever ? . Dispose ( ) ;
138139 ArgPlaceholder = null ;
139140
140141 // Process CLI handler response specially to support parameter injection.
141142 ResponseData data = null ;
142- if ( copilotResponse . TopicName == CopilotActivity . CLIHandlerTopic )
143+ if ( _copilotResponse . TopicName == CopilotActivity . CLIHandlerTopic )
143144 {
144- data = ParseCLIHandlerResponse ( copilotResponse , shell ) ;
145+ data = ParseCLIHandlerResponse ( shell ) ;
145146 }
146147
147148 if ( data ? . PlaceholderSet is not null )
148149 {
149150 ArgPlaceholder = new ArgumentPlaceholder ( input , data , _httpClient ) ;
150151 }
151152
152- string answer = data is null ? copilotResponse . Text : GenerateAnswer ( data ) ;
153+ string answer = data is null ? _copilotResponse . Text : GenerateAnswer ( data ) ;
153154 host . RenderFullResponse ( answer ) ;
154155 }
155156 else
@@ -161,12 +162,12 @@ public async Task<bool> ChatAsync(string input, IShell shell)
161162
162163 while ( true )
163164 {
164- CopilotActivity activity = copilotResponse . ChunkReader . ReadChunk ( token ) ;
165+ CopilotActivity activity = _copilotResponse . ChunkReader . ReadChunk ( token ) ;
165166 if ( activity is null )
166167 {
167168 prevActivity . ExtractMetadata ( out string [ ] suggestion , out ConversationState state ) ;
168- copilotResponse . SuggestedUserResponses = suggestion ;
169- copilotResponse . ConversationState = state ;
169+ _copilotResponse . SuggestedUserResponses = suggestion ;
170+ _copilotResponse . ConversationState = state ;
170171 break ;
171172 }
172173
@@ -182,7 +183,7 @@ public async Task<bool> ChatAsync(string input, IShell shell)
182183 }
183184 }
184185
185- var conversationState = copilotResponse . ConversationState ;
186+ var conversationState = _copilotResponse . ConversationState ;
186187 _turnsLeft = conversationState . TurnLimit - conversationState . TurnNumber ;
187188 if ( _turnsLeft <= 5 )
188189 {
@@ -210,9 +211,9 @@ public async Task<bool> ChatAsync(string input, IShell shell)
210211 return true ;
211212 }
212213
213- private ResponseData ParseCLIHandlerResponse ( CopilotResponse copilotResponse , IShell shell )
214+ private ResponseData ParseCLIHandlerResponse ( IShell shell )
214215 {
215- string text = copilotResponse . Text ;
216+ string text = _copilotResponse . Text ;
216217 List < CodeBlock > codeBlocks = shell . ExtractCodeBlocks ( text , out List < SourceInfo > sourceInfos ) ;
217218 if ( codeBlocks is null || codeBlocks . Count is 0 )
218219 {
@@ -264,7 +265,7 @@ private ResponseData ParseCLIHandlerResponse(CopilotResponse copilotResponse, IS
264265 Text = text ,
265266 CommandSet = commands ,
266267 PlaceholderSet = placeholders ,
267- Locale = copilotResponse . Locale ,
268+ Locale = _copilotResponse . Locale ,
268269 } ;
269270
270271 string first = placeholders [ 0 ] . Name ;
0 commit comments