fix: 飞书 /workspace 切换后 /new 偶发创建会话到错误的工作区 【已审核 PR】#354
Merged
ErlichLiu merged 2 commits intoErlichLiu:mainfrom Apr 30, 2026
Merged
Conversation
根因:飞书 SDK 事件回调不 await,快速连续发 /workspace + /new 时两条消息 并发执行,/new 可能在 /workspace 更新 botConfig 之前就读了旧值。 修复:在 handleFeishuMessage 加锁位置增加 has 检查,同一聊天已有消息 处理中时跳过后续消息,避免并发读写字端。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
两个层面的修复: 1. feishu-config.ts 持久化层:更新路径使用 ?? 保留现有值,防止 undefined 覆盖 2. FeishuSettings.tsx 调用层:handleSave 显式传递已有的 defaultWorkspaceId/defaultChannelId/defaultModelId 同时修复废弃的 saveFeishuConfig 漏传 defaultChannelId/defaultModelId 的问题。 Co-Authored-By: Claude Opus 4.7 <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.
Overview
修复飞书 Bot 中使用
/workspace <arg>切换工作区后,立即发/new创建会话时,会话偶发创建到「默认工作区」而非刚刚切换的工作区。根因
飞书 SDK 要求事件回调立即返回(不能
await),否则网关会超时重投。因此handleFeishuMessage是 fire-and-forget 调用。当用户快速连续发两条消息(/workspace <arg>→/new),两条消息的处理器并发执行。原有代码中的
processingChats集合只做了add操作,没有在进入临界区前检查是否已有同聊天在处理中。导致/new的处理可能跑到createNewSession读取this.botConfig.defaultWorkspaceId时,/workspace那条还没来得及更新内存中的botConfig。Changes
apps/electron/src/main/lib/feishu-bridge.ts— 在handleFeishuMessage的processingChats.add()之前增加processingChats.has()检查。同一聊天已有消息在处理中时,跳过后续消息,防止并发读写字端。How to Test
/workspace <工作区名称>切换工作区/new创建新会话/new被跳过(无响应),再发一次/new,此时应正常创建Notes