Validate repository connection before disconnect operation#2799
Validate repository connection before disconnect operation#2799alexweininger merged 3 commits intomainfrom
Conversation
Co-authored-by: nturinski <5290572+nturinski@users.noreply.github.com>
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>
alexweininger
left a comment
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
scmTypecheck 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.
| if (siteConfig.scmType === ScmType.None) { | ||
| void window.showWarningMessage(localize('notConnectedToRepo', 'This app is not connected to any repository.')); | ||
| throw new UserCancelledError('notConnectedToRepo'); | ||
| } |
There was a problem hiding this comment.
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.
| void window.showWarningMessage(localize('notConnectedToRepo', 'This app is not connected to any repository.')); | ||
| throw new UserCancelledError('notConnectedToRepo'); |
There was a problem hiding this comment.
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.
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
disconnectRepocommand to checkscmTypebefore proceedingscmType === ScmType.None: "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
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.