@@ -42,12 +42,13 @@ import {
4242 IdeSettings ,
4343 ModelDescription ,
4444 RangeInFile ,
45+ ToolCall ,
4546 type ContextItem ,
4647 type ContextItemId ,
4748 type IDE ,
4849} from "." ;
4950
50- import { ConfigYaml } from "@continuedev/config-yaml" ;
51+ import { BLOCK_TYPES , ConfigYaml } from "@continuedev/config-yaml" ;
5152import { getDiffFn , GitDiffCache } from "./autocomplete/snippets/gitDiffCache" ;
5253import { isLocalDefinitionFile } from "./config/loadLocalAssistants" ;
5354import {
@@ -58,6 +59,7 @@ import {
5859import { createNewWorkspaceBlockFile } from "./config/workspace/workspaceBlocks" ;
5960import { MCPManagerSingleton } from "./context/mcp/MCPManagerSingleton" ;
6061import { setMdmLicenseKey } from "./control-plane/mdm/mdm" ;
62+ import { ApplyAbortManager } from "./edit/applyAbortManager" ;
6163import { streamDiffLines } from "./edit/streamDiffLines" ;
6264import { shouldIgnore } from "./indexing/shouldIgnore" ;
6365import { walkDirCache } from "./indexing/walkDir" ;
@@ -67,7 +69,6 @@ import { llmStreamChat } from "./llm/streamChat";
6769import type { FromCoreProtocol , ToCoreProtocol } from "./protocol" ;
6870import { OnboardingModes } from "./protocol/core" ;
6971import type { IMessenger , Message } from "./protocol/messenger" ;
70- import { StreamAbortManager } from "./util/abortManager" ;
7172import { getUriPathBasename } from "./util/uri" ;
7273
7374const hasRulesFiles = ( uris : string [ ] ) : boolean => {
@@ -147,6 +148,18 @@ export class Core {
147148
148149 MCPManagerSingleton . getInstance ( ) . onConnectionsRefreshed = ( ) => {
149150 void this . configHandler . reloadConfig ( ) ;
151+
152+ // Refresh @mention dropdown submenu items for MCP providers
153+ const mcpManager = MCPManagerSingleton . getInstance ( ) ;
154+ const mcpProviderNames = Array . from ( mcpManager . connections . keys ( ) ) . map (
155+ ( mcpId ) => `mcp-${ mcpId } ` ,
156+ ) ;
157+
158+ if ( mcpProviderNames . length > 0 ) {
159+ this . messenger . send ( "refreshSubmenuItems" , {
160+ providers : mcpProviderNames ,
161+ } ) ;
162+ }
150163 } ;
151164
152165 this . codeBaseIndexer = new CodebaseIndexer (
@@ -512,6 +525,11 @@ export class Core {
512525 throw new Error ( "No model selected" ) ;
513526 }
514527
528+ const abortManager = ApplyAbortManager . getInstance ( ) ;
529+ const abortController = abortManager . get (
530+ data . fileUri ?? "current-file-stream" ,
531+ ) ; // not super important since currently cancelling apply will cancel all streams it's one file at a time
532+
515533 return streamDiffLines ( {
516534 highlighted : data . highlighted ,
517535 prefix : data . prefix ,
@@ -525,13 +543,13 @@ export class Core {
525543 language : data . language ,
526544 onlyOneInsertion : false ,
527545 overridePrompt : undefined ,
528- abortControllerId : data . fileUri ?? "current-file-stream" , // not super important since currently cancelling apply will cancel all streams it's one file at a time
546+ abortController ,
529547 } ) ;
530548 } ) ;
531549
532550 on ( "cancelApply" , async ( msg ) => {
533- const abortManager = StreamAbortManager . getInstance ( ) ;
534- abortManager . clear ( ) ;
551+ const abortManager = ApplyAbortManager . getInstance ( ) ;
552+ abortManager . clear ( ) ; // for now abort all streams
535553 } ) ;
536554
537555 on ( "onboarding/complete" , this . handleCompleteOnboarding . bind ( this ) ) ;
@@ -738,44 +756,9 @@ export class Core {
738756 return { url } ;
739757 } ) ;
740758
741- on ( "tools/call" , async ( { data : { toolCall } } ) => {
742- const { config } = await this . configHandler . loadConfig ( ) ;
743- if ( ! config ) {
744- throw new Error ( "Config not loaded" ) ;
745- }
746-
747- const tool = config . tools . find (
748- ( t ) => t . function . name === toolCall . function . name ,
749- ) ;
750-
751- if ( ! tool ) {
752- throw new Error ( `Tool ${ toolCall . function . name } not found` ) ;
753- }
754-
755- if ( ! config . selectedModelByRole . chat ) {
756- throw new Error ( "No chat model selected" ) ;
757- }
758-
759- // Define a callback for streaming output updates
760- const onPartialOutput = ( params : {
761- toolCallId : string ;
762- contextItems : ContextItem [ ] ;
763- } ) => {
764- this . messenger . send ( "toolCallPartialOutput" , params ) ;
765- } ;
766-
767- return await callTool ( tool , toolCall , {
768- config,
769- ide : this . ide ,
770- llm : config . selectedModelByRole . chat ,
771- fetch : ( url , init ) =>
772- fetchwithRequestOptions ( url , init , config . requestOptions ) ,
773- tool,
774- toolCallId : toolCall . id ,
775- onPartialOutput,
776- codeBaseIndexer : this . codeBaseIndexer ,
777- } ) ;
778- } ) ;
759+ on ( "tools/call" , async ( { data : { toolCall } } ) =>
760+ this . handleToolCall ( toolCall ) ,
761+ ) ;
779762
780763 on ( "isItemTooBig" , async ( { data : { item } } ) => {
781764 return this . isItemTooBig ( item ) ;
@@ -800,6 +783,45 @@ export class Core {
800783 } ) ;
801784 }
802785
786+ private async handleToolCall ( toolCall : ToolCall ) {
787+ const { config } = await this . configHandler . loadConfig ( ) ;
788+ if ( ! config ) {
789+ throw new Error ( "Config not loaded" ) ;
790+ }
791+
792+ const tool = config . tools . find (
793+ ( t ) => t . function . name === toolCall . function . name ,
794+ ) ;
795+
796+ if ( ! tool ) {
797+ throw new Error ( `Tool ${ toolCall . function . name } not found` ) ;
798+ }
799+
800+ if ( ! config . selectedModelByRole . chat ) {
801+ throw new Error ( "No chat model selected" ) ;
802+ }
803+
804+ // Define a callback for streaming output updates
805+ const onPartialOutput = ( params : {
806+ toolCallId : string ;
807+ contextItems : ContextItem [ ] ;
808+ } ) => {
809+ this . messenger . send ( "toolCallPartialOutput" , params ) ;
810+ } ;
811+
812+ return await callTool ( tool , toolCall , {
813+ config,
814+ ide : this . ide ,
815+ llm : config . selectedModelByRole . chat ,
816+ fetch : ( url , init ) =>
817+ fetchwithRequestOptions ( url , init , config . requestOptions ) ,
818+ tool,
819+ toolCallId : toolCall . id ,
820+ onPartialOutput,
821+ codeBaseIndexer : this . codeBaseIndexer ,
822+ } ) ;
823+ }
824+
803825 private async isItemTooBig ( item : ContextItemWithId ) {
804826 const { config } = await this . configHandler . loadConfig ( ) ;
805827 if ( ! config ) {
@@ -887,7 +909,12 @@ export class Core {
887909 uri . endsWith ( ".prompt" ) ||
888910 uri . endsWith ( SYSTEM_PROMPT_DOT_FILE ) ||
889911 ( uri . includes ( ".continue" ) && uri . endsWith ( ".yaml" ) ) ||
890- uri . endsWith ( RULES_MARKDOWN_FILENAME )
912+ uri . endsWith ( RULES_MARKDOWN_FILENAME ) ||
913+ BLOCK_TYPES . some (
914+ ( blockType ) =>
915+ uri . includes ( `.continue/${ blockType } ` ) ||
916+ uri . includes ( `.continue\\${ blockType } ` ) ,
917+ )
891918 ) {
892919 await this . configHandler . reloadConfig ( ) ;
893920 } else if (
0 commit comments