Skip to content

Commit

Permalink
enable continue features only when extension is active
Browse files Browse the repository at this point in the history
  • Loading branch information
ajshedivy committed Oct 31, 2024
1 parent c7c2b8f commit a10a936
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -875,11 +875,6 @@
"group": "navigation@1",
"when": "view == jobManager"
},
{
"command": "vscode-db2i.jobManager.continue",
"group": "navigation@1",
"when": "view == jobManager"
},
{
"command": "vscode-db2i.jobManager.defaultSelfSettings",
"group": "navigation",
Expand Down Expand Up @@ -1093,7 +1088,7 @@
},
{
"command": "vscode-db2i.self.explainSelf",
"when": "view == vscode-db2i.self.nodes && viewItem == selfCodeNode",
"when": "view == vscode-db2i.self.nodes && viewItem == selfCodeNode && continueExtensionActive",
"group": "navigation"
}
],
Expand Down
15 changes: 13 additions & 2 deletions src/aiProviders/continue/continueContextProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
} from "../../..";
import { DB2_SELF_PROMPT, DB2_SYSTEM_PROMPT } from "./prompts";

export let isContinueActive = false;

const db2ContextProviderDesc: ContextProviderDescription = {
title: "db2i",
displayTitle: "Db2i",
Expand Down Expand Up @@ -176,6 +178,15 @@ export async function registerContinueProvider() {
const provider = new db2ContextProvider();
const continueID = `Continue.continue`;
const continueEx = vscode.extensions.getExtension(continueID);
const continueAPI = continueEx?.exports;
continueAPI?.registerCustomContextProvider(provider);
if (continueEx) {
if (!continueEx.isActive) {
await continueEx.activate();
}

isContinueActive = true;
const continueAPI = continueEx?.exports;
continueAPI?.registerCustomContextProvider(provider);
vscode.commands.executeCommand('setContext', 'continueExtensionActive', true);
vscode.window.showInformationMessage(`@Db2i context provider enabled in Continue!`);
}
}
2 changes: 0 additions & 2 deletions src/views/jobManager/jobManagerView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import { displayJobLog } from "./jobLog";
import { SelfValue, selfCodesMap } from "./selfCodes/nodes";
import { SelfCodesQuickPickItem } from "./selfCodes/selfCodesBrowser";
import { updateStatusBar } from "./statusBar";
import { selfCodesResultsView } from "./selfCodes/selfCodesResultsView";
import { setCancelButtonVisibility } from "../results";
import { registerContinueProvider } from "../../aiProviders/continue/continueContextProvider";
import { JDBCOptions } from "@ibm/mapepire-js/dist/src/types";

const selectJobCommand = `vscode-db2i.jobManager.selectJob`;
Expand Down
3 changes: 2 additions & 1 deletion src/views/jobManager/selfCodes/selfCodesResultsView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { SQLExample } from "../../examples";
import { JobInfo } from "../../../connection/manager";
import { OldSQLJob } from "../../../connection/sqlJob";
import { JobLogEntry } from "../../../connection/types";
import { isContinueActive } from "../../../aiProviders/continue/continueContextProvider";

type ChangeTreeDataEventType = SelfCodeTreeItem | undefined | null | void;

Expand Down Expand Up @@ -70,7 +71,7 @@ export class selfCodesResultsView implements TreeDataProvider<any> {
}
}),
vscode.commands.registerCommand(`vscode-db2i.self.explainSelf`, async (item: SelfCodeTreeItem) => {
if (item && item.error) {
if (item && item.error && isContinueActive) {
const jsonData = JSON.stringify(item.error, null, 2);
const document = await vscode.workspace.openTextDocument({
content: jsonData,
Expand Down

0 comments on commit a10a936

Please sign in to comment.