Skip to content

feat(open): add 'open vscode' and 'open ssms', remove retired 'open ads'#688

Open
dlevy-msft-sql wants to merge 57 commits into
microsoft:mainfrom
dlevy-msft-sql:pr-685
Open

feat(open): add 'open vscode' and 'open ssms', remove retired 'open ads'#688
dlevy-msft-sql wants to merge 57 commits into
microsoft:mainfrom
dlevy-msft-sql:pr-685

Conversation

@dlevy-msft-sql
Copy link
Copy Markdown
Contributor

@dlevy-msft-sql dlevy-msft-sql commented Feb 1, 2026

Summary

Adds two new subcommands and removes one that no longer applies:

  • sqlcmd open vscode — writes a connection profile for the current context into VS Code's settings.json and launches VS Code on it via the vscode:// URL handler (which prompts to install the MSSQL extension on first use if needed).
  • sqlcmd open ssms — launches SSMS connected to the current context (Ssms.exe -S host,port -nosplash [-C] [-U user] with the password handed off via the clipboard).
  • sqlcmd open ads is removed: Azure Data Studio was retired in August 2025.

Password handling for VS Code

The VS Code profile includes the SQL password inline in settings.json rather than prompting the user for it. sqlcmd's containers are short-lived local development instances with throwaway credentials, and the goal of open vscode is one-shot, zero-prompt connect. The MSSQL extension migrates the password out of settings.json and into the OS credential store on first read, so the on-disk window is brief; we accept that trade-off in exchange for not requiring the user to paste a password they did not choose. This applies only to the local-container dev flow; users connecting to real servers should manage credentials through the extension directly.

