From 3d6e26fdcc7f03278f3b9480c59480023ba61c2b Mon Sep 17 00:00:00 2001 From: taekchef Date: Sat, 22 Aug 2026 21:04:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B5=81=E5=BC=8F=E6=94=B6=E5=B0=BE?= =?UTF-8?q?=E4=B8=A4=E5=A4=84=E4=BD=93=E9=AA=8C=E5=9B=9E=E9=80=80=E2=80=94?= =?UTF-8?q?=E2=80=94=E7=AA=84=E5=B8=83=E5=B1=80=E7=8A=B6=E6=80=81=E8=AF=8D?= =?UTF-8?q?=E5=AD=97=E5=8F=B7=E9=95=9C=E5=83=8F=E4=B8=8E=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E8=B7=B3=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 加载动词镜像修正:回答 WebView 恒为 compact 预览(14px),仅 chat-wide 属性抬到 16px。 #326 的镜像把非 chat-wide 当 17pt,窄窗口(#334 起最小宽 520)下内容宽 <620 时 状态词 17pt vs 正文 14px,肉眼明显偏大。改为 chatWide 且非 compact 才 16,否则 14。 2. 完成跳变改缓动:收尾快照与后续 KaTeX/字体异步重测的高度修正,原先瞬间定格 contentHeight,行高跳一下。非流式接受的高度统一走 0.14s easeOut 过渡 (reduce motion 与流式期间保持即时)。 --- Sources/WeiBei/Views/NotesAgentView.swift | 42 ++++++++++++++++------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/Sources/WeiBei/Views/NotesAgentView.swift b/Sources/WeiBei/Views/NotesAgentView.swift index 1ecf28a8b..5b64de2ec 100644 --- a/Sources/WeiBei/Views/NotesAgentView.swift +++ b/Sources/WeiBei/Views/NotesAgentView.swift @@ -902,6 +902,7 @@ struct MarkdownPreviewView: View { private static let compactPreviewMaximumHeight: CGFloat = 20_000 var onMeasuredHeight: (CGFloat) -> Void = { _ in } + @Environment(\.weibeiReduceMotion) private var reduceMotion @State private var command: NoteEditorCommand? @State private var contentHeight: CGFloat = Self.compactPreviewLoadingHeight @State private var heightFrozen = false @@ -910,6 +911,21 @@ struct MarkdownPreviewView: View { @State private var lastLayoutWidthKey = 0 @State private var lastChatWideTypography = false + /// Post-streaming height corrections ease instead of snapping: the finalized + /// snapshot and the async re-measures that follow (KaTeX, fonts) can land + /// tens of points from the last streamed height, and an instant frame + /// change read as the row visibly jumping at completion. Streaming keeps + /// the instant gated cadence so growth still tracks the token flow. + private func applySettledHeight(_ next: CGFloat) { + if reduceMotion || streamsMarkdownUpdates { + contentHeight = next + } else { + withAnimation(WeiBeiMotion.micro) { + contentHeight = next + } + } + } + var body: some View { RichMarkdownEditorView( markdown: markdown, @@ -984,7 +1000,7 @@ struct MarkdownPreviewView: View { ) return } - contentHeight = nextFrameHeight + applySettledHeight(nextFrameHeight) // Do NOT freeze on a fresh accept: KaTeX displayMode re-layout // and font loading can still grow the content. Freeze happens // in the jitter branch above once two consecutive measures @@ -1020,7 +1036,7 @@ struct MarkdownPreviewView: View { ) heightFrozen = false acceptedMeasureCount = 0 - contentHeight = nextFrameHeight + applySettledHeight(nextFrameHeight) maxObservedMeasuredHeight = nextFrameHeight onMeasuredHeight(measuredHeight) onContentHeightChange() @@ -5034,10 +5050,10 @@ private struct AgentThinkingIndicator: View { @EnvironmentObject private var store: WorkspaceStore var activityText: String? /// Match the answer text that follows this indicator in the same surface: - /// main conversation rows are chat-wide 16pt (17pt when narrow), the - /// selection float is compact 14pt — the same bases as the Milkdown - /// `.ProseMirror` CSS, so the status word never reads larger or smaller - /// than the reply it precedes. + /// every hosting surface renders the reply in a compact Milkdown preview + /// (14pt base), lifted to 16pt only by the chat-wide attribute — the + /// selection float and narrow conversation columns both stay at 14pt, + /// which is exactly what the `.ProseMirror` CSS shows next to this word. var chatWideTypography = false var compact = false @Environment(\.weibeiReduceMotion) private var reduceMotion @@ -5050,15 +5066,17 @@ private struct AgentThinkingIndicator: View { private static let minimumStatusHold: TimeInterval = 0.6 - /// Answer-text bases in pt, mirroring `.ProseMirror` in Editor/index.html - /// (17 base / 16 chat-wide / 14 compact preview). ⌘± changes the text tier, - /// so the status word must scale with it exactly like the reply text. - private static let answerBaseFontSize: CGFloat = 17 + /// Answer-text bases in pt, mirroring `.ProseMirror` in Editor/index.html. + /// The reply WebView is always a compact preview (14), raised to 16 by + /// `data-weibei-chat-wide`; the 17 non-compact base never applies here — + /// using it made the word read 3pt larger than the reply in narrow + /// conversation columns once the 520pt window minimum made those common. + /// ⌘± changes the text tier, so the status word must scale with it + /// exactly like the reply text. private static let chatWideFontSize: CGFloat = 16 private static let compactFontSize: CGFloat = 14 private var baseFontSize: CGFloat { - compact ? Self.compactFontSize - : (chatWideTypography ? Self.chatWideFontSize : Self.answerBaseFontSize) + chatWideTypography && !compact ? Self.chatWideFontSize : Self.compactFontSize } /// Single source for measure + line box + AppKit painting. Drawing at a /// different size than the measured width is what made the orbit sit far