Skip to content

fix(code-server): merge settings with existing instead of skipping#953

Open
35C4n0r wants to merge 2 commits into
mainfrom
35C4n0r/fix-settings-merge-447
Open

fix(code-server): merge settings with existing instead of skipping#953
35C4n0r wants to merge 2 commits into
mainfrom
35C4n0r/fix-settings-merge-447

Conversation

@35C4n0r

@35C4n0r 35C4n0r commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Description

The code-server module had the same settings bug reported in #447 for vscode-web: User settings were only written when the file did not exist (silently skipped otherwise), and Machine settings always overwrote the entire file, destroying any existing settings.

This PR ports the merge_settings approach already used in the vscode-web module (added in #758) to code-server, so both modules handle settings the same way.

Type of Change

  • Bug fix
  • Feature/enhancement

Module Information

Path: registry/coder/modules/code-server

What Changed

run.sh

  • Replaced the skip-if-exists User settings block and the always-overwrite Machine settings block with a merge_settings() function (identical to vscode-web).
  • merge_settings() uses jq -s '.[0] * .[1]' for deep merge, falls back to python3, and preserves existing settings with a warning if neither tool is available.
  • Switched from fragile escaped-JSON (replace(jsonencode(...))) to base64 encoding.
  • Empty settings ({}) are now skipped entirely instead of writing an empty object.

main.tf

  • Added locals block with settings_b64 and machine_settings_b64.
  • Replaced SETTINGS / MACHINE_SETTINGS template vars with base64 variants.
  • Updated settings and machine_settings variable descriptions to document merge behaviour.

main.test.ts

  • Added three integration tests: create user settings, merge user settings with existing, merge machine settings with existing.
  • Aligned test structure with vscode-web tests (beforeAll, afterEach cleanup, timeout).

README.md

  • Renamed "Pre-configure Settings" to "Pre-configure User Settings".
  • Updated description to mention merge behaviour.
  • Added jq / python3 requirement warning (matching vscode-web).

Testing & Validation

  • Tests pass (bun test)
  • Code formatted (bun fmt)
  • Changes tested locally
  • Terraform validate and terraform test pass
bun test registry/coder/modules/code-server/main.test.ts
 8 pass, 0 fail

bun test registry/coder/modules/vscode-web/main.test.ts
 7 pass, 0 fail

terraform test (code-server): 8 passed, 0 failed
terraform test (vscode-web):  3 passed, 0 failed

Related Issues

Closes #447


Generated by Coder Agents on behalf of @35C4n0r

The code-server module had two settings bugs matching issue #447:
User settings were only written when the file did not exist, and
machine settings always overwrote the entire file.

Port the merge_settings function from the vscode-web module so both
User and Machine settings are deep-merged (jq, python3 fallback).
Switch from fragile escaped-JSON to base64 encoding. Add integration
tests for create, merge, and machine-merge paths. Update README and
variable descriptions to document the new behaviour.

Also remove the stale python3-fallback comment from vscode-web run.sh.
@35C4n0r 35C4n0r self-assigned this Jul 8, 2026
@35C4n0r 35C4n0r requested a review from andrewdennis117 July 8, 2026 17:15
@35C4n0r 35C4n0r marked this pull request as ready for review July 8, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vscode-web module: settings not applied

1 participant