Repository navigation
Add settings backup/restore functionality with export/import - #17
Conversation
- manifestに固定keyを追加し、拡張機能IDを安定化 (別ディレクトリから読み込んでもchrome.storageが引き継がれる) - Options画面に設定のエクスポート/インポート機能を追加 (JSONファイルによるバックアップ/リストア) https://claude.ai/code/session_01XfY62vnDiXY6WFdDtoY3uS
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f66ea90180
ℹ️ 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".
| if (validData.provider) setProvider(validData.provider as string); | ||
| if (validData.apiKey) setApiKey(validData.apiKey as string); | ||
| if (validData.model) setModel(validData.model as string); | ||
| if (validData.customUrl) setCustomUrl(validData.customUrl as string); |
There was a problem hiding this comment.
Sync empty imported values into local form state
The post-import UI update skips string fields when the imported value is an empty string because it uses truthy checks (if (validData.apiKey), etc.). If a backup intentionally contains "apiKey": "" or "customUrl": "", chrome.storage.sync is updated but the form keeps showing the previous non-empty value, which can mislead users and cause accidental overwrite on the next manual save.
Useful? React with 👍 / 👎.
| for (const key of SETTINGS_KEYS) { | ||
| if (key in data) validData[key] = data[key]; | ||
| } |
There was a problem hiding this comment.
Validate imported setting values before saving
Import currently validates only key names and writes values as-is, so malformed JSON like {"provider":"foo"} is accepted. That leaves invalid settings in sync storage, and the summarize path later fails when generateText rejects unsupported providers, effectively breaking summarization until the user manually repairs settings; validating enum/boolean/string formats before chrome.storage.sync.set would prevent this.
Useful? React with 👍 / 👎.
Summary
This PR adds the ability to export and import extension settings as JSON files, enabling users to easily backup and restore their configuration when reinstalling or migrating the extension.
Key Changes
handleExportSettings()andhandleImportSettings()functions to the Options component that allow users to download their settings as a timestamped JSON file and restore them from a previously exported fileSETTINGS_KEYSconstant array that defines which settings can be backed up (provider, apiKey, model, customUrl, useCustomModel, extractionMode, twoPassMode)keyfield to the manifest configuration to ensure the extension ID remains stable across updates, allowing Chrome storage to persist properly during reinstallsImplementation Details
SETTINGS_KEYS, and updates both storage and UI statehttps://claude.ai/code/session_01XfY62vnDiXY6WFdDtoY3uS