Skip to content

fix(claude-plugin): sync current provider config to settings.json#1905

Merged
farion1231 merged 3 commits intofarion1231:mainfrom
chengww5217:fix/enable-claude-plugin-integration-sync
Apr 21, 2026
Merged

fix(claude-plugin): sync current provider config to settings.json#1905
farion1231 merged 3 commits intofarion1231:mainfrom
chengww5217:fix/enable-claude-plugin-integration-sync

Conversation

@chengww5217
Copy link
Copy Markdown
Contributor

@chengww5217 chengww5217 commented Apr 5, 2026

Summary / 概述

When enabling the "Apply to Claude Code extension" toggle (enableClaudePluginIntegration), the app only wrote primaryApiKey to ~/.claude/config.json but never synced the current provider's full config (apiKey, apiBaseUrl, etc.) to ~/.claude/settings.json. This caused the VS Code Claude Code extension to fail to connect, especially for first-time users.

This PR fixes the issue by:

  1. Determining the actual provider type (official or not) instead of hardcoding official: false
  2. Calling syncCurrentProvidersLiveSafe() to write the current provider's full config to ~/.claude/settings.json when the toggle is enabled

Related Issue / 关联 Issue

Fixes #1904

Screenshots / 截图

Before / 修改前 After / 修改后
Toggle on → settings.json empty, extension cannot connect Toggle on → settings.json synced with current provider config immediately

Checklist / 检查清单

  • pnpm typecheck passes / 通过 TypeScript 类型检查
  • pnpm format:check passes / 通过代码格式检查
  • cargo clippy passes (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)
    N/A, no Rust code changed
  • Updated i18n files if user-facing text changed / 如修改了用户可见文本,已更新国际化文件
    N/A, no user-facing text changed

@chengww5217
Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@farion1231
Copy link
Copy Markdown
Owner

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c5bf24ae97

ℹ️ 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".

Comment thread src/hooks/useSettings.ts Outdated
Comment thread src/hooks/useSettings.ts Outdated
@chengww5217 chengww5217 force-pushed the fix/enable-claude-plugin-integration-sync branch 2 times, most recently from 13110a2 to b994f5f Compare April 5, 2026 12:13
chengww5217 and others added 2 commits April 21, 2026 11:04
…toggle enable

- Extract syncClaudePluginIfChanged to share logic between autoSaveSettings and saveSettings
- Fix P1: enableClaudePluginIntegration toggle in General tab now actually syncs ~/.claude/settings.json
- Fix P2: check syncCurrentProvidersLiveSafe() return value and show toast on failure
- Fix P3: sync providers on both enable and disable, not just enable
- Fix P4: avoid double syncCurrentProvidersLiveSafe when plugin toggle + dir change happen together
- Remove duplicate comment
- Add missing providersApi.getCurrent/getAll mocks in tests
Prettier flagged a line-break introduced by the openclaw directory
change (from main) after rebase.
@farion1231 farion1231 force-pushed the fix/enable-claude-plugin-integration-sync branch from b994f5f to f087363 Compare April 21, 2026 03:11
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0873634e6

ℹ️ 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".

Comment thread src/hooks/useSettings.ts Outdated
…stale closure

syncClaudePluginIfChanged compared enabled against data?.enableClaudePluginIntegration
captured in a useCallback closure. After invalidateQueries + refetch, the React
Query cache is up to date, but the consuming hook's closure does not see the new
value until React re-renders. Quick on->off toggles could therefore skip
applyClaudePluginConfig, leaving ~/.claude/config.json in the previously enabled
state even though settings.json was persisted as disabled.

Read the previous value synchronously from queryClient.getQueryData(["settings"])
before saveMutation.mutateAsync(), then pass it to the helper as prevEnabled.
getQueryData bypasses the closure and reflects the live cache at call time.

Test covers the race: closure data stays at false while the cache reports true;
the helper must still call applyClaudePluginConfig({ official: true }).
Copy link
Copy Markdown
Owner

@farion1231 farion1231 left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

@farion1231 farion1231 merged commit c5b15dd into farion1231:main Apr 21, 2026
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.

enableClaudePluginIntegration Does Not Immediately Sync Current Provider on Enable

2 participants