From 61ad5a8eaa5d7515ed7f3ed24069c4edc39afeea Mon Sep 17 00:00:00 2001 From: Jan Scheffler Date: Tue, 28 Apr 2026 10:59:30 +0200 Subject: [PATCH] fix: recover workspace root on config/PAT change after empty activation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a user activates the extension before setting tfvc.adoProject (and without a .vscode-tfvc/ folder), activate() early-returns without resolving `root`. The config-change listener already re-runs initRestClient(), so the REST client comes alive on first config save — but `root` stays undefined, so doInitRestClient() bails at line 122 without creating `repo`/`scmProvider`. Every TFVC command then trips wrapSCM's `!scmProvider` check and shows the misleading "Not configured" toast even though every setting is correct. Symptom from a customer's output channel: No TFVC workspace detected (...). ADO REST client initialized for https://tfs.ieq-network.de//FiF ADO client ready but no workspace root — SCM features disabled until a TFVC workspace is opened. Fix: in reinitOrWarn(), before kicking off initRestClient(), retry the root resolution if it's still undefined. Mirrors the activation-time fallback (first .vscode-tfvc/ folder, else first workspace folder). The user's window reload workaround is no longer needed. Co-Authored-By: Claude Opus 4.7 (1M context) --- CHANGELOG.md | 3 +++ src/extension.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+) 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);