Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
29e427c
feat(workspace): separate display label and SSH host alias from works…
skevetter Nov 1, 2026
d315909
refactor(desktop): split workspace presentation helpers to reduce met…
skevetter Nov 1, 2026
ed5be1f
refactor(desktop): extract secret protection helpers and mock present…
skevetter Nov 1, 2026
34e8e4a
fix(workspace): satisfy lint on presentation and ssh alias code
skevetter Nov 1, 2026
a3d1000
fix(workspace): isolate presentation tests and fix rename e2e flows
skevetter Nov 1, 2026
109a64c
test(desktop): allow subpixel rounding in wizard footer overlap check
skevetter Nov 1, 2026
1b85ba3
chore: merge main into feat/workspace-label-ssh-alias
skevetter Nov 2, 2026
48b246c
fix(workspace): address review findings on alias collisions, locking …
skevetter Nov 2, 2026
1df0dda
fix(workspace): validate derived workspace id after resolve and prefe…
skevetter Nov 2, 2026
51d75e2
fix(workspace): address review findings on ssh parsing, locking, clie…
skevetter Nov 2, 2026
d97c85b
fix(workspace): address second round of review findings on ssh lockin…
skevetter Nov 2, 2026
049b184
fix(workspace): address third round of review findings
skevetter Nov 2, 2026
5178006
chore: merge main into feat/workspace-label-ssh-alias
skevetter Nov 2, 2026
ad035bd
fix(workspace): address fourth round of review findings
skevetter Nov 2, 2026
8580207
feat(workspace): ownership-aware ssh blocks, staged import validation…
skevetter Nov 2, 2026
06ec1f6
chore: merge main into feat/workspace-label-ssh-alias
skevetter Nov 2, 2026
54afdf3
fix(workspace): claim legacy tunnel blocks and serialize import with …
skevetter Nov 2, 2026
49ba931
fix(workspace): stamp ownership when an alias edit claims a legacy ss…
skevetter Nov 2, 2026
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 .agents/skills/devsy/references/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ flags before using them.
| --- | --- |
| `devsy workspace build <name-or-source>` | Build/prebuild the workspace environment; publishing behavior depends on flags/configuration. Inspect help and requested destination first. |
| `devsy workspace rename <current-name> <new-name>` | Change workspace identity; refresh discovery afterward. |
| `devsy workspace edit <id> [--display-name <label>] [--ssh-host-alias <alias>]` | Change the display label and preferred SSH host without renaming or recreating. The canonical `<id>.devsy` host stays valid. |
| `devsy workspace set-ide <name> <ide>` | Change the configured IDE. |
| `devsy workspace export <name>` | Hidden command exporting configuration JSON, **not a data backup**. |
| `devsy workspace import --data '<exported-json>'` | Hidden configuration import; validate intended identities/provider references first. |
Expand Down
14 changes: 12 additions & 2 deletions cmd/workspace/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type DescribeCmd struct {

// describeOutput is the JSON shape: the full workspace config plus live state.
type describeOutput struct {
*provider.Workspace
*provider.WorkspaceListEntry
State string `json:"state"`
}

Expand Down Expand Up @@ -91,7 +91,10 @@ func render(mode string, cfg *provider.Workspace, state string) error {
case output.ModePlain:
table.Print([]string{"Field", "Value"}, describeRows(cfg, state))
case output.ModeJSON:
out, err := json.Marshal(&describeOutput{Workspace: cfg, State: state})
out, err := json.Marshal(&describeOutput{
WorkspaceListEntry: provider.NewWorkspaceListEntry(cfg),
State: state,
})
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
if err != nil {
return err
}
Expand Down Expand Up @@ -130,6 +133,13 @@ func describeRows(cfg *provider.Workspace, state string) [][]string {
}

add("ID", cfg.ID)
if label := cfg.EffectiveDisplayName(); label != cfg.ID {
add("Label", label)
}
add("SSH Host", cfg.PreferredSSHHost())
if cfg.PreferredSSHHost() != cfg.CanonicalSSHHost() {
add("Canonical SSH Host", cfg.CanonicalSSHHost())
}
add("State", state)
add("Provider", cfg.Provider.Name)
add("IDE", cfg.IDE.Name)
Expand Down
43 changes: 43 additions & 0 deletions cmd/workspace/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,49 @@ func TestDescribeCmd_JSONOutput(t *testing.T) {
assert.Equal(t, testProvider, provBlock["name"])
}

func describeJSON(t *testing.T, cfg *provider.Workspace) map[string]any {
t.Helper()
log.Init(log.Config{Verbosity: 0})

cmd := &DescribeCmd{GlobalFlags: &flags.GlobalFlags{ResultFormat: formatJSON}}
fake := &fakeWorkspaceClient{
workspace: cfg.ID,
config: cfg,
status: client.StatusRunning,
}
out := captureStdout(t, func() {
require.NoError(t, cmd.Run(t.Context(), fake))
})

var got map[string]any
require.NoError(t, json.Unmarshal([]byte(out), &got))
return got
}

func TestDescribeCmd_JSONDisplayNameIsStoredLabel(t *testing.T) {
got := describeJSON(t, &provider.Workspace{
ID: testWorkspaceName,
DisplayName: testDisplayName,
SSHHostAlias: testSSHAlias,
Platform: &provider.PlatformMetadata{DisplayName: "Team Workspace"},
})

assert.Equal(t, testDisplayName, got["displayName"])
assert.Equal(t, "Team Workspace", got["effectiveDisplayName"])
assert.Equal(t, testSSHAlias, got["sshHostAlias"])
assert.Equal(t, "node-js.devsy", got["preferredSSHHost"])
assert.Equal(t, "node-js.devsy", got["canonicalSSHHost"])
assert.Equal(t, string(client.StatusRunning), got["state"])
}

func TestDescribeCmd_JSONDisplayNameEmptyWhenUnset(t *testing.T) {
got := describeJSON(t, &provider.Workspace{ID: testWorkspaceName})

assert.Equal(t, "", got["displayName"])
assert.Equal(t, testWorkspaceName, got["effectiveDisplayName"])
assert.Equal(t, "", got["sshHostAlias"])
}

func TestDescribeCmd_PlainPrintsAtDefaultVerbosity(t *testing.T) {
log.Init(log.Config{Verbosity: 0})

Expand Down
212 changes: 212 additions & 0 deletions cmd/workspace/edit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
package workspace

import (
"encoding/json"
"errors"
"fmt"
"io"

"github.com/devsy-org/devsy/cmd/completion"
"github.com/devsy-org/devsy/cmd/flags"
"github.com/devsy-org/devsy/pkg/clierr"
"github.com/devsy-org/devsy/pkg/config"
cliflags "github.com/devsy-org/devsy/pkg/flags"
"github.com/devsy-org/devsy/pkg/flags/names"
"github.com/devsy-org/devsy/pkg/output"
"github.com/devsy-org/devsy/pkg/table"
workspace "github.com/devsy-org/devsy/pkg/workspace"
"github.com/spf13/cobra"
)

type editPresentationFunc func(workspace.PresentationRequest) (*workspace.PresentationResult, error)

type EditCmd struct {
*flags.GlobalFlags

DisplayName string
SSHHostAlias string
ExpectedUID string
ExpectedDisplayName string
ExpectedSSHHostAlias string

displayNameSet bool
sshHostAliasSet bool
expectedDisplayNameSet bool
expectedSSHHostAliasSet bool

edit editPresentationFunc
}

func NewEditCmd(globalFlags *flags.GlobalFlags) *cobra.Command {
return newEditCmd(globalFlags, workspace.EditPresentation)
}

func newEditCmd(globalFlags *flags.GlobalFlags, edit editPresentationFunc) *cobra.Command {
cmd := &EditCmd{
GlobalFlags: globalFlags,
edit: edit,
}

editCmd := &cobra.Command{
Use: "edit <workspace> [--display-name <label>] [--ssh-host-alias <alias>]",
Short: "Edit a workspace's display label and preferred SSH host alias",
Long: `Edit how a workspace is presented without changing its ID.

--display-name sets a local human-facing label. --ssh-host-alias sets an
additional SSH host name (without the .devsy suffix) that resolves to the
workspace; the canonical <id>.devsy host keeps working. Pass an empty value to
clear either override. Label edits never touch the SSH config.`,
Args: cobra.ExactArgs(1),
RunE: func(cobraCmd *cobra.Command, args []string) error {
cmd.displayNameSet = cobraCmd.Flags().Changed(names.DisplayName)
cmd.sshHostAliasSet = cobraCmd.Flags().Changed(names.SSHHostAlias)
cmd.expectedDisplayNameSet = cobraCmd.Flags().Changed(names.ExpectedDisplayName)
cmd.expectedSSHHostAliasSet = cobraCmd.Flags().Changed(names.ExpectedSSHHostAlias)
return cmd.Run(cobraCmd.OutOrStdout(), args[0])
},
ValidArgsFunction: func(
rootCmd *cobra.Command, args []string, toComplete string,
) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
return completion.GetWorkspaceSuggestions(
rootCmd,
completion.SuggestionRequest{
Context: cmd.Context,
Provider: cmd.Provider,
Args: args,
ToComplete: toComplete,
Owner: cmd.Owner,
},
)
}
return nil, cobra.ShellCompDirectiveNoFileComp
},
}

cliflags.Add(
editCmd,
cliflags.String(&cmd.DisplayName, names.DisplayName, "",
"Local display label for the workspace (empty clears the label)"),
cliflags.String(&cmd.SSHHostAlias, names.SSHHostAlias, "",
"Preferred SSH host alias without the .devsy suffix (empty clears the alias)"),
cliflags.String(&cmd.ExpectedUID, names.ExpectedUID, "",
"Fail unless the workspace still has this UID").Hidden(),
cliflags.String(&cmd.ExpectedDisplayName, names.ExpectedDisplayName, "",
"Fail unless the current display label matches").Hidden(),
cliflags.String(&cmd.ExpectedSSHHostAlias, names.ExpectedSSHHostAlias, "",
"Fail unless the current SSH host alias matches").Hidden(),
)
return editCmd
}

func (cmd *EditCmd) Run(out io.Writer, id string) error {
if !cmd.displayNameSet && !cmd.sshHostAliasSet {
return fmt.Errorf(
"at least one of --%s or --%s is required",
names.DisplayName,
names.SSHHostAlias,
)
}

mode, err := output.ResolveMode(cmd.ResultFormat)
if err != nil {
return err
}

devsyConfig, err := config.LoadConfig(cmd.Context, cmd.Provider)
if err != nil {
return err
}

result, err := cmd.edit(cmd.request(devsyConfig, id))
if err != nil {
return presentationCLIError(err)
}

return renderEdit(out, mode, result)
}

func (cmd *EditCmd) request(
devsyConfig *config.Config,
id string,
) workspace.PresentationRequest {
req := workspace.PresentationRequest{
DevsyConfig: devsyConfig,
ID: id,
ExpectedUID: cmd.ExpectedUID,
}
if cmd.displayNameSet {
req.DisplayName = &cmd.DisplayName
}
if cmd.sshHostAliasSet {
req.SSHHostAlias = &cmd.SSHHostAlias
}
if cmd.expectedDisplayNameSet {
req.ExpectedDisplayName = &cmd.ExpectedDisplayName
}
if cmd.expectedSSHHostAliasSet {
req.ExpectedSSHHostAlias = &cmd.ExpectedSSHHostAlias
}
return req
}

func presentationCLIError(err error) error {
presentationErr, ok := errors.AsType[*workspace.PresentationError](err)
if !ok {
return err
}

var errContext map[string]string
if presentationErr.Field != "" || presentationErr.Conflict != "" {
errContext = map[string]string{}
}
if presentationErr.Field != "" {
errContext["field"] = presentationErr.Field
}
if presentationErr.Conflict != "" {
errContext["conflict"] = presentationErr.Conflict
}

message := presentationErr.Message
if message == "" {
message = presentationErr.Error()
}
if joined := err.Error(); joined != presentationErr.Error() {
message = joined
}

return &clierr.CLIError{
Code: clierr.Code(presentationErr.Code),
Message: message,
Context: errContext,
}
}

func renderEdit(out io.Writer, mode string, result *workspace.PresentationResult) error {
switch mode {
case output.ModeJSON:
encoded, err := json.Marshal(result)
if err != nil {
return err
}
_, err = fmt.Fprint(out, string(encoded))
return err
case output.ModePlain:
return writeEditRows(out, result)
}

return nil
}

func writeEditRows(out io.Writer, result *workspace.PresentationResult) error {
rows := [][]string{
{"ID", result.ID},
{"Label", result.EffectiveDisplayName},
{"SSH Host", result.PreferredSSHHost},
}
if result.CanonicalSSHHost != result.PreferredSSHHost {
rows = append(rows, []string{"Canonical SSH Host", result.CanonicalSSHHost})
}
_, err := fmt.Fprintln(out, table.Render([]string{"Field", "Value"}, rows))
return err
}
Loading
Loading