From f6233e622bd0f7392367107d3e1dcbd1bd63c525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kayla=20=E3=81=AF=E3=81=AA?= Date: Tue, 5 May 2026 19:43:08 -0600 Subject: [PATCH] fix(cli): use app slug instead of raw command in terminal URLs (#24827) --- cli/open.go | 6 +----- cli/open_internal_test.go | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cli/open.go b/cli/open.go index 192695d415..fceda71394 100644 --- a/cli/open.go +++ b/cli/open.go @@ -645,7 +645,6 @@ func buildAppLinkURL(baseURL *url.URL, workspace codersdk.Workspace, agent coder agent.Name, url.PathEscape(app.Slug), ) - // The frontend leaves the returns a relative URL for the terminal, but we don't have that luxury. if app.Command != "" { u.Path = fmt.Sprintf( "%s/@%s/%s.%s/terminal", @@ -655,11 +654,8 @@ func buildAppLinkURL(baseURL *url.URL, workspace codersdk.Workspace, agent coder agent.Name, ) q := u.Query() - q.Set("command", app.Command) + q.Set("app", app.Slug) u.RawQuery = q.Encode() - // encodeURIComponent replaces spaces with %20 but url.QueryEscape replaces them with +. - // We replace them with %20 to match the TypeScript implementation. - u.RawQuery = strings.ReplaceAll(u.RawQuery, "+", "%20") } if appsHost != "" && app.Subdomain && app.SubdomainName != "" { diff --git a/cli/open_internal_test.go b/cli/open_internal_test.go index 5c3ec338ac..3237e45ccd 100644 --- a/cli/open_internal_test.go +++ b/cli/open_internal_test.go @@ -114,9 +114,10 @@ func Test_buildAppLinkURL(t *testing.T) { Name: "a-workspace-agent", }, app: codersdk.WorkspaceApp{ + Slug: "my-terminal", Command: "ls -la", }, - expectedLink: "https://coder.tld/@username/Test-Workspace.a-workspace-agent/terminal?command=ls%20-la", + expectedLink: "https://coder.tld/@username/Test-Workspace.a-workspace-agent/terminal?app=my-terminal", }, { name: "with subdomain",