Skip to content

feat: add edit-json CLI command and fix custom JSON key preservation#157

Open
52dyd wants to merge 3 commits intoSaladDay:mainfrom
52dyd:allow-edit-json
Open

feat: add edit-json CLI command and fix custom JSON key preservation#157
52dyd wants to merge 3 commits intoSaladDay:mainfrom
52dyd:allow-edit-json

Conversation

@52dyd
Copy link
Copy Markdown

@52dyd 52dyd commented May 5, 2026

Summary

  • Add edit-json provider CLI command to edit provider settings_config in an external editor
  • Fix custom JSON key preservation: deep-merge saves and live snapshots no longer drop user-added keys
  • Add --force flag for full settings_config replacement (skip merge)

Changes

  • New edit-json CLI subcommand with external editor integration
  • save_provider, update_provider_settings_config, build_effective_live_snapshot, and write_live_snapshot now merge into existing settings instead of overwriting
  • merge_settings_config helper uses deep-merge to preserve custom keys in the DB layer
  • json_deep_merge, is_codex_official_provider, codex_config_has_base_url made pub(crate) for cross-module reuse
  • Proxy token sync and legacy Codex config migration updated to use merge mode

Test plan

  • Unit tests for JSON validation (syntax errors, non-object rejection, Codex base_url checks)
  • Unit tests for merge vs force-replace behavior
  • Integration tests for custom key preservation through switch round-trip (Codex + Gemini)
  • Existing test suite passes

52dyd and others added 3 commits May 5, 2026 13:30
Add `cc-switch edit-json provider <id> --app-type <type>` command for
editing provider settings_config via external editor with `--force` flag
for full replacement (default: incremental merge).

Fix custom JSON keys disappearing after TUI switch/edit operations:
- DB layer: save_provider and update_provider_settings_config now merge
  incoming settings_config with existing DB row to preserve custom keys
- Live snapshots: Codex/Gemini build_effective_live_snapshot and
  refresh_provider_snapshot functions now clone provider.settings_config
  and update in-place instead of rebuilding from scratch

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Inline useless passthrough function apply_settings_config_update
- Fix dead assertion in no_change_detection test
- Simplify make_provider to use Provider::with_id()
- Extract duplicate merge logic into merge_settings_config helper
- Combine redundant DB round-trips in save_provider into single SELECT
- Remove redundant auth/config re-inserts in Codex build_effective_live_snapshot

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.

1 participant