Skip to content

fix(tests): RecordingChatStore dispatch contract must not capture ambient context - #181

Merged
YoungSx merged 1 commit into
mainfrom
fix-ci
Sep 7, 2026
Merged

fix(tests): RecordingChatStore dispatch contract must not capture ambient context#181
YoungSx merged 1 commit into
mainfrom
fix-ci

Conversation

@YoungSx

@YoungSx YoungSx commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

问题

CI 上 ArchiveConversation_WhenMutationCompletesOffUi_UpdatesTerminalPanelStateOnUiContext(ChatViewModelTests)随机挂死到超时。

根因(dotnet-dump 取证闭环)

测试 fake RecordingChatStore.Dispatch 的临界区内 4 处裸 await。测试泵 QueueingSynchronizationContext.RunNext 执行回调前会 SetSynchronizationContext(this),因此泵内发起的 fire-and-forget dispatch(ChatViewModel.AcpSessionLifecycle.csRemoveBottomPanelState_ = _chatStore.Dispatch(new ClearConversationRuntimeStateAction(...)))会捕获队列上下文。测试泵排空后,该孤儿续体躺在无人泵的队列里——_dispatchGate 永不释放,测试随后自己的 await archiveTask(内含一次 Dispatch)永久排队 → 死锁。

真实 ChatStore.Dispatch 对所有 await 一律 .ConfigureAwait(false)(闸的释放绝不依赖外部泵,fire-and-forget 分发必须能自完成)。fake 偏离了这一契约才是病根。

修复

给 fake 的 Dispatch(3 处)与 SetStateAsync(1 处)补齐 .ConfigureAwait(false),对齐真 store 契约。AfterDispatch 回调无任何测试设置,行为面无额外影响。

验证

验证 结果
原挂死测试 ×5 5/5 绿
整类 ChatViewModelTests ×3 348×3 全绿
全套 Presentation.Core.Tests 3316/3316 绿(1m32s)

🤖 Generated with Claude Code

…text

Fake store's Dispatch/SetStateAsync awaited bare inside the gate, so any
call made while QueueingSynchronizationContext.RunNext had installed
itself captured the queue context. A fire-and-forget dispatch (the
RemoveBottomPanelState path) then parked its continuation on a queue no
one pumps after the test stops draining it, holding _dispatchGate and
deadlocking the test's own Dispatch forever — the ArchiveConversation_
WhenMutationCompletesOffUi hang.

Real ChatStore.Dispatch awaits everything with ConfigureAwait(false) so
the gate never depends on an external pump; the fake now honors the same
contract, making fire-and-forget dispatches self-complete.

Verified: previously-hung test 5/5 green, full ChatViewModelTests
348x3 green, full Presentation.Core suite 3316/3316 green.

Co-Authored-By: Claude <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@vercel

vercel Bot commented Sep 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
salmonegg Ready Ready Preview Sep 7, 2026 1:17am UTC

@YoungSx
YoungSx merged commit 244816d into main Sep 7, 2026
15 checks passed
@YoungSx
YoungSx deleted the fix-ci branch September 7, 2026 01:32
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