Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions windsurf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Windsurf IDE

Adds a Windsurf IDE application.

## Examples

```hcl
module "windsurf_ide" {
source = "github.com/coder/modules//windsurf"
agent_id = coder_agent.example.id
folder = "/home/coder/project"
}
```

Without a folder parameter:

```hcl
module "windsurf_ide" {
source = "github.com/coder/modules//windsurf"
agent_id = coder_agent.example.id
}
```

## Inputs/Outputs

| Input | Description | Type | Default |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- |
| agent_id | The ID of a Coder agent. | string | |
| folder | The folder to open in Windsurf IDE. | string | "" |
| open_recent | Open the most recent workspace or folder. Falls back to the folder if there is no recent workspace or folder to open. | bool | false |
| order | 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. | number | null |

| Output | Description | Type |
| ------------ | ------------------- | ------ |
| windsurf_url | Windsurf IDE URL. | string |
41 changes: 41 additions & 0 deletions windsurf/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { describe, expect, it } from "vitest";
import { TerraformStack } from "cdktf";
import { generateTraces } from "@coder/cdktf-traces";
import { CoderApp } from "../../cdktf/coder/resources";

describe("windsurf", async () => {
const traces = await generateTraces(__dirname);

it("creates an app", () => {
const stack = new TerraformStack(traces.app, "stack");
const app = CoderApp.fromStack<CoderApp>(stack, "coder_app.windsurf");
expect(app.url).toContain("workspace=");
expect(app.url).toContain("token=$SESSION_TOKEN");
expect(app.icon).toBe("/icon/windsurf.svg");
expect(app.slug).toBe("windsurf");
expect(app.displayName).toBe("Windsurf IDE");
expect(app.external).toBe(true);
});

describe("supports folder spec", () => {
it("folder = '/home/coder'", async () => {
const traces = await generateTraces(__dirname, {
folder: "/home/coder",
});
const stack = new TerraformStack(traces.app, "stack");
const app = CoderApp.fromStack<CoderApp>(stack, "coder_app.windsurf");
expect(app.url).toContain("&folder=/home/coder");
});
});

describe("supports openRecent", () => {
it("open_recent = true", async () => {
const traces = await generateTraces(__dirname, {
open_recent: true,
});
const stack = new TerraformStack(traces.app, "stack");
const app = CoderApp.fromStack<CoderApp>(stack, "coder_app.windsurf");
expect(app.url).toContain("&openRecent");
});
});
});
62 changes: 62 additions & 0 deletions windsurf/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
terraform {
required_version = ">= 1.0"

required_providers {
coder = {
source = "coder/coder"
version = ">= 0.23"
}
}
}

variable "agent_id" {
type = string
description = "The ID of a Coder agent."
}

variable "folder" {
type = string
description = "The folder to open in Windsurf IDE."
default = ""
}

variable "open_recent" {
type = bool
description = "Open the most recent workspace or folder. Falls back to the folder if there is no recent workspace or folder to open."
default = false
}

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
}

data "coder_workspace" "me" {}
data "coder_workspace_owner" "me" {}

resource "coder_app" "windsurf" {
agent_id = var.agent_id
external = true
icon = "/icon/windsurf.svg"
slug = "windsurf"
display_name = "Windsurf IDE"
order = var.order
url = join("", [
"windsurf://coder.coder-remote/open",
"?owner=",
data.coder_workspace_owner.me.name,
"&workspace=",
data.coder_workspace.me.name,
var.folder != "" ? join("", ["&folder=", var.folder]) : "",
var.open_recent ? "&openRecent" : "",
"&url=",
data.coder_workspace.me.access_url,
"&token=$SESSION_TOKEN",
])
}

output "windsurf_url" {
value = coder_app.windsurf.url
description = "Windsurf IDE Desktop URL."
}
Loading