From 34141c27032f15dd60f09a4a1a27e3ac92fbf696 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Mon, 25 Aug 2025 17:51:51 +0000 Subject: [PATCH 1/3] feat(claude-code): add configurable subdomain support --- registry/coder/modules/claude-code/main.tf | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/registry/coder/modules/claude-code/main.tf b/registry/coder/modules/claude-code/main.tf index 7175311ff..ada36c82e 100644 --- a/registry/coder/modules/claude-code/main.tf +++ b/registry/coder/modules/claude-code/main.tf @@ -103,6 +103,12 @@ variable "agentapi_version" { default = "v0.3.0" } +variable "subdomain" { + type = bool + description = "Whether to use a subdomain for the Claude Code app." + default = true +} + locals { # we have to trim the slash because otherwise coder exp mcp will # set up an invalid claude config @@ -113,6 +119,13 @@ locals { agentapi_wait_for_start_script_b64 = base64encode(file("${path.module}/scripts/agentapi-wait-for-start.sh")) remove_last_session_id_script_b64 = base64encode(file("${path.module}/scripts/remove-last-session-id.sh")) claude_code_app_slug = "ccw" + // Chat base path is only set if not using a subdomain. + // NOTE: + // - Initial support for --chat-base-path was added in v0.3.1 but configuration + // via environment variable AGENTAPI_CHAT_BASE_PATH was added in v0.3.3. + // - As CODER_WORKSPACE_AGENT_NAME is a recent addition we use agent ID + // for backward compatibility. + agentapi_chat_base_path = var.subdomain ? "" : "/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}.${var.agent_id}/apps/${local.claude_code_app_slug}/chat" } # Install and Initialize Claude Code @@ -229,6 +242,9 @@ resource "coder_script" "claude_code" { # Disable host header check since AgentAPI is proxied by Coder (which does its own validation) export AGENTAPI_ALLOWED_HOSTS="*" + + # Set chat base path for non-subdomain routing (only set if not using subdomain) + export AGENTAPI_CHAT_BASE_PATH="${local.agentapi_chat_base_path}" nohup "$module_path/scripts/agentapi-start.sh" use_prompt &> "$module_path/agentapi-start.log" & "$module_path/scripts/agentapi-wait-for-start.sh" @@ -245,7 +261,7 @@ resource "coder_app" "claude_code_web" { icon = var.icon order = var.order group = var.group - subdomain = true + subdomain = var.subdomain healthcheck { url = "http://localhost:3284/status" interval = 3 From ef25f59316c2e5030a2585250ddeba460006cb35 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Mon, 25 Aug 2025 18:13:23 +0000 Subject: [PATCH 2/3] fix: update AgentAPI default version to v0.3.3 and improve healthcheck URL configuration --- registry/coder/modules/claude-code/main.tf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/registry/coder/modules/claude-code/main.tf b/registry/coder/modules/claude-code/main.tf index ada36c82e..e56b8844b 100644 --- a/registry/coder/modules/claude-code/main.tf +++ b/registry/coder/modules/claude-code/main.tf @@ -100,7 +100,7 @@ variable "install_agentapi" { variable "agentapi_version" { type = string description = "The version of AgentAPI to install." - default = "v0.3.0" + default = "v0.3.3" } variable "subdomain" { @@ -126,6 +126,8 @@ locals { // - As CODER_WORKSPACE_AGENT_NAME is a recent addition we use agent ID // for backward compatibility. agentapi_chat_base_path = var.subdomain ? "" : "/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}.${var.agent_id}/apps/${local.claude_code_app_slug}/chat" + server_base_path = var.subdomain ? "" : "/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}.${var.agent_id}/apps/${local.claude_code_app_slug}" + healthcheck_url = "http://localhost:3284${local.server_base_path}/status" } # Install and Initialize Claude Code @@ -263,7 +265,7 @@ resource "coder_app" "claude_code_web" { group = var.group subdomain = var.subdomain healthcheck { - url = "http://localhost:3284/status" + url = local.healthcheck_url interval = 3 threshold = 20 } From a1618eddeeef11d11c0429ed9b6641559f2e0714 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Mon, 25 Aug 2025 20:20:18 +0000 Subject: [PATCH 3/3] chore: minor version bump to 2.2.0 --- registry/coder/modules/claude-code/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/registry/coder/modules/claude-code/README.md b/registry/coder/modules/claude-code/README.md index 313e43182..91e966362 100644 --- a/registry/coder/modules/claude-code/README.md +++ b/registry/coder/modules/claude-code/README.md @@ -13,7 +13,7 @@ Run the [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude ```tf module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "2.1.0" + version = "2.2.0" agent_id = coder_agent.example.id folder = "/home/coder" install_claude_code = true @@ -83,7 +83,7 @@ resource "coder_agent" "main" { module "claude-code" { count = data.coder_workspace.me.start_count source = "registry.coder.com/coder/claude-code/coder" - version = "2.1.0" + version = "2.2.0" agent_id = coder_agent.example.id folder = "/home/coder" install_claude_code = true @@ -101,7 +101,7 @@ Run Claude Code as a standalone app in your workspace. This will install Claude ```tf module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "2.1.0" + version = "2.2.0" agent_id = coder_agent.example.id folder = "/home/coder" install_claude_code = true