Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/ide/ide.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func NewIDECmd(flags *flags.GlobalFlags) *cobra.Command {
}

ideCmd.AddCommand(NewUseCmd(flags))
ideCmd.AddCommand(NewSetCmd(flags))
ideCmd.AddCommand(NewSetOptionsCmd(flags))
ideCmd.AddCommand(NewOptionsCmd(flags))
ideCmd.AddCommand(NewListCmd(flags))
Expand Down
78 changes: 78 additions & 0 deletions cmd/ide/set.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package ide

import (
"context"
"fmt"
"strings"

"github.com/devsy-org/devsy/cmd/flags"
"github.com/devsy-org/devsy/pkg/config"
"github.com/devsy-org/devsy/pkg/ide/ideparse"
"github.com/devsy-org/devsy/pkg/log"
"github.com/devsy-org/devsy/pkg/provider"
"github.com/spf13/cobra"
)

// SetCmd holds the set cmd flags.
type SetCmd struct {
*flags.GlobalFlags

Options []string
}

// NewSetCmd creates a command that sets the IDE for an existing workspace
// without starting the workspace.
func NewSetCmd(flags *flags.GlobalFlags) *cobra.Command {
cmd := &SetCmd{
GlobalFlags: flags,
}
setCmd := &cobra.Command{
Use: "set [workspace] [ide]",
Short: "Set the IDE for an existing workspace without starting it",
Long: `Set the IDE for an existing workspace without starting it.

The change is persisted to the workspace config and will be used on the next
'devsy up'. Available IDEs can be listed with 'devsy ide list'.`,
RunE: func(cobraCmd *cobra.Command, args []string) error {
if len(args) != 2 {
return fmt.Errorf("usage: devsy ide set <workspace> <ide>")
}
return cmd.Run(cobraCmd.Context(), args[0], args[1])
},
}

setCmd.Flags().
StringArrayVarP(&cmd.Options, "option", "o", []string{}, "IDE option in the form KEY=VALUE")
return setCmd
}

// Run runs the command logic.
func (cmd *SetCmd) Run(_ context.Context, workspaceID, ideName string) error {
devsyConfig, err := config.LoadConfig(cmd.Context, cmd.Provider)
if err != nil {
return err
}

contextName := devsyConfig.DefaultContext
if !provider.WorkspaceExists(contextName, workspaceID) {
return fmt.Errorf("workspace %q not found in context %q", workspaceID, contextName)
}

workspace, err := provider.LoadWorkspaceConfig(contextName, workspaceID)
if err != nil {
return fmt.Errorf("load workspace config: %w", err)
}

ideName = strings.ToLower(ideName)
if _, err := ideparse.GetIDEOptions(ideName); err != nil {
return err
}
Comment on lines +66 to +69

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Add an explicit “clear IDE” path instead of rejecting non-IDE sentinels.

Right now this flow only accepts recognized IDE names. That blocks persisting a “no IDE” selection for existing workspaces, so stale workspace IDE config can remain active in later starts when --ide is omitted. Please support an explicit unset value (e.g., none) or a dedicated unset command and persist that state.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/ide/set.go` around lines 66 - 69, Update the IDE-setting flow in
cmd/ide/set.go to accept an explicit "clear" sentinel (e.g., "none" or "unset")
by checking ideName after lowercasing and, if it matches the sentinel, clear the
workspace IDE config and persist that empty/unset state instead of calling
ideparse.GetIDEOptions; otherwise continue to validate via
ideparse.GetIDEOptions(ideName) as before. Use the existing variables (ideName)
and the code path that writes the workspace config to save the cleared state and
return success.


workspace, err = ideparse.RefreshIDEOptions(devsyConfig, workspace, ideName, cmd.Options)
if err != nil {
return fmt.Errorf("refresh ide options: %w", err)
}

log.Infof("set IDE for workspace %q to %q", workspace.ID, workspace.IDE.Name)
return nil
}
8 changes: 8 additions & 0 deletions desktop/src/main/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ export function registerIpcHandlers(deps: IpcDependencies): { tunnelProcesses: M
},
)

ipcMain.handle(
"workspace_set_ide",
async (_event, args: { workspaceId: string; ide: string }) => {
trackEvent("workspace_set_ide", { ide: args.ide })
await cli.runRaw(["ide", "set", args.workspaceId, args.ide])
},
)

// ── Providers ──
ipcMain.handle("provider_list", async () => {
const raw = await cli.run<Record<string, ProviderEntry>>([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ async function handleLaunch() {
source: source.trim(),
workspaceId,
provider: selectedProvider || undefined,
ide: selectedIde && selectedIde !== "none" ? selectedIde : undefined,
ide: selectedIde,
ideLaunch: "auto",
workspaceFolder: workspaceFolder.trim() || undefined,
debug: true,
Expand Down
7 changes: 7 additions & 0 deletions desktop/src/renderer/src/lib/ipc/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ export async function workspaceRename(
return invoke("workspace_rename", { workspaceId, newWorkspaceId })
}

export async function workspaceSetIde(
workspaceId: string,
ide: string,
): Promise<void> {
return invoke("workspace_set_ide", { workspaceId, ide })
}

// Provider commands
export async function providerList(): Promise<Provider[]> {
return invoke<Provider[]>("provider_list")
Expand Down
26 changes: 22 additions & 4 deletions desktop/src/renderer/src/pages/WorkspaceDetailPage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
workspaceReset,
workspaceDelete,
workspaceRename,
workspaceSetIde,
workspaceLogsList,
workspaceLogRead,
workspaceLogDelete,
Expand Down Expand Up @@ -124,6 +125,7 @@ let connecting = $state(false)
let ideComboOpen = $state(false)
let ideSearch = $state("")
let selectedIde = $state<string | null>(null)
let ideSetSeq = 0
let renaming = $state(false)
let renameValue = $state("")
let renameSaving = $state(false)
Expand Down Expand Up @@ -305,17 +307,24 @@ function startStreamingOp(label: string) {
}

async function handleStart() {
const ide = currentIde
const folder = customFolder || undefined
startStreamingOp("Start")
try {
commandId = await workspaceUp({ source: id, debug: isDebug() })
commandId = await workspaceUp({
source: id,
ide,
debug: isDebug(),
workspaceFolder: folder,
})
} catch (err) {
operationRunning = false
toasts.error(`Failed to start: ${extractErrorMessage(err)}`)
}
}

async function handleOpenIde() {
const ide = currentIde !== "none" ? currentIde : undefined
const ide = currentIde
const folder = customFolder || undefined
startStreamingOp("Open IDE")
try {
Expand Down Expand Up @@ -450,7 +459,7 @@ async function handleRename() {
</Button>
{/if}

<Button variant="outline" size="sm" onclick={handleOpenIde} disabled={!isRunning || operationRunning}>
<Button variant="outline" size="sm" onclick={handleOpenIde} disabled={!isRunning || operationRunning || currentIde === "none"}>
{#if operationRunning && operationLabel === "Open IDE"}<Spinner />{:else}<Monitor class="h-4 w-4" />{/if}
Open IDE
</Button>
Expand Down Expand Up @@ -545,10 +554,19 @@ async function handleRename() {
<Command.Item
value={ide.value}
class="justify-start"
onSelect={() => {
onSelect={async () => {
const seq = ++ideSetSeq
const prev = selectedIde
selectedIde = ide.value
ideComboOpen = false
ideSearch = ""
try {
await workspaceSetIde(id, ide.value)
} catch (err) {
if (seq !== ideSetSeq) return
selectedIde = prev
toasts.error(`Failed to set IDE: ${extractErrorMessage(err)}`)
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}}
>
<Check class="mr-2 h-4 w-4 {currentIde === ide.value ? 'opacity-100' : 'opacity-0'}" />
Expand Down
4 changes: 4 additions & 0 deletions pkg/ide/opener/opener.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func Open(
ideOptions map[string]config.OptionValue,
params IDEParams,
) (string, error) {
if ideName == string(config.IDENone) {
return "", nil
}

if fn, ok := browserIDEOpener(ideName); ok {
return fn(ctx, ideOptions, params)
}
Expand Down
Loading