diff --git a/registry/coder/modules/jetbrains/main.test.ts b/registry/coder/modules/jetbrains/main.test.ts index 6be97ef1..73f7650d 100644 --- a/registry/coder/modules/jetbrains/main.test.ts +++ b/registry/coder/modules/jetbrains/main.test.ts @@ -300,7 +300,27 @@ describe("jetbrains", async () => { expect(url).toContain("&token=$SESSION_TOKEN"); expect(url).toContain("&ide_product_code=GO"); expect(url).toContain("&ide_build_number="); - expect(url).toContain("&agent_id=test-agent-123"); + // No agent_name parameter should be included when agent_name is not specified + expect(url).not.toContain("&agent_name="); + }); + + it("should include agent_name parameter when agent_name is specified", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "test-agent-123", + agent_name: "main-agent", + folder: "/custom/project/path", + default: '["GO"]', + }); + + const coder_app = state.resources.find( + (res) => res.type === "coder_app" && res.name === "jetbrains", + ); + const url = coder_app?.instances[0].attributes.url; + + expect(url).toContain("jetbrains://gateway/coder"); + expect(url).toContain("&agent_name=main-agent"); + expect(url).toContain("&ide_product_code=GO"); + expect(url).toContain("&ide_build_number="); }); it("should include build numbers from API in URLs", async () => { diff --git a/registry/coder/modules/jetbrains/main.tf b/registry/coder/modules/jetbrains/main.tf index 1d511eb6..1959b98e 100644 --- a/registry/coder/modules/jetbrains/main.tf +++ b/registry/coder/modules/jetbrains/main.tf @@ -15,7 +15,13 @@ terraform { variable "agent_id" { type = string - description = "The ID of a Coder agent." + description = "The resource ID of a Coder agent." +} + +variable "agent_name" { + type = string + description = "The name of a Coder agent. Needed for workspaces with multiple agents." + default = null } variable "folder" { @@ -239,7 +245,6 @@ resource "coder_app" "jetbrains" { each.key, "&ide_build_number=", local.options_metadata[each.key].build, - "&agent_id=", - var.agent_id, + var.agent_name != null ? "&agent_name=${var.agent_name}" : "", ]) } \ No newline at end of file