* Initialize the task API config name from the provider state. * This method handles async initialization with proper error handling. * * ## Flow * 1. Attempts to fetch the current API config name from provider state * 2. Sets `_taskApiConfigName` to the fetched name or "default" if unavai
(provider: ClineProvider)
| 667 | * @returns Promise that resolves when initialization is complete |
| 668 | */ |
| 669 | private async initializeTaskApiConfigName(provider: ClineProvider): Promise<void> { |
| 670 | try { |
| 671 | const state = await provider.getState() |
| 672 | |
| 673 | // Avoid clobbering a newer value that may have been set while awaiting provider state |
| 674 | // (e.g., user switches provider profile immediately after task creation). |
| 675 | if (this._taskApiConfigName === undefined) { |
| 676 | this._taskApiConfigName = state?.currentApiConfigName ?? "default" |
| 677 | } |
| 678 | } catch (error) { |
| 679 | // If there's an error getting state, use the default profile (unless a newer value was set). |
| 680 | if (this._taskApiConfigName === undefined) { |
| 681 | this._taskApiConfigName = "default" |
| 682 | } |
| 683 | // Use the provider's log method for better error visibility |
| 684 | const errorMessage = `Failed to initialize task API config name: ${error instanceof Error ? error.message : String(error)}` |
| 685 | provider.log(errorMessage) |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | /** |
| 690 | * Sets up a listener for provider profile changes. |
no test coverage detected