MCPcopy Index your code
hub / github.com/continuedev/continue / executeStreamingResponse

Function executeStreamingResponse

extensions/cli/src/ui/hooks/useChat.ts:294–381  ·  view source on GitHub ↗
(
    newHistory: ChatHistoryItem[],
    currentCompactionIndex: number | null,
  )

Source from the content-addressed store, hash-verified

292 }, [initialPrompt, additionalPrompts, isChatHistoryInitialized]);
293
294 const executeStreamingResponse = async (
295 newHistory: ChatHistoryItem[],
296 currentCompactionIndex: number | null,
297 ) => {
298 // Clean up previous abort controller if it exists
299 if (abortController && !abortController.signal.aborted) {
300 abortController.abort();
301 }
302
303 // Start streaming response
304 const controller = new AbortController();
305 setAbortController(controller);
306 setIsWaitingForResponse(true);
307 setResponseStartTime(Date.now());
308 setInputMode(false);
309 logger.debug("Starting chat response stream", {
310 historyLength: newHistory.length,
311 });
312
313 try {
314 const streamCallbacks = createStreamCallbacks({
315 setChatHistory: setChatHistory,
316 setActivePermissionRequest,
317 llmApi,
318 model,
319 });
320
321 // Execute streaming chat response
322 await executeStreaming({
323 chatHistory: newHistory,
324 model,
325 llmApi,
326 controller,
327 streamCallbacks,
328 currentCompactionIndex,
329 });
330
331 // Save the updated session with the latest chat history that includes the assistant's reply
332 // The streamCallbacks update setChatHistory during streaming, so we need to get the current state
333 setChatHistory((currentHistory) => {
334 const updatedSession: Session = {
335 ...currentSession,
336 history: currentHistory,
337 };
338 updateSessionHistory(currentHistory);
339 setCurrentSession(updatedSession);
340 logger.debug("Session saved");
341 return currentHistory;
342 });
343 } catch (error: any) {
344 const errorMessage = `Error: ${formatError(error)}`;
345 setChatHistory((prev) => [
346 ...prev,
347 {
348 message: {
349 role: "system",
350 content: errorMessage,
351 },

Callers 2

handleResumeRequestFunction · 0.85
processMessageFunction · 0.85

Calls 10

createStreamCallbacksFunction · 0.85
executeStreamingFunction · 0.85
setChatHistoryFunction · 0.85
updateSessionHistoryFunction · 0.85
formatErrorFunction · 0.85
processQueuedMessageFunction · 0.85
stopActiveTimeMethod · 0.80
getNextMessageMethod · 0.80
abortMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected