fix(cli): use app slug instead of raw command in terminal URLs (#24827)

This commit is contained in:
Kayla はな
2026-05-05 19:43:08 -06:00
committed by GitHub
parent a7377f7613
commit f6233e622b
2 changed files with 3 additions and 6 deletions
+1 -5
View File
@@ -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 != "" {
+2 -1
View File
@@ -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",