Skip to content

Commit 2932fb4

Browse files
Completely restore cursor module to original state
- Undo all changes to existing cursor module - Keep only the new cursor-cli module - Ensure backward compatibility Co-authored-by: matifali <10648092+matifali@users.noreply.github.com>
1 parent 6ce61c9 commit 2932fb4

File tree

2 files changed

+49
-138
lines changed

2 files changed

+49
-138
lines changed

registry/coder/modules/cursor/main.test.ts

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,29 @@ describe("cursor", async () => {
1212
agent_id: "foo",
1313
});
1414

15-
it("default output with CLI enabled", async () => {
15+
it("default output", async () => {
1616
const state = await runTerraformApply(import.meta.dir, {
1717
agent_id: "foo",
1818
});
19-
20-
// Check desktop app output
21-
expect(state.outputs.cursor_desktop_url.value).toBe(
22-
"cursor://coder.coder-remote/open?owner=default&workspace=default&folder=/home/coder&url=https://mydeployment.coder.com&token=$SESSION_TOKEN",
19+
expect(state.outputs.cursor_url.value).toBe(
20+
"cursor://coder.coder-remote/open?owner=default&workspace=default&url=https://mydeployment.coder.com&token=$SESSION_TOKEN",
2321
);
2422

25-
// Check that AgentAPI module is created
26-
const agentapi_module = state.resources.find(
27-
(res) => res.type === "module" && res.name === "agentapi",
28-
);
29-
expect(agentapi_module).not.toBeNull();
30-
31-
// Check desktop app resource
3223
const coder_app = state.resources.find(
33-
(res) => res.type === "coder_app" && res.name === "cursor_desktop",
24+
(res) => res.type === "coder_app" && res.name === "cursor",
3425
);
26+
3527
expect(coder_app).not.toBeNull();
3628
expect(coder_app?.instances.length).toBe(1);
3729
expect(coder_app?.instances[0].attributes.order).toBeNull();
3830
});
3931

40-
it("adds custom folder", async () => {
32+
it("adds folder", async () => {
4133
const state = await runTerraformApply(import.meta.dir, {
4234
agent_id: "foo",
4335
folder: "/foo/bar",
4436
});
45-
expect(state.outputs.cursor_desktop_url.value).toBe(
37+
expect(state.outputs.cursor_url.value).toBe(
4638
"cursor://coder.coder-remote/open?owner=default&workspace=default&folder=/foo/bar&url=https://mydeployment.coder.com&token=$SESSION_TOKEN",
4739
);
4840
});
@@ -53,53 +45,44 @@ describe("cursor", async () => {
5345
folder: "/foo/bar",
5446
open_recent: "true",
5547
});
56-
expect(state.outputs.cursor_desktop_url.value).toBe(
48+
expect(state.outputs.cursor_url.value).toBe(
5749
"cursor://coder.coder-remote/open?owner=default&workspace=default&folder=/foo/bar&openRecent&url=https://mydeployment.coder.com&token=$SESSION_TOKEN",
5850
);
5951
});
6052

61-
it("adds open_recent with default folder", async () => {
53+
it("adds folder but not open_recent", async () => {
6254
const state = await runTerraformApply(import.meta.dir, {
6355
agent_id: "foo",
64-
open_recent: "true",
56+
folder: "/foo/bar",
57+
openRecent: "false",
6558
});
66-
expect(state.outputs.cursor_desktop_url.value).toBe(
67-
"cursor://coder.coder-remote/open?owner=default&workspace=default&folder=/home/coder&openRecent&url=https://mydeployment.coder.com&token=$SESSION_TOKEN",
59+
expect(state.outputs.cursor_url.value).toBe(
60+
"cursor://coder.coder-remote/open?owner=default&workspace=default&folder=/foo/bar&url=https://mydeployment.coder.com&token=$SESSION_TOKEN",
6861
);
6962
});
7063

71-
it("expect order to be set", async () => {
64+
it("adds open_recent", async () => {
7265
const state = await runTerraformApply(import.meta.dir, {
7366
agent_id: "foo",
74-
order: "22",
67+
open_recent: "true",
7568
});
76-
77-
const coder_app = state.resources.find(
78-
(res) => res.type === "coder_app" && res.name === "cursor_desktop",
69+
expect(state.outputs.cursor_url.value).toBe(
70+
"cursor://coder.coder-remote/open?owner=default&workspace=default&openRecent&url=https://mydeployment.coder.com&token=$SESSION_TOKEN",
7971
);
80-
81-
expect(coder_app).not.toBeNull();
82-
expect(coder_app?.instances.length).toBe(1);
83-
expect(coder_app?.instances[0].attributes.order).toBe(23); // order + 1 for desktop app
8472
});
8573

86-
it("disables CLI installation", async () => {
74+
it("expect order to be set", async () => {
8775
const state = await runTerraformApply(import.meta.dir, {
8876
agent_id: "foo",
89-
install_cursor_cli: "false",
90-
install_agentapi: "false",
77+
order: "22",
9178
});
9279

93-
// Should still have desktop app
9480
const coder_app = state.resources.find(
95-
(res) => res.type === "coder_app" && res.name === "cursor_desktop",
81+
(res) => res.type === "coder_app" && res.name === "cursor",
9682
);
97-
expect(coder_app).not.toBeNull();
9883

99-
// AgentAPI module should still exist but with install_agentapi = false
100-
const agentapi_module = state.resources.find(
101-
(res) => res.type === "module" && res.name === "agentapi",
102-
);
103-
expect(agentapi_module).not.toBeNull();
84+
expect(coder_app).not.toBeNull();
85+
expect(coder_app?.instances.length).toBe(1);
86+
expect(coder_app?.instances[0].attributes.order).toBe(22);
10487
});
10588
});

registry/coder/modules/cursor/main.tf

Lines changed: 26 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
coder = {
66
source = "coder/coder"
7-
version = ">= 2.7"
7+
version = ">= 2.5"
88
}
99
}
1010
}
@@ -14,32 +14,10 @@ variable "agent_id" {
1414
description = "The ID of a Coder agent."
1515
}
1616

17-
data "coder_workspace" "me" {}
18-
19-
data "coder_workspace_owner" "me" {}
20-
21-
variable "order" {
22-
type = number
23-
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)."
24-
default = null
25-
}
26-
27-
variable "group" {
28-
type = string
29-
description = "The name of a group that this app belongs to."
30-
default = null
31-
}
32-
33-
variable "icon" {
34-
type = string
35-
description = "The icon to use for the app."
36-
default = "/icon/cursor.svg"
37-
}
38-
3917
variable "folder" {
4018
type = string
41-
description = "The folder to run Cursor in."
42-
default = "/home/coder"
19+
description = "The folder to open in Cursor IDE."
20+
default = ""
4321
}
4422

4523
variable "open_recent" {
@@ -48,106 +26,56 @@ variable "open_recent" {
4826
default = false
4927
}
5028

51-
variable "install_cursor_cli" {
52-
type = bool
53-
description = "Whether to install Cursor CLI."
54-
default = true
55-
}
56-
57-
variable "install_agentapi" {
58-
type = bool
59-
description = "Whether to install AgentAPI."
60-
default = true
61-
}
62-
63-
variable "agentapi_version" {
64-
type = string
65-
description = "The version of AgentAPI to install."
66-
default = "v0.3.3"
67-
}
68-
69-
variable "subdomain" {
70-
type = bool
71-
description = "Whether to use a subdomain for AgentAPI."
72-
default = true
29+
variable "order" {
30+
type = number
31+
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)."
32+
default = null
7333
}
7434

75-
variable "pre_install_script" {
35+
variable "group" {
7636
type = string
77-
description = "Custom script to run before installing Cursor CLI."
37+
description = "The name of a group that this app belongs to."
7838
default = null
7939
}
8040

81-
variable "post_install_script" {
41+
variable "slug" {
8242
type = string
83-
description = "Custom script to run after installing Cursor CLI."
84-
default = null
43+
description = "The slug of the app."
44+
default = "cursor"
8545
}
8646

87-
locals {
88-
app_slug = "cursor"
89-
install_script = file("${path.module}/scripts/install.sh")
90-
start_script = file("${path.module}/scripts/start.sh")
91-
module_dir_name = ".cursor-module"
47+
variable "display_name" {
48+
type = string
49+
description = "The display name of the app."
50+
default = "Cursor Desktop"
9251
}
9352

94-
module "agentapi" {
95-
source = "registry.coder.com/coder/agentapi/coder"
96-
version = "1.1.0"
97-
98-
agent_id = var.agent_id
99-
web_app_slug = local.app_slug
100-
web_app_order = var.order
101-
web_app_group = var.group
102-
web_app_icon = var.icon
103-
web_app_display_name = "Cursor"
104-
cli_app_slug = "${local.app_slug}-cli"
105-
cli_app_display_name = "Cursor CLI"
106-
module_dir_name = local.module_dir_name
107-
install_agentapi = var.install_agentapi
108-
agentapi_version = var.agentapi_version
109-
agentapi_subdomain = var.subdomain
110-
pre_install_script = var.pre_install_script
111-
post_install_script = var.post_install_script
112-
start_script = local.start_script
113-
install_script = <<-EOT
114-
#!/bin/bash
115-
set -o errexit
116-
set -o pipefail
117-
118-
echo -n '${base64encode(local.install_script)}' | base64 -d > /tmp/install.sh
119-
chmod +x /tmp/install.sh
120-
121-
ARG_FOLDER='${var.folder}' \
122-
ARG_INSTALL='${var.install_cursor_cli}' \
123-
/tmp/install.sh
124-
EOT
125-
}
53+
data "coder_workspace" "me" {}
54+
data "coder_workspace_owner" "me" {}
12655

127-
# Legacy desktop app for backward compatibility
128-
resource "coder_app" "cursor_desktop" {
56+
resource "coder_app" "cursor" {
12957
agent_id = var.agent_id
13058
external = true
131-
icon = var.icon
132-
slug = "cursor-desktop"
133-
display_name = "Cursor Desktop"
134-
order = var.order != null ? var.order + 1 : null
59+
icon = "/icon/cursor.svg"
60+
slug = var.slug
61+
display_name = var.display_name
62+
order = var.order
13563
group = var.group
13664
url = join("", [
13765
"cursor://coder.coder-remote/open",
13866
"?owner=",
13967
data.coder_workspace_owner.me.name,
14068
"&workspace=",
14169
data.coder_workspace.me.name,
142-
var.folder != "/home/coder" ? join("", ["&folder=", var.folder]) : "",
70+
var.folder != "" ? join("", ["&folder=", var.folder]) : "",
14371
var.open_recent ? "&openRecent" : "",
14472
"&url=",
14573
data.coder_workspace.me.access_url,
14674
"&token=$SESSION_TOKEN",
14775
])
14876
}
14977

150-
output "cursor_desktop_url" {
151-
value = coder_app.cursor_desktop.url
78+
output "cursor_url" {
79+
value = coder_app.cursor.url
15280
description = "Cursor IDE Desktop URL."
15381
}

0 commit comments

Comments
 (0)