Editor discovery (Windows)

  • VS Code: PATH (code / code-insiders) → Inno Setup uninstall registry → default install dirs. --build stable|insiders selects which build to launch; the connection profile is written to that build's settings.json so the profile and the launched build always match.
  • SSMS: vswhere -products Microsoft.VisualStudio.Product.Ssms, which finds SSMS 21+ on any drive. --version pins a major version; values below 21 are rejected (older SSMS releases are legacy-MSI and aren't registered with the VS Installer).

Why not ssms://?

An earlier revision used the ssms:// protocol handler. Its grammar only accepts s/a/u/d/h/q/dn and silently drops -C (trust server certificate) and -P. Local container connections need -C, so the URL path could not connect to a fresh local SQL container regardless of SSMS version. That commit was reverted; the argv launch path is what ships.

Testing

  • go build ./... on windows/linux/darwin
  • go test ./internal/tools/tool/... ./cmd/modern/root/open/...
  • New unit tests cover: vswhere arg construction and output parsing, SSMS install resolution, VS Code build selection, per-build settings.json routing.

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

This PR adds support for opening Visual Studio Code and SQL Server Management Studio (SSMS) to work with SQL Server connections managed by sqlcmd, addressing the deprecation of Azure Data Studio. The implementation uses clipboard-based password sharing since both tools use sandboxed credential storage.

Changes:

  • Adds sqlcmd open vscode command that creates connection profiles in VS Code settings and auto-installs the MSSQL extension
  • Adds sqlcmd open ssms command (Windows-only) that launches SSMS with pre-configured connection parameters
  • Implements cross-platform clipboard support for secure password sharing
  • Includes comprehensive tests and documentation updates

Reviewed changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cmd/modern/root/open.go Updates open command to include VSCode and SSMS subcommands
cmd/modern/root/open/vscode.go Main VSCode command implementation with settings file manipulation
cmd/modern/root/open/vscode_*.go Platform-specific VSCode implementations
cmd/modern/root/open/ssms.go Main SSMS command implementation
cmd/modern/root/open/ssms_*.go Platform-specific SSMS implementations (Fatal on non-Windows)
cmd/modern/root/open/clipboard.go Helper function for clipboard-based password sharing
cmd/modern/root/open/*_test.go Comprehensive test coverage for new commands
internal/tools/tool/vscode*.go VSCode tool detection and configuration
internal/tools/tool/ssms*.go SSMS tool detection and configuration
internal/pal/clipboard*.go Cross-platform clipboard implementation using native APIs
internal/tools/tools.go Registers VSCode and SSMS tools
README.md Adds clear documentation with usage examples
.gitignore Adds /modern build artifact

Comment thread cmd/modern/root/open/vscode.go Outdated
Comment thread cmd/modern/root/open/ssms.go Outdated
Comment thread cmd/modern/root/open/vscode.go Outdated
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

Copilot reviewed 30 out of 31 changed files in this pull request and generated 9 comments.

Comment thread cmd/modern/root/open/ssms_unix.go
Comment thread cmd/modern/root/open/vscode.go Outdated
Comment thread cmd/modern/root/open/ssms.go Outdated
Comment thread cmd/modern/root/open/ssms.go Outdated
Comment thread cmd/modern/root/open/vscode_test.go Outdated
Comment thread cmd/modern/root/open/ssms_test.go Outdated
Comment thread cmd/modern/root/open/ssms_darwin.go Outdated
Comment thread cmd/modern/root/open/vscode.go Outdated
Comment thread cmd/modern/root/open/vscode.go Outdated
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

Copilot reviewed 30 out of 31 changed files in this pull request and generated 1 comment.

Comment thread cmd/modern/root/open/vscode.go Outdated
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

Copilot reviewed 30 out of 31 changed files in this pull request and generated 1 comment.

Comment thread cmd/modern/root/open/vscode.go Outdated
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

Copilot reviewed 32 out of 33 changed files in this pull request and generated 3 comments.

Comment thread cmd/modern/root/open/vscode.go Outdated
Comment thread internal/tools/tool/vscode_linux.go
Comment thread README.md Outdated
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

Copilot reviewed 33 out of 34 changed files in this pull request and generated 1 comment.

Comment thread cmd/modern/root/open/ssms.go Outdated
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

Copilot reviewed 33 out of 34 changed files in this pull request and generated 2 comments.

Comment thread cmd/modern/root/open/vscode.go Outdated
Comment thread cmd/modern/root/open/ssms.go Outdated
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

Copilot reviewed 33 out of 34 changed files in this pull request and generated 4 comments.

Comment thread internal/tools/tool/tool.go Outdated
Comment thread cmd/modern/root/open.go Outdated
Comment thread cmd/modern/root/open/ssms.go Outdated
Comment thread cmd/modern/root/open/vscode.go Outdated
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

Copilot reviewed 61 out of 73 changed files in this pull request and generated 6 comments.

Comment thread cmd/modern/root/open/vscode.go
Comment thread cmd/modern/root/open/vscode.go
Comment thread cmd/modern/root/open/vscode.go
Comment thread cmd/modern/root/open/vscode.go
Comment thread cmd/modern/root/open/vscode.go
Comment thread cmd/modern/root/open/vscode.go
On Windows, suggest USERPROFILE instead of HOME since that's what os.UserHomeDir consults.
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

Copilot reviewed 61 out of 73 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

internal/tools/tool/tool_test.go:106

  • TestRun is currently skipped on Linux because the Linux implementation used to be missing, but tool_linux.go now implements generateCommandLine. Leaving the skip in place means the new Linux code path is untested, and the test still hard-codes exeName from COMSPEC (empty on Linux), which would fail if the skip is removed later.

Comment thread cmd/modern/root/open/clipboard.go
Comment thread cmd/modern/root/open/ssms.go
Comment thread cmd/modern/root/open/ssms_unix.go Outdated
Comment thread cmd/modern/root/open/ssms_unix.go Outdated
- clipboard.go: guard user.BasicAuth != nil for consistency with other call sites

- ssms.go/ssms_unix.go: drop '(Windows only)' suffix from Short text so it matches existing catalog entry

- ssms_unix.go: drop localizer wrap on the Windows-only fatal stub message (string is unique to !windows build and not in the catalog)
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

Copilot reviewed 61 out of 73 changed files in this pull request and generated 2 comments.

Comment thread cmd/modern/root/open/vscode.go
Comment thread cmd/modern/root/open/ssms_unix.go Outdated
- vscode.go: use %s with err.Error() so gotext extracts the home dir error

- ssms_unix.go: wrap the unix-only fatal in localizer.Sprintf

- regenerate catalog under GOOS=linux to register the !windows-tagged string
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

Copilot reviewed 61 out of 73 changed files in this pull request and generated 3 comments.

Comment thread internal/tools/tool/tool.go
Comment thread cmd/modern/root/open/vscode.go
Comment thread cmd/modern/root/open/ssms.go Outdated
…and ssms integrated auth

- tool.go: normalize argv[0] to match cmd.Path so darwin's open-based invocation is consistent with windows/linux

- vscode.go: guard against empty home with nil error to avoid panic in err.Error()

- ssms.go: append -E for integrated Windows auth when context has no SQL basic credentials
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

Copilot reviewed 61 out of 73 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

internal/tools/tool/tool_test.go:120

  • TestRun is currently skipped only on Linux but still hardcodes COMSPEC for exeName, which is typically empty on macOS and will make the test fail there. Also, tool_linux.go is now implemented, so the “Not implemented for Linux yet” skip is stale and leaves the Linux path untested. Suggest making the test OS-aware (and skipping darwin if needed due to the open -a launcher).

Comment thread cmd/modern/root/open/ssms_windows.go Outdated
Moves the Ssms struct, DefineCommand, and its localizable strings into an untagged ssms.go so gotext extraction picks them up on every GOOS, eliminating catalog drift between Windows and non-Windows builds. Platform-specific run() bodies stay in ssms_run_windows.go and ssms_unix.go.
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

Copilot reviewed 62 out of 74 changed files in this pull request and generated 3 comments.

Comment thread internal/tools/tool/vscode_windows.go Outdated
Comment thread cmd/modern/root/open/vscode.go
Comment thread cmd/modern/root/open/ssms_unix.go Outdated
…detection

- Verify VS Code is installed before creating settings.json, so a failed launch no longer leaves behind a fresh settings file (and possibly a plaintext local-context password) when the build is missing.

- Detect whether the PATH-resolved code/code-insiders entry is a bin\\code.cmd shim before walking up two directories. Falls back to one-up when the install dir itself is on PATH (Code.exe directly).

- Move the non-Windows ssms unsupported-platform message behind a helper in the untagged ssms.go so gotext extracts it regardless of host GOOS.
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

Copilot reviewed 62 out of 74 changed files in this pull request and generated 1 comment.

Comment thread cmd/modern/root/open/ssms.go Outdated
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

Copilot reviewed 62 out of 74 changed files in this pull request and generated 2 comments.

Comment thread cmd/modern/root/open/clipboard.go
Comment thread internal/tools/tool/tool.go Outdated
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

Copilot reviewed 62 out of 74 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

internal/tools/tool/tool_test.go:107

  • TestRun is only skipped on Linux, but it hardcodes COMSPEC/cmd.exe and Windows-only ping -n. This will fail on macOS (and other non-Windows platforms) where COMSPEC is empty and the arguments are invalid. Gate this test to Windows (or choose a cross-platform command).

Comment thread internal/tools/tool/tool_test.go
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

Copilot reviewed 62 out of 74 changed files in this pull request and generated 1 comment.

Comment thread internal/tools/tool/tool.go
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

Copilot reviewed 62 out of 74 changed files in this pull request and generated 1 comment.

Comment thread cmd/modern/root/open/vscode.go
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

Copilot reviewed 62 out of 74 changed files in this pull request and generated 1 comment.

Comment thread cmd/modern/root/open/vscode.go
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

Copilot reviewed 62 out of 74 changed files in this pull request and generated 1 comment.

Comment thread internal/pal/clipboard_windows.go
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

Copilot reviewed 62 out of 74 changed files in this pull request and generated no new comments.

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.

3 participants