refactor(ide/vscode): flavors to configuration struct#370
Conversation
Signed-off-by: Samuel K <skevetter@pm.me>
📝 WalkthroughWalkthroughReplaces the old per-argument VS Code open API with a single exported Changes
Sequence Diagram(s)sequenceDiagram
participant UpCmd as Up Command
participant OpenAPI as vscode.Open (OpenParams)
participant OS as Operating System
participant CLI as VSCode CLI
participant Browser as Web Browser
participant ExtSvc as Extension Installer
UpCmd->>OpenAPI: Call Open(ctx, OpenParams{Workspace, Folder, NewWindow, Flavor, Log})
OpenAPI->>OpenAPI: lookup openConfigs[Flavor]
alt CLI available
OpenAPI->>CLI: resolve CLI path (getCLIPath)
CLI-->>OpenAPI: cliPath
OpenAPI->>CLI: listInstalledExtensions(cliPath)
CLI-->>OpenAPI: installedExtensions
alt SSH/Containers extension missing
OpenAPI->>ExtSvc: install extension via CLI
ExtSvc-->>OpenAPI: install result
end
OpenAPI->>CLI: spawn CLI with built args (buildOpenArgs)
CLI-->>OS: process spawn
CLI-->>OpenAPI: result
else CLI not available
OpenAPI->>Browser: construct/open protocol URL (openViaBrowser)
Browser-->>OS: open URL
Browser-->>OpenAPI: result
end
OpenAPI-->>UpCmd: return error/success
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@pkg/ide/vscode/open.go`:
- Around line 105-109: The log call in the error path after open.Run(openURL)
uses the incorrect printf verb `%w`; replace it with a logging-safe verb like
`%v` or `%s` in the params.Log.Errorf call so the error is formatted correctly
(e.g., params.Log.Errorf("flavor %s is not installed on host device: %v",
params.Flavor.DisplayName(), err)). Leave the open.Run(openURL) error handling
and return err unchanged.
🧹 Nitpick comments (1)
pkg/ide/vscode/open.go (1)
169-177: Consider usingCombinedOutput()for better error diagnostics.Using
Output()discards stderr, which may contain useful error information when extension installation fails. Other exec calls in this file useCombinedOutput().Proposed fix
func ensureSSHExtension(ctx context.Context, cliPath, sshExtension string, log log.Logger) error { args := []string{"--install-extension", sshExtension} log.Debugf("%s %s", cliPath, strings.Join(args, " ")) - out, err := exec.CommandContext(ctx, cliPath, args...).Output() + out, err := exec.CommandContext(ctx, cliPath, args...).CombinedOutput() if err != nil { return command.WrapCommandError(out, err) } return nil }
Signed-off-by: Samuel K <skevetter@pm.me>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@pkg/ide/vscode/open.go`:
- Around line 146-150: Change listInstalledExtensions to accept a
context.Context parameter (update its signature: listInstalledExtensions(ctx
context.Context, cliPath, sshExtension string) ...) and replace exec.Command
with exec.CommandContext(ctx, cliPath, "--list-extensions") so the call respects
cancellation; also use CombinedOutput() instead of Output() so both stdout and
stderr are captured and passed into command.WrapCommandError on failure. Update
the call site in openViaCLI to pass the existing ctx into
listInstalledExtensions. Ensure any tests or callers are adjusted accordingly.
Signed-off-by: Samuel K <skevetter@pm.me>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@pkg/ide/vscode/open.go`:
- Around line 78-91: The Open function currently always tries openViaBrowser
even if the context was canceled or timed out; update Open to short‑circuit if
ctx has been canceled or if cliErr is a context error by checking ctx.Err() (or
using errors.Is(cliErr, context.Canceled) / context.DeadlineExceeded) after
openViaCLI returns, and return the appropriate error without calling
openViaBrowser when cancellation/timeouts occur; keep use of params.Log.Infof
and preserve returning errors.Join for non‑context failures.
Signed-off-by: Samuel K <skevetter@pm.me>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Signed-off-by: Samuel K skevetter@pm.me
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.