fix: 修复流程图 AI 功能——自动迁移明文 API Key 而非丢弃#4
Merged
QinQinChina merged 1 commit intoJun 8, 2026
Conversation
SecureStorageService.decrypt() previously discarded values without the 'enc:' prefix, breaking flowchart AI and image generation for users who had saved API keys before encryption was introduced. Now plaintext values are accepted on read and automatically encrypted on disk in the background (one-time migration). This preserves the security improvement while not breaking existing configurations.
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
修复 PR #2 引入的问题:
SecureStorageService.decrypt()遇到无enc:前缀的值时直接返回null,导致已保存的流程图 AI / 图片生成 API Key 被丢弃,功能无法使用。修复方式:
decrypt()遇到明文值时接受并返回(不再丢弃),同时标记needsMigrationLocalSettingsService.readFromDisk()检测到needsMigration后在后台自动重写设置文件(将明文 Key 加密为enc:<base64>)encrypt()在safeStorage不可用时回退存储明文(而非返回null导致丢失)效果:用户无需重新输入 API Key,现有明文配置在首次读取时自动迁移为加密格式。
Scope
packages/app/src/main/services/SecureStorageService.tspackages/app/src/main/services/LocalSettingsService.tsVerification
pnpm run format:checkpnpm run lint(通过推断)pnpm run typecheck— 4 个子包全部通过pnpm run test— 36 tests passedScreenshots or Recordings
N/A
Notes
runFlowchartAiWithSettings需要flowchartAi.apiKey非 null 才能工作)。Link to Devin session: https://app.devin.ai/sessions/26c0ad2a81d3440eaa67d6f4feb3df33
Requested by: @QinQinChina