Skip to content
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

DEV2-4433 chat api usage #1397

Merged
merged 6 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/enterprise/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ export const UPDATE_PREFIX = "/update/vscode";
export const EXTENSION_SUBSTRING = "tabnine-vscode";

export const EXTENSION_ID = `tabnine-vscode-self-hosted-updater`;

export const TABNINE_ENTERPISE_CONTEXT_KEY = "tabnine.enterprise";
27 changes: 17 additions & 10 deletions src/enterprise/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ import {
TABNINE_HOST_CONFIGURATION,
EXTENSION_ID,
OPEN_SETTINGS_COMMAND,
TABNINE_ENTERPISE_CONTEXT_KEY,
} from "./consts";
import TabnineAuthenticationProvider from "../authentication/TabnineAuthenticationProvider";
import {
BRAND_NAME,
CONFIG_COMMAND,
ENTERPRISE_BRAND_NAME,
IS_SELF_HOSTED_CONTEXT_KEY,
} from "../globals/consts";
import { StatusBar } from "./statusBar";
import { isHealthyServer } from "./update/isHealthyServer";
Expand All @@ -53,15 +53,15 @@ import { emptyStateAuthenticateView } from "../tabnineChatWidget/webviews/emptyS
import { emptyStateNotPartOfATeamView } from "../tabnineChatWidget/webviews/emptyStateNotPartOfATeamView";
import BINARY_STATE from "../binary/binaryStateSingleton";
import { activeTextEditorState } from "../activeTextEditorState";

const TABNINE_ENTERPISE_CONTEXT_KEY = "tabnine.enterprise";
import { ChatAPI } from "../tabnineChatWidget/ChatApi";
import ChatViewProvider from "../tabnineChatWidget/ChatViewProvider";

export async function activate(
context: vscode.ExtensionContext
): Promise<void> {
Logger.init(context);
setTabnineExtensionContext(context);
context.subscriptions.push(await setEnterpriseContext(context));
context.subscriptions.push(await setEnterpriseContext());
context.subscriptions.push(new WorkspaceUpdater());
context.subscriptions.push(BINARY_STATE);
context.subscriptions.push(activeTextEditorState);
Expand Down Expand Up @@ -129,7 +129,18 @@ export async function activate(
const chatEnabledState = new SelfHostedChatEnabledState(context);
context.subscriptions.push(chatEnabledState);

registerTabnineChatWidgetWebview(context, chatEnabledState, server);
registerTabnineChatWidgetWebview(
context,
chatEnabledState,
new ChatViewProvider(
context,
new ChatAPI(context, {
serverUrl: server,
isSelfHosted: true,
isTelemetryEnabled: false,
})
)
);

await initBinary([
"--no_bootstrap",
Expand All @@ -143,18 +154,14 @@ export async function activate(
context.subscriptions.push(await registerInlineProvider());
}

async function setEnterpriseContext(
context: vscode.ExtensionContext
): Promise<vscode.Disposable> {
async function setEnterpriseContext(): Promise<vscode.Disposable> {
await vscode.commands.executeCommand(
"setContext",
TABNINE_ENTERPISE_CONTEXT_KEY,
true
);
await context.workspaceState.update(IS_SELF_HOSTED_CONTEXT_KEY, true);

return new vscode.Disposable(() => {
void context.workspaceState.update(IS_SELF_HOSTED_CONTEXT_KEY, undefined);
void vscode.commands.executeCommand(
"setContext",
TABNINE_ENTERPISE_CONTEXT_KEY,
Expand Down
16 changes: 13 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ import { WorkspaceUpdater } from "./WorkspaceUpdater";
import SaasChatEnabledState from "./tabnineChatWidget/SaasChatEnabledState";
import BINARY_STATE from "./binary/binaryStateSingleton";
import EvalSaasChatEnabledState from "./tabnineChatWidget/EvalSaasChatEnabledState";
import { ChatAPI } from "./tabnineChatWidget/ChatApi";
import ChatViewProvider from "./tabnineChatWidget/ChatViewProvider";

export async function activate(
context: vscode.ExtensionContext
Expand Down Expand Up @@ -152,9 +154,17 @@ async function backgroundInit(context: vscode.ExtensionContext) {
registerTabnineChatWidgetWebview(
context,
chatEnabledState,
context.extensionMode === vscode.ExtensionMode.Test
? process.env.CHAT_SERVER_URL
: undefined
new ChatViewProvider(
context,
new ChatAPI(context, {
serverUrl:
context.extensionMode === vscode.ExtensionMode.Test
? process.env.CHAT_SERVER_URL
: undefined,
isSelfHosted: false,
isTelemetryEnabled: isCapabilityEnabled(Capability.ALPHA_CAPABILITY),
})
)
);
pollNotifications(context);
pollStatuses(context);
Expand Down
1 change: 0 additions & 1 deletion src/globals/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,5 @@ export enum SuggestionTrigger {
}

export const TLS_CONFIG_MIN_SUPPORTED_VERSION = "4.22.0";
export const IS_SELF_HOSTED_CONTEXT_KEY = "tabnine.isSelfHosted";
export const CONFIG_COMMAND = "TabNine::config";
export const EXTENSION_ID = "TabNine.tabnine-vscode";
Loading
Loading