mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 16:30:27 +00:00
Introduce a new AbortService to centralize cancellation logic across all async operations, replacing scattered AbortSignal parameters with a unified singleton service. This improves maintainability and provides consistent cancellation behavior throughout the application. Key changes: - Add AbortService for centralized abort signal management with automatic cleanup - Refactor all AI providers (Claude, Gemini, OpenAI) to use AbortService instead of passing AbortSignal parameters - Update streaming operations to use centralized abort handling - Add CancellationIndicator component to show visual feedback during operation cancellation - Rename ChatAreaThought to ThoughtIndicator for better semantic clarity - Add Environment enum for consistent environment detection - Enhance ChatService lifecycle with proper cancellation state management - Remove scattered abort-related UI selectors and error messages in favor of dedicated indicator - Add safeContinue() factory method to ConversationContent for internal continuations - Update all tests to reflect new abort handling architecture This change simplifies the API surface by removing AbortSignal parameters from method signatures while improving the user experience with clearer cancellation feedback.
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
/**
|
|
* Test setup file - runs before all tests
|
|
*/
|
|
|
|
import { afterEach, vi } from 'vitest';
|
|
|
|
// Mock global window if needed
|
|
if (typeof global.window === 'undefined') {
|
|
global.window = {} as any;
|
|
}
|
|
|
|
// Mock Obsidian's Component class
|
|
vi.mock('obsidian', async () => {
|
|
const actual = await vi.importActual('obsidian');
|
|
return {
|
|
...actual,
|
|
Component: class Component {
|
|
public load() {}
|
|
public onload() {}
|
|
public unload() {}
|
|
public onunload() {}
|
|
public addChild<T extends Component>(component: T): T {
|
|
return component;
|
|
}
|
|
public removeChild<T extends Component>(component: T): T {
|
|
return component;
|
|
}
|
|
public register(_cb: () => any): void {}
|
|
public registerEvent(_eventRef: any): void {}
|
|
public registerDomEvent(_el: any, _type: any, _callback: any, _options?: any): void {}
|
|
public registerInterval(id: number): number {
|
|
return id;
|
|
}
|
|
}
|
|
};
|
|
});
|
|
|
|
// Add Obsidian's .empty() method to HTMLElement prototype for testing
|
|
if (typeof HTMLElement !== 'undefined') {
|
|
HTMLElement.prototype.empty = function() {
|
|
while (this.firstChild) {
|
|
this.removeChild(this.firstChild);
|
|
}
|
|
};
|
|
}
|
|
|
|
// Clean up after each test
|
|
afterEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|