fix: 审批通过后 approved 标记在进程重启后丢失#226
Merged
lishuceo merged 4 commits intolishuceo:mainfrom Apr 10, 2026
Merged
Conversation
resolveApproval() 中 setThreadApproved (UPDATE) 在 thread session 行创建 (INSERT) 之前执行,导致 UPDATE 影响 0 行,approved 标记未持久化到 DB。 进程重启后内存状态丢失,DB 中 approved=NULL,用户需要重新授权。 修复方式:无论 threadId 是否存在,始终设置 preApprovedUsers 兜底。 thread-context.ts 的 consumePreApproved 会在行创建后将标记持久化。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
删除 resolveApproval 的第一个测试用例——该用例使用硬编码的 'nonexistent-id' 调用 resolveApproval,注定返回 undefined, 属于死代码。第二个测试用例已通过 handleApprovalCardAction 正确覆盖了相同场景。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
approved标记未能持久化到数据库。进程重启(pm2 restart)后,用户需要重新授权。resolveApproval()中setThreadApproved()(UPDATE) 在 thread session 行 (INSERT) 创建之前执行,UPDATE 影响 0 行,approved标记静默丢失。threadId是否存在,始终设置preApprovedUsers内存标记兜底。thread-context.ts的consumePreApproved会在 thread session 行创建后将标记持久化到 DB。Test plan
approval.test.ts回归测试(6 个用例),覆盖核心场景🤖 Generated with Claude Code