Skip to content

Validate repository connection before disconnect operation#2799

Merged
alexweininger merged 3 commits intomainfrom
copilot/fix-disconnect-repo-action-issue
Mar 12, 2026
Merged

Validate repository connection before disconnect operation#2799
alexweininger merged 3 commits intomainfrom
copilot/fix-disconnect-repo-action-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 7, 2026

The "Disconnect from Repo..." command executes successfully on apps with deployment source already set to "None", showing confusing dialogs with empty repository names and performing no-op updates.

Changes

  • Added pre-flight validation in disconnectRepo command to check scmType before proceeding
  • Throw user-friendly error when scmType === ScmType.None: "This app is not connected to any repository."
// Check if the app is already disconnected from any repository
const client = await node.parent.site.createClient(context);
const siteConfig = await client.getSiteConfig();

if (siteConfig.scmType === ScmType.None) {
    throw new Error(localize('notConnectedToRepo', 'This app is not connected to any repository.'));
}

This prevents the confusing Disconnect from "{0}"? dialog where {0} is empty, and avoids unnecessary API calls to set deployment source to "None" when already "None".

Original prompt

This section details on the original issue you should resolve

<issue_title>“Disconnect from Repo...” is shown even when the deployment source is set to “None”</issue_title>
<issue_description>OS: Win 11
Build Version: 20260106.1

Repro Steps:

  1. Create a new web app in VS Code.
  2. Expand this web app -> Right click "Deployments" node to open its context menu.
  3. Check whether there is no "Disconnect from Repo..." action for "Deployments" node.

Expect:
There is no "Disconnect from Repo..." action for "Deployments" node.

Actual:
Extra "Disconnect from Repo..." action appears for "Deployments" node.
Image

More Info:
Execute "Disconnect from Repo..." action for the above web app -> Observe confirmation dialog shows Disconnect from "{0}"? -> Click "Disconnect" button -> Observe notification: Deployment source for "" has been updated to "None".
Image</issue_description>

<agent_instructions>Throw a user friendly error that their app is not connected to any repository.

PLEASE DO NOT CHANGE THE MAIN.JS FILE</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: nturinski <5290572+nturinski@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix extra disconnect from repo action in deployments menu Validate repository connection before disconnect operation Jan 7, 2026
Copilot AI requested a review from nturinski January 7, 2026 19:30
@nturinski nturinski marked this pull request as ready for review January 7, 2026 22:03
@nturinski nturinski requested a review from a team as a code owner January 7, 2026 22:03
Comment thread src/commands/deployments/disconnectRepo.ts Outdated
Address review feedback: use UserCancelledError to gracefully cancel
the operation and suppress the Report Issue button. Show a warning
toast to inform the user their app is not connected to any repository.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@alexweininger alexweininger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed the feedback — now using UserCancelledError with a warning toast via window.showWarningMessage. This gracefully cancels the operation, suppresses the Report Issue button, and shows the user an informative warning message.

Changes in ef9424a:

  • Replaced throw new Error(...)throw new UserCancelledError('notConnectedToRepo')
  • Added void window.showWarningMessage(...) to show a warning toast before cancelling

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the “Disconnect from Repo…” command flow to avoid running a disconnect operation (and showing confusing empty repo-name dialogs) when the app’s deployment source is already set to “None”.

Changes:

  • Adds a pre-flight scmType check before calling the underlying disconnect operation.
  • Introduces a localized “not connected” user-facing message for the no-op/disconnected case.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +28 to +31
if (siteConfig.scmType === ScmType.None) {
void window.showWarningMessage(localize('notConnectedToRepo', 'This app is not connected to any repository.'));
throw new UserCancelledError('notConnectedToRepo');
}
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says this scenario should throw a user-friendly error (e.g., Error(localize(...))), but the implementation shows a warning toast and then throws UserCancelledError. Treating this as a cancellation may suppress normal error handling/telemetry and doesn’t match the intended behavior/message contract. Consider throwing an Error with the localized message (and avoid the extra warning toast) so the user sees a clear error and the command stops consistently.

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +30
void window.showWarningMessage(localize('notConnectedToRepo', 'This app is not connected to any repository.'));
throw new UserCancelledError('notConnectedToRepo');
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command has an IActionContext available; elsewhere in the repo user prompts typically use context.ui.showWarningMessage(...) (e.g., src/commands/logstream/enableFileLogging.ts and src/commands/appSettings/getLocalEnvironmentVariables.ts). Using vscode.window here is inconsistent with that pattern and makes it harder to attach modal/step metadata consistently. Consider switching to context.ui.showWarningMessage (or removing the prompt entirely if you throw a user-facing Error) so you can also drop the window import.

Copilot uses AI. Check for mistakes.
@alexweininger alexweininger merged commit bd80caa into main Mar 12, 2026
6 checks passed
@alexweininger alexweininger deleted the copilot/fix-disconnect-repo-action-issue branch March 12, 2026 17:54
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.

“Disconnect from Repo...” is shown even when the deployment source is set to “None”

5 participants