Skip to content

fix: recover workspace root on config/PAT change after empty activation - #41

Merged
jschfflr merged 1 commit into
mainfrom
fix/recover-workspace-root-on-config-change
Apr 28, 2026
Merged

fix: recover workspace root on config/PAT change after empty activation#41
jschfflr merged 1 commit into
mainfrom
fix/recover-workspace-root-on-config-change

Conversation

@jschfflr

Copy link
Copy Markdown
Contributor

Summary

A customer reported a misleading "Not configured" toast even though every setting was correct. The output channel showed the giveaway:

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.

Root cause: If activate() runs before tfvc.adoProject is set (and there is no .vscode-tfvc/ folder), the early return at extension.ts:302-305 skips workspace-root resolution. The config-change listener correctly rebuilds the REST client when the user later types settings, but root stays undefined — so doInitRestClient() bails out at line 122 without creating repo/scmProvider. Every TFVC command then trips wrapSCMs !scmProvider check and shows the misleading toast.

The customer's only workaround was "reload the window after configuring".

Fix: In reinitOrWarn(), retry the root resolution before calling initRestClient() if root is still undefined. Mirrors the activation-time fallback (first .vscode-tfvc/ folder, else first workspace folder).

Test plan

  • npm run compile clean
  • npm test — 244/244 pass
  • Manual repro:
    1. Open VS Code with an empty folder, no TFVC settings.
    2. Run TFVC: Set PAT (triggers activation with empty config — hits the early return).
    3. Configure adoBaseUrl + adoCollectionPath + adoProject in settings.
    4. Run TFVC: Initialize Workspace — should work without a window reload.

🤖 Generated with Claude Code

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) <noreply@anthropic.com>
@jschfflr
jschfflr merged commit 84d463d into main Apr 28, 2026
2 checks passed
@jschfflr
jschfflr deleted the fix/recover-workspace-root-on-config-change branch April 28, 2026 09:09
@jschfflr jschfflr mentioned this pull request Apr 28, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant