Repository navigation
fix(ui): 卸载流式 Markdown 测试根节点并防护定时器回调 - #323
Merged
Merged
Conversation
helsome
approved these changes
Oct 18, 2026
helsome
left a comment
Owner
There was a problem hiding this comment.
独立审查通过。本轮精确 HEAD focused tests 14 pass / 0 fail、类型检查通过;按当前顺序累计组合完整测试 1817 pass / 7 skip / 0 fail,全 typecheck 与 i18n 通过。生产变更文件高信号 secret 扫描无命中(非完整历史扫描)。本 PR 按明确范围验收,不替代父 Issue 未完成的真实模型/UI/其他范围验收。
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.
fix(ui): 卸载流式 Markdown 测试根节点并防护定时器回调
改了什么
packages/ui/src/components/chat/MarkdownContent.test.tsx的流式测试用例结束前,显式调用act(() => { streamingRoot.unmount(); staticRoot.unmount(); })。packages/ui/src/components/chat/MarkdownContent.tsx中useStreamingContent内部定时器回调触发setDisplayContent前增加typeof window !== 'undefined'防御性判断。为什么要改
在 PR #285 引入的
keeps partial blocks stable and matches static rendering when complete测试中,组件以streaming={true}挂载并触发了setTimeout(..., 16)帧合并调度器。由于测试未卸载该 root,在测试完成、afterAll中的restoreDom()销毁window之后,残留于 Node/Bun 事件循环的定时器延迟触发并执行setDisplayContent,在无window状态下访问window.event抛出ReferenceError: window is not defined,导致后置测试(如SourceInspector.test.tsx)被污染报错并导致 UI 测试套件整体 Exit 1。对应 Issue
无直接对应 Issue(在本地运行全量 CI / focused-tests 时发现的深层测试泄漏与异常)。
做了哪些验证
测试环境:Windows 11 / Bun 1.4.2 / Node v24.20.0
聚焦复现验证:
bun test packages/ui/src/components/chat/MarkdownContent.test.tsx packages/ui/src/components/chat/SourceInspector.test.tsx→
6 pass / 1 fail / 2 errors(ReferenceError: window is not defined)14 pass / 0 fail工作区测试(Focused tests):
bun test packages/ui全仓测试(Full unit suite):
bun test --isolate类型检查:
bun run typecheck@finagent/core,@finagent/i18n,@finagent/shared,@finagent/ui,@finagent/electron全部 Exit 0高危信息扫描:
UI 变化与截图
无可见 UI 变化(纯内部测试和时钟卸载保护)。