Compare commits

...
Author SHA1 Message Date
celestial-vault d195ace8c9 remove authservice as controller class variable 2025-09-30 14:11:05 -07:00
3 changed files with 24 additions and 10 deletions
@@ -1,6 +1,7 @@
import { RecordingResult } from "@shared/proto/cline/dictation"
import * as os from "os"
import { HostProvider } from "@/hosts/host-provider"
import { AuthService } from "@/services/auth/AuthService"
import { audioRecordingService } from "@/services/dictation/AudioRecordingService"
import { telemetryService } from "@/services/telemetry"
import { AUDIO_PROGRAM_CONFIG } from "@/shared/audioProgramConstants"
@@ -68,7 +69,7 @@ async function handleMissingDependency(
/**
* Handles sign-in errors for dictation
*/
async function handleSignInError(controller: Controller, errorMessage: string): Promise<void> {
async function handleSignInError(errorMessage: string): Promise<void> {
const signInAction = "Sign in to Cline"
const action = await HostProvider.window.showMessage({
type: ShowMessageType.ERROR,
@@ -77,7 +78,7 @@ async function handleSignInError(controller: Controller, errorMessage: string):
})
if (action.selectedOption === signInAction) {
await controller.authService.createAuthRequest()
await AuthService.getInstance().createAuthRequest()
}
}
@@ -112,7 +113,7 @@ export const startRecording = async (controller: Controller): Promise<RecordingR
try {
// Verify user authentication
const userInfo = controller.authService.getInfo()
const userInfo = AuthService.getInstance().getInfo()
if (!userInfo?.user?.uid) {
throw new Error("Please sign in to your Cline Account to use Dictation.")
}
@@ -149,7 +150,7 @@ export const startRecording = async (controller: Controller): Promise<RecordingR
// Handle different error types
if (errorMessage.includes("sign in")) {
// Don't await - show dialog asynchronously so frontend gets immediate response
handleSignInError(controller, errorMessage)
handleSignInError(errorMessage)
} else {
// Don't await - show dialog asynchronously so frontend gets immediate response
showGenericError(errorMessage)
+6 -5
View File
@@ -57,7 +57,6 @@ export class Controller {
mcpHub: McpHub
accountService: ClineAccountService
authService: AuthService
ocaAuthService: OcaAuthService
readonly stateManager: StateManager
@@ -68,7 +67,6 @@ export class Controller {
PromptRegistry.getInstance() // Ensure prompts and tools are registered
HostProvider.get().logToChannel("ClineProvider instantiated")
this.stateManager = new StateManager(context)
this.authService = AuthService.getInstance(this)
this.ocaAuthService = OcaAuthService.initialize(this)
this.accountService = ClineAccountService.getInstance()
@@ -76,7 +74,8 @@ export class Controller {
this.stateManager
.initialize()
.then(() => {
this.authService.restoreRefreshTokenAndRetrieveAuthInfo()
const authService = AuthService.getInstance(this)
authService.restoreRefreshTokenAndRetrieveAuthInfo()
})
.catch((error) => {
console.error(
@@ -353,7 +352,8 @@ export class Controller {
async handleAuthCallback(customToken: string, provider: string | null = null) {
try {
await this.authService.handleAuthCallback(customToken, provider ? provider : "google")
const authService = AuthService.getInstance(this)
await authService.handleAuthCallback(customToken, provider ? provider : "google")
const clineProvider: ApiProvider = "cline"
@@ -681,6 +681,7 @@ export class Controller {
}
async getStateToPostToWebview(): Promise<ExtensionState> {
const authService = AuthService.getInstance(this)
// Get API configuration from cache for immediate access
const apiConfiguration = this.stateManager.getApiConfiguration()
const lastShownAnnouncementId = this.stateManager.getGlobalStateKey("lastShownAnnouncementId")
@@ -708,7 +709,7 @@ export class Controller {
const defaultTerminalProfile = this.stateManager.getGlobalSettingsKey("defaultTerminalProfile")
const isNewUser = this.stateManager.getGlobalStateKey("isNewUser")
const welcomeViewCompleted = Boolean(
this.stateManager.getGlobalStateKey("welcomeViewCompleted") || this.authService.getInfo()?.user?.uid,
this.stateManager.getGlobalStateKey("welcomeViewCompleted") || authService.getInfo()?.user?.uid,
)
const customPrompt = this.stateManager.getGlobalSettingsKey("customPrompt")
const mcpResponsesCollapsed = this.stateManager.getGlobalStateKey("mcpResponsesCollapsed")
@@ -3,17 +3,29 @@ import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react"
import { memo, useEffect, useState } from "react"
import ClineLogoWhite from "@/assets/ClineLogoWhite"
import ApiOptions from "@/components/settings/ApiOptions"
import { useClineAuth } from "@/context/ClineAuthContext"
import { useExtensionState } from "@/context/ExtensionStateContext"
import { AccountServiceClient, StateServiceClient } from "@/services/grpc-client"
import { validateApiConfiguration } from "@/utils/validate"
const WelcomeView = memo(() => {
const { apiConfiguration, mode } = useExtensionState()
const { apiConfiguration, mode, welcomeViewCompleted } = useExtensionState()
const [apiErrorMessage, setApiErrorMessage] = useState<string | undefined>(undefined)
const [showApiOptions, setShowApiOptions] = useState(false)
const { clineUser } = useClineAuth()
const disableLetsGoButton = apiErrorMessage != null
useEffect(() => {
if (clineUser?.uid && !welcomeViewCompleted) {
try {
StateServiceClient.setWelcomeViewCompleted(BooleanRequest.create({ value: true }))
} catch (error) {
console.error("Failed to update API configuration or complete welcome view:", error)
}
}
}, [clineUser])
const handleLogin = () => {
AccountServiceClient.accountLoginClicked(EmptyRequest.create()).catch((err) =>
console.error("Failed to get login URL:", err),