Skip to content

fix: add save button to settings page with draft mode#77

Open
bennylii wants to merge 1 commit into
xiaoY233:mainfrom
bennylii:feat/settings-save-button
Open

fix: add save button to settings page with draft mode#77
bennylii wants to merge 1 commit into
xiaoY233:mainfrom
bennylii:feat/settings-save-button

Conversation

@bennylii
Copy link
Copy Markdown
Contributor

Summary

Fixes #76 — settings page changes were not always persisting correctly with the instant-save approach. This PR converts settings controls to draft mode with an explicit save button.

Changes

  • settingsStore: All setters are now synchronous (zustand only), new saveSettings() batches and persists to backend
  • AppearanceSettings: theme, language, sidebar → draft + save button
  • GeneralSettings: autoStart, autoStartProxy, minimizeToTray, closeBehavior, notifications, oauthProxyMode → draft + save button
  • DataManagement: logLevel, logRetentionDays, maxLogs → draft + save button; requestLogConfig stays immediate-save
  • i18n: Added save, saving, saveSuccess, saveFailed keys (zh-CN + en-US)

How it works

  1. User changes any setting → updates local useState draft only
  2. User clicks "Save Settings" button → writes drafts to store → calls saveSettings() to persist via window.electronAPI.config.update()
  3. Toast feedback on success / failure

Closes #76

- Convert settings controls to draft mode: changes only update local state,
  not persisted until user clicks save
- Add saveSettings() batch persist method to settingsStore
- Make all setters synchronous (no individual config.update calls)
- Add save button with loading state to Appearance, General, DataManagement tabs
- Add i18n keys: save, saving, saveSuccess, saveFailed (zh-CN + en-US)
- requestLogConfig remains immediate-save (by design)

Closes xiaoY233#76
leisvip added a commit to leisvip/Chat2API that referenced this pull request May 3, 2026
Merged PRs from xiaoY233/Chat2API:
- xiaoY233#74: DeepSeek V4 Pro/Flash model support
- xiaoY233#92: Credential encryption toggle
- xiaoY233#93: Kimi K2.6 upgrade
- xiaoY233#84: Account weight-based load balancing
- xiaoY233#83: Qwen silent content drop fix
- xiaoY233#85: data.json performance optimization (log buffering)
- xiaoY233#87: Multi-turn conversation session reuse
- xiaoY233#77: Settings page draft mode with save button
- xiaoY233#106: Qwen context loss fix (messagesToPrompt)
github-actions Bot pushed a commit to PouyaFakhari/Chat2API that referenced this pull request May 5, 2026
@xiaoY233
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: 481dc48f5f

ℹ️ 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 on lines +64 to +66
setLanguage: (language) => {
set({ language })
await i18n.changeLanguage(language)
try {
await window.electronAPI.config.update({ language: language })
} catch (error) {
console.error('Failed to update language:', error)
}
i18n.changeLanguage(language)
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 Persist header language changes to main config

When users switch languages from the header (Header.tsx calls setLanguage directly), this setter now only updates Zustand/i18n and no longer writes the Electron config. Because the Settings page calls fetchConfig() and overwrites language from the main config, a header-only language change is reverted the next time that page is opened (and can also be lost across flows that reload config). Keep the direct setter persistent or add a separate draft-only setter for the Appearance form.

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