Skip to content

fix(#689): provider cache reset after settings import#726

Open
JunyongParkDev wants to merge 1 commit into
Zoo-Code-Org:mainfrom
JunyongParkDev:fix/settings-provider-import-cache
Open

fix(#689): provider cache reset after settings import#726
JunyongParkDev wants to merge 1 commit into
Zoo-Code-Org:mainfrom
JunyongParkDev:fix/settings-provider-import-cache

Conversation

@JunyongParkDev

@JunyongParkDev JunyongParkDev commented Jun 26, 2026

Copy link
Copy Markdown

Related GitHub Issue

Closes: #689

Description

SettingsView uses a local cachedState buffer so settings edits do not write through to live extension state before Save. After importing settings, the cache-busting effect could run multiple times for the same settingsImportedAt value whenever extensionState changed identity.

That could overwrite an in-progress provider edit with the previously saved provider, making the UI briefly switch and then revert.

This change tracks the handled settingsImportedAt value and resets cachedState only once per import event. It also adds a regression test covering the imported-settings flow where Baseten is saved with an API key, the same import timestamp replays, and a later DeepSeek provider edit is preserved and saved.

Test Procedure

  • Ran the focused webview regression test: - all 3 tests passed.

    pnpm --dir webview-ui exec vitest run src/components/settings/__tests__/SettingsView.change-detection.spec.tsx
    
  • Verified the new regression coverage for the imported-settings flow:

    1. Start with settingsImportedAt set.
    2. Change Provider to Baseten.
    3. Enter a Baseten API key.
    4. Save the settings.
    5. Change Provider to DeepSeek.
    6. Replay the same imported extension state timestamp.
    7. Confirm the Provider remains DeepSeek and Save posts apiProvider: "deepseek".
  • This verifies that SettingsView only busts cachedState once per settingsImportedAt value, so a replayed imported state does not overwrite an in-progress Provider edit.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the [Contributor Guidelines](/CONTRIBUTING.md).

Screenshots / Videos

Documentation Updates

Additional Notes

Get in Touch

Summary by CodeRabbit

  • Bug Fixes

    • Improved settings import handling so imported settings are processed only once, preventing repeated cache refreshes and avoiding incorrect change-detection resets.
    • Fixed persistence of provider-related settings when the same import timestamp is replayed, ensuring edits remain intact after saving and reloading.
  • Tests

    • Expanded automated coverage for settings change detection and save behavior across provider switches and imported settings replay.

SettingsView keeps a local cachedState buffer so settings edits do not write through to the live extension state before Save. After importing settings, the import timestamp was used to bust that cache, but the effect could run again for the same import timestamp whenever extensionState changed identity.

That allowed a later live state update to overwrite an in-progress provider edit with the previously saved provider, causing the provider UI to briefly switch and then revert.

Track the handled settingsImportedAt value and only reset cachedState once per import event.

Add a regression test for the imported-settings flow where Baseten is saved with an API key, the same import timestamp is replayed, and a subsequent DeepSeek provider edit is preserved and saved.
@coderabbitai

coderabbitai Bot commented Jun 26, 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 Plus

Run ID: 7a4449d9-6cf9-43ff-b81e-f2cb8af82275

📥 Commits

Reviewing files that changed from the base of the PR and between f75b64e and f8ac8ef.

📒 Files selected for processing (2)
  • webview-ui/src/components/settings/SettingsView.tsx
  • webview-ui/src/components/settings/__tests__/SettingsView.change-detection.spec.tsx

📝 Walkthrough

Walkthrough

SettingsView now handles each settingsImportedAt value once before refreshing cached settings and clearing change detection. The change-detection spec updates its VS Code mocks, renders provider controls, and adds a regression test for provider changes after imported settings.

Changes

Imported settings replay handling

Layer / File(s) Summary
Guard imported state replay
webview-ui/src/components/settings/SettingsView.tsx
SettingsView stores the last handled settingsImportedAt value, then refreshes cachedState and resets isChangeDetected only for a new import timestamp.
Provider regression test
webview-ui/src/components/settings/__tests__/SettingsView.change-detection.spec.tsx
The spec shares a postMessage mock, renders interactive ApiOptions controls, and adds a regression test that saves provider changes after an import and checks the emitted configuration payload.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • taltas
  • JamesRobert20
  • navedmerchant

Poem

A bunny hopped through cache and time,
"One import stamp, one truth, just fine!"
DeepSeek, Baseten—switch and save,
my fluffy paws stayed neat and brave.
🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the cache-reset fix after settings import.
Description check ✅ Passed The description includes the linked issue, change summary, test procedure, and checklist, so it is sufficiently complete.
Linked Issues check ✅ Passed The code and regression test address #689 by preventing repeated cache resets from replayed import timestamps.
Out of Scope Changes check ✅ Passed The changes stay focused on the import cache bug and its test coverage, with no明显 unrelated scope added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

Warning

⚠️ This pull request shows signs of AI-generated slop (trivial_assertion). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

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.

[BUG] API Provider can revert to previous Provider after importing settings

1 participant