Compare commits

...

2 Commits

Author SHA1 Message Date
celestial-vault fa7cb98795 changeset 2025-08-03 16:17:02 -07:00
celestial-vault defdacc951 initialize cachService in controller constructor; remove authService as a class level variable on Controller 2025-08-03 16:16:13 -07:00
4 changed files with 21 additions and 25 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": patch
---
Fix login check on extension restart
+14 -7
View File
@@ -54,20 +54,30 @@ export class Controller {
workspaceTracker: WorkspaceTracker
mcpHub: McpHub
accountService: ClineAccountService
authService: AuthService
readonly cacheService: CacheService
constructor(
readonly context: vscode.ExtensionContext,
postMessage: (message: ExtensionMessage) => Thenable<boolean> | undefined,
id: string,
cacheService: CacheService,
) {
this.id = id
HostProvider.get().logToChannel("ClineProvider instantiated")
this.postMessage = postMessage
this.cacheService = cacheService
this.accountService = ClineAccountService.getInstance()
this.cacheService = new CacheService(context)
const authService = AuthService.getInstance(this)
// Initialize cache service asynchronously - critical for extension functionality
this.cacheService
.initialize()
.then(() => {
authService.restoreRefreshTokenAndRetrieveAuthInfo()
})
.catch((error) => {
console.error("CRITICAL: Failed to initialize CacheService - extension may not function properly:", error)
})
// Set up persistence error recovery
this.cacheService.onPersistenceError = async ({ error }: PersistenceErrorEvent) => {
@@ -95,9 +105,6 @@ export class Controller {
(msg) => this.postMessageToWebview(msg),
this.context.extension?.packageJSON?.version ?? "1.0.0",
)
this.accountService = ClineAccountService.getInstance()
this.authService = AuthService.getInstance(this)
this.authService.restoreRefreshTokenAndRetrieveAuthInfo()
// Clean up legacy checkpoints
cleanupLegacyCheckpoints(this.context.globalStorageUri.fsPath).catch((error) => {
@@ -344,7 +351,7 @@ export class Controller {
async handleAuthCallback(customToken: string, provider: string | null = null) {
try {
await this.authService.handleAuthCallback(customToken, provider ? provider : "google")
await AuthService.getInstance(this).handleAuthCallback(customToken, provider ? provider : "google")
const clineProvider: ApiProvider = "cline"
+1 -15
View File
@@ -22,7 +22,6 @@ export abstract class WebviewProvider {
protected disposables: vscode.Disposable[] = []
controller: Controller
private clientId: string
private cacheService: CacheService
constructor(
readonly context: vscode.ExtensionContext,
@@ -33,21 +32,8 @@ export abstract class WebviewProvider {
this.clientId = uuidv4()
WebviewProvider.clientIdMap.set(this, this.clientId)
// Create and initialize cache service
this.cacheService = new CacheService(context)
// Create controller with cache service
this.controller = new Controller(
context,
(message) => this.postMessageToWebview(message),
this.clientId,
this.cacheService,
)
// Initialize cache service asynchronously - critical for extension functionality
this.cacheService.initialize().catch((error) => {
console.error("CRITICAL: Failed to initialize CacheService - extension may not function properly:", error)
})
this.controller = new Controller(context, (message) => this.postMessageToWebview(message), this.clientId)
}
// Add a method to get the client ID
+1 -3
View File
@@ -24,11 +24,9 @@ async function main() {
activate(extensionContext)
// Create and initialize cache service
const cacheService = new CacheService(extensionContext)
await cacheService.initialize()
// Create controller with cache service
const controller = new Controller(extensionContext, postMessage, uuidv4(), cacheService)
const controller = new Controller(extensionContext, postMessage, uuidv4())
startProtobusService(controller)
AuthHandler.getInstance().setEnabled(true)