Skip to content

Commit d4a370e

Browse files
committed
fix: handle missing globalStorageUri in test environment
- Add safety check for globalStorageUri before initializing TaskHistoryCleanupService - Prevents test failures when globalStorageUri is not mocked in test context
1 parent 826a714 commit d4a370e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,13 @@ export class ClineProvider
260260
}
261261

262262
// Initialize task history cleanup service
263-
this.taskHistoryCleanupService = new TaskHistoryCleanupService(
264-
this.context.globalStorageUri.fsPath,
265-
this.log.bind(this),
266-
)
263+
// Only initialize if globalStorageUri is available (not in test environment)
264+
if (this.context.globalStorageUri) {
265+
this.taskHistoryCleanupService = new TaskHistoryCleanupService(
266+
this.context.globalStorageUri.fsPath,
267+
this.log.bind(this),
268+
)
269+
}
267270
}
268271

269272
/**
@@ -2195,6 +2198,7 @@ export class ClineProvider
21952198
* Triggers automatic cleanup of task history if configured
21962199
*/
21972200
private async triggerAutoCleanup(): Promise<void> {
2201+
// Skip if cleanup service is not initialized (e.g., in test environment)
21982202
if (!this.taskHistoryCleanupService) {
21992203
return
22002204
}

0 commit comments

Comments
 (0)