fix: 流式渲染器在首 token 到达前启动(消除开头字号突变与首字延迟) - #272
Merged
Merged
Conversation
The streaming WebView mounted only when the first token landed, so its cold start (HTML load + Milkdown init) serialized after the wait for content: the opening characters appeared late and in a burst, and the row visibly hopped between the thinking indicator, a 14px loading placeholder, and the body type size. - Mount AgentMessageMarkdownText as soon as the generating row exists and keep the thinking indicator as an overlay (chat pane and floating panel), so the renderer warms up in parallel with the request. - Replay accumulated text on editorReady: the else branch neither re-pushed the streaming snapshot nor consumed a pending completion, which also froze ultra-short answers (finished before ready) on their first chunk forever. - Hide the in-WebView loading line in compact chat previews; the thinking overlay owns the waiting state now. Error status stays.
1b06643 更新了 index.html 但漏提交 build:editor 重新生成的 editor-resources.json,CI 的构建可复现门禁 (git diff --exit-code) 因此失败。
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.
问题
回答开头的体验断裂:
根因
流式 WebView 等到首个 token 到达才挂载,冷启动(HTML 加载 + Milkdown 初始化)被串行排在了等内容之后:
editorReady的 else 分支不补推已累计文本(也不消费pendingStreamingCompletion),开头要等下一个 33ms tick 才进入渲染器——首字延迟。改动
NotesAgentView.swift:generating 行一出现即挂载AgentMessageMarkdownText,thinking 指示器改为覆盖层(chat 窗格 + 选区浮窗),冷启动与等首 token 并行;视图身份跨「等首 token → 流式」保持不变(与 fix: 会话回答完成瞬间气泡闪烁(视图身份跨完成时刻保持稳定) #271 同一原则)。RichMarkdownEditorView.swift:editorReadyelse 分支补推——streaming 中补updateStreamingMarkdown,有 pending completion 补finishStreamingMarkdown(修掉极短回答卡死)。index.html:compact chat 预览隐藏 WebView 内 14px 载入占位文本(错误状态保留),等待期由 thinking 覆盖层承担。共享核心文件占用
无(NotesAgentView / RichMarkdownEditorView / index.html 均不在共享核心面)。
验证
swift build✅ /WeiBeiSelfCheck✅ /WeiBeiWebEditorCheck✅未做
后续提交(Kimi 配额中断后由 ZCode 接续)
a0cd79dchore: 补提 index.html 重建后的资源清单——1b06643漏提build:editor重新生成的editor-resources.json,导致 CI 构建可复现门禁(git diff --exit-code)失败。已本地复跑npm run build:editor确认产物一致后提交。验证(更新)
git diff --exit-code -- Sources/WeiBei/Resources/Editor✅dist/魏碑.app,WeiBeiGitCommit=a0cd79d,production_hygiene=clean,已按最终提交重建