Skip to content

Add settings backup/restore functionality with export/import - #17

Merged
ivgtr merged 2 commits into
mainfrom
claude/preserve-extension-settings-YJU3M
Mar 12, 2026
Merged

ivgtr merged 2 commits into
mainfrom
claude/preserve-extension-settings-YJU3M

Conversation

@ivgtr

@ivgtr ivgtr commented Mar 12, 2026

Copy link
Copy Markdown
Owner

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

  • Settings Export/Import Functions: Added handleExportSettings() and handleImportSettings() functions to the Options component that allow users to download their settings as a timestamped JSON file and restore them from a previously exported file
  • Settings Keys Definition: Created a SETTINGS_KEYS constant array that defines which settings can be backed up (provider, apiKey, model, customUrl, useCustomModel, extractionMode, twoPassMode)
  • UI Controls: Added a new "設定のバックアップ" (Settings Backup) section with two buttons for exporting and importing settings
  • Validation: Import functionality validates that only recognized settings keys are restored and provides user feedback if the file is invalid or contains no valid settings
  • Manifest Key: Added a fixed key field to the manifest configuration to ensure the extension ID remains stable across updates, allowing Chrome storage to persist properly during reinstalls

Implementation Details

  • Export creates a Blob with formatted JSON and triggers a browser download with a date-stamped filename
  • Import uses a hidden file input to let users select a JSON file, validates the contents against SETTINGS_KEYS, and updates both storage and UI state
  • The UI reflects imported settings immediately with a 3-second success notification
  • Error handling includes alerts for invalid files or missing valid settings

https://claude.ai/code/session_01XfY62vnDiXY6WFdDtoY3uS

claude added 2 commits March 12, 2026 07:15
- manifestに固定keyを追加し、拡張機能IDを安定化
  (別ディレクトリから読み込んでもchrome.storageが引き継がれる)
- Options画面に設定のエクスポート/インポート機能を追加
  (JSONファイルによるバックアップ/リストア)

https://claude.ai/code/session_01XfY62vnDiXY6WFdDtoY3uS
@ivgtr
ivgtr merged commit 5b5e7f6 into main Mar 12, 2026
@ivgtr
ivgtr deleted the claude/preserve-extension-settings-YJU3M branch March 12, 2026 07:52

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

Copy link
Copy Markdown

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: 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".

Comment thread src/options/Options.tsx
Comment on lines +64 to +67
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread src/options/Options.tsx
Comment on lines +55 to +57
for (const key of SETTINGS_KEYS) {
if (key in data) validData[key] = data[key];
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

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