Skip to content

fix: preserve Zed settings during connect#953

Open
IgorArkhipov wants to merge 1 commit into
rohitg00:mainfrom
IgorArkhipov:fix/952-zed-settings-initialization
Open

fix: preserve Zed settings during connect#953
IgorArkhipov wants to merge 1 commit into
rohitg00:mainfrom
IgorArkhipov:fix/952-zed-settings-initialization

Conversation

@IgorArkhipov

@IgorArkhipov IgorArkhipov commented Jun 20, 2026

Copy link
Copy Markdown

Summary

  • preserve existing Zed settings.json content when adding context_servers.agentmemory
  • parse/edit Zed settings as JSONC so comments and trailing commas do not cause the config to be treated as empty
  • leave invalid existing JSON MCP config unchanged instead of replacing it
  • add a regression test covering existing Zed settings, comments, and another context server

Root Cause

agentmemory connect zed used the shared JSON MCP adapter, which parsed settings with strict JSON.parse. Zed settings may be JSONC, so comments or trailing commas caused parsing to fail. The adapter then treated the existing file as missing/empty and wrote a fresh config containing only context_servers.agentmemory.

Validation

  • npm run build
  • npm test -- test/connect-new-agents.test.ts
  • npm test

Fixes #952

Summary by CodeRabbit

  • New Features

    • Added JSONC support for MCP configuration updates, preserving existing comments and non-standard JSONC content while updating settings.
    • Improved Zed MCP integration to maintain existing context_servers entries and comments during installs.
  • Improvements

    • Enhanced atomic configuration file writing to reduce the risk of partial updates and keep formatting stable.
  • Tests

    • Added coverage to verify JSONC settings content is preserved when agentmemory is added.

@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

@IgorArkhipov is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 223e8959-2c1a-46af-9ea7-e1db8f99468a

📥 Commits

Reviewing files that changed from the base of the PR and between 17f6c1d and 0be9466.

📒 Files selected for processing (5)
  • package.json
  • src/cli/connect/json-mcp-adapter.ts
  • src/cli/connect/util.ts
  • src/cli/connect/zed.ts
  • test/connect-new-agents.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • package.json
  • src/cli/connect/zed.ts
  • src/cli/connect/util.ts
  • test/connect-new-agents.test.ts
  • src/cli/connect/json-mcp-adapter.ts

📝 Walkthrough

Walkthrough

Adds jsonc-parser as a dependency and updates the Zed MCP adapter to parse, edit, and verify settings.json with JSONC support. It also extracts shared atomic text writing, enables JSONC for Zed, and adds a regression test covering preservation of comments and existing entries.

Changes

JSONC-safe Zed settings merge

Layer / File(s) Summary
Dependency and writeTextAtomic utility
package.json, src/cli/connect/util.ts
Adds jsonc-parser and extracts shared atomic text writing into writeTextAtomic, with writeJsonAtomic delegating to it after formatting JSON.
JSONC config types, helpers, and install/write logic
src/cli/connect/json-mcp-adapter.ts
Adds jsonc?: boolean, JSON/JSONC config parsing helpers, JSONC edit application via modify/applyEdits, and verification based on re-reading parsed config.
Zed wiring and JSONC preservation test
src/cli/connect/zed.ts, test/connect-new-agents.test.ts
Enables JSONC handling for Zed and adds a test that preserves comments and existing context_servers entries while adding agentmemory.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • rohitg00/agentmemory#677: Shares the same src/cli/connect/json-mcp-adapter.ts and src/cli/connect/zed.ts adapter path that this JSONC update extends.

Poem

🐇 I hopped through JSONC, neat and bright,
Keeping Zed's old comments in sight.
One server added, none erased,
By atomic writes, the config stayed grazed.
Carrots for settings, preserved just right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change: preserving Zed settings during connect.
Linked Issues check ✅ Passed The changes preserve existing Zed settings, merge context_servers.agentmemory, handle JSONC, and add a regression test as requested.
Out of Scope Changes check ✅ Passed All changes support the Zed settings merge fix and related regression coverage; no unrelated scope appears introduced.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@IgorArkhipov IgorArkhipov marked this pull request as ready for review June 20, 2026 04:01
Signed-off-by: Igor Arkhipov <igor.arkhipov@joinhandshake.com>
@IgorArkhipov IgorArkhipov force-pushed the fix/952-zed-settings-initialization branch from 17f6c1d to 0be9466 Compare June 29, 2026 01:46
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.

agentmemory connect zed overwrites existing Zed settings.json instead of merging context_servers

1 participant