diff --git a/.changeset/pink-deers-burn.md b/.changeset/pink-deers-burn.md new file mode 100644 index 0000000000..f018cf442c --- /dev/null +++ b/.changeset/pink-deers-burn.md @@ -0,0 +1,5 @@ +--- +"claude-dev": minor +--- + +migrate accountLogoutClicked to protobus diff --git a/proto/account.proto b/proto/account.proto index 21bf064ee8..31cb51766e 100644 --- a/proto/account.proto +++ b/proto/account.proto @@ -12,4 +12,8 @@ service AccountService { // Generates a secure nonce for state validation, stores it in secrets, // and opens the authentication URL in the external browser. rpc accountLoginClicked(EmptyRequest) returns (String); + + // Handles the user clicking the logout button in the UI. + // Clears API keys and user state. + rpc accountLogoutClicked(EmptyRequest) returns (Empty); } diff --git a/src/core/controller/account/accountLogoutClicked.ts b/src/core/controller/account/accountLogoutClicked.ts new file mode 100644 index 0000000000..787ff4a108 --- /dev/null +++ b/src/core/controller/account/accountLogoutClicked.ts @@ -0,0 +1,14 @@ +import type { Empty } from "../../../shared/proto/common" +import type { EmptyRequest } from "../../../shared/proto/common" +import type { Controller } from "../index" + +/** + * Handles the account logout action + * @param controller The controller instance + * @param _request The empty request object + * @returns Empty response + */ +export async function accountLogoutClicked(controller: Controller, _request: EmptyRequest): Promise { + await controller.handleSignOut() + return {} +} diff --git a/src/core/controller/account/methods.ts b/src/core/controller/account/methods.ts index 0d79b0df86..287c3fe61c 100644 --- a/src/core/controller/account/methods.ts +++ b/src/core/controller/account/methods.ts @@ -4,9 +4,11 @@ // Import all method implementations import { registerMethod } from "./index" import { accountLoginClicked } from "./accountLoginClicked" +import { accountLogoutClicked } from "./accountLogoutClicked" // Register all account service methods export function registerAllMethods(): void { // Register each method with the registry registerMethod("accountLoginClicked", accountLoginClicked) + registerMethod("accountLogoutClicked", accountLogoutClicked) } diff --git a/src/core/controller/index.ts b/src/core/controller/index.ts index 078f8f4dfc..3f27de4512 100644 --- a/src/core/controller/index.ts +++ b/src/core/controller/index.ts @@ -341,10 +341,6 @@ export class Controller { case "openMention": openMention(message.text) break - case "accountLogoutClicked": { - await this.handleSignOut() - break - } case "showAccountViewClicked": { await this.postMessageToWebview({ type: "action", action: "accountButtonClicked" }) break diff --git a/src/shared/WebviewMessage.ts b/src/shared/WebviewMessage.ts index 75f6813bec..5867ba4964 100644 --- a/src/shared/WebviewMessage.ts +++ b/src/shared/WebviewMessage.ts @@ -26,7 +26,6 @@ export interface WebviewMessage { | "openExtensionSettings" | "requestVsCodeLmModels" | "toggleToolAutoApprove" - | "accountLogoutClicked" | "showAccountViewClicked" | "authStateChanged" | "authCallback" diff --git a/src/shared/proto/account.ts b/src/shared/proto/account.ts index 5a4af7e984..471e546fbf 100644 --- a/src/shared/proto/account.ts +++ b/src/shared/proto/account.ts @@ -5,7 +5,7 @@ // source: account.proto /* eslint-disable */ -import { EmptyRequest, String } from "./common" +import { Empty, EmptyRequest, String } from "./common" export const protobufPackage = "cline" @@ -28,5 +28,17 @@ export const AccountServiceDefinition = { responseStream: false, options: {}, }, + /** + * Handles the user clicking the logout button in the UI. + * Clears API keys and user state. + */ + accountLogoutClicked: { + name: "accountLogoutClicked", + requestType: EmptyRequest, + requestStream: false, + responseType: Empty, + responseStream: false, + options: {}, + }, }, } as const diff --git a/src/standalone/server-setup.ts b/src/standalone/server-setup.ts index 363dec7f55..1daefab878 100644 --- a/src/standalone/server-setup.ts +++ b/src/standalone/server-setup.ts @@ -6,6 +6,7 @@ import { GrpcHandlerWrapper, GrpcStreamingResponseHandlerWrapper } from "./grpc- // Account Service import { accountLoginClicked } from "../core/controller/account/accountLoginClicked" +import { accountLogoutClicked } from "../core/controller/account/accountLogoutClicked" // Browser Service import { getBrowserConnectionInfo } from "../core/controller/browser/getBrowserConnectionInfo" @@ -83,6 +84,7 @@ export function addServices( // Account Service server.addService(proto.cline.AccountService.service, { accountLoginClicked: wrapper(accountLoginClicked, controller), + accountLogoutClicked: wrapper(accountLogoutClicked, controller), }) // Browser Service diff --git a/webview-ui/src/components/account/AccountView.tsx b/webview-ui/src/components/account/AccountView.tsx index 1483132b63..c29536de16 100644 --- a/webview-ui/src/components/account/AccountView.tsx +++ b/webview-ui/src/components/account/AccountView.tsx @@ -76,8 +76,8 @@ export const ClineAccountView = () => { } const handleLogout = () => { - // First notify extension to clear API keys and state - vscode.postMessage({ type: "accountLogoutClicked" }) + // Use gRPC client to notify extension to clear API keys and state + AccountServiceClient.accountLogoutClicked(EmptyRequest.create()).catch((err) => console.error("Failed to logout:", err)) // Then sign out of Firebase handleSignOut() } diff --git a/webview-ui/src/components/settings/ClineAccountInfoCard.tsx b/webview-ui/src/components/settings/ClineAccountInfoCard.tsx index b5999ebb54..6199c132fb 100644 --- a/webview-ui/src/components/settings/ClineAccountInfoCard.tsx +++ b/webview-ui/src/components/settings/ClineAccountInfoCard.tsx @@ -17,13 +17,6 @@ export const ClineAccountInfoCard = () => { ) } - const handleLogout = () => { - // First notify extension to clear API keys and state - vscode.postMessage({ type: "accountLogoutClicked" }) - // Then sign out of Firebase - handleSignOut() - } - const handleShowAccount = () => { vscode.postMessage({ type: "showAccountViewClicked" }) } @@ -35,38 +28,6 @@ export const ClineAccountInfoCard = () => { View Billing & Usage ) : ( - //
- //
- // {user.photoURL ? ( - // Profile - // ) : ( - //
- // {user.displayName?.[0] || user.email?.[0] || "?"} - //
- // )} - //
- // {user.displayName && ( - //
- // {user.displayName} - //
- // )} - // {user.email && ( - //
- // {user.email} - //
- // )} - //
- - // - // Log out - // - //
- //
- //
- //
Sign Up with Cline