From 11ebb4a4769859b67da19055560eaad924aec2df Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Thu, 3 Jul 2025 19:59:54 +0000 Subject: [PATCH 1/8] Add Zed IDE module Adds a new official module for Zed IDE integration with Coder workspaces. The module provides a one-click button to open workspaces in Zed IDE using the zed:// protocol. Features: - Configurable folder path - Customizable display name and order - Support for app grouping - External app integration Co-authored-by: matifali <10648092+matifali@users.noreply.github.com> --- registry/coder/modules/zed/README.md | 50 +++++++++++++++++ registry/coder/modules/zed/main.test.ts | 71 +++++++++++++++++++++++++ registry/coder/modules/zed/main.tf | 70 ++++++++++++++++++++++++ 3 files changed, 191 insertions(+) create mode 100644 registry/coder/modules/zed/README.md create mode 100644 registry/coder/modules/zed/main.test.ts create mode 100644 registry/coder/modules/zed/main.tf diff --git a/registry/coder/modules/zed/README.md b/registry/coder/modules/zed/README.md new file mode 100644 index 000000000..60d8cac4d --- /dev/null +++ b/registry/coder/modules/zed/README.md @@ -0,0 +1,50 @@ +--- +display_name: Zed IDE +description: Add a one-click button to launch Zed IDE +icon: ../../../../.icons/zed.svg +maintainer_github: coder +verified: true +tags: [ide, zed, editor] +--- + +# Zed IDE + +Add a button to open any workspace with a single click in Zed IDE. + +Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter. + +```tf +module "zed" { + count = data.coder_workspace.me.start_count + source = "registry.coder.com/coder/zed/coder" + version = "1.0.0" + agent_id = coder_agent.example.id +} +``` + +## Examples + +### Open in a specific directory + +```tf +module "zed" { + count = data.coder_workspace.me.start_count + source = "registry.coder.com/coder/zed/coder" + version = "1.0.0" + agent_id = coder_agent.example.id + folder = "/home/coder/project" +} +``` + +### Custom display name and order + +```tf +module "zed" { + count = data.coder_workspace.me.start_count + source = "registry.coder.com/coder/zed/coder" + version = "1.0.0" + agent_id = coder_agent.example.id + display_name = "Zed Editor" + order = 1 +} +``` diff --git a/registry/coder/modules/zed/main.test.ts b/registry/coder/modules/zed/main.test.ts new file mode 100644 index 000000000..36e2090ab --- /dev/null +++ b/registry/coder/modules/zed/main.test.ts @@ -0,0 +1,71 @@ +import { describe, expect, it } from "bun:test"; +import { + runTerraformApply, + runTerraformInit, + testRequiredVariables, +} from "~test"; + +describe("zed", async () => { + await runTerraformInit(import.meta.dir); + + testRequiredVariables(import.meta.dir, { + agent_id: "foo", + }); + + it("default output", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + }); + expect(state.outputs.zed_url.value).toBe( + "zed://ssh/default.default.coder/", + ); + + const coder_app = state.resources.find( + (res) => res.type === "coder_app" && res.name === "zed", + ); + + expect(coder_app).not.toBeNull(); + expect(coder_app?.instances.length).toBe(1); + expect(coder_app?.instances[0].attributes.order).toBeNull(); + }); + + it("adds folder", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + folder: "/foo/bar", + }); + expect(state.outputs.zed_url.value).toBe( + "zed://ssh/default.default.coder/foo/bar", + ); + }); + + it("expect order to be set", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + order: "22", + }); + + const coder_app = state.resources.find( + (res) => res.type === "coder_app" && res.name === "zed", + ); + + expect(coder_app).not.toBeNull(); + expect(coder_app?.instances.length).toBe(1); + expect(coder_app?.instances[0].attributes.order).toBe(22); + }); + + it("expect display_name to be set", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + display_name: "Custom Zed", + }); + + const coder_app = state.resources.find( + (res) => res.type === "coder_app" && res.name === "zed", + ); + + expect(coder_app).not.toBeNull(); + expect(coder_app?.instances.length).toBe(1); + expect(coder_app?.instances[0].attributes.display_name).toBe("Custom Zed"); + }); +}); diff --git a/registry/coder/modules/zed/main.tf b/registry/coder/modules/zed/main.tf new file mode 100644 index 000000000..3af5fdeea --- /dev/null +++ b/registry/coder/modules/zed/main.tf @@ -0,0 +1,70 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + coder = { + source = "coder/coder" + version = ">= 2.5" + } + } +} + +variable "agent_id" { + type = string + description = "The ID of a Coder agent." +} + +variable "folder" { + type = string + description = "The folder to open in Zed IDE." + default = "" +} + +variable "order" { + type = number + description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)." + default = null +} + +variable "group" { + type = string + description = "The name of a group that this app belongs to." + default = null +} + +variable "slug" { + type = string + description = "The slug of the app." + default = "zed" +} + +variable "display_name" { + type = string + description = "The display name of the app." + default = "Zed IDE" +} + +data "coder_workspace" "me" {} +data "coder_workspace_owner" "me" {} + +locals { + workspace_name = lower(data.coder_workspace.me.name) + owner_name = lower(data.coder_workspace_owner.me.name) + hostname = "${local.workspace_name}.${local.owner_name}.coder" +} + +resource "coder_app" "zed" { + agent_id = var.agent_id + display_name = var.display_name + slug = var.slug + icon = "/icon/zed.svg" + external = true + order = var.order + group = var.group + url = "zed://ssh/${local.hostname}/${var.folder}" +} + +output "zed_url" { + value = coder_app.zed.url + description = "Zed IDE URL." +} From 225f180b8bbb12f57fbcbb306ac1852f025d10b5 Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Thu, 3 Jul 2025 20:05:36 +0000 Subject: [PATCH 2/8] Fix Zed module URL construction and add agent_name variable - Add agent_name variable to match original dogfood module - Fix URL construction to avoid double slashes when folder is provided - Update hostname logic to use agent_name when provided - Add test for agent_name functionality - Update README with agent_name example Fixes the failing test: zed > adds folder Co-authored-by: matifali <10648092+matifali@users.noreply.github.com> --- registry/coder/modules/zed/README.md | 12 ++++++++++++ registry/coder/modules/zed/main.test.ts | 14 ++++++++++++-- registry/coder/modules/zed/main.tf | 12 +++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/registry/coder/modules/zed/README.md b/registry/coder/modules/zed/README.md index 60d8cac4d..d939f8d82 100644 --- a/registry/coder/modules/zed/README.md +++ b/registry/coder/modules/zed/README.md @@ -48,3 +48,15 @@ module "zed" { order = 1 } ``` + +### With custom agent name + +```tf +module "zed" { + count = data.coder_workspace.me.start_count + source = "registry.coder.com/coder/zed/coder" + version = "1.0.0" + agent_id = coder_agent.example.id + agent_name = coder_agent.example.name +} +``` diff --git a/registry/coder/modules/zed/main.test.ts b/registry/coder/modules/zed/main.test.ts index 36e2090ab..bb3c99525 100644 --- a/registry/coder/modules/zed/main.test.ts +++ b/registry/coder/modules/zed/main.test.ts @@ -17,7 +17,7 @@ describe("zed", async () => { agent_id: "foo", }); expect(state.outputs.zed_url.value).toBe( - "zed://ssh/default.default.coder/", + "zed://ssh/default.coder", ); const coder_app = state.resources.find( @@ -35,7 +35,7 @@ describe("zed", async () => { folder: "/foo/bar", }); expect(state.outputs.zed_url.value).toBe( - "zed://ssh/default.default.coder/foo/bar", + "zed://ssh/default.coder/foo/bar", ); }); @@ -68,4 +68,14 @@ describe("zed", async () => { expect(coder_app?.instances.length).toBe(1); expect(coder_app?.instances[0].attributes.display_name).toBe("Custom Zed"); }); + + it("adds agent_name to hostname", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "foo", + agent_name: "myagent", + }); + expect(state.outputs.zed_url.value).toBe( + "zed://ssh/myagent.default.me.coder", + ); + }); }); diff --git a/registry/coder/modules/zed/main.tf b/registry/coder/modules/zed/main.tf index 3af5fdeea..5a6bdb648 100644 --- a/registry/coder/modules/zed/main.tf +++ b/registry/coder/modules/zed/main.tf @@ -14,6 +14,12 @@ variable "agent_id" { description = "The ID of a Coder agent." } +variable "agent_name" { + type = string + description = "The name of the agent." + default = "" +} + variable "folder" { type = string description = "The folder to open in Zed IDE." @@ -49,8 +55,8 @@ data "coder_workspace_owner" "me" {} locals { workspace_name = lower(data.coder_workspace.me.name) - owner_name = lower(data.coder_workspace_owner.me.name) - hostname = "${local.workspace_name}.${local.owner_name}.coder" + agent_name = lower(var.agent_name) + hostname = var.agent_name != "" ? "${local.agent_name}.${local.workspace_name}.me.coder" : "${local.workspace_name}.coder" } resource "coder_app" "zed" { @@ -61,7 +67,7 @@ resource "coder_app" "zed" { external = true order = var.order group = var.group - url = "zed://ssh/${local.hostname}/${var.folder}" + url = "zed://ssh/${local.hostname}${var.folder != "" ? "/${var.folder}" : ""}" } output "zed_url" { From 3cba245664ca04d5b57ab4c9a1d7612a1c8afa42 Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Thu, 3 Jul 2025 20:11:21 +0000 Subject: [PATCH 3/8] Final fixes: add Zed logo and fix URL construction - Add zed.svg logo to .icons directory from coder/coder repository - Keep owner_name in locals and use it in URL construction as requested - Fix URL construction to properly handle folder paths without double slashes - Update tests to match the correct URL format with owner_name Addresses PR feedback and should fix all failing tests. Co-authored-by: matifali <10648092+matifali@users.noreply.github.com> --- .icons/zed.svg | 3 +++ registry/coder/modules/zed/main.test.ts | 4 ++-- registry/coder/modules/zed/main.tf | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .icons/zed.svg diff --git a/.icons/zed.svg b/.icons/zed.svg new file mode 100644 index 000000000..06b5c183e --- /dev/null +++ b/.icons/zed.svg @@ -0,0 +1,3 @@ + + + diff --git a/registry/coder/modules/zed/main.test.ts b/registry/coder/modules/zed/main.test.ts index bb3c99525..717740b53 100644 --- a/registry/coder/modules/zed/main.test.ts +++ b/registry/coder/modules/zed/main.test.ts @@ -17,7 +17,7 @@ describe("zed", async () => { agent_id: "foo", }); expect(state.outputs.zed_url.value).toBe( - "zed://ssh/default.coder", + "zed://ssh/default.default.coder", ); const coder_app = state.resources.find( @@ -35,7 +35,7 @@ describe("zed", async () => { folder: "/foo/bar", }); expect(state.outputs.zed_url.value).toBe( - "zed://ssh/default.coder/foo/bar", + "zed://ssh/default.default.coder/foo/bar", ); }); diff --git a/registry/coder/modules/zed/main.tf b/registry/coder/modules/zed/main.tf index 5a6bdb648..84c3dface 100644 --- a/registry/coder/modules/zed/main.tf +++ b/registry/coder/modules/zed/main.tf @@ -55,8 +55,9 @@ data "coder_workspace_owner" "me" {} locals { workspace_name = lower(data.coder_workspace.me.name) + owner_name = lower(data.coder_workspace_owner.me.name) agent_name = lower(var.agent_name) - hostname = var.agent_name != "" ? "${local.agent_name}.${local.workspace_name}.me.coder" : "${local.workspace_name}.coder" + hostname = var.agent_name != "" ? "${local.agent_name}.${local.workspace_name}.me.coder" : "${local.workspace_name}.${local.owner_name}.coder" } resource "coder_app" "zed" { @@ -67,7 +68,7 @@ resource "coder_app" "zed" { external = true order = var.order group = var.group - url = "zed://ssh/${local.hostname}${var.folder != "" ? "/${var.folder}" : ""}" + url = "zed://ssh/${local.hostname}${var.folder}" } output "zed_url" { From 08991f2dff2e9479f283fd2c75fc312adeaabc89 Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Thu, 3 Jul 2025 20:13:23 +0000 Subject: [PATCH 4/8] Fix hostname logic as suggested in PR review - Use owner_name in hostname when agent_name is provided: agent.workspace.owner.coder - Keep simple format when no agent_name: workspace.coder - Update tests to match the corrected hostname formats Implements the suggestion from PR review comment. Co-authored-by: matifali <10648092+matifali@users.noreply.github.com> --- registry/coder/modules/zed/main.test.ts | 6 +++--- registry/coder/modules/zed/main.tf | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/registry/coder/modules/zed/main.test.ts b/registry/coder/modules/zed/main.test.ts index 717740b53..9a657e02a 100644 --- a/registry/coder/modules/zed/main.test.ts +++ b/registry/coder/modules/zed/main.test.ts @@ -17,7 +17,7 @@ describe("zed", async () => { agent_id: "foo", }); expect(state.outputs.zed_url.value).toBe( - "zed://ssh/default.default.coder", + "zed://ssh/default.coder", ); const coder_app = state.resources.find( @@ -35,7 +35,7 @@ describe("zed", async () => { folder: "/foo/bar", }); expect(state.outputs.zed_url.value).toBe( - "zed://ssh/default.default.coder/foo/bar", + "zed://ssh/default.coder/foo/bar", ); }); @@ -75,7 +75,7 @@ describe("zed", async () => { agent_name: "myagent", }); expect(state.outputs.zed_url.value).toBe( - "zed://ssh/myagent.default.me.coder", + "zed://ssh/myagent.default.default.coder", ); }); }); diff --git a/registry/coder/modules/zed/main.tf b/registry/coder/modules/zed/main.tf index 84c3dface..682c41074 100644 --- a/registry/coder/modules/zed/main.tf +++ b/registry/coder/modules/zed/main.tf @@ -57,7 +57,7 @@ locals { workspace_name = lower(data.coder_workspace.me.name) owner_name = lower(data.coder_workspace_owner.me.name) agent_name = lower(var.agent_name) - hostname = var.agent_name != "" ? "${local.agent_name}.${local.workspace_name}.me.coder" : "${local.workspace_name}.${local.owner_name}.coder" + hostname = var.agent_name != "" ? "${local.agent_name}.${local.workspace_name}.${local.owner_name}.coder" : "${local.workspace_name}.coder" } resource "coder_app" "zed" { From ec52f9f190bc0015d86968650a1436b8fa8280b2 Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Thu, 3 Jul 2025 20:21:02 +0000 Subject: [PATCH 5/8] Add important note about Zed requirements to README Add note that Zed needs either Coder CLI with config-ssh or Coder Desktop to work properly with SSH connections. Co-authored-by: matifali <10648092+matifali@users.noreply.github.com> --- registry/coder/modules/zed/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/registry/coder/modules/zed/README.md b/registry/coder/modules/zed/README.md index d939f8d82..3652a4096 100644 --- a/registry/coder/modules/zed/README.md +++ b/registry/coder/modules/zed/README.md @@ -13,6 +13,9 @@ Add a button to open any workspace with a single click in Zed IDE. Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter. +> [!IMPORTANT] +> Zed needs you to either have Coder CLI installed with `coder config-ssh` run or [Coder Desktop](https://coder.com/docs/user-guides/desktop). + ```tf module "zed" { count = data.coder_workspace.me.start_count From ef8d732eabad881c19ae2f09cd328f5f313b0c86 Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Thu, 3 Jul 2025 20:30:55 +0000 Subject: [PATCH 6/8] Change display name from 'Zed IDE' to 'Zed Editor' - Update default display_name in main.tf - Update variable descriptions to use 'Zed Editor' - Update output description - Update README frontmatter and title - Update all references in README content Makes the naming consistent throughout the module. Co-authored-by: matifali <10648092+matifali@users.noreply.github.com> --- registry/coder/modules/zed/README.md | 8 ++++---- registry/coder/modules/zed/main.tf | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/registry/coder/modules/zed/README.md b/registry/coder/modules/zed/README.md index 3652a4096..39757171d 100644 --- a/registry/coder/modules/zed/README.md +++ b/registry/coder/modules/zed/README.md @@ -1,15 +1,15 @@ --- -display_name: Zed IDE -description: Add a one-click button to launch Zed IDE +display_name: Zed Editor +description: Add a one-click button to launch Zed Editor icon: ../../../../.icons/zed.svg maintainer_github: coder verified: true tags: [ide, zed, editor] --- -# Zed IDE +# Zed Editor -Add a button to open any workspace with a single click in Zed IDE. +Add a button to open any workspace with a single click in Zed Editor. Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter. diff --git a/registry/coder/modules/zed/main.tf b/registry/coder/modules/zed/main.tf index 682c41074..b763487af 100644 --- a/registry/coder/modules/zed/main.tf +++ b/registry/coder/modules/zed/main.tf @@ -22,7 +22,7 @@ variable "agent_name" { variable "folder" { type = string - description = "The folder to open in Zed IDE." + description = "The folder to open in Zed Editor." default = "" } @@ -47,7 +47,7 @@ variable "slug" { variable "display_name" { type = string description = "The display name of the app." - default = "Zed IDE" + default = "Zed Editor" } data "coder_workspace" "me" {} @@ -73,5 +73,5 @@ resource "coder_app" "zed" { output "zed_url" { value = coder_app.zed.url - description = "Zed IDE URL." + description = "Zed Editor URL." } From 9394169c3bf9bd75d3d854ccab65d1de3a5d6d97 Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Thu, 3 Jul 2025 20:38:13 +0000 Subject: [PATCH 7/8] Simplify display name to just 'Zed' and remove trailing period - Change display_name from 'Zed Editor' to 'Zed' everywhere - Update main.tf default display_name and descriptions - Update README frontmatter, title, and content - Remove trailing period from important note as requested Addresses PR feedback for simpler, cleaner naming. Co-authored-by: matifali <10648092+matifali@users.noreply.github.com> --- registry/coder/modules/zed/README.md | 10 +++++----- registry/coder/modules/zed/main.tf | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/registry/coder/modules/zed/README.md b/registry/coder/modules/zed/README.md index 39757171d..ea11372eb 100644 --- a/registry/coder/modules/zed/README.md +++ b/registry/coder/modules/zed/README.md @@ -1,20 +1,20 @@ --- -display_name: Zed Editor -description: Add a one-click button to launch Zed Editor +display_name: Zed +description: Add a one-click button to launch Zed icon: ../../../../.icons/zed.svg maintainer_github: coder verified: true tags: [ide, zed, editor] --- -# Zed Editor +# Zed -Add a button to open any workspace with a single click in Zed Editor. +Add a button to open any workspace with a single click in Zed. Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter. > [!IMPORTANT] -> Zed needs you to either have Coder CLI installed with `coder config-ssh` run or [Coder Desktop](https://coder.com/docs/user-guides/desktop). +> Zed needs you to either have Coder CLI installed with `coder config-ssh` run or [Coder Desktop](https://coder.com/docs/user-guides/desktop) ```tf module "zed" { diff --git a/registry/coder/modules/zed/main.tf b/registry/coder/modules/zed/main.tf index b763487af..87270114b 100644 --- a/registry/coder/modules/zed/main.tf +++ b/registry/coder/modules/zed/main.tf @@ -22,7 +22,7 @@ variable "agent_name" { variable "folder" { type = string - description = "The folder to open in Zed Editor." + description = "The folder to open in Zed." default = "" } @@ -47,7 +47,7 @@ variable "slug" { variable "display_name" { type = string description = "The display name of the app." - default = "Zed Editor" + default = "Zed" } data "coder_workspace" "me" {} @@ -73,5 +73,5 @@ resource "coder_app" "zed" { output "zed_url" { value = coder_app.zed.url - description = "Zed Editor URL." + description = "Zed URL." } From 904159e6572801d472b9d6938bf18da9d3dffa31 Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Thu, 3 Jul 2025 20:41:38 +0000 Subject: [PATCH 8/8] Remove trailing periods from all description fields Remove trailing periods from all variable and output description fields to follow consistent formatting conventions. Co-authored-by: matifali <10648092+matifali@users.noreply.github.com> --- registry/coder/modules/zed/main.tf | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/registry/coder/modules/zed/main.tf b/registry/coder/modules/zed/main.tf index 87270114b..2f6376a44 100644 --- a/registry/coder/modules/zed/main.tf +++ b/registry/coder/modules/zed/main.tf @@ -11,42 +11,42 @@ terraform { variable "agent_id" { type = string - description = "The ID of a Coder agent." + description = "The ID of a Coder agent" } variable "agent_name" { type = string - description = "The name of the agent." + description = "The name of the agent" default = "" } variable "folder" { type = string - description = "The folder to open in Zed." + description = "The folder to open in Zed" default = "" } variable "order" { type = number - description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)." + description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)" default = null } variable "group" { type = string - description = "The name of a group that this app belongs to." + description = "The name of a group that this app belongs to" default = null } variable "slug" { type = string - description = "The slug of the app." + description = "The slug of the app" default = "zed" } variable "display_name" { type = string - description = "The display name of the app." + description = "The display name of the app" default = "Zed" } @@ -73,5 +73,5 @@ resource "coder_app" "zed" { output "zed_url" { value = coder_app.zed.url - description = "Zed URL." + description = "Zed URL" }