(options: ApiHandlerOptions)
| 67 | private currentRequestCancellation: vscode.CancellationTokenSource | null |
| 68 | |
| 69 | constructor(options: ApiHandlerOptions) { |
| 70 | super() |
| 71 | this.options = options |
| 72 | this.client = null |
| 73 | this.disposable = null |
| 74 | this.currentRequestCancellation = null |
| 75 | |
| 76 | try { |
| 77 | // Listen for model changes and reset client |
| 78 | this.disposable = vscode.workspace.onDidChangeConfiguration((event) => { |
| 79 | if (event.affectsConfiguration("lm")) { |
| 80 | try { |
| 81 | this.client = null |
| 82 | this.ensureCleanState() |
| 83 | } catch (error) { |
| 84 | console.error("Error during configuration change cleanup:", error) |
| 85 | } |
| 86 | } |
| 87 | }) |
| 88 | this.initializeClient() |
| 89 | } catch (error) { |
| 90 | // Ensure cleanup if constructor fails |
| 91 | this.dispose() |
| 92 | |
| 93 | throw new Error( |
| 94 | `Roo Code <Language Model API>: Failed to initialize handler: ${error instanceof Error ? error.message : "Unknown error"}`, |
| 95 | ) |
| 96 | } |
| 97 | } |
| 98 | /** |
| 99 | * Initializes the VS Code Language Model client. |
| 100 | * This method is called during the constructor to set up the client. |
nothing calls this directly
no test coverage detected