Skip to content

Commit f3c24af

Browse files
authored
fix(coder/modules/claude-code): check existing session-ids when using --session-id flag (#557)
1 parent 1436560 commit f3c24af

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

registry/coder/modules/claude-code/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Run the [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude
1313
```tf
1414
module "claude-code" {
1515
source = "registry.coder.com/coder/claude-code/coder"
16-
version = "4.2.0"
16+
version = "4.2.1"
1717
agent_id = coder_agent.example.id
1818
workdir = "/home/coder/project"
1919
claude_api_key = "xxxx-xxxxx-xxxx"
@@ -51,7 +51,7 @@ module "claude-code" {
5151
boundary_log_level = "WARN"
5252
boundary_additional_allowed_urls = ["GET *google.com"]
5353
boundary_proxy_port = "8087"
54-
version = "3.4.3"
54+
version = "4.2.1"
5555
}
5656
```
5757

@@ -70,7 +70,7 @@ data "coder_parameter" "ai_prompt" {
7070
7171
module "claude-code" {
7272
source = "registry.coder.com/coder/claude-code/coder"
73-
version = "4.2.0"
73+
version = "4.2.1"
7474
agent_id = coder_agent.example.id
7575
workdir = "/home/coder/project"
7676
@@ -106,7 +106,7 @@ Run and configure Claude Code as a standalone CLI in your workspace.
106106
```tf
107107
module "claude-code" {
108108
source = "registry.coder.com/coder/claude-code/coder"
109-
version = "4.2.0"
109+
version = "4.2.1"
110110
agent_id = coder_agent.example.id
111111
workdir = "/home/coder"
112112
install_claude_code = true
@@ -129,7 +129,7 @@ variable "claude_code_oauth_token" {
129129
130130
module "claude-code" {
131131
source = "registry.coder.com/coder/claude-code/coder"
132-
version = "4.2.0"
132+
version = "4.2.1"
133133
agent_id = coder_agent.example.id
134134
workdir = "/home/coder/project"
135135
claude_code_oauth_token = var.claude_code_oauth_token
@@ -202,7 +202,7 @@ resource "coder_env" "bedrock_api_key" {
202202
203203
module "claude-code" {
204204
source = "registry.coder.com/coder/claude-code/coder"
205-
version = "4.2.0"
205+
version = "4.2.1"
206206
agent_id = coder_agent.example.id
207207
workdir = "/home/coder/project"
208208
model = "global.anthropic.claude-sonnet-4-5-20250929-v1:0"
@@ -259,7 +259,7 @@ resource "coder_env" "google_application_credentials" {
259259
260260
module "claude-code" {
261261
source = "registry.coder.com/coder/claude-code/coder"
262-
version = "4.2.0"
262+
version = "4.2.1"
263263
agent_id = coder_agent.example.id
264264
workdir = "/home/coder/project"
265265
model = "claude-sonnet-4@20250514"

registry/coder/modules/claude-code/scripts/start.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,13 @@ task_session_exists() {
103103
local workdir_normalized=$(echo "$ARG_WORKDIR" | tr '/' '-')
104104
local project_dir="$HOME/.claude/projects/${workdir_normalized}"
105105

106+
printf "PROJECT_DIR: %s, workdir_normalized: %s\n" "$project_dir" "$workdir_normalized"
107+
106108
if [ -d "$project_dir" ] && find "$project_dir" -type f -name "*${TASK_SESSION_ID}*" 2> /dev/null | grep -q .; then
109+
printf "TASK_SESSION_ID: %s file found\n" "$TASK_SESSION_ID"
107110
return 0
108111
else
112+
printf "TASK_SESSION_ID: %s file not found\n" "$TASK_SESSION_ID"
109113
return 1
110114
fi
111115
}
@@ -149,7 +153,11 @@ function start_agentapi() {
149153
else
150154
echo "No existing session found"
151155
if [ "$ARG_REPORT_TASKS" = "true" ]; then
152-
ARGS+=(--session-id "$TASK_SESSION_ID")
156+
if task_session_exists; then
157+
ARGS+=(--resume "$TASK_SESSION_ID")
158+
else
159+
ARGS+=(--session-id "$TASK_SESSION_ID")
160+
fi
153161
fi
154162
if [ -n "$ARG_AI_PROMPT" ]; then
155163
if [ "$ARG_REPORT_TASKS" = "true" ]; then
@@ -171,7 +179,11 @@ function start_agentapi() {
171179
else
172180
echo "Continue disabled, starting fresh session"
173181
if [ "$ARG_REPORT_TASKS" = "true" ]; then
174-
ARGS+=(--session-id "$TASK_SESSION_ID")
182+
if task_session_exists; then
183+
ARGS+=(--resume "$TASK_SESSION_ID")
184+
else
185+
ARGS+=(--session-id "$TASK_SESSION_ID")
186+
fi
175187
fi
176188
if [ -n "$ARG_AI_PROMPT" ]; then
177189
if [ "$ARG_REPORT_TASKS" = "true" ]; then

0 commit comments

Comments
 (0)