Skip to content

Refresh items for new Context Provider titles + MCP Resource Improvements #5017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/config/profile/doLoadConfig.ts
Original file line number Diff line number Diff line change
@@ -160,6 +160,7 @@ export default async function doLoadConfig(
const serverContextProvider = new MCPContextProvider({
submenuItems,
mcpId: server.id,
serverName: server.name,
});
newConfig.contextProviders.push(serverContextProvider);
}
11 changes: 11 additions & 0 deletions core/context/providers/MCPContextProvider.ts
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import { MCPManagerSingleton } from "../mcp";

interface MCPContextProviderOptions {
mcpId: string;
serverName: string;
submenuItems: ContextSubmenuItem[];
}

@@ -20,6 +21,16 @@ class MCPContextProvider extends BaseContextProvider {
description: "Model Context Protocol",
type: "submenu",
};
override get description(): ContextProviderDescription {
return {
title: `${MCPContextProvider.description.title}-${this.options["mcpId"]}`,
displayTitle: this.options["serverName"]
? `${this.options["serverName"]} resources`
: "MCP",
description: "Model Context Protocol",
type: "submenu",
};
}

static encodeMCPResourceId(mcpId: string, uri: string): string {
return JSON.stringify({ mcpId, uri });
20 changes: 14 additions & 6 deletions gui/src/context/SubmenuContextProviders.tsx
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@ export const SubmenuContextProvidersProvider = ({
}) => {
const ideMessenger = useContext(IdeMessengerContext);
const submenuContextProviders = useAppSelector(selectSubmenuContextProviders);
const lastProviders = useRef(submenuContextProviders);
const disableIndexing = useAppSelector(
(store) => store.config.config.disableIndexing,
);
@@ -356,15 +357,22 @@ export const SubmenuContextProvidersProvider = ({
);

// Reload all submenu items on the initial config load
// TODO - could refresh on any change
const initialLoad = useRef(false);
useEffect(() => {
if (!submenuContextProviders.length || initialLoad.current) {
if (!submenuContextProviders.length) {
return;
}
void loadSubmenuItems("all");
initialLoad.current = true;
}, [loadSubmenuItems, submenuContextProviders, initialLoad]);
// Refresh submenu items when new titles detected
const newTitles = submenuContextProviders
.filter(
(provider) =>
!lastProviders.current.find((p) => p.title === provider.title),
)
.map((provider) => provider.title);
if (newTitles.length > 0) {
loadSubmenuItems(newTitles);
}
lastProviders.current = submenuContextProviders;
}, [loadSubmenuItems, submenuContextProviders]);

return (
<SubmenuContextProvidersContext.Provider

Unchanged files with check annotations Beta

stopStatusBarLoading,
} from "./statusBar";
import type { IDE } from "core";

Check warning on line 26 in extensions/vscode/src/autocomplete/completionProvider.ts

GitHub Actions / vscode-checks

There should be at least one empty line between import groups
import { handleLLMError } from "../util/errorHandling";

Check warning on line 27 in extensions/vscode/src/autocomplete/completionProvider.ts

GitHub Actions / vscode-checks

`../util/errorHandling` import should occur before import of `../util/messages`
interface VsCodeCompletionInput {
document: vscode.TextDocument;
import * as vscode from "vscode";
import type { IDE, Range, RangeInFile, RangeInFileWithContents } from "core";
import type Parser from "web-tree-sitter";

Check warning on line 11 in extensions/vscode/src/autocomplete/lsp.ts

GitHub Actions / vscode-checks

There should be at least one empty line between import groups
import { GetLspDefinitionsFunction } from "core/autocomplete/types";

Check warning on line 12 in extensions/vscode/src/autocomplete/lsp.ts

GitHub Actions / vscode-checks

`core/autocomplete/types` import should occur before import of `core/autocomplete/util/ast`
import {

Check warning on line 13 in extensions/vscode/src/autocomplete/lsp.ts

GitHub Actions / vscode-checks

`core/autocomplete/snippets/types` import should occur before import of `core/autocomplete/util/ast`
AutocompleteCodeSnippet,
AutocompleteSnippetType,
} from "core/autocomplete/snippets/types";
import * as URI from "uri-js";

Check warning on line 17 in extensions/vscode/src/autocomplete/lsp.ts

GitHub Actions / vscode-checks

`uri-js` import should occur before import of `vscode`
type GotoProviderName =
| "vscode.executeDefinitionProvider"
setupStatusBar,
StatusBarStatus,
} from "./autocomplete/statusBar";
import { ContinueGUIWebviewViewProvider } from "./ContinueGUIWebviewViewProvider";

Check warning on line 30 in extensions/vscode/src/commands.ts

GitHub Actions / vscode-checks

There should be no empty line within import group
import { VerticalDiffManager } from "./diff/vertical/manager";
import EditDecorationManager from "./quickEdit/EditDecorationManager";
import { getMetaKeyLabel } from "./util/util";
import { VsCodeIde } from "./VsCodeIde";
import { LOCAL_DEV_DATA_VERSION } from "core/data/log";

Check warning on line 39 in extensions/vscode/src/commands.ts

GitHub Actions / vscode-checks

`core/data/log` import should occur before import of `core/indexing/walkDir`
import { isModelInstaller } from "core/llm";

Check warning on line 40 in extensions/vscode/src/commands.ts

GitHub Actions / vscode-checks

`core/llm` import should occur before import of `core/util/paths`
import { startLocalOllama } from "core/util/ollamaHelper";

Check warning on line 41 in extensions/vscode/src/commands.ts

GitHub Actions / vscode-checks

There should be at least one empty line between import groups
import type { VsCodeWebviewProtocol } from "./webviewProtocol";
let fullScreenPanel: vscode.WebviewPanel | undefined;