From e520069329c11e1be3b452841528653d1a5ed303 Mon Sep 17 00:00:00 2001 From: taekchef Date: Sat, 25 Jul 2026 06:34:57 +0800 Subject: [PATCH] fix: restore dark top bar and document selection hit-testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dark header no longer uses washed system material over 墨石/石碑. ImmersiveHoverTitleView only hit-tests the top DOC strip so PDF/HTML selection and the selection float capsule work again. Chat native text is selectable again. --- Sources/WeiBei/Support/Theme.swift | 60 ++++++++++++++--------- Sources/WeiBei/Views/NotesAgentView.swift | 4 +- Sources/WeiBei/Views/ReaderView.swift | 18 ++++--- Sources/WeiBeiSelfCheck/main.swift | 11 ++--- 4 files changed, 56 insertions(+), 37 deletions(-) diff --git a/Sources/WeiBei/Support/Theme.swift b/Sources/WeiBei/Support/Theme.swift index 3d4443e9d..cd8452e7c 100644 --- a/Sources/WeiBei/Support/Theme.swift +++ b/Sources/WeiBei/Support/Theme.swift @@ -598,37 +598,51 @@ struct WeiBeiGlassHeaderBackground: View { var paperOpacity: Double = 0.72 var materialOpacity: Double = 0.14 - /// Use product theme, not system colorScheme (纸面/宣纸 are both light). + /// Product theme (not system colorScheme — 纸面/宣纸 are both light). private var isDark: Bool { WeiBeiThemeRuntime.mode.isDark } var body: some View { ZStack { - Rectangle() - .fill(.regularMaterial) - .opacity(materialOpacity) - - Rectangle() - .fill(WeiBeiTheme.paperRaised.opacity(paperWashOpacity)) - - LinearGradient( - colors: [ - WeiBeiTheme.glassHighlight.opacity(isDark ? 0.12 : 0.20), - WeiBeiTheme.glassTint.opacity(isDark ? 0.16 : 0.24), - WeiBeiTheme.paperRaised.opacity(isDark ? 0.12 : 0.13), - WeiBeiTheme.paper.opacity(isDark ? 0.10 : 0.04) - ], - startPoint: .top, - endPoint: .bottom - ) - - Rectangle() - .fill(WeiBeiTheme.paperInset.opacity(0.018)) + if isDark { + // Dark themes: solid product surface. `.regularMaterial` reads as a + // washed gray bar on 墨石/石碑 and must not sit above the page. + Rectangle() + .fill(WeiBeiTheme.paper) + Rectangle() + .fill(WeiBeiTheme.paperRaised.opacity(0.55)) + LinearGradient( + colors: [ + WeiBeiTheme.glassHighlight.opacity(0.08), + WeiBeiTheme.paper.opacity(0.0) + ], + startPoint: .top, + endPoint: .bottom + ) + } else { + Rectangle() + .fill(.regularMaterial) + .opacity(materialOpacity) + Rectangle() + .fill(WeiBeiTheme.paperRaised.opacity(paperWashOpacity)) + LinearGradient( + colors: [ + WeiBeiTheme.glassHighlight.opacity(0.20), + WeiBeiTheme.glassTint.opacity(0.24), + WeiBeiTheme.paperRaised.opacity(0.13), + WeiBeiTheme.paper.opacity(0.04) + ], + startPoint: .top, + endPoint: .bottom + ) + Rectangle() + .fill(WeiBeiTheme.paperInset.opacity(0.018)) + } } } private var paperWashOpacity: Double { - let factor = isDark ? 0.30 : 0.42 - return min(isDark ? 0.34 : 0.48, max(0.20, paperOpacity * factor)) + // Light themes only — dark path is solid product paper above. + min(0.48, max(0.20, paperOpacity * 0.42)) } } diff --git a/Sources/WeiBei/Views/NotesAgentView.swift b/Sources/WeiBei/Views/NotesAgentView.swift index 6aca5b0df..2e187b071 100644 --- a/Sources/WeiBei/Views/NotesAgentView.swift +++ b/Sources/WeiBei/Views/NotesAgentView.swift @@ -4031,8 +4031,8 @@ private struct AgentMessageMarkdownText: View { .foregroundStyle(WeiBeiTheme.ink) .multilineTextAlignment(.leading) .fixedSize(horizontal: false, vertical: true) - // Let wheel events reach the conversation ScrollView (no textSelection). - .allowsHitTesting(false) + // Selectable chat text — wheel still reaches ScrollView via Text's default handling. + .textSelection(.enabled) } private var renderedText: AttributedString { diff --git a/Sources/WeiBei/Views/ReaderView.swift b/Sources/WeiBei/Views/ReaderView.swift index 8985831d6..68aaf8884 100644 --- a/Sources/WeiBei/Views/ReaderView.swift +++ b/Sources/WeiBei/Views/ReaderView.swift @@ -40,10 +40,14 @@ struct ImmersiveHoverTitleView: View { } var body: some View { + // Hit-test only the top strip + the visible chip. A full-pane contentShape + // was swallowing PDF/HTML selection and killing the selection float capsule. ZStack(alignment: .top) { Color.clear .frame(maxWidth: .infinity) - .frame(height: 30) + .frame(height: 34) + .contentShape(Rectangle()) + .onHover(perform: updateVisibility) if visible || isPinned { HStack(alignment: .center, spacing: actionsAlignedTrailing ? 10 : 8) { @@ -72,22 +76,24 @@ struct ImmersiveHoverTitleView: View { .frame(minHeight: 30) .background { RoundedRectangle(cornerRadius: 7) - .fill(WeiBeiTheme.paperRaised.opacity(appearanceMode.isDark ? 0.34 : 0.72)) + .fill(WeiBeiTheme.paperRaised.opacity(appearanceMode.isDark ? 0.88 : 0.92)) .overlay { RoundedRectangle(cornerRadius: 7) - .stroke(WeiBeiTheme.hairline.opacity(appearanceMode.isDark ? 0.30 : 0.42), lineWidth: 1) + .stroke(WeiBeiTheme.hairline.opacity(appearanceMode.isDark ? 0.42 : 0.48), lineWidth: 1) } } - .shadow(color: WeiBeiTheme.ink.opacity(appearanceMode.isDark ? 0.24 : 0.07), radius: 9, y: 4) + .shadow(color: WeiBeiTheme.ink.opacity(appearanceMode.isDark ? 0.28 : 0.08), radius: 9, y: 4) .padding(.horizontal, actionsAlignedTrailing ? 14 : 0) .padding(.top, 7) + .contentShape(Rectangle()) + .onHover(perform: updateVisibility) .modifier(PaneHeaderReorderModifier(role: reorderRole)) .transition(WeiBeiTransition.floating) } } - .contentShape(Rectangle()) - .onHover(perform: updateVisibility) .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top) + .allowsHitTesting(true) + // Children define the hit regions; do NOT expand contentShape to the whole pane. .onDisappear { hideTask?.cancel() } diff --git a/Sources/WeiBeiSelfCheck/main.swift b/Sources/WeiBeiSelfCheck/main.swift index 63d910be8..ce5d5c6c7 100644 --- a/Sources/WeiBeiSelfCheck/main.swift +++ b/Sources/WeiBeiSelfCheck/main.swift @@ -1913,9 +1913,9 @@ expect(themeSource.contains("WeiBeiTheme.glassTint.opacity(0.16 * opacity)") && expect(themeSource.contains("static func glassTint(for mode:") && themeSource.contains("static func glassHighlight(for mode:") && themeSource.contains("static func documentMaskFill(for mode:") - && themeSource.contains("isDark ? 0.12 : 0.20") - && themeSource.contains("isDark ? 0.16 : 0.24") - && themeSource.contains("WeiBeiThemeRuntime.mode.isDark"), "dark glass headers use product-theme washes (not system colorScheme alone)") + && themeSource.contains("WeiBeiThemeRuntime.mode.isDark") + && themeSource.contains("// Dark themes: solid product surface") + && themeSource.contains(".regularMaterial"), "dark glass headers use solid product paper; light themes keep material wash") expect(themeSource.contains("paperRaised.opacity(0.985)") && themeSource.contains(".opacity(0.015)") && !themeSource.contains("paperRaised.opacity(0.92)"), "floating panels stay readable without losing the light glass surface") @@ -4212,9 +4212,8 @@ if let messageTextStart = notesAgentSource.range(of: "private struct AgentMessag && messageTextSource.contains("NEVER wire onContentHeightChange to scrollAgentToBottom") && messageTextSource.contains("AttributedString(markdown:") && messageTextSource.contains("RichAnswerDisplayText.normalizedInlineMath") - && messageTextSource.contains(".allowsHitTesting(false)") - && !messageTextSource.contains("onContentHeightChange: onMarkdownHeightChange") - && !messageTextSource.contains(".textSelection(.enabled)"), "agent chat uses finalized KaTeX with width-aware height and native streaming text without height-scroll thrash") + && messageTextSource.contains(".textSelection(.enabled)") + && !messageTextSource.contains("onContentHeightChange: onMarkdownHeightChange"), "agent chat uses finalized KaTeX with width-aware height and selectable native text") } else { expect(false, "agent message text source is inspectable") }