-
Notifications
You must be signed in to change notification settings - Fork 2
feat(ide): add vscode-web (code serve-web) browser IDE #532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9d04eca
9132ca8
4c423bb
067720a
06aacb0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package agentcontainer | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
|
|
||
| "github.com/devsy-org/devsy/cmd/flags" | ||
| "github.com/devsy-org/devsy/pkg/compress" | ||
| "github.com/devsy-org/devsy/pkg/devcontainer/config" | ||
| "github.com/devsy-org/devsy/pkg/ide/vscodeweb" | ||
| "github.com/devsy-org/devsy/pkg/log" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| // VSCodeWebAsyncCmd holds the cmd flags. | ||
| type VSCodeWebAsyncCmd struct { | ||
| *flags.GlobalFlags | ||
|
|
||
| SetupInfo string | ||
| } | ||
|
|
||
| // NewVSCodeWebAsyncCmd creates a new command. | ||
| func NewVSCodeWebAsyncCmd() *cobra.Command { | ||
| cmd := &VSCodeWebAsyncCmd{} | ||
| vsCodeWebAsyncCmd := &cobra.Command{ | ||
| Use: "vscode-web-async", | ||
| Short: "Starts VS Code Web", | ||
| Args: cobra.NoArgs, | ||
| RunE: cmd.Run, | ||
| } | ||
| vsCodeWebAsyncCmd.Flags(). | ||
| StringVar(&cmd.SetupInfo, "setup-info", "", "The container setup info") | ||
| _ = vsCodeWebAsyncCmd.MarkFlagRequired("setup-info") | ||
| return vsCodeWebAsyncCmd | ||
| } | ||
|
|
||
| // Run runs the command logic. | ||
| func (cmd *VSCodeWebAsyncCmd) Run(_ *cobra.Command, _ []string) error { | ||
| log.Debugf("Start setting up container") | ||
| decompressed, err := compress.Decompress(cmd.SetupInfo) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| setupInfo := &config.Result{} | ||
| if err := json.Unmarshal([]byte(decompressed), setupInfo); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| return setupVSCodeWebExtensions(setupInfo) | ||
| } | ||
|
|
||
| func setupVSCodeWebExtensions(setupInfo *config.Result) error { | ||
| vsCodeConfiguration := config.GetVSCodeConfiguration(setupInfo.MergedConfig) | ||
| user := config.GetRemoteUser(setupInfo) | ||
| return vscodeweb.NewVSCodeWeb(vscodeweb.ServerOptions{ | ||
| Extensions: vsCodeConfiguration.Extensions, | ||
| UserName: user, | ||
| }).InstallExtensions() | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ( | |
| "context" | ||
| "fmt" | ||
| "net" | ||
| "net/url" | ||
| "strconv" | ||
| "strings" | ||
|
|
||
|
|
@@ -22,6 +23,7 @@ import ( | |
| "github.com/devsy-org/devsy/pkg/ide/openvscode" | ||
| "github.com/devsy-org/devsy/pkg/ide/rstudio" | ||
| "github.com/devsy-org/devsy/pkg/ide/vscode" | ||
| "github.com/devsy-org/devsy/pkg/ide/vscodeweb" | ||
| "github.com/devsy-org/devsy/pkg/ide/zed" | ||
| pkglog "github.com/devsy-org/devsy/pkg/log" | ||
| open2 "github.com/devsy-org/devsy/pkg/open" | ||
|
|
@@ -97,6 +99,8 @@ func browserIDEOpener( | |
| return openVSCodeBrowser, true | ||
| case string(config.IDECodeServer): | ||
| return openCodeServerBrowser, true | ||
| case string(config.IDEVSCodeWeb): | ||
| return openVSCodeWebBrowser, true | ||
| case string(config.IDEJupyterNotebook): | ||
| return openJupyterBrowser, true | ||
| case string(config.IDEMarimo): | ||
|
|
@@ -417,7 +421,7 @@ func openVSCodeBrowser( | |
| Label: LabelVSCodeBrowser, | ||
| LogName: "vscode", | ||
| TargetURLFn: func(port int, folder string) string { | ||
| return fmt.Sprintf("http://localhost:%d/?folder=%s", port, folder) | ||
| return fmt.Sprintf("http://localhost:%d/?folder=%s", port, url.QueryEscape(folder)) | ||
| }, | ||
| }) | ||
| } | ||
|
|
@@ -436,7 +440,26 @@ func openCodeServerBrowser( | |
| Label: LabelCodeServer, | ||
| LogName: "code-server", | ||
| TargetURLFn: func(port int, folder string) string { | ||
| return fmt.Sprintf("http://localhost:%d/?folder=%s", port, folder) | ||
| return fmt.Sprintf("http://localhost:%d/?folder=%s", port, url.QueryEscape(folder)) | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| func openVSCodeWebBrowser( | ||
| ctx context.Context, | ||
| ideOptions map[string]config.OptionValue, | ||
| params IDEParams, | ||
| ) (string, error) { | ||
| return openBrowserIDE(ctx, params, browserIDESpec{ | ||
| BindAddrOption: vscodeweb.Options.GetValue(ideOptions, vscodeweb.BindAddressOption), | ||
| DefaultPort: vscodeweb.DefaultVSCodeWebPort, | ||
| ForwardPorts: vscodeweb.Options.GetValue( | ||
| ideOptions, vscodeweb.ForwardPortsOption, | ||
| ) == config.BoolTrue, | ||
|
Comment on lines
+453
to
+458
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Use the parsed bind port for forwarded ports. This path exposes 🤖 Prompt for AI Agents |
||
| Label: LabelVSCodeWeb, | ||
| LogName: "vscode-web", | ||
| TargetURLFn: func(port int, folder string) string { | ||
| return fmt.Sprintf("http://localhost:%d/?folder=%s", port, url.QueryEscape(folder)) | ||
| }, | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| }) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Honor
BIND_ADDRESSinstead of hardcoding the default listener.pkg/ide/vscodeweb/vscodeweb.goexposesBIND_ADDRESS, but this path always passes0.0.0.0:10802, andNewVSCodeWebonly usesValuesfor download selection. As written, any user-supplied bind address is ignored.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents