Compare commits

...

7 Commits

Author SHA1 Message Date
blink-so[bot] 602e4a6d84 fix: simplify workspace/folder handling using template variable
- Add WORKSPACE_ARG template variable to main.tf using coalesce()
- Remove conditional logic from run.sh since precondition ensures only one is set
- Much cleaner approach that leverages Terraform's template system properly
2025-08-21 03:52:47 +00:00
blink-so[bot] fef2c41480 fix: escape WORKSPACE_ARG references to avoid Terraform template parsing
Use 14899 to escape shell variables so they're not treated as Terraform
template variables by the templatefile() function.
2025-08-20 23:28:58 +00:00
blink-so[bot] 56dbdd9a5e fix: move WORKSPACE_ARG logic inside function to avoid template variable error
Fixes test failures by ensuring WORKSPACE_ARG is defined within the function
scope rather than as a global template variable.
2025-08-20 23:22:42 +00:00
blink-so[bot] 2da86abcb9 test: add validation test for folder/workspace mutual exclusion 2025-08-20 23:16:29 +00:00
blink-so[bot] 4d4584624e chore: bump module versions (minor) 2025-08-20 23:13:52 +00:00
blink-so[bot] ecb6e8f4bf fix: add missing closing backticks in README
Fixes prettier formatting validation failure.
2025-08-20 23:08:34 +00:00
blink-so[bot] e737aa2a38 feat(vscode-web): add workspace file support
- Add 'workspace' variable to open .code-workspace files
- Add mutual exclusion validation between 'folder' and 'workspace'
- Update run.sh to handle workspace files as arguments to code-server
- Update README with workspace file example
- Bump version to 1.3.2

Fixes workspace file refresh issue by using proper VS Code web URL parameters.
2025-08-20 23:06:12 +00:00
5 changed files with 55 additions and 12 deletions
+18 -5
View File
@@ -14,7 +14,7 @@ Automatically install [Visual Studio Code Server](https://code.visualstudio.com/
module "vscode-web" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/vscode-web/coder"
version = "1.3.1"
version = "1.4.0"
agent_id = coder_agent.example.id
accept_license = true
}
@@ -30,7 +30,7 @@ module "vscode-web" {
module "vscode-web" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/vscode-web/coder"
version = "1.3.1"
version = "1.4.0"
agent_id = coder_agent.example.id
install_prefix = "/home/coder/.vscode-web"
folder = "/home/coder"
@@ -38,13 +38,26 @@ module "vscode-web" {
}
```
### Open a VS Code workspace file
```tf
module "vscode-web" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/vscode-web/coder"
version = "1.4.0"
agent_id = coder_agent.example.id
workspace = "/home/coder/project.code-workspace"
accept_license = true
}
```
### Install Extensions
```tf
module "vscode-web" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/vscode-web/coder"
version = "1.3.1"
version = "1.4.0"
agent_id = coder_agent.example.id
extensions = ["github.copilot", "ms-python.python", "ms-toolsai.jupyter"]
accept_license = true
@@ -59,7 +72,7 @@ Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarte
module "vscode-web" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/vscode-web/coder"
version = "1.3.1"
version = "1.4.0"
agent_id = coder_agent.example.id
extensions = ["dracula-theme.theme-dracula"]
settings = {
@@ -77,7 +90,7 @@ By default, this module installs the latest. To pin a specific version, retrieve
module "vscode-web" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/vscode-web/coder"
version = "1.3.1"
version = "1.4.0"
agent_id = coder_agent.example.id
commit_id = "e54c774e0add60467559eb0d1e229c6452cf8447"
accept_license = true
+13 -1
View File
@@ -38,5 +38,17 @@ describe("vscode-web", async () => {
expect(t).toThrow("Offline mode does not allow extensions to be installed");
});
it("folder and workspace can not be used together", () => {
const t = async () => {
await runTerraformApply(import.meta.dir, {
agent_id: "foo",
accept_license: "true",
folder: "/home/coder",
workspace: "/home/coder/project.code-workspace",
});
};
expect(t).toThrow("Cannot specify both 'folder' and 'workspace'. Please use only one.");
});
// More tests depend on shebang refactors
});
});
+22 -4
View File
@@ -34,7 +34,13 @@ variable "slug" {
variable "folder" {
type = string
description = "The folder to open in vscode-web."
description = "The folder to open in vscode-web. Cannot be used with 'workspace'."
default = ""
}
variable "workspace" {
type = string
description = "Path to a .code-workspace file to open on startup. Cannot be used with 'folder'."
default = ""
}
@@ -178,6 +184,8 @@ resource "coder_script" "vscode-web" {
DISABLE_TRUST : var.disable_trust,
EXTENSIONS_DIR : var.extensions_dir,
FOLDER : var.folder,
WORKSPACE : var.workspace,
WORKSPACE_ARG : coalesce(var.workspace, var.folder),
AUTO_INSTALL_EXTENSIONS : var.auto_install_extensions,
SERVER_BASE_PATH : local.server_base_path,
COMMIT_ID : var.commit_id,
@@ -186,6 +194,11 @@ resource "coder_script" "vscode-web" {
run_on_start = true
lifecycle {
precondition {
condition = !(var.folder != "" && var.workspace != "")
error_message = "Cannot specify both 'folder' and 'workspace'. Please use only one."
}
precondition {
condition = !var.offline || length(var.extensions) == 0
error_message = "Offline mode does not allow extensions to be installed"
@@ -218,6 +231,11 @@ resource "coder_app" "vscode-web" {
locals {
server_base_path = var.subdomain ? "" : format("/@%s/%s/apps/%s/", data.coder_workspace_owner.me.name, data.coder_workspace.me.name, var.slug)
url = var.folder == "" ? "http://localhost:${var.port}${local.server_base_path}" : "http://localhost:${var.port}${local.server_base_path}?folder=${var.folder}"
healthcheck_url = var.subdomain ? "http://localhost:${var.port}/healthz" : "http://localhost:${var.port}${local.server_base_path}/healthz"
}
# Mutually exclusive: workspace takes precedence over folder
query_param = var.workspace != "" ? "workspace=${urlencode(var.workspace)}" : (var.folder != "" ? "folder=${urlencode(var.folder)}" : "")
url = local.query_param != "" ? "http://localhost:${var.port}${local.server_base_path}?${local.query_param}" : "http://localhost:${var.port}${local.server_base_path}"
healthcheck_url = var.subdomain ? "http://localhost:${var.port}/healthz" : "http://localhost:${var.port}${local.server_base_path}/healthz"
}
+2 -2
View File
@@ -23,9 +23,9 @@ if [ "${DISABLE_TRUST}" = true ]; then
fi
run_vscode_web() {
echo "👷 Running $VSCODE_WEB serve-local $EXTENSION_ARG $SERVER_BASE_PATH_ARG $DISABLE_TRUST_ARG --port ${PORT} --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level ${TELEMETRY_LEVEL} in the background..."
echo "👷 Running $VSCODE_WEB serve-local with workspace: ${WORKSPACE_ARG}"
echo "Check logs at ${LOG_PATH}!"
"$VSCODE_WEB" serve-local "$EXTENSION_ARG" "$SERVER_BASE_PATH_ARG" "$DISABLE_TRUST_ARG" --port "${PORT}" --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level "${TELEMETRY_LEVEL}" > "${LOG_PATH}" 2>&1 &
"$VSCODE_WEB" serve-local "$EXTENSION_ARG" "$SERVER_BASE_PATH_ARG" "$DISABLE_TRUST_ARG" --port "${PORT}" --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level "${TELEMETRY_LEVEL}" "${WORKSPACE_ARG}" > "${LOG_PATH}" 2>&1 &
}
# Check if the settings file exists...
BIN
View File
Binary file not shown.