修复 Qwen 上下文丢失问题#106
Conversation
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)
…credential encryption warnings
|
@codex review and check it |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4cd8376f6d
ℹ️ 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".
| session.providerSessionId = providerSessionId || session.providerSessionId | ||
| session.parentMessageId = parentMessageId || session.parentMessageId |
There was a problem hiding this comment.
Persist provider session updates in SQLite
When a streamed/non-streamed response returns the provider conversation IDs, this only mutates the object returned by storeManager.getSessionById. With the new SQLite store, getSessionById parses JSON and returns a detached copy, so providerSessionId, parentMessageId, historyHash, and lastActiveAt are never written back via storeManager.updateSession. On the next turn the route reads the old row and sends no provider parent/session IDs, so Qwen multi-turn context is still lost after the first request.
Useful? React with 👍 / 👎.
| await this.migrateFromElectronStore() | ||
| } | ||
|
|
||
| this.db = new Database(this.dbPath) |
There was a problem hiding this comment.
Create the storage directory before opening SQLite
On a fresh install where ~/.chat2api does not already exist, new Database(this.dbPath) attempts to create store.db inside a missing parent directory and fails with SQLITE_CANTOPEN, aborting storage initialization before the later request-log manager has a chance to mkdir anything. This only works for users who already have the legacy storage directory, so new users cannot start the app.
Useful? React with 👍 / 👎.
| const encrypted = safeStorage.encryptString(value) | ||
| encryptedCreds[key] = encrypted.toString('base64') |
There was a problem hiding this comment.
Do not re-encrypt migrated credentials
During migration, account credential values read from the old data.json are already the per-field safeStorage ciphertext written by the previous addAccount path, but this loop encrypts those ciphertext strings again. After upgrade, getAccounts(true) decrypts only the outer layer and providers receive the old base64 ciphertext instead of the real token, so existing accounts fail authentication until users re-enter every credential.
Useful? React with 👍 / 👎.
本次修复内容摘要
qwen.ts):使用messagesToPrompt()传递完整对话历史,修正enableWeb变量错误qwen-ai.ts):同样改为传递完整历史,确保多轮对话上下文不丢失Z.ai上下文暂未完全修复