Skip to content

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

Merged
35C4n0r merged 3 commits into
mainfrom
35C4n0r/fix-settings-merge-447
Jul 9, 2026
Merged

fix(code-server): merge settings with existing instead of skipping#953
35C4n0r merged 3 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

@DevelopmentCats DevelopmentCats left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM I tested everything and the merges work fine with both python and jq

@35C4n0r 35C4n0r added the version:patch Add to PRs requiring a patch version upgrade label Jul 9, 2026
@35C4n0r 35C4n0r merged commit a6bf545 into main Jul 9, 2026
5 checks passed
@35C4n0r 35C4n0r deleted the 35C4n0r/fix-settings-merge-447 branch July 9, 2026 16:51
rodmk added a commit to rodmk/registry that referenced this pull request Jul 9, 2026
Resolve conflicts against the latest main:

- code-server/run.sh: keep both coder#953's new settings-merge logic
  (base64 SETTINGS_B64/MACHINE_SETTINGS_B64 + merge_settings) and this
  branch's JSONC parsing (strip_jsonc_for_extensions) + null-safe
  recommendations query. Auto-merged cleanly.
- code-server/README.md: version pins resolved to 1.5.2
  (latest release tag v1.5.1 + patch), keeping upstream's coder#953 README
  content outside the version lines.
- vscode-web/README.md: corrected version pins to 1.6.1
  (latest release tag v1.6.0 + patch); the previous 1.6.2 was one ahead
  of the released baseline and would have failed the version-bump CI check.

Validation after merge: bun run fmt:ci, shellcheck, terraform test
(code-server 8/8, vscode-web 3/3), bun test (code-server 8/8,
vscode-web 7/7), and the 25-case JSONC matrix (GNU/BSD/BusyBox sed) all pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

version:patch Add to PRs requiring a patch version upgrade

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vscode-web module: settings not applied

2 participants