Skip to content

fix: support JSON-with-comments for OpenCode/Claude config and keep provider save on live sync failure#1350

Open
crmmc wants to merge 2 commits intofarion1231:mainfrom
crmmc:main
Open

fix: support JSON-with-comments for OpenCode/Claude config and keep provider save on live sync failure#1350
crmmc wants to merge 2 commits intofarion1231:mainfrom
crmmc:main

Conversation

@crmmc
Copy link

@crmmc crmmc commented Mar 8, 2026

Background

When opencode.json or Claude live config contains comments, strict JSON parsing fails.
This could block provider-related save flows (including non-OpenCode providers) because live sync paths also touch OpenCode/Claude config parsing.

What changed

  1. Enabled comment-tolerant JSON parsing for OpenCode and Claude live config reads.
  2. Changed provider add/update flow to preserve CC Switch internal save (DB) even if live sync fails.
    • Live sync / MCP sync failures are now returned as warnings instead of hard-failing the whole save.
  3. Added frontend warning toasts for these non-fatal sync failures, so users still see clear error feedback.
  4. Updated related API typing and test mocks for the new warning payload.

Why this fixes the issue

  • Commented config files are now parsed correctly, avoiding unnecessary parse failures.
  • Save behavior is split into:
    • internal config persistence (must succeed)
    • live sync (best-effort with explicit warnings)

So users no longer lose save capability in CC Switch due to external live config parse/sync errors.

Validation

  • pnpm typecheck
  • pnpm format:check
  • pnpm test:unit (24 files, 167 tests)

All passed.

Thanks for the review.

@farion1231
Copy link
Owner

@codex

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. 👍

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

2 participants