From 9105618285d3245ed23e3a07e58fb33f5f236f39 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 15:19:51 +0000 Subject: [PATCH] fix: show only the current runner status in freeform WELCOME.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Short Summary (TL;DR) The freeform self-hosted runner status no longer piles up in `~/WELCOME.txt`. Each workspace start now replaces the previous status line, so a stale "NOT started" line from the first boot goes away too. ## The Issue Freeform copies `~/WELCOME.txt` once and keeps it across restarts. The runner startup snippet appended its status line on every start. After many restarts, the file showed one "✓ N Claude Code self-hosted runner(s) started" line per start. It also kept the "✗ … NOT started: save your environment secret" line from the first boot, when no secret existed yet. ## How This PR Solves The Issue Before it writes the status, the startup snippet deletes every line in `~/WELCOME.txt` that contains "Claude Code self-hosted runner". The deletion runs even when the runner is disabled, so turning the runner off also removes its old line. Existing workspaces lose their accumulated lines on the next start. ## Manual Testing Instructions Push the template as an inactive version: ```bash make push-template-freeform ACTIVATE=false coder templates versions list freeform ``` Create a workspace from that version with the runner on: ```bash coder create --template freeform --template-version runnertest --yes --use-parameter-defaults --parameter enable_claude_runner=true --parameter claude_runner_capacity=1 coder ssh runnertest -- "grep 'self-hosted runner' ~/WELCOME.txt" # Expect one "✗ ... NOT started" line ``` Add a secret and restart twice: ```bash coder ssh runnertest -- "echo dummy > ~/.claude-runner/environment-secret && chmod 600 ~/.claude-runner/environment-secret" coder restart runnertest --yes coder restart runnertest --yes coder ssh runnertest -- "grep 'self-hosted runner' ~/WELCOME.txt" # Expect exactly one "✓ 1 Claude Code self-hosted runner(s) started" line, and no "NOT started" line ``` Clean up: ```bash coder delete runnertest --yes ``` ## Automated Testing Overview Claude Code ran `terraform fmt -check -recursive`, `make validate`, and `make test-templates` on Linux, and all passed. Claude Code ran the manual steps above on staging-coder.ddev.com. `WELCOME.txt` stayed at one runner line and 19 lines total after two restarts. No new Terraform tests: the mock tests don't run the startup script. ## Release/Deployment Notes The Claude Code remote control banner in `modules/claude-remote-control` also appends to `~/WELCOME.txt` on every start, so it piles up in freeform the same way. This PR does not change it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01UrTUMvZiSTQq4KvnwqNQTo Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UrTUMvZiSTQq4KvnwqNQTo --- freeform/modules/claude-self-hosted-runner/outputs.tf | 5 +++++ modules/claude-self-hosted-runner/outputs.tf | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/freeform/modules/claude-self-hosted-runner/outputs.tf b/freeform/modules/claude-self-hosted-runner/outputs.tf index a688eb1..4071d0e 100644 --- a/freeform/modules/claude-self-hosted-runner/outputs.tf +++ b/freeform/modules/claude-self-hosted-runner/outputs.tf @@ -10,6 +10,11 @@ output "startup_script" { # Claude Code self-hosted runner, in tmux session "claude-runner". CLAUDE_RUNNER_ENABLED="${local.enabled}" CLAUDE_REMOTE_CONTROL_ENABLED="${var.remote_control_enabled}" + # ~/WELCOME.txt persists across restarts in freeform, so drop the status + # line an earlier start left there; only the current one is shown below. + if [ -f ~/WELCOME.txt ]; then + sed -i '/Claude Code self-hosted runner/d' ~/WELCOME.txt + fi if [ "$CLAUDE_RUNNER_ENABLED" = "true" ]; then # Created before the checks below, so the secret has an obvious home. mkdir -p ~/.claude-runner diff --git a/modules/claude-self-hosted-runner/outputs.tf b/modules/claude-self-hosted-runner/outputs.tf index a688eb1..4071d0e 100644 --- a/modules/claude-self-hosted-runner/outputs.tf +++ b/modules/claude-self-hosted-runner/outputs.tf @@ -10,6 +10,11 @@ output "startup_script" { # Claude Code self-hosted runner, in tmux session "claude-runner". CLAUDE_RUNNER_ENABLED="${local.enabled}" CLAUDE_REMOTE_CONTROL_ENABLED="${var.remote_control_enabled}" + # ~/WELCOME.txt persists across restarts in freeform, so drop the status + # line an earlier start left there; only the current one is shown below. + if [ -f ~/WELCOME.txt ]; then + sed -i '/Claude Code self-hosted runner/d' ~/WELCOME.txt + fi if [ "$CLAUDE_RUNNER_ENABLED" = "true" ]; then # Created before the checks below, so the secret has an obvious home. mkdir -p ~/.claude-runner