diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d585a5..7385f29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Extension recovers from an empty-then-configured activation without a window reload. Previously, if a user activated the extension before setting `tfvc.adoProject` (and without a `.vscode-tfvc/` folder), `activate()` early-returned without resolving a workspace root. After the user filled in settings, the config-change listener re-built the REST client but `root` stayed undefined, so `repo`/`scmProvider` were never created — every TFVC command then showed a misleading "Not configured" toast even though all settings were correct. The recovery now retries the root resolution from the config/PAT-change listener so the extension comes fully alive on the spot. + ## [0.4.1] ### Fixed diff --git a/src/extension.ts b/src/extension.ts index e29977a..79daa7b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -252,6 +252,21 @@ export async function activate(context: vscode.ExtensionContext): Promise // no visible cue. Surface the error as a warning toast pointing the // user at their settings. function reinitOrWarn(cause: string): void { + // Activation may have early-returned without resolving a workspace + // root (no .vscode-tfvc/ + no tfvc.adoProject at activation time). + // Now that the user has changed config or set a PAT, retry the + // root resolution so the extension can come fully alive without + // requiring a window reload — otherwise initRestClient builds the + // REST client but never creates `repo`/`scmProvider`, and any TFVC + // command shows a misleading "Not configured" toast. + if (!root) { + const tfvcRoots = findTfvcRoots(); + const folders = vscode.workspace.workspaceFolders; + root = tfvcRoots[0] ?? folders?.[0]?.uri.fsPath; + if (root) { + outputChannel.appendLine(`TFVC workspace root resolved on ${cause.toLowerCase()} change: ${root}`); + } + } initRestClient().catch(err => { logError(`${cause} re-init failed: ${err}`); const detail = err instanceof Error ? err.message : String(err);