diff --git a/package.json b/package.json index c9642df..7b5015f 100644 --- a/package.json +++ b/package.json @@ -256,11 +256,6 @@ "view": "workbench.panel.chat.view.copilot", "contents": "$(loading~spin) Please wait while Flexpilot is getting activated", "when": "!flexpilot:isError && !flexpilot:isLoaded" - }, - { - "view": "workbench.panel.chat.view.copilot", - "contents": "Sign in with GitHub to use Flexpilot, your AI pair programmer.\n[Sign In](command:flexpilot.github.signin)", - "when": "!flexpilot:isError && flexpilot:isLoaded && !flexpilot:isLoggedIn" } ], "commands": [ @@ -373,4 +368,4 @@ "engines": { "vscode": "1.95.x" } -} +} \ No newline at end of file diff --git a/src/commands/github-sign-in.ts b/src/commands/github-sign-in.ts deleted file mode 100644 index 8930f3a..0000000 --- a/src/commands/github-sign-in.ts +++ /dev/null @@ -1,93 +0,0 @@ -import * as vscode from "vscode"; -import { logger } from "../logger"; -import { storage } from "../storage"; - -/** - * GithubSignInCommand class manages the GitHub sign-in functionality. - * It implements the Singleton pattern to ensure a single instance across the application. - */ -export class GithubSignInCommand { - private static instance: GithubSignInCommand; - - /** - * Private constructor to prevent direct instantiation. - * Registers the command and initializes the disposable. - */ - private constructor(extensionContext = storage.getContext()) { - // Register the command - extensionContext.subscriptions.push( - vscode.commands.registerCommand( - "flexpilot.github.signin", - this.handler.bind(this), - ), - ); - logger.info("GithubSignInCommand instance created"); - } - - /** - * Gets the singleton instance of GithubSignInCommand. - * @returns {GithubSignInCommand} The singleton instance. - */ - public static register() { - if (!GithubSignInCommand.instance) { - GithubSignInCommand.instance = new GithubSignInCommand(); - logger.debug("New GithubSignInCommand instance created"); - } - } - - /** - * Handles the GitHub sign-in process. - * Prompts for GitHub star support if not previously set, then initiates the sign-in. - */ - public async handler(): Promise { - try { - logger.info("Handling `GithubSignInCommand`"); - // Check if the user has already accepted GitHub support - const githubSupportStatus = storage.get("github.support"); - - if (!githubSupportStatus) { - const shouldSupport = await this.promptForGithubSupport(); - logger.info( - `User opted to ${ - shouldSupport ? "support" : "not support" - } the project with a GitHub star`, - ); - await storage.set("github.support", shouldSupport); - } - - await vscode.authentication.getSession("github", ["public_repo"], { - createIfNone: true, - }); - - // Set the context to indicate successful sign-in for walkthroughs - await vscode.commands.executeCommand( - "setContext", - "flexpilot:walkthroughSignin", - true, - ); - - logger.notifyInfo("Successfully signed in with GitHub"); - } catch (error) { - logger.error(error as Error); - logger.notifyError("Error in `Github Sign In` command"); - } - } - - /** - * Prompts the user to support the project with a GitHub star. - * @returns {Promise} True if the user agrees to support, false otherwise. - */ - private async promptForGithubSupport(): Promise { - const selectedOption = await vscode.window.showInformationMessage( - "Flexpilot: Support Us!", - { - modal: true, - detail: - "Help our open-source project stay alive. We'll auto-star on GitHub when you sign in. No extra steps!", - }, - "Proceed to Login", - "No, I don't support", - ); - return !selectedOption || selectedOption === "Proceed to Login"; - } -} diff --git a/src/inline-chat.ts b/src/inline-chat.ts index 7646031..f88c4d8 100644 --- a/src/inline-chat.ts +++ b/src/inline-chat.ts @@ -14,7 +14,7 @@ import { getEol } from "./utilities"; class InlineChatParticipant { private static instance: InlineChatParticipant | null = null; private readonly chatParticipant: vscode.ChatParticipant; - private readonly githubSession: vscode.AuthenticationSession; + // private readonly githubSession: vscode.AuthenticationSession; /** * Private constructor to prevent direct instantiation. @@ -28,14 +28,11 @@ class InlineChatParticipant { ); // Get the GitHub session - this.githubSession = storage.session.get(); + // this.githubSession = storage.session.get(); // Set up requester information this.chatParticipant.requester = { - name: this.githubSession.account.label, - icon: vscode.Uri.parse( - `https://avatars.githubusercontent.com/u/${this.githubSession.account.id}`, - ), + name: "anonymous", }; // Set chat participant icon diff --git a/src/lazy-load.ts b/src/lazy-load.ts index e3a2484..9d53192 100644 --- a/src/lazy-load.ts +++ b/src/lazy-load.ts @@ -1,6 +1,5 @@ import { CommitMessageCommand } from "./commands/commit-message"; import { ConfigureModelCommand } from "./commands/configure-model"; -import { GithubSignInCommand } from "./commands/github-sign-in"; import { StatusIconMenuCommand } from "./commands/status-icon-menu"; import { events } from "./events"; import { logger } from "./logger"; @@ -31,7 +30,6 @@ export const activate = async () => { // Register the commands StatusIconMenuCommand.register(); CommitMessageCommand.register(); - GithubSignInCommand.register(); ConfigureModelCommand.register(); // Handle the session change diff --git a/src/panel-chat.ts b/src/panel-chat.ts index 3b61739..7b95ec0 100644 --- a/src/panel-chat.ts +++ b/src/panel-chat.ts @@ -14,7 +14,7 @@ import { VariablesManager } from "./variables"; class PanelChatParticipant { private static instance: PanelChatParticipant | null = null; private readonly chatParticipant: vscode.ChatParticipant; - private readonly githubSession: vscode.AuthenticationSession; + // private readonly githubSession: vscode.AuthenticationSession; /** * Private constructor to prevent direct instantiation. @@ -22,7 +22,7 @@ class PanelChatParticipant { */ private constructor() { // Get the GitHub session - this.githubSession = storage.session.get(); + // this.githubSession = storage.session.get(); // Create the chat participant this.chatParticipant = vscode.chat.createChatParticipant( @@ -63,10 +63,10 @@ class PanelChatParticipant { // Set up requester information this.chatParticipant.requester = { - name: this.githubSession.account.label, - icon: vscode.Uri.parse( - `https://avatars.githubusercontent.com/u/${this.githubSession.account.id}`, - ), + name: "anonymous", + // icon: vscode.Uri.parse( + // `https://avatars.githubusercontent.com/u/${this.githubSession.account.id}`, + // ), }; // Set up help text variables prefix @@ -219,9 +219,7 @@ class PanelChatParticipant { return { icon: new vscode.ThemeIcon("flexpilot-default"), title: "Ask Flexpilot", - message: PanelChatPrompt.getWelcomeMessage( - this.githubSession.account.label, - ), + message: PanelChatPrompt.getWelcomeMessage("anonymous"), }; } diff --git a/src/session.ts b/src/session.ts index ff0984b..9f6a597 100644 --- a/src/session.ts +++ b/src/session.ts @@ -30,13 +30,6 @@ export class SessionManager extends vscode.Disposable { // Register the session manager extensionContext.subscriptions.push(this); - // Handle the session change - this.disposables.push( - vscode.authentication.onDidChangeSessions(() => - this.handleSessionChange(), - ), - ); - // Initialize the session manager logger.info("Session manager initialized"); } @@ -47,7 +40,8 @@ export class SessionManager extends vscode.Disposable { public static async register() { if (!SessionManager.instance) { SessionManager.instance = new SessionManager(); - SessionManager.instance.handleSessionChange(); + SessionManager.instance.registerSessionFeatures(); + // SessionManager.instance.handleSessionChange(); logger.debug("New SessionManager instance created"); } }