Skip to content

fix: 修复流程图 AI 功能——自动迁移明文 API Key 而非丢弃#4

Merged
QinQinChina merged 1 commit into
mainfrom
devin/1780831148-fix-flowchart-api-key-migration
Jun 8, 2026
Merged

fix: 修复流程图 AI 功能——自动迁移明文 API Key 而非丢弃#4
QinQinChina merged 1 commit into
mainfrom
devin/1780831148-fix-flowchart-api-key-migration

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

修复 PR #2 引入的问题:SecureStorageService.decrypt() 遇到无 enc: 前缀的值时直接返回 null,导致已保存的流程图 AI / 图片生成 API Key 被丢弃,功能无法使用。

修复方式:

  • decrypt() 遇到明文值时接受并返回(不再丢弃),同时标记 needsMigration
  • LocalSettingsService.readFromDisk() 检测到 needsMigration 后在后台自动重写设置文件(将明文 Key 加密为 enc:<base64>
  • encrypt()safeStorage 不可用时回退存储明文(而非返回 null 导致丢失)

效果:用户无需重新输入 API Key,现有明文配置在首次读取时自动迁移为加密格式。

Scope

  • packages/app/src/main/services/SecureStorageService.ts
  • packages/app/src/main/services/LocalSettingsService.ts

Verification

  • pnpm run format:check
  • pnpm run lint(通过推断)
  • pnpm run typecheck — 4 个子包全部通过
  • pnpm run test — 36 tests passed

Screenshots or Recordings

N/A

Notes

  • 迁移是一次性的:明文值在首次读取后会被加密写回,后续读取走正常解密路径。
  • 这修复了流程图 AI 功能(runFlowchartAiWithSettings 需要 flowchartAi.apiKey 非 null 才能工作)。

Link to Devin session: https://app.devin.ai/sessions/26c0ad2a81d3440eaa67d6f4feb3df33
Requested by: @QinQinChina

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.
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@QinQinChina QinQinChina merged commit 9f486d7 into main Jun 8, 2026
1 check passed
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.

1 participant