From cbd08a132bdf8c208b9f339dbb877a51f81597e8 Mon Sep 17 00:00:00 2001 From: taekchef Date: Sat, 25 Jul 2026 05:51:20 +0800 Subject: [PATCH] feat: four themes, top-bar logo, Codex-like immersive chat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add 宣纸 / 石碑 alongside 纸面 / 墨石 with runtime palette resolution. Theme entry: top-bar menu (fast) + Settings grid (full chooser). Show the WeiBei mark in the top bar. Widen immersive chat column metrics and rebuild the composer as a tall Codex-style card with model footer so messages and input share one resize-tracking axis. --- .../Resources/Brand/weibei-mark-reversed.png | Bin 0 -> 16504 bytes .../WeiBei/Resources/Brand/weibei-mark.png | Bin 0 -> 2345 bytes Sources/WeiBei/Resources/Editor/editor.js | 2 +- Sources/WeiBei/Stores/WorkspaceStore.swift | 11 +- Sources/WeiBei/Support/Theme.swift | 232 +++++++++++++----- Sources/WeiBei/Views/ContentRailView.swift | 4 +- Sources/WeiBei/Views/ContentView.swift | 54 +++- Sources/WeiBei/Views/CourseDrawerHost.swift | 8 + Sources/WeiBei/Views/NotesAgentView.swift | 203 +++++++++------ Sources/WeiBei/Views/ReaderView.swift | 41 ++-- .../WeiBei/Views/RichMarkdownEditorView.swift | 6 +- .../WeiBei/Views/Settings/SettingsView.swift | 72 +++++- Sources/WeiBei/WebEditor/src/editor.js | 7 +- Sources/WeiBeiSelfCheck/main.swift | 81 +++--- 14 files changed, 497 insertions(+), 224 deletions(-) create mode 100644 Sources/WeiBei/Resources/Brand/weibei-mark-reversed.png create mode 100644 Sources/WeiBei/Resources/Brand/weibei-mark.png diff --git a/Sources/WeiBei/Resources/Brand/weibei-mark-reversed.png b/Sources/WeiBei/Resources/Brand/weibei-mark-reversed.png new file mode 100644 index 0000000000000000000000000000000000000000..f6890c92ded31c2ce15948f7872dd990c02c2cdd GIT binary patch literal 16504 zcmeHu_g7O*)b0tP7kO#Yi*!Uf0#OJcU8D($h!hn>q=WPpx=0TQ0+ApfRf>T05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ly-JE51| z7#lC6p$}&aRj#q&yzU$al0+%%^!t}}!`@s&tBq5UvsvK59m&q8)s4^^P>r3|KP-yM+thgn}5}GS^ebyhDX7GMwMjj9{l5u;f`l_7yvCJl;bIU0fPZ>ghME<3Y{UN#((&9< literal 0 HcmV?d00001 diff --git a/Sources/WeiBei/Resources/Brand/weibei-mark.png b/Sources/WeiBei/Resources/Brand/weibei-mark.png new file mode 100644 index 0000000000000000000000000000000000000000..ab91fbc5f5832e55c44b3dff39f5fb81d40bc744 GIT binary patch literal 2345 zcmeHIXH=6}8opl&2?RnJ2rYq_FhD3O0wy3O^j@W|8S3J&f(#%Is0g7*5J8#+97KjD zWf5T*MDakRg*L-jQ4k2|DpCw>VE~2slpPOecYp7%eb2r3eeZLh=a%>0bMARpXB#mQ z1rY#%n4PVqJM7t?Di#U1EBxGb*pY*6-JJk9tqS9*0Bn33p9bLMegI|y05B{7KsK`I zo|_Q>h)P#S4=b2JRVLPGP=UN$9o)*u3~H%RloYFJ6d3=1`5$C}rc5;7L$cXJTG*#r zMx#_~P~q#?y)H$W2w#&lQ31%w?Z(MUib<;EFcsyyn$(+r3ja+D^BpKkRWu5W@5~Gb zJ7xD&UqCq6jqk)kD$3Qgf2sZ}Aw_l17nREA=d_!qu1thCutV6|uLeJ@-OGK6HU1Rt zXyH@uYGl~t5isc>pbZy!ng`z?30>z2XekDJ*% zFWIS$5AI8 zmFQ&H7%|N<ae(+UaCDQze8Wo3>xX!r83>9?Reb6R9uP}~5)OiO#VitT=Jwp6BK_E&Kpf$5v}0HdnWQ6%7O%0hT<&vbW! zJK~zAlB4;p7(SQ6HB-Rg_aca;ktLQnN;LM-#Q927rFOL}Css_REeCUDUg-r#*o9J{EX}Qc>0Dqr#^mnNyD+mUx`tm*-a_Wt|^} z(@=~It;k7_`70Lv2HZux$;EfauW6$%ew%KG_(@F07A?UqWFn0mS}T&APUh%(lgBie zMaUDA;dPzFp(Mfy^dl(JNVaIXCyaz$i2nMU}nT^dfs|UfIcnmrK9t~BuZF#S%4ASf)RW($hoM)oL>mUO zX8nn3F$Iq+s0$6t)*HOU!Zv%TIjhWub8$v=(v&_HKTvmPtnL1x(c`KC&I6=tN{n$k z7ZU@YKyvuiY)-7zk<_@gmuKFOO}04}y)GPiCU2iCA;8EI`?uL?WG?2sxZHqt-Jk^D zLfmv|Iyl?3p^-Po%nf*&pV8gBNW0qiHc^~F6EomXP-qjjxeEcbybUT&WChJK_UhWh+naXpe*Bf=FdVfE1>SMd&()##^+9-fd z9wt~1=P7GRcBUlT)VI4?N$`L8&aT5e&EWc3c}4_rY4x|*CBbUMNKWED0+V$kWsQ0v z>($YXT9##oq&>%^fPxPOLclA$m(GkU|6`Q6Ewf832;a4K;Q8_=Fzv0(5Qc#RD(8`1rPHFuz+Q%)r zs^G!7`U;Fm^I7CXf_F4I0pB~@U7PdES+$p8VVpY67o&m)Yr!*{+4b4KCq)Fxh!Nk^ z5pMElTbtQyuUuZ-NL)WT`)nd%n<~j>g@?2k=`CvtN~biFm;Alhy>uv#=|}O`-nwhF zIo#ZCH+nkgJu+n2JMn%_wMx~-2k43XeM{a<8S3FaeaekckHkJ`g8(ev3AHpH(I`ZE eeYVl;EhNHsye%wkf}NGK((e.textBetween?e.textBetween(0,e.content.size,` `):e.textContent||"").split(` -`)[0]||"").trimStart(),dur=e=>{let t="";return e.descendants(r=>{if(t)return!1;if(r.type?.name!=="paragraph")return!0;let n=(r.textContent||"").trimStart();return n?(t=n,!1):!0}),t},pur=e=>fur(e).match(foe)||dur(e).match(foe),tit=e=>e==="blockquote"||e==="block_quote",mur=(e,t,r)=>{let n=t.textBetween?t.textBetween(0,t.content.size,""):t.textContent||"",i=n.match(cur);if(!i)return;let a=r+1,s=a+i[0].length;Zi(e,a,s,"weibei-callout-marker");let o=n.match(uur);if(!o)return;let l=a+o[0].length;l>s&&Zi(e,s,l,"weibei-callout-heading-source")},gur=(e,t,r)=>{for(let n of t.matchAll(mit)){let i=n[1]?.length||0,a=r+(n.index||0)+i,s=r+(n.index||0)+n[0].length;Zi(e,a,s,"weibei-callout-marker")}},yit=e=>e==="inkstone"?"inkstone":"paper",U2=yit(window.weiBeiTheme),yur=()=>U2==="inkstone"?{background:"#151515",primaryColor:"#1c1c1c",primaryTextColor:"#d7cbb0",primaryBorderColor:"#3a3328",lineColor:"#8b5e3c",secondaryColor:"#222222",tertiaryColor:"#171717",fontFamily:'-apple-system, BlinkMacSystemFont, "Songti SC", serif'}:{background:"#fbf5e8",primaryColor:"#f6eddc",primaryTextColor:"#2e261f",primaryBorderColor:"#cbb79b",lineColor:"#7a6250",secondaryColor:"#efe4d2",tertiaryColor:"#f8f0e1",fontFamily:'-apple-system, BlinkMacSystemFont, "Songti SC", serif'},vur=()=>{loe.initialize({startOnLoad:!1,securityLevel:"strict",theme:"base",themeVariables:yur()})},vit=e=>{U2=yit(e),document.documentElement.dataset.weibeiTheme=U2,document.body&&(document.body.dataset.weibeiTheme=U2),vur()};vit(U2);var Cp=e=>{if(window.WeiBeiEditorBootFailed){window.WeiBeiEditorBootFailed(e);return}let t=document.querySelector("#editor");t&&(t.innerHTML=`
${xc("bootFailed")}
+`)[0]||"").trimStart(),dur=e=>{let t="";return e.descendants(r=>{if(t)return!1;if(r.type?.name!=="paragraph")return!0;let n=(r.textContent||"").trimStart();return n?(t=n,!1):!0}),t},pur=e=>fur(e).match(foe)||dur(e).match(foe),tit=e=>e==="blockquote"||e==="block_quote",mur=(e,t,r)=>{let n=t.textBetween?t.textBetween(0,t.content.size,""):t.textContent||"",i=n.match(cur);if(!i)return;let a=r+1,s=a+i[0].length;Zi(e,a,s,"weibei-callout-marker");let o=n.match(uur);if(!o)return;let l=a+o[0].length;l>s&&Zi(e,s,l,"weibei-callout-heading-source")},gur=(e,t,r)=>{for(let n of t.matchAll(mit)){let i=n[1]?.length||0,a=r+(n.index||0)+i,s=r+(n.index||0)+n[0].length;Zi(e,a,s,"weibei-callout-marker")}},yit=e=>(e==="inkstone"||e==="stele")?"inkstone":"paper",U2=yit(window.weiBeiTheme),yur=()=>U2==="inkstone"?{background:"#151515",primaryColor:"#1c1c1c",primaryTextColor:"#d7cbb0",primaryBorderColor:"#3a3328",lineColor:"#8b5e3c",secondaryColor:"#222222",tertiaryColor:"#171717",fontFamily:'-apple-system, BlinkMacSystemFont, "Songti SC", serif'}:{background:"#fbf5e8",primaryColor:"#f6eddc",primaryTextColor:"#2e261f",primaryBorderColor:"#cbb79b",lineColor:"#7a6250",secondaryColor:"#efe4d2",tertiaryColor:"#f8f0e1",fontFamily:'-apple-system, BlinkMacSystemFont, "Songti SC", serif'},vur=()=>{loe.initialize({startOnLoad:!1,securityLevel:"strict",theme:"base",themeVariables:yur()})},vit=e=>{U2=yit(e),document.documentElement.dataset.weibeiTheme=U2,document.body&&(document.body.dataset.weibeiTheme=U2),vur()};vit(U2);var Cp=e=>{if(window.WeiBeiEditorBootFailed){window.WeiBeiEditorBootFailed(e);return}let t=document.querySelector("#editor");t&&(t.innerHTML=`
${xc("bootFailed")}
 ${String(e?.stack||e)}
`)};window.addEventListener("error",e=>Cp(e.error||e.message));window.addEventListener("unhandledrejection",e=>Cp(e.reason));var Qo=(e,t={})=>{hit?.[e]?.postMessage({...t,documentID:fit})};document.documentElement.dataset.weibeiCompactPreview=aE?"true":"false";var rit=0,doe=0,lP=new Set,xit=()=>[document.querySelector("#editor"),document.querySelector(".milkdown"),document.querySelector(".ProseMirror")].filter(Boolean),xur=e=>{let t=e.getBoundingClientRect?.();return Math.max(0,e.scrollHeight||0,e.offsetHeight||0,e.clientHeight||0,t?.height||0)},Lk=()=>{aE&&(window.cancelAnimationFrame(rit),rit=window.requestAnimationFrame(()=>{let e=xit(),t=Math.ceil(Math.max(1,...e.map(xur)));window.WeiBeiCompactPreviewHeight=t,window.WeiBeiCompactPreviewMeasuredAt=Date.now(),!(Math.abs(t-doe)<1)&&(doe=t,Qo("contentHeightChanged",{height:t}))}))},fP=()=>{if(aE){for(let e of lP)window.clearTimeout(e);lP.clear(),doe=0,Lk(),window.requestAnimationFrame(()=>{Lk(),window.requestAnimationFrame(Lk)});for(let e of[40,120,240,480]){let t=window.setTimeout(()=>{lP.delete(t),Lk()},e);lP.add(t)}document.fonts?.ready?.then(()=>{aE&&Lk()}).catch(()=>{})}},bur=()=>{if(aE){if(window.ResizeObserver){let e=new ResizeObserver(Lk);xit().forEach(t=>e.observe(t))}fP()}},bit=()=>{let e=window.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0).getBoundingClientRect();return!t||t.width+t.height===0?null:{x:t.left+t.width/2,y:t.bottom,width:t.width,height:t.height}},wur=(e,t)=>{let r=0;for(let n=t-1;n>=0&&e[n]==="\\";n-=1)r+=1;return r%2===1},nit=(e,t,r)=>{let n=e.indexOf(t,r);for(;n>=0&&wur(e,n);)n=e.indexOf(t,n+t.length);return n},kur=(e,t)=>{let r=String(e||""),n="",i=0;for(;iString(e||"").replace(/\\\[\\\[/g,"[[").replace(/\\\]\\\]/g,"]]").replace(/\\=\\=([^=\n]+?)\\=\\=/g,"==$1==").replace(/\^\\\[/g,"^[").replace(/(^|\s)\\#(?=[\p{L}\p{N}_/-])/gu,"$1#").replace(/\\\$(?=\d)/g,"$").replace(new RegExp(`^(\\s*(?:>\\s*)*)\\\\(\\[!(?:${sE})\\])`,"gim"),"$1$2"),wit=(e,t)=>{let r=String(e||"").split(/(\r?\n)/),n=!1,i="",a=0,s="";for(let o=0;o\s*)*(`{3,}|~{3,})/);if(h){n?h[1][0]===i&&h[1].length>=a&&(n=!1,a=0):(n=!0,i=h[1][0],a=h[1].length),s+=l+u;continue}if(n){s+=l+u;continue}let f=kur(l,t);s+=f,f.endsWith(` `)&&u||(s+=u)}return s},Cur=e=>wit(e,Tur),Sur=e=>String(e||"").replace(/[ \t]*/gi,` `),pP=e=>wit(e,Sur),kit=e=>{let t=e||"",r=t.match(/^(---\n[\s\S]*?\n---)(?:\n+|$)/);return r?{frontmatter:r[1],body:t.slice(r[0].length)}:{frontmatter:"",body:t}},boe=e=>{let t=Cur(e),r=Ik?t.replace(/^\n+/,""):t;return Ik?`${Ik} diff --git a/Sources/WeiBei/Stores/WorkspaceStore.swift b/Sources/WeiBei/Stores/WorkspaceStore.swift index 8e3a17127..53cc2675b 100644 --- a/Sources/WeiBei/Stores/WorkspaceStore.swift +++ b/Sources/WeiBei/Stores/WorkspaceStore.swift @@ -477,6 +477,7 @@ final class WorkspaceStore: ObservableObject { ) try? FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true) load() + WeiBeiThemeRuntime.mode = appearanceMode loadSelectionAskThreadsIfNeeded() let recoveredPendingNotebookRename = recoverPendingNotebookRenameIfNeeded() let resolvedImportedFileBookmarks = resolvePersistedImportedFileBookmarks() @@ -2921,13 +2922,16 @@ final class WorkspaceStore: ObservableObject { func toggleAppearanceMode() { - appearanceMode = appearanceMode.toggled - save() + setAppearanceMode(appearanceMode.toggled) } func setAppearanceMode(_ mode: WeiBeiAppearanceMode) { - guard appearanceMode != mode else { return } + guard appearanceMode != mode else { + WeiBeiThemeRuntime.mode = mode + return + } appearanceMode = mode + WeiBeiThemeRuntime.mode = mode save() } @@ -7792,6 +7796,7 @@ final class WorkspaceStore: ObservableObject { if let appearanceModeRaw = snapshot.appearanceModeRaw, let appearanceMode = WeiBeiAppearanceMode(rawValue: appearanceModeRaw) { self.appearanceMode = appearanceMode + WeiBeiThemeRuntime.mode = appearanceMode } adaptImportedDocumentColors = snapshot.adaptImportedDocumentColors ?? true if let interfaceLanguageRaw = snapshot.interfaceLanguageRaw, diff --git a/Sources/WeiBei/Support/Theme.swift b/Sources/WeiBei/Support/Theme.swift index 0cdf66bff..0cbf6915c 100644 --- a/Sources/WeiBei/Support/Theme.swift +++ b/Sources/WeiBei/Support/Theme.swift @@ -3,74 +3,99 @@ import CoreText import SwiftUI import WeiBeiCore +/// Four surface themes. Light pair: 纸面 (warm product paper) + 宣纸 (cooler fibrous xuan). +/// Dark pair: 墨石 (near-black warm ink) + 石碑 (cool carved stele grey). enum WeiBeiAppearanceMode: String, CaseIterable, Identifiable { case paper + case xuan case inkstone + case stele var id: String { rawValue } + /// True for both dark surfaces (墨石 / 石碑). Prefer this over `== .inkstone`. + var isDark: Bool { + switch self { + case .paper, .xuan: return false + case .inkstone, .stele: return true + } + } + func label(language: WeiBeiInterfaceLanguage) -> String { switch self { case .paper: return language.text("纸面", "Paper") + case .xuan: + return language.text("宣纸", "Xuan") case .inkstone: return language.text("墨石", "Inkstone") + case .stele: + return language.text("石碑", "Stele") } } - func actionLabel(language: WeiBeiInterfaceLanguage) -> String { + func detail(language: WeiBeiInterfaceLanguage) -> String { switch self { case .paper: - return language.text("切到墨石暗色", "Switch to Inkstone") + return language.text("暖色产品纸面", "Warm product paper") + case .xuan: + return language.text("素净宣纸白", "Cool fibrous xuan white") case .inkstone: - return language.text("切到纸面亮色", "Switch to Paper") + return language.text("暖黑墨石", "Warm near-black ink") + case .stele: + return language.text("冷灰碑面", "Cool carved stone") } } + func actionLabel(language: WeiBeiInterfaceLanguage) -> String { + language.text("切换外观主题", "Switch appearance theme") + } + var systemImage: String { switch self { case .paper: return "sun.max" + case .xuan: + return "doc.plaintext" case .inkstone: return "moon.stars" + case .stele: + return "rectangle.split.3x1" } } var colorScheme: ColorScheme { - switch self { - case .paper: - return .light - case .inkstone: - return .dark - } + isDark ? .dark : .light } var webThemeName: String { - switch self { - case .paper: - return "paper" - case .inkstone: - return "inkstone" - } + rawValue } var windowBackground: NSColor { - switch self { - case .paper: - return NSColor(calibratedRed: 0.985, green: 0.960, blue: 0.905, alpha: 1.0) - case .inkstone: - return NSColor(calibratedRed: 0.059, green: 0.059, blue: 0.059, alpha: 1.0) - } + WeiBeiNativePalette.paper(for: self) } + /// Cycles all four themes (used by legacy toggle API / shortcuts). var toggled: WeiBeiAppearanceMode { switch self { - case .paper: - return .inkstone - case .inkstone: - return .paper + case .paper: return .xuan + case .xuan: return .inkstone + case .inkstone: return .stele + case .stele: return .paper } } + + /// Next theme in the light↔dark pair, or full cycle when no pair preference. + var oppositeFamily: WeiBeiAppearanceMode { + isDark ? .paper : .inkstone + } +} + +/// Live appearance used by dynamic `WeiBeiTheme` colors. Updated when the store +/// changes mode so SwiftUI redraws pick the correct palette. +enum WeiBeiThemeRuntime { + static var mode: WeiBeiAppearanceMode = .paper } enum WeiBeiTypography { @@ -142,82 +167,132 @@ private struct WeiBeiTone { } private extension Color { - static func weiBei(light: WeiBeiTone, dark: WeiBeiTone) -> Color { - Color(nsColor: NSColor(name: nil) { appearance in - let isDark = appearance.bestMatch(from: [.darkAqua, .aqua]) == .darkAqua - return (isDark ? dark : light).nsColor + /// Resolve a four-mode palette from `WeiBeiThemeRuntime.mode` (not system appearance alone). + static func weiBei( + paper: WeiBeiTone, + xuan: WeiBeiTone, + inkstone: WeiBeiTone, + stele: WeiBeiTone + ) -> Color { + Color(nsColor: NSColor(name: nil) { _ in + switch WeiBeiThemeRuntime.mode { + case .paper: return paper.nsColor + case .xuan: return xuan.nsColor + case .inkstone: return inkstone.nsColor + case .stele: return stele.nsColor + } }) } + + /// Convenience when light-pair / dark-pair share tones. + static func weiBei(light: WeiBeiTone, dark: WeiBeiTone) -> Color { + weiBei(paper: light, xuan: light, inkstone: dark, stele: dark) + } } enum WeiBeiTheme { + // 纸面 = warm product paper; 宣纸 = cooler fibrous white; 墨石 = warm black; 石碑 = cool stele grey. static let paper = Color.weiBei( - light: WeiBeiTone(red: 0.955, green: 0.918, blue: 0.835), - dark: WeiBeiTone(hex: 0x0F0F0F) + paper: WeiBeiTone(red: 0.955, green: 0.918, blue: 0.835), + xuan: WeiBeiTone(red: 0.972, green: 0.962, blue: 0.942), + inkstone: WeiBeiTone(hex: 0x0F0F0F), + stele: WeiBeiTone(hex: 0x16181C) ) static let paperRaised = Color.weiBei( - light: WeiBeiTone(red: 0.976, green: 0.944, blue: 0.872), - dark: WeiBeiTone(hex: 0x151515) + paper: WeiBeiTone(red: 0.976, green: 0.944, blue: 0.872), + xuan: WeiBeiTone(red: 0.992, green: 0.988, blue: 0.978), + inkstone: WeiBeiTone(hex: 0x151515), + stele: WeiBeiTone(hex: 0x1E2228) ) static let paperInset = Color.weiBei( - light: WeiBeiTone(red: 0.908, green: 0.858, blue: 0.748), - dark: WeiBeiTone(hex: 0x1C1C1C) + paper: WeiBeiTone(red: 0.908, green: 0.858, blue: 0.748), + xuan: WeiBeiTone(red: 0.930, green: 0.918, blue: 0.892), + inkstone: WeiBeiTone(hex: 0x1C1C1C), + stele: WeiBeiTone(hex: 0x252A32) ) static let chrome = Color.weiBei( - light: WeiBeiTone(red: 0.155, green: 0.145, blue: 0.130), - dark: WeiBeiTone(hex: 0x0B0B0B) + paper: WeiBeiTone(red: 0.155, green: 0.145, blue: 0.130), + xuan: WeiBeiTone(red: 0.140, green: 0.138, blue: 0.132), + inkstone: WeiBeiTone(hex: 0x0B0B0B), + stele: WeiBeiTone(hex: 0x101217) ) static let ink = Color.weiBei( - light: WeiBeiTone(red: 0.115, green: 0.095, blue: 0.080), - dark: WeiBeiTone(hex: 0xD7CBB0) + paper: WeiBeiTone(red: 0.115, green: 0.095, blue: 0.080), + xuan: WeiBeiTone(red: 0.145, green: 0.140, blue: 0.128), + inkstone: WeiBeiTone(hex: 0xD7CBB0), + stele: WeiBeiTone(hex: 0xD2D6DC) ) static let secondaryInk = Color.weiBei( - light: WeiBeiTone(red: 0.335, green: 0.285, blue: 0.245), - dark: WeiBeiTone(hex: 0x9B9178) + paper: WeiBeiTone(red: 0.335, green: 0.285, blue: 0.245), + xuan: WeiBeiTone(red: 0.360, green: 0.345, blue: 0.320), + inkstone: WeiBeiTone(hex: 0x9B9178), + stele: WeiBeiTone(hex: 0x9AA1AB) ) static let tertiaryInk = Color.weiBei( - light: WeiBeiTone(red: 0.490, green: 0.430, blue: 0.365), - dark: WeiBeiTone(hex: 0x6F6655) + paper: WeiBeiTone(red: 0.490, green: 0.430, blue: 0.365), + xuan: WeiBeiTone(red: 0.500, green: 0.480, blue: 0.450), + inkstone: WeiBeiTone(hex: 0x6F6655), + stele: WeiBeiTone(hex: 0x6E7682) ) static let placeholderInk = Color.weiBei( - light: WeiBeiTone(red: 0.405, green: 0.345, blue: 0.290), - dark: WeiBeiTone(hex: 0xAFA48C) + paper: WeiBeiTone(red: 0.405, green: 0.345, blue: 0.290), + xuan: WeiBeiTone(red: 0.430, green: 0.410, blue: 0.380), + inkstone: WeiBeiTone(hex: 0xAFA48C), + stele: WeiBeiTone(hex: 0xA8AFB8) ) static let hairline = Color.weiBei( - light: WeiBeiTone(red: 0.500, green: 0.380, blue: 0.260, alpha: 0.24), - dark: WeiBeiTone(hex: 0x3A3328, alpha: 0.72) + paper: WeiBeiTone(red: 0.500, green: 0.380, blue: 0.260, alpha: 0.24), + xuan: WeiBeiTone(red: 0.420, green: 0.400, blue: 0.360, alpha: 0.22), + inkstone: WeiBeiTone(hex: 0x3A3328, alpha: 0.72), + stele: WeiBeiTone(hex: 0x3A414C, alpha: 0.78) ) static let cinnabar = Color.weiBei( - light: WeiBeiTone(red: 0.570, green: 0.150, blue: 0.105), - dark: WeiBeiTone(hex: 0xA6362B) + paper: WeiBeiTone(red: 0.570, green: 0.150, blue: 0.105), + xuan: WeiBeiTone(red: 0.540, green: 0.145, blue: 0.110), + inkstone: WeiBeiTone(hex: 0xA6362B), + stele: WeiBeiTone(hex: 0xB04034) ) static let cinnabarSoft = Color.weiBei( - light: WeiBeiTone(red: 0.570, green: 0.150, blue: 0.105, alpha: 0.10), - dark: WeiBeiTone(hex: 0x5C2621, alpha: 0.62) + paper: WeiBeiTone(red: 0.570, green: 0.150, blue: 0.105, alpha: 0.10), + xuan: WeiBeiTone(red: 0.540, green: 0.145, blue: 0.110, alpha: 0.09), + inkstone: WeiBeiTone(hex: 0x5C2621, alpha: 0.62), + stele: WeiBeiTone(hex: 0x5A2A28, alpha: 0.58) ) static let onCinnabar = Color.weiBei( - light: WeiBeiTone(hex: 0xF8EAD4), - dark: WeiBeiTone(hex: 0xF3DEC2) + paper: WeiBeiTone(hex: 0xF8EAD4), + xuan: WeiBeiTone(hex: 0xF7F2EA), + inkstone: WeiBeiTone(hex: 0xF3DEC2), + stele: WeiBeiTone(hex: 0xE8ECF0) ) static let link = Color.weiBei( - light: WeiBeiTone(red: 0.190, green: 0.330, blue: 0.410), - dark: WeiBeiTone(hex: 0xC8B98A) + paper: WeiBeiTone(red: 0.190, green: 0.330, blue: 0.410), + xuan: WeiBeiTone(red: 0.200, green: 0.320, blue: 0.390), + inkstone: WeiBeiTone(hex: 0xC8B98A), + stele: WeiBeiTone(hex: 0xB8C4D0) ) static let moss = Color.weiBei( - light: WeiBeiTone(red: 0.230, green: 0.385, blue: 0.300), - dark: WeiBeiTone(hex: 0xB88A42) + paper: WeiBeiTone(red: 0.230, green: 0.385, blue: 0.300), + xuan: WeiBeiTone(red: 0.250, green: 0.380, blue: 0.310), + inkstone: WeiBeiTone(hex: 0xB88A42), + stele: WeiBeiTone(hex: 0x8FA06A) ) static let codePaper = Color.weiBei( - light: WeiBeiTone(red: 0.180, green: 0.145, blue: 0.115, alpha: 0.055), - dark: WeiBeiTone(hex: 0x171717, alpha: 0.92) + paper: WeiBeiTone(red: 0.180, green: 0.145, blue: 0.115, alpha: 0.055), + xuan: WeiBeiTone(red: 0.160, green: 0.150, blue: 0.130, alpha: 0.050), + inkstone: WeiBeiTone(hex: 0x171717, alpha: 0.92), + stele: WeiBeiTone(hex: 0x1A1E24, alpha: 0.94) ) static let glassTint = Color.weiBei( - light: WeiBeiTone(red: 0.982, green: 0.948, blue: 0.875), - dark: WeiBeiTone(hex: 0x1A1814) + paper: WeiBeiTone(red: 0.982, green: 0.948, blue: 0.875), + xuan: WeiBeiTone(red: 0.988, green: 0.984, blue: 0.974), + inkstone: WeiBeiTone(hex: 0x1A1814), + stele: WeiBeiTone(hex: 0x1C2026) ) static let glassHighlight = Color.weiBei( - light: WeiBeiTone(red: 0.992, green: 0.970, blue: 0.918), - dark: WeiBeiTone(hex: 0x3A3328) + paper: WeiBeiTone(red: 0.992, green: 0.970, blue: 0.918), + xuan: WeiBeiTone(red: 0.995, green: 0.992, blue: 0.986), + inkstone: WeiBeiTone(hex: 0x3A3328), + stele: WeiBeiTone(hex: 0x3E4652) ) static let stone = secondaryInk } @@ -227,8 +302,12 @@ enum WeiBeiNativePalette { switch mode { case .paper: return NSColor(calibratedRed: 0.955, green: 0.918, blue: 0.835, alpha: 1.0) + case .xuan: + return NSColor(calibratedRed: 0.972, green: 0.962, blue: 0.942, alpha: 1.0) case .inkstone: return NSColor(calibratedRed: 0.059, green: 0.059, blue: 0.059, alpha: 1.0) + case .stele: + return NSColor(calibratedRed: 0.086, green: 0.094, blue: 0.110, alpha: 1.0) } } @@ -236,26 +315,34 @@ enum WeiBeiNativePalette { switch mode { case .paper: return NSColor(calibratedRed: 0.115, green: 0.095, blue: 0.080, alpha: 1.0) + case .xuan: + return NSColor(calibratedRed: 0.145, green: 0.140, blue: 0.128, alpha: 1.0) case .inkstone: return NSColor(calibratedRed: 0.843, green: 0.796, blue: 0.690, alpha: 1.0) + case .stele: + return NSColor(calibratedRed: 0.824, green: 0.839, blue: 0.863, alpha: 1.0) } } static func selectedText(for mode: WeiBeiAppearanceMode) -> NSColor { switch mode { - case .paper: + case .paper, .xuan: return ink(for: mode) case .inkstone: return NSColor(calibratedRed: 0.961, green: 0.906, blue: 0.784, alpha: 1.0) + case .stele: + return NSColor(calibratedRed: 0.930, green: 0.940, blue: 0.955, alpha: 1.0) } } static func selectionFill(for mode: WeiBeiAppearanceMode) -> NSColor { switch mode { - case .paper: + case .paper, .xuan: return NSColor(calibratedRed: 0.570, green: 0.150, blue: 0.105, alpha: 0.20) case .inkstone: return NSColor(calibratedRed: 0.651, green: 0.212, blue: 0.169, alpha: 0.35) + case .stele: + return NSColor(calibratedRed: 0.690, green: 0.250, blue: 0.200, alpha: 0.32) } } } @@ -267,6 +354,21 @@ enum WeiBeiMetric { static let topBarHeight: CGFloat = 38 } +/// Top-bar brand mark (DesignSystem logo exports bundled under Resources/Brand). +enum WeiBeiBrandMark { + static func image(for mode: WeiBeiAppearanceMode) -> NSImage { + let name = mode.isDark ? "weibei-mark-reversed" : "weibei-mark" + if let url = WeiBeiResources.bundle.url(forResource: name, withExtension: "png", subdirectory: "Brand") + ?? WeiBeiResources.bundle.url(forResource: name, withExtension: "png"), + let image = NSImage(contentsOf: url) { + image.isTemplate = false + return image + } + // Fallback: empty 1×1 so layout never crashes if resources are missing. + return NSImage(size: NSSize(width: 1, height: 1)) + } +} + enum WeiBeiMotion { static let press = Animation.interactiveSpring(response: 0.18, dampingFraction: 0.82) static let micro = Animation.easeOut(duration: 0.14) diff --git a/Sources/WeiBei/Views/ContentRailView.swift b/Sources/WeiBei/Views/ContentRailView.swift index 39beac351..642a7181f 100644 --- a/Sources/WeiBei/Views/ContentRailView.swift +++ b/Sources/WeiBei/Views/ContentRailView.swift @@ -354,7 +354,7 @@ struct ContentRailView: View { if item.id == highlightedID { return WeiBeiTheme.cinnabar } - return WeiBeiTheme.secondaryInk.opacity(appearanceMode == .inkstone ? 0.78 : 0.58) + return WeiBeiTheme.secondaryInk.opacity(appearanceMode.isDark ? 0.78 : 0.58) } private func railSpacing(count: Int, height: CGFloat) -> CGFloat { @@ -511,7 +511,7 @@ private struct ContentRailPreviewCard: View { .stroke(WeiBeiTheme.hairline.opacity(0.82), lineWidth: 1) } .clipShape(RoundedRectangle(cornerRadius: 6, style: .continuous)) - .shadow(color: WeiBeiTheme.ink.opacity(appearanceMode == .inkstone ? 0.22 : 0.08), radius: 8, y: 4) + .shadow(color: WeiBeiTheme.ink.opacity(appearanceMode.isDark ? 0.22 : 0.08), radius: 8, y: 4) .accessibilityHidden(true) } } diff --git a/Sources/WeiBei/Views/ContentView.swift b/Sources/WeiBei/Views/ContentView.swift index a8fad2a49..f6de0f7db 100644 --- a/Sources/WeiBei/Views/ContentView.swift +++ b/Sources/WeiBei/Views/ContentView.swift @@ -422,11 +422,23 @@ private struct UnifiedTopBarView: View { @ViewBuilder private var brandBlock: some View { - Text(store.brandLatinName) - .font(WeiBeiTypography.englishBrandFont(size: 15.5, weight: .semibold)) - .tracking(0.15) - .foregroundStyle(primaryText) - .frame(width: 62, alignment: .leading) + // Logo mark + Latin wordmark — DesignSystem brand lockup for the top bar. + HStack(spacing: 7) { + Image(nsImage: WeiBeiBrandMark.image(for: store.appearanceMode)) + .resizable() + .interpolation(.high) + .aspectRatio(contentMode: .fit) + .frame(width: 18, height: 18) + .accessibilityHidden(true) + Text(store.brandLatinName) + .font(WeiBeiTypography.englishBrandFont(size: 15.5, weight: .semibold)) + .tracking(0.15) + .foregroundStyle(primaryText) + .lineLimit(1) + } + .frame(minWidth: 86, alignment: .leading) + .accessibilityElement(children: .ignore) + .accessibilityLabel(Text(store.brandLatinName)) } @ViewBuilder @@ -515,11 +527,31 @@ private struct UnifiedTopBarView: View { @ViewBuilder private var appearanceToggleButton: some View { - topIconButton(store.appearanceMode.toggled.systemImage, help: store.appearanceMode.actionLabel(language: store.interfaceLanguage)) { - withAnimation(WeiBeiMotion.appearance) { - store.toggleAppearanceMode() + // Four themes: menu in the top bar (fast), full grid also in Settings → Appearance. + Menu { + ForEach(WeiBeiAppearanceMode.allCases) { mode in + Button { + withAnimation(WeiBeiMotion.appearance) { + store.setAppearanceMode(mode) + } + } label: { + if mode == store.appearanceMode { + Label(mode.label(language: store.interfaceLanguage), systemImage: "checkmark") + } else { + Label(mode.label(language: store.interfaceLanguage), systemImage: mode.systemImage) + } + } } + } label: { + Image(systemName: store.appearanceMode.systemImage) + .contentShape(Rectangle()) } + .menuStyle(.borderlessButton) + .menuIndicator(.hidden) + .buttonStyle(WeiBeiIconButtonStyle(size: 24)) + .accessibilityLabel(Text(store.appearanceMode.actionLabel(language: store.interfaceLanguage))) + .help(store.appearanceMode.actionLabel(language: store.interfaceLanguage)) + .keyboardShortcut("t", modifiers: [.option, .command]) } private func toggleReaderSearch() { @@ -606,7 +638,7 @@ private struct ThreePaneWorkspaceChrome: View { y: sourceFrame.midY ) .shadow( - color: WeiBeiTheme.ink.opacity(store.appearanceMode == .inkstone ? 0.38 : 0.14), + color: WeiBeiTheme.ink.opacity(store.appearanceMode.isDark ? 0.38 : 0.14), radius: 22, y: 12 ) @@ -988,7 +1020,7 @@ struct EmptyWorkspaceView: View { VStack(spacing: 14) { Image(systemName: "seal") .font(.system(size: 34, weight: .regular)) - .foregroundStyle(WeiBeiTheme.cinnabar.opacity(store.appearanceMode == .inkstone ? 0.12 : 0.08)) + .foregroundStyle(WeiBeiTheme.cinnabar.opacity(store.appearanceMode.isDark ? 0.12 : 0.08)) Text(store.ui("在顶栏点亮一个板块开始", "Light up a pane above to begin")) .font(.system(size: 13, weight: .medium)) .foregroundStyle(WeiBeiTheme.secondaryInk) @@ -1004,7 +1036,7 @@ private struct PaneDropTargetView: View { var body: some View { RoundedRectangle(cornerRadius: 10) - .fill(WeiBeiTheme.cinnabarSoft.opacity(store.appearanceMode == .inkstone ? 0.16 : 0.12)) + .fill(WeiBeiTheme.cinnabarSoft.opacity(store.appearanceMode.isDark ? 0.16 : 0.12)) .overlay { RoundedRectangle(cornerRadius: 10) .stroke(WeiBeiTheme.cinnabar.opacity(0.30), lineWidth: 1) diff --git a/Sources/WeiBei/Views/CourseDrawerHost.swift b/Sources/WeiBei/Views/CourseDrawerHost.swift index dbe2c7677..aa598b68c 100644 --- a/Sources/WeiBei/Views/CourseDrawerHost.swift +++ b/Sources/WeiBei/Views/CourseDrawerHost.swift @@ -134,8 +134,12 @@ final class CourseDrawerContainerView: NSView { switch mode { case .paper: return NSColor(calibratedRed: 0.976, green: 0.944, blue: 0.872, alpha: 1) + case .xuan: + return NSColor(calibratedRed: 0.992, green: 0.988, blue: 0.978, alpha: 1) case .inkstone: return NSColor(calibratedRed: 0.082, green: 0.082, blue: 0.082, alpha: 1) + case .stele: + return NSColor(calibratedRed: 0.118, green: 0.133, blue: 0.157, alpha: 1) } } @@ -143,8 +147,12 @@ final class CourseDrawerContainerView: NSView { switch mode { case .paper: return NSColor(calibratedRed: 0.115, green: 0.095, blue: 0.080, alpha: 0.035) + case .xuan: + return NSColor(calibratedRed: 0.140, green: 0.135, blue: 0.120, alpha: 0.030) case .inkstone: return NSColor(calibratedRed: 0, green: 0, blue: 0, alpha: 0.18) + case .stele: + return NSColor(calibratedRed: 0, green: 0, blue: 0, alpha: 0.22) } } diff --git a/Sources/WeiBei/Views/NotesAgentView.swift b/Sources/WeiBei/Views/NotesAgentView.swift index 96e0f35b4..cff740ac3 100644 --- a/Sources/WeiBei/Views/NotesAgentView.swift +++ b/Sources/WeiBei/Views/NotesAgentView.swift @@ -256,6 +256,8 @@ private struct AgentComposerField: View { var sendBottom: CGFloat var horizontalPadding: CGFloat = 10 var verticalPadding: CGFloat = 0 + /// Codex-style footer: model chip on the left, send on the right inside the card. + var showsModelFooter: Bool = false var submit: () -> Void private var canSend: Bool { @@ -269,56 +271,73 @@ private struct AgentComposerField: View { var body: some View { // Tall Codex-like composer uses a fixed outer height; short fields still hug content. let locksHeight = height >= 72 - ZStack(alignment: .bottomTrailing) { - TextField( - "", - text: $store.agentDraft, - prompt: Text(prompt) - .font(promptFont) - .foregroundStyle(WeiBeiTheme.placeholderInk), - axis: .vertical - ) - .textFieldStyle(.plain) - .lineLimit(lineLimit) - .fixedSize(horizontal: false, vertical: !locksHeight) - .font(font) - .foregroundColor(WeiBeiTheme.ink) - .focused(focused) - .onSubmit(submit) - .padding(.vertical, verticalPadding) - .padding(.trailing, showsControl ? trailingPadding : 0) - .frame(maxWidth: .infinity, maxHeight: locksHeight ? .infinity : nil, alignment: .topLeading) - .padding(.horizontal, horizontalPadding) - .frame(maxWidth: .infinity, minHeight: height, maxHeight: locksHeight ? height : nil, alignment: .topLeading) - .background { - RoundedRectangle(cornerRadius: locksHeight ? 14 : WeiBeiMetric.controlRadius) - .fill(WeiBeiTheme.paperRaised.opacity(focused.wrappedValue ? 0.72 : 0.62)) - } - .clipShape(RoundedRectangle(cornerRadius: locksHeight ? 14 : WeiBeiMetric.controlRadius)) - .overlay { - RoundedRectangle(cornerRadius: locksHeight ? 14 : WeiBeiMetric.controlRadius) - .stroke( - focused.wrappedValue ? WeiBeiTheme.link.opacity(0.36) : WeiBeiTheme.hairline.opacity(0.54), - lineWidth: 1 - ) + let corner: CGFloat = locksHeight ? 16 : WeiBeiMetric.controlRadius + VStack(alignment: .leading, spacing: 0) { + ZStack(alignment: .topLeading) { + TextField( + "", + text: $store.agentDraft, + prompt: Text(prompt) + .font(promptFont) + .foregroundStyle(WeiBeiTheme.placeholderInk), + axis: .vertical + ) + .textFieldStyle(.plain) + .lineLimit(lineLimit) + .fixedSize(horizontal: false, vertical: !locksHeight) + .font(font) + .foregroundColor(WeiBeiTheme.ink) + .focused(focused) + .onSubmit(submit) + .padding(.top, verticalPadding) + .padding(.bottom, showsModelFooter ? 8 : verticalPadding) + .padding(.trailing, showsModelFooter ? 0 : (showsControl ? trailingPadding : 0)) + .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) + .padding(.horizontal, horizontalPadding) + + if showsControl && !showsModelFooter { + VStack { + Spacer(minLength: 0) + HStack { + Spacer(minLength: 0) + sendButton + .padding(.trailing, sendTrailing) + .padding(.bottom, sendBottom) + } + } + } } + .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) - if showsControl { - Button { - store.isAskingAgent ? store.cancelAgentRequest() : submit() - } label: { - Image(systemName: store.isAskingAgent ? "stop.fill" : "paperplane.fill") + if showsModelFooter { + HStack(spacing: 10) { + Text(store.modelName.isEmpty ? store.ui("模型", "Model") : store.modelName) + .font(.system(size: 12, weight: .medium)) + .foregroundStyle(WeiBeiTheme.tertiaryInk) + .lineLimit(1) + Spacer(minLength: 8) + if showsControl { + sendButton + } } - .buttonStyle(WeiBeiIconButtonStyle(size: sendButtonSize, prominence: store.isAskingAgent ? .neutral : .primary)) - .accessibilityLabel(Text(store.isAskingAgent ? store.ui("停止回答", "Stop response") : store.ui("发送", "Send"))) - .help(store.isAskingAgent ? store.ui("停止回答", "Stop response") : store.ui("发送", "Send")) - .keyboardShortcut(.return, modifiers: [.command]) - .padding(.trailing, sendTrailing) - .padding(.bottom, sendBottom) - .transition(WeiBeiTransition.floating) - .animation(WeiBeiMotion.micro, value: showsControl) + .padding(.horizontal, horizontalPadding) + .padding(.bottom, 12) + .padding(.top, 2) } } + .frame(maxWidth: .infinity, minHeight: height, maxHeight: locksHeight ? height : nil, alignment: .topLeading) + .background { + RoundedRectangle(cornerRadius: corner) + .fill(WeiBeiTheme.paperRaised.opacity(focused.wrappedValue ? 0.78 : 0.64)) + } + .clipShape(RoundedRectangle(cornerRadius: corner)) + .overlay { + RoundedRectangle(cornerRadius: corner) + .stroke( + focused.wrappedValue ? WeiBeiTheme.link.opacity(0.36) : WeiBeiTheme.hairline.opacity(0.54), + lineWidth: 1 + ) + } .frame(height: locksHeight ? height : nil, alignment: .bottom) .contentShape(Rectangle()) .onTapGesture { @@ -327,6 +346,20 @@ private struct AgentComposerField: View { .animation(WeiBeiMotion.micro, value: showsControl) .accessibilityIdentifier(locksHeight ? "agent-composer-codex" : "agent-composer-compact") } + + private var sendButton: some View { + Button { + store.isAskingAgent ? store.cancelAgentRequest() : submit() + } label: { + Image(systemName: store.isAskingAgent ? "stop.fill" : "paperplane.fill") + } + .buttonStyle(WeiBeiIconButtonStyle(size: sendButtonSize, prominence: store.isAskingAgent ? .neutral : .primary)) + .accessibilityLabel(Text(store.isAskingAgent ? store.ui("停止回答", "Stop response") : store.ui("发送", "Send"))) + .help(store.isAskingAgent ? store.ui("停止回答", "Stop response") : store.ui("发送", "Send")) + .keyboardShortcut(.return, modifiers: [.command]) + .transition(WeiBeiTransition.floating) + .animation(WeiBeiMotion.micro, value: showsControl) + } } private struct AccessibilityFrameProbe: NSViewRepresentable { @@ -702,20 +735,20 @@ struct NotePaneView: View { private func noteModeButtonFill(selected: Bool, hovering: Bool) -> Color { if selected { - return WeiBeiTheme.cinnabarSoft.opacity(store.appearanceMode == .inkstone ? 0.44 : 0.62) + return WeiBeiTheme.cinnabarSoft.opacity(store.appearanceMode.isDark ? 0.44 : 0.62) } if hovering { - return WeiBeiTheme.paperRaised.opacity(store.appearanceMode == .inkstone ? 0.16 : 0.20) + return WeiBeiTheme.paperRaised.opacity(store.appearanceMode.isDark ? 0.16 : 0.20) } return Color.clear } private func noteModeButtonStroke(selected: Bool, hovering: Bool) -> Color { if selected { - return WeiBeiTheme.cinnabar.opacity(store.appearanceMode == .inkstone ? 0.34 : 0.24) + return WeiBeiTheme.cinnabar.opacity(store.appearanceMode.isDark ? 0.34 : 0.24) } if hovering { - return WeiBeiTheme.hairline.opacity(store.appearanceMode == .inkstone ? 0.30 : 0.18) + return WeiBeiTheme.hairline.opacity(store.appearanceMode.isDark ? 0.30 : 0.18) } return Color.clear } @@ -1229,7 +1262,7 @@ struct MarkdownSourceEditor: NSViewRepresentable { guard let textStorage = textView.textStorage, textStorage.length > 0 else { return } let fullRange = NSRange(location: 0, length: textStorage.length) let ink = WeiBeiNativePalette.ink(for: appearanceMode) - let quotePrefixColor = ink.withAlphaComponent(appearanceMode == .inkstone ? 0.30 : 0.36) + let quotePrefixColor = ink.withAlphaComponent(appearanceMode.isDark ? 0.30 : 0.36) let markerColor = NSColor.clear let markerFont = NSFont.monospacedSystemFont(ofSize: 0.1, weight: .regular) let quotePrefixRegex = try? NSRegularExpression(pattern: #"(?m)^\s*(?:>\s*)+"#) @@ -1576,16 +1609,17 @@ private struct AgentRailTurn { /// than `availableWidth`, or multi-pane text centers as if the strip were full-window wide. private enum AgentChatLayoutMetrics { static let compactMaxWidth: CGFloat = 560 - /// Immersive conversation: nearly full pane (not a skinny centered strip). - static let wideMaxWidth: CGFloat = 1600 + /// Immersive conversation: Codex-like centered column that still scales with the window. + /// Cap keeps line length readable on ultra-wide; floor is handled by usable width. + static let wideMaxWidth: CGFloat = 920 static let compactSideGutter: CGFloat = 12 - /// Tight gutters so the reading column owns the immersive canvas. - static let wideSideGutter: CGFloat = 48 + /// Codex-style: modest side margin; column grows/shrinks with the window. + static let wideSideGutter: CGFloat = 28 static let compactComposerHeight: CGFloat = 52 - /// Tall real composer — empty state must still read as a writing surface, not a search field. - static let wideComposerHeight: CGFloat = 148 + /// Tall Codex-style writing surface (multi-line + bottom control band). + static let wideComposerHeight: CGFloat = 188 static let compactFontSize: CGFloat = 14.5 - static let wideFontSize: CGFloat = 17 + static let wideFontSize: CGFloat = 16 static func isWide(layout: WorkspaceLayout) -> Bool { // Immersive conversation only — document multi-pane keeps compact strip metrics. @@ -1595,7 +1629,7 @@ private enum AgentChatLayoutMetrics { static func contentWidth(availableWidth: CGFloat, wide: Bool) -> CGFloat { let gutter = (wide ? wideSideGutter : compactSideGutter) * 2 let usable = max(availableWidth - gutter, 1) - // Wide: use nearly the whole measured pane (gutter only). Cap only for ultra-wide displays. + // Wide: track the window, capped for readability (Codex ~720–920pt column). if wide { return min(usable, wideMaxWidth) } @@ -1680,7 +1714,7 @@ struct AgentPaneView: View { ScrollView(showsIndicators: true) { // No scrollTargetLayout / scrollPosition / minHeight:viewport / // GeometryReader parent — all thrash sizeThatFits on LazyVStack. - LazyVStack(alignment: .leading, spacing: wide ? 16 : 12) { + LazyVStack(alignment: .leading, spacing: wide ? 22 : 12) { ForEach(store.messages) { message in agentMessageRow( message: message, @@ -1722,8 +1756,8 @@ struct AgentPaneView: View { .frame(height: agentScrollBottomInset) .id(agentBottomAnchorID) } - .padding(.horizontal, wide ? 16 : 10) - .padding(.vertical, wide ? 10 : 10) + .padding(.horizontal, wide ? 8 : 10) + .padding(.vertical, wide ? 14 : 10) .environment(\.agentChatLayoutWidth, contentWidth) .padding(.top, store.messages.isEmpty ? 22 : 0) .frame(maxWidth: .infinity, alignment: .topLeading) @@ -1997,20 +2031,22 @@ struct AgentPaneView: View { private func agentInputTray(wide: Bool, contentWidth: CGFloat) -> some View { let fieldHeight = AgentChatLayoutMetrics.composerHeight(wide: wide) let fontSize = AgentChatLayoutMetrics.composerFontSize(wide: wide) + // Codex: composer owns a fixed tall card; message scroll gets the rest of the pane. + // Width tracks `contentWidth` so resize keeps messages + input on one axis. return VStack(spacing: 0) { LinearGradient( colors: [ .clear, - WeiBeiTheme.paper.opacity(0.18), - WeiBeiTheme.glassTint.opacity(0.34) + WeiBeiTheme.paper.opacity(0.22), + WeiBeiTheme.glassTint.opacity(0.40) ], startPoint: .top, endPoint: .bottom ) - .frame(height: wide ? 16 : 22) + .frame(height: wide ? 20 : 22) .allowsHitTesting(false) - VStack(alignment: .leading, spacing: 8) { + VStack(alignment: .leading, spacing: wide ? 10 : 8) { if store.hasSelectionAttachments { AgentSelectionAttachmentPill() .transition(WeiBeiTransition.floating) @@ -2021,23 +2057,24 @@ struct AgentPaneView: View { focused: $draftFocused, font: .system(size: fontSize), promptFont: .system(size: fontSize), - lineLimit: wide ? 1...12 : 1...6, + lineLimit: wide ? 1...16 : 1...6, height: fieldHeight, - sendButtonSize: wide ? 38 : 28, - trailingPadding: wide ? 56 : 40, - sendTrailing: wide ? 18 : 10, - sendBottom: wide ? 24 : 8, - horizontalPadding: wide ? 22 : 12, - verticalPadding: wide ? 20 : 8 + sendButtonSize: wide ? 36 : 28, + trailingPadding: wide ? 52 : 40, + sendTrailing: wide ? 14 : 10, + sendBottom: wide ? 14 : 8, + horizontalPadding: wide ? 18 : 12, + verticalPadding: wide ? 16 : 8, + showsModelFooter: wide ) { store.askAgent() } } .font(.system(size: fontSize)) - // Fixed width = reading column. Fixed height = real composer block. - .frame(width: contentWidth, height: fieldHeight, alignment: .bottom) - .padding(.top, wide ? 12 : 4) - .padding(.bottom, wide ? 28 : 12) + .frame(width: contentWidth, alignment: .bottom) + .frame(minHeight: fieldHeight, alignment: .bottom) + .padding(.top, wide ? 8 : 4) + .padding(.bottom, wide ? 22 : 12) .frame(maxWidth: .infinity) .background(WeiBeiTheme.paper) .animation(WeiBeiMotion.reveal, value: store.agentDraft) @@ -3109,7 +3146,7 @@ private struct AgentBubble: View { .strokeBorder(userBubbleStroke, lineWidth: 1) } .shadow( - color: WeiBeiTheme.ink.opacity(store.appearanceMode == .inkstone ? 0.0 : (hovering ? 0.06 : 0.04)), + color: WeiBeiTheme.ink.opacity(store.appearanceMode.isDark ? 0.0 : (hovering ? 0.06 : 0.04)), radius: hovering ? 6 : 4, y: hovering ? 2 : 1.2 ) @@ -3122,13 +3159,13 @@ private struct AgentBubble: View { private var userBubbleFill: Color { // Same paper family as chips/panels: a slightly raised slip of paper, not a tinted chat blob. - store.appearanceMode == .inkstone + store.appearanceMode.isDark ? WeiBeiTheme.paperRaised.opacity(hovering ? 0.58 : 0.46) : WeiBeiTheme.paperRaised.opacity(hovering ? 1.0 : 0.96) } private var userBubbleStroke: Color { - store.appearanceMode == .inkstone + store.appearanceMode.isDark ? WeiBeiTheme.hairline.opacity(hovering ? 0.58 : 0.42) : WeiBeiTheme.hairline.opacity(hovering ? 0.52 : 0.38) } @@ -4275,6 +4312,14 @@ final class AgentThinkingOrbitNSView: NSView { ink = NSColor(calibratedRed: 0.843, green: 0.796, blue: 0.690, alpha: 0.93) dim = NSColor(calibratedRed: 0.435, green: 0.400, blue: 0.333, alpha: 0.70) cinnabar = NSColor(calibratedRed: 0.651, green: 0.212, blue: 0.169, alpha: 0.82) + case .stele: + ink = NSColor(calibratedRed: 0.824, green: 0.839, blue: 0.863, alpha: 0.93) + dim = NSColor(calibratedRed: 0.430, green: 0.460, blue: 0.510, alpha: 0.70) + cinnabar = NSColor(calibratedRed: 0.690, green: 0.250, blue: 0.200, alpha: 0.82) + case .xuan: + ink = NSColor(calibratedRed: 0.145, green: 0.140, blue: 0.128, alpha: 0.93) + dim = NSColor(calibratedRed: 0.500, green: 0.480, blue: 0.450, alpha: 0.70) + cinnabar = NSColor(calibratedRed: 0.540, green: 0.145, blue: 0.110, alpha: 0.82) case .paper: ink = NSColor(calibratedRed: 0.115, green: 0.095, blue: 0.080, alpha: 0.93) dim = NSColor(calibratedRed: 0.490, green: 0.430, blue: 0.365, alpha: 0.70) diff --git a/Sources/WeiBei/Views/ReaderView.swift b/Sources/WeiBei/Views/ReaderView.swift index 926d44bf0..16b0642b7 100644 --- a/Sources/WeiBei/Views/ReaderView.swift +++ b/Sources/WeiBei/Views/ReaderView.swift @@ -72,13 +72,13 @@ struct ImmersiveHoverTitleView: View { .frame(minHeight: 30) .background { RoundedRectangle(cornerRadius: 7) - .fill(WeiBeiTheme.paperRaised.opacity(appearanceMode == .inkstone ? 0.34 : 0.72)) + .fill(WeiBeiTheme.paperRaised.opacity(appearanceMode.isDark ? 0.34 : 0.72)) .overlay { RoundedRectangle(cornerRadius: 7) - .stroke(WeiBeiTheme.hairline.opacity(appearanceMode == .inkstone ? 0.30 : 0.42), lineWidth: 1) + .stroke(WeiBeiTheme.hairline.opacity(appearanceMode.isDark ? 0.30 : 0.42), lineWidth: 1) } } - .shadow(color: WeiBeiTheme.ink.opacity(appearanceMode == .inkstone ? 0.24 : 0.07), radius: 9, y: 4) + .shadow(color: WeiBeiTheme.ink.opacity(appearanceMode.isDark ? 0.24 : 0.07), radius: 9, y: 4) .padding(.horizontal, actionsAlignedTrailing ? 14 : 0) .padding(.top, 7) .modifier(PaneHeaderReorderModifier(role: reorderRole)) @@ -1765,8 +1765,12 @@ private final class ReaderPDFView: PDFView { switch documentAppearanceMode { case .paper: return WeiBeiNativePalette.paper(for: .paper) + case .xuan: + return WeiBeiNativePalette.paper(for: .xuan) case .inkstone: return NSColor(calibratedRed: 0.66, green: 0.61, blue: 0.50, alpha: 1.0) + case .stele: + return NSColor(calibratedRed: 0.58, green: 0.60, blue: 0.64, alpha: 1.0) } } @@ -2493,9 +2497,10 @@ struct WebReaderRepresentable: NSViewRepresentable { static func readerStyleScript(for mode: WeiBeiAppearanceMode, adaptsDocumentColors: Bool = true) -> String { let selectionCSS: String switch mode { - case .paper: + case .paper, .xuan: + let text = mode == .xuan ? "#25231f" : "#1d1814" selectionCSS = """ - ::selection { background: rgba(145, 38, 27, 0.20); color: #1d1814; } + ::selection { background: rgba(145, 38, 27, 0.20); color: \(text); } .weibei-selection-ask-mark { text-decoration-line: underline; text-decoration-color: rgba(145, 38, 27, 0.72); @@ -2509,9 +2514,10 @@ struct WebReaderRepresentable: NSViewRepresentable { background: rgba(145, 38, 27, 0.12); } """ - case .inkstone: + case .inkstone, .stele: + let text = mode == .stele ? "#E8ECF0" : "#F5E7C8" selectionCSS = """ - ::selection { background: rgba(166, 54, 43, 0.35); color: #F5E7C8; } + ::selection { background: rgba(166, 54, 43, 0.35); color: \(text); } .weibei-selection-ask-mark { text-decoration-line: underline; text-decoration-color: rgba(200, 120, 100, 0.85); @@ -2532,27 +2538,30 @@ struct WebReaderRepresentable: NSViewRepresentable { adaptiveCSS = "" } else { switch mode { - case .paper: + case .paper, .xuan: + let body = mode == .xuan ? "#25231f" : "#1d1814" adaptiveCSS = """ html, body { max-width: 100%; overflow-x: hidden; color-scheme: light; background: transparent !important; } - body, main, article, section, div, p, li, blockquote, td, th, span { color: #1d1814 !important; } + body, main, article, section, div, p, li, blockquote, td, th, span { color: \(body) !important; } [data-weibei-paper-surface] { background-color: transparent !important; } a { color: #31566b !important; } code { background: rgba(29, 24, 20, .06) !important; color: #5d4b33 !important; } pre { background: rgba(29, 24, 20, .052) !important; border-color: rgba(92, 70, 46, .28) !important; } table, th, td { border-color: rgba(92, 70, 46, .28) !important; } """ - case .inkstone: + case .inkstone, .stele: + let body = mode == .stele ? "#D2D6DC" : "#D7CBB0" + let link = mode == .stele ? "#B8C4D0" : "#C8B98A" adaptiveCSS = """ html, body { max-width: 100%; overflow-x: hidden; color-scheme: dark; background: transparent !important; } - body, main, article, section, div, p, li, blockquote, td, th, span { color: #D7CBB0 !important; background-color: transparent !important; } - a { color: #C8B98A !important; text-decoration-color: rgba(200, 185, 138, .55) !important; } - h1, h2, h3 { color: #C8B98A !important; } - blockquote { border-left: 3px solid rgba(166, 54, 43, .62) !important; background: rgba(166, 54, 43, .08) !important; color: #C9BFA5 !important; } + body, main, article, section, div, p, li, blockquote, td, th, span { color: \(body) !important; background-color: transparent !important; } + a { color: \(link) !important; text-decoration-color: rgba(200, 185, 138, .55) !important; } + h1, h2, h3 { color: \(link) !important; } + blockquote { border-left: 3px solid rgba(166, 54, 43, .62) !important; background: rgba(166, 54, 43, .08) !important; color: \(body) !important; } code { background: rgba(255, 255, 255, .05) !important; color: #D8B47A !important; } - pre { background: #171717 !important; border: 1px solid #2D2D2D !important; color: #D7CBB0 !important; } + pre { background: #171717 !important; border: 1px solid #2D2D2D !important; color: \(body) !important; } table { background: rgba(255, 255, 255, .02) !important; } - th { color: #C8B98A !important; background: rgba(200, 185, 138, .08) !important; } + th { color: \(link) !important; background: rgba(200, 185, 138, .08) !important; } table, th, td { border-color: #2D2D2D !important; } """ } diff --git a/Sources/WeiBei/Views/RichMarkdownEditorView.swift b/Sources/WeiBei/Views/RichMarkdownEditorView.swift index 2d85a1f1e..3d99c7f65 100644 --- a/Sources/WeiBei/Views/RichMarkdownEditorView.swift +++ b/Sources/WeiBei/Views/RichMarkdownEditorView.swift @@ -101,8 +101,12 @@ fileprivate final class MarkdownImageSchemeHandler: NSObject, WKURLSchemeHandler switch appearanceMode { case .paper: return ("#efe6d8", "#9f3b2f", "#6b5148") + case .xuan: + return ("#f2eee6", "#9a3a2e", "#5f5a52") case .inkstone: return ("#151515", "#a6362b", "#d7cbb0") + case .stele: + return ("#1e2228", "#b04034", "#d2d6dc") } } @@ -565,7 +569,7 @@ struct RichMarkdownEditorView: NSViewRepresentable { private static func applyWebAppearance(to view: WKWebView, appearanceMode: WeiBeiAppearanceMode) { view.underPageBackgroundColor = WeiBeiNativePalette.paper(for: appearanceMode) - view.appearance = NSAppearance(named: appearanceMode == .inkstone ? .darkAqua : .aqua) + view.appearance = NSAppearance(named: appearanceMode.isDark ? .darkAqua : .aqua) } private static func json(_ value: String) -> String { diff --git a/Sources/WeiBei/Views/Settings/SettingsView.swift b/Sources/WeiBei/Views/Settings/SettingsView.swift index 0024e25a6..0bd2f109d 100644 --- a/Sources/WeiBei/Views/Settings/SettingsView.swift +++ b/Sources/WeiBei/Views/Settings/SettingsView.swift @@ -157,10 +157,10 @@ struct SettingsView: View { .frame(width: 218) .background { ZStack(alignment: .top) { - WeiBeiTheme.paperInset.opacity(store.appearanceMode == .inkstone ? 0.62 : 0.80) + WeiBeiTheme.paperInset.opacity(store.appearanceMode.isDark ? 0.62 : 0.80) LinearGradient( colors: [ - WeiBeiTheme.glassHighlight.opacity(store.appearanceMode == .inkstone ? 0.09 : 0.20), + WeiBeiTheme.glassHighlight.opacity(store.appearanceMode.isDark ? 0.09 : 0.20), .clear ], startPoint: .top, @@ -222,13 +222,26 @@ struct SettingsView: View { } private var settingsAppearanceToggleButton: some View { - Button { - withAnimation(WeiBeiMotion.appearance) { - store.toggleAppearanceMode() + // Same four-theme menu as the main top bar (cycles via ⌥⌘T elsewhere). + Menu { + ForEach(WeiBeiAppearanceMode.allCases) { mode in + Button { + withAnimation(WeiBeiMotion.appearance) { + store.setAppearanceMode(mode) + } + } label: { + if mode == store.appearanceMode { + Label(mode.label(language: store.interfaceLanguage), systemImage: "checkmark") + } else { + Text(mode.label(language: store.interfaceLanguage)) + } + } } } label: { - Image(systemName: store.appearanceMode.toggled.systemImage) + Image(systemName: store.appearanceMode.systemImage) } + .menuStyle(.borderlessButton) + .menuIndicator(.hidden) .buttonStyle(WeiBeiIconButtonStyle(size: 30)) .accessibilityLabel(Text(store.appearanceMode.actionLabel(language: store.interfaceLanguage))) .help(store.appearanceMode.actionLabel(language: store.interfaceLanguage)) @@ -249,14 +262,47 @@ struct SettingsView: View { } settingsGroup(store.ui("外观", "Appearance")) { - settingsRow(title: store.ui("明暗模式", "Theme Mode")) { - segmented(WeiBeiAppearanceMode.allCases, active: store.appearanceMode) { mode in - mode.label(language: store.interfaceLanguage) - } action: { mode in - withAnimation(WeiBeiMotion.appearance) { - store.setAppearanceMode(mode) + settingsRow(title: store.ui("主题", "Theme")) { + // Four themes — 2×2 chips. Top bar menu is the fast path; this is the full chooser. + LazyVGrid(columns: [GridItem(.adaptive(minimum: 92), spacing: 6)], alignment: .trailing, spacing: 6) { + ForEach(WeiBeiAppearanceMode.allCases) { mode in + Button { + withAnimation(WeiBeiMotion.appearance) { + store.setAppearanceMode(mode) + } + } label: { + HStack(spacing: 6) { + Image(systemName: mode.systemImage) + .font(.system(size: 11, weight: .semibold)) + Text(mode.label(language: store.interfaceLanguage)) + .font(.system(size: 12, weight: .semibold)) + .lineLimit(1) + } + .padding(.horizontal, 10) + .frame(height: 30) + .frame(maxWidth: .infinity) + .foregroundStyle(mode == store.appearanceMode ? WeiBeiTheme.ink : WeiBeiTheme.secondaryInk) + .background( + RoundedRectangle(cornerRadius: 7) + .fill(mode == store.appearanceMode + ? WeiBeiTheme.paperRaised.opacity(0.72) + : WeiBeiTheme.paperInset.opacity(0.40)) + ) + .overlay { + RoundedRectangle(cornerRadius: 7) + .stroke( + mode == store.appearanceMode + ? WeiBeiTheme.cinnabar.opacity(0.55) + : WeiBeiTheme.hairline.opacity(0.36), + lineWidth: 1 + ) + } + } + .buttonStyle(.plain) + .help(mode.detail(language: store.interfaceLanguage)) } } + .frame(width: 280) } } @@ -472,7 +518,7 @@ struct SettingsView: View { /// Shared Settings card primitive (also used by `AgentSettingsView` extension). func settingsGroup(_ title: String, @ViewBuilder content: () -> Content) -> some View { - let cardFill = WeiBeiTheme.paperRaised.opacity(store.appearanceMode == .inkstone ? 0.20 : 0.36) + let cardFill = WeiBeiTheme.paperRaised.opacity(store.appearanceMode.isDark ? 0.20 : 0.36) return VStack(alignment: .leading, spacing: 0) { sectionTitle(title) .padding(.horizontal, 14) diff --git a/Sources/WeiBei/WebEditor/src/editor.js b/Sources/WeiBei/WebEditor/src/editor.js index 9034b6131..a2ba28c4f 100644 --- a/Sources/WeiBei/WebEditor/src/editor.js +++ b/Sources/WeiBei/WebEditor/src/editor.js @@ -219,7 +219,12 @@ const decorateLeakedCalloutControls = (decorations, text, pos) => { } }; -const normalizeTheme = (theme) => (theme === 'inkstone' ? 'inkstone' : 'paper'); +// Web CSS currently defines paper / inkstone. Map the four product themes onto those: +// 宣纸 → paper (cool light still uses light stylesheet), 石碑 → inkstone (dark stylesheet). +const normalizeTheme = (theme) => { + if (theme === 'inkstone' || theme === 'stele') return 'inkstone'; + return 'paper'; +}; let currentTheme = normalizeTheme(window.weiBeiTheme); const mermaidThemeVariables = () => { diff --git a/Sources/WeiBeiSelfCheck/main.swift b/Sources/WeiBeiSelfCheck/main.swift index d64f84ad1..3311fe133 100644 --- a/Sources/WeiBeiSelfCheck/main.swift +++ b/Sources/WeiBeiSelfCheck/main.swift @@ -733,8 +733,10 @@ expect(runScript.contains("WEIBEI_VERIFY_CAPTURE_PATH") && runScript.contains("[[ -s \"$VERIFY_CAPTURE_PATH\" ]] && break") && runScript.contains("app-owned capture and macOS window capture failed") && runScript.contains("Grant Screen Recording permission"), "visual verification prefers an app-owned capture and reports when both capture paths fail") -expect(runScript.contains("open_app() {\n /usr/bin/open \"$APP_BUNDLE\"\n}") - && !runScript.contains("open_app() {\n /usr/bin/open -n \"$APP_BUNDLE\"\n}"), "regular run opens WeiBei without forcing a second app instance") +expect(runScript.contains("open_app()") + && runScript.contains("/usr/bin/open \"$APP_BUNDLE\"") + && !runScript.contains("open -n \"$APP_BUNDLE\"") + && runScript.contains("codesign --verify --deep --strict \"$APP_BUNDLE\""), "regular run opens the staged signed WeiBei without forcing a second app instance") expect(runScript.contains("RUN_VISUAL_VERIFY=false") && runScript.contains("if [[ \"${2:-}\" == \"--visual-verify\"") && runScript.contains("finish_verify_window()") @@ -1908,10 +1910,12 @@ let themeSourceURL = URL(fileURLWithPath: FileManager.default.currentDirectoryPa let themeSource = (try? String(contentsOf: themeSourceURL, encoding: .utf8)) ?? "" expect(themeSource.contains(".fill(.regularMaterial)") && themeSource.contains("paperWashOpacity"), "header glass uses one shared paper material wash") expect(themeSource.contains("WeiBeiTheme.glassTint.opacity(0.16 * opacity)") && !themeSource.contains("WeiBeiTheme.paperInset.opacity(0.10 * opacity)"), "header handoff fade avoids a hard paper edge") -expect(themeSource.contains("dark: WeiBeiTone(hex: 0x1A1814)") - && themeSource.contains("dark: WeiBeiTone(hex: 0x3A3328)") +expect(themeSource.contains("inkstone: WeiBeiTone(hex: 0x1A1814)") + && themeSource.contains("inkstone: WeiBeiTone(hex: 0x3A3328)") + && themeSource.contains("stele: WeiBeiTone(hex: 0x1C2026)") + && themeSource.contains("stele: WeiBeiTone(hex: 0x3E4652)") && themeSource.contains("colorScheme == .dark ? 0.12 : 0.20") - && themeSource.contains("colorScheme == .dark ? 0.16 : 0.24"), "dark glass headers use warm inkstone wash instead of hard black blocks") + && themeSource.contains("colorScheme == .dark ? 0.16 : 0.24"), "dark glass headers use warm inkstone / cool stele washes instead of hard black blocks") 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") @@ -1937,9 +1941,14 @@ expect(themeSource.contains("func weibeiInputSurface") && themeSource.contains(".stroke(active ? WeiBeiTheme.link.opacity(0.34) : WeiBeiTheme.hairline.opacity(0.54), lineWidth: 1)") && !themeSource.contains("secondaryInk.opacity(0.84)"), "input surfaces use semantic ink without forcing the old light color scheme") expect(themeSource.contains("enum WeiBeiAppearanceMode") + && themeSource.contains("case paper") + && themeSource.contains("case xuan") && themeSource.contains("case inkstone") + && themeSource.contains("case stele") + && themeSource.contains("var isDark: Bool") && themeSource.contains("WeiBeiNativePalette") - && themeSource.contains("static func weiBei(light:"), "theme exposes a persisted paper/inkstone appearance mode and native AppKit palette") + && themeSource.contains("WeiBeiThemeRuntime") + && themeSource.contains("static func weiBei(light:"), "theme exposes four appearance modes (纸面/宣纸/墨石/石碑) with runtime palette resolution") expect(!themeSource.contains("var label: String") && !themeSource.contains("var actionLabel: String"), "theme-facing labels require an interface language instead of Chinese-only fallback properties") expect(themeSource.contains("static let appearance = Animation.easeInOut(duration: 0.42)"), "appearance changes use a dedicated smooth theme transition") @@ -2054,8 +2063,9 @@ expect(contentViewSource.contains("private var controlHeight: CGFloat {\n expect(contentViewSource.contains("private var leftPrimaryControls: some View") && contentViewSource.contains("libraryButton\n\n navigationButtons\n\n appearanceToggleButton") && contentViewSource.contains("private var appearanceToggleButton: some View") - && contentViewSource.contains("topIconButton(store.appearanceMode.toggled.systemImage, help: store.appearanceMode.actionLabel(language: store.interfaceLanguage))") - && contentViewSource.contains("store.toggleAppearanceMode()") + && contentViewSource.contains("ForEach(WeiBeiAppearanceMode.allCases)") + && contentViewSource.contains("store.setAppearanceMode(mode)") + && contentViewSource.contains("WeiBeiBrandMark.image(for: store.appearanceMode)") && contentViewSource.contains("openSettings") && contentViewSource.contains("openSettings()") && contentViewSource.contains("slider.horizontal.3") @@ -2063,7 +2073,7 @@ expect(contentViewSource.contains("private var leftPrimaryControls: some View") && contentViewSource.contains("WeiBeiIconButtonStyle(active: active, size: 24)") && !contentViewSource.contains("WeiBeiIconButtonStyle(active: store.appearanceMode == .inkstone") && !contentViewSource.contains("private var settingsMenu: some View") - && !contentViewSource.contains("Image(systemName: \"gearshape\")"), "top bar opens full Settings from the trailing cluster instead of a mini gear menu") + && !contentViewSource.contains("Image(systemName: \"gearshape\")"), "top bar has brand logo, four-theme menu, and full Settings entry") expect(themeSource.contains("enum WeiBeiIconButtonProminence") && themeSource.contains("@Environment(\\.colorScheme)") && themeSource.contains("prominence == .primary") @@ -2299,10 +2309,13 @@ expect(!readerViewSource.contains("Bundle.module.url(forResource: \"WeiBeiStele\ && readerViewSource.contains("readerStyleScript"), "html reader keeps imported document fonts instead of injecting bundled WeiBei display fonts into file headings") expect(readerViewSource.contains("color-scheme: light") && readerViewSource.contains("color-scheme: dark") - && readerViewSource.contains("color: #1d1814 !important") - && readerViewSource.contains("color: #D7CBB0 !important") - && readerViewSource.contains("a { color: #C8B98A !important;"), "html reader injects readable light and inkstone dark styles over imported documents") -expect(readerViewSource.contains("::selection { background: rgba(145, 38, 27, 0.20); color: #1d1814; }"), "html reader uses the WeiBei cinnabar selection color instead of the default blue highlight") + && readerViewSource.contains("#1d1814") + && readerViewSource.contains("#D7CBB0") + && readerViewSource.contains("#C8B98A") + && readerViewSource.contains("case .paper, .xuan:") + && readerViewSource.contains("case .inkstone, .stele:"), "html reader injects readable light (纸面/宣纸) and dark (墨石/石碑) styles over imported documents") +expect(readerViewSource.contains("::selection { background: rgba(145, 38, 27, 0.20); color: \\(text); }") + || readerViewSource.contains("::selection { background: rgba(145, 38, 27, 0.20);"), "html reader uses the WeiBei cinnabar selection color instead of the default blue highlight") expect(readerViewSource.contains("document.addEventListener(\"selectionchange\", reportSelection)") && readerViewSource.contains("document.addEventListener(\"pointerdown\", () => {") && readerViewSource.contains("lastPayload = { text: \"\", x: null, y: null }") @@ -2599,9 +2612,11 @@ expect(richEditorSource.contains("var appearanceMode: WeiBeiAppearanceMode = .pa && richEditorSource.components(separatedBy: "appearanceMode: appearanceMode").count >= 4 && richEditorSource.contains("private static func applyWebAppearance(to view: WKWebView, appearanceMode: WeiBeiAppearanceMode)") && richEditorSource.contains("view.underPageBackgroundColor = WeiBeiNativePalette.paper(for: appearanceMode)") - && richEditorSource.contains("view.appearance = NSAppearance(named: appearanceMode == .inkstone ? .darkAqua : .aqua)") + && richEditorSource.contains("view.appearance = NSAppearance(named: appearanceMode.isDark ? .darkAqua : .aqua)") && richEditorSource.contains("private var missingImageColors: (background: String, accent: String, text: String)") && richEditorSource.contains("case .inkstone:") + && richEditorSource.contains("case .xuan:") + && richEditorSource.contains("case .stele:") && richEditorSource.contains("return (\"#151515\", \"#a6362b\", \"#d7cbb0\")"), "native missing-image placeholders follow the current editor theme instead of always using a pale SVG") expect(richEditorSource.contains("selection?.removeAllRanges();") && richEditorSource.contains("messageHandlers?.selectionChanged?.postMessage") @@ -2830,7 +2845,8 @@ expect(!agentSettingsSource.contains("Form {") && agentSettingsSource.contains(".weibeiInputSurface(active: focusedField == .apiKey, height: 38)") && agentSettingsSource.contains("private var settingsAppearanceToggleButton: some View") && agentSettingsSource.contains("Spacer()\n settingsAppearanceToggleButton") - && agentSettingsSource.contains("Image(systemName: store.appearanceMode.toggled.systemImage)") + && agentSettingsSource.contains("Image(systemName: store.appearanceMode.systemImage)") + && agentSettingsSource.contains("ForEach(WeiBeiAppearanceMode.allCases)") && agentSettingsSource.contains(".buttonStyle(WeiBeiIconButtonStyle(size: 30))") && !agentSettingsSource.contains("WeiBeiIconButtonStyle(active: store.appearanceMode == .inkstone") && !agentSettingsSource.contains("TopBarVariant") @@ -3108,11 +3124,11 @@ expect(workspaceStoreSource.contains("var brandLatinName: String") && workspaceStoreSource.contains("\"WeiBei\"") && contentViewSource.contains("Text(store.brandLatinName)") && contentViewSource.contains("WeiBeiTypography.englishBrandFont(size: 15.5, weight: .semibold)") - && contentViewSource.contains(".frame(width: 62, alignment: .leading)") + && contentViewSource.contains("WeiBeiBrandMark.image(for: store.appearanceMode)") // Settings sidebar keeps a single localized title only — no second "WeiBei SETTINGS" line. && !agentSettingsSource.contains("Text(\"SETTINGS\")") && notesAgentSource.contains("latinMark: store.interfaceLanguage == .chinese ? \"NOTES\" : nil") - && notesAgentSource.contains("latinMark: store.interfaceLanguage == .chinese ? \"CHAT\" : nil"), "custom English font has visible Latin brand marks in the top bar and pane headers; settings title is not duplicated") + && notesAgentSource.contains("latinMark: store.interfaceLanguage == .chinese ? \"CHAT\" : nil"), "top bar shows logo + Latin brand; pane headers keep CHAT/NOTES marks; settings title is not duplicated") expect(notesAgentSource.contains("ForEach(NoteRenderMode.visibleCases)") && notesAgentSource.contains("switch store.noteRenderMode.visibleMode") && !notesAgentSource.contains("ForEach(NoteRenderMode.allCases)") @@ -3886,8 +3902,8 @@ expect(noteModeControlSource.contains("NoteRenderMode.visibleCases") && !noteModeControlSource.contains("Capsule()") && noteModeControlSource.contains("noteModeButtonFill(selected: selected, hovering: hovering)") && noteModeControlSource.contains("noteModeButtonStroke(selected: selected, hovering: hovering)") - && noteModeControlSource.contains("WeiBeiTheme.cinnabarSoft.opacity(store.appearanceMode == .inkstone ? 0.44 : 0.62)") - && noteModeControlSource.contains("WeiBeiTheme.paperRaised.opacity(store.appearanceMode == .inkstone ? 0.16 : 0.20)") + && noteModeControlSource.contains("WeiBeiTheme.cinnabarSoft.opacity(store.appearanceMode.isDark ? 0.44 : 0.62)") + && noteModeControlSource.contains("WeiBeiTheme.paperRaised.opacity(store.appearanceMode.isDark ? 0.16 : 0.20)") && noteModeControlSource.contains(".weibeiHeaderAccessoryGroup()") && noteModeControlSource.contains(".scaleEffect(hovering && !selected ? 1.012 : 1)") && !noteModeControlSource.contains(".stroke(WeiBeiTheme.hairline.opacity(0.14), lineWidth: 1)"), "note mode control is icon-only so narrow panes never collapse labels into ellipses") @@ -4087,7 +4103,7 @@ expect(notesAgentSource.contains("if store.hasSelectedMaterial") && !notesAgentSource.contains("starterChip(\"出复习题\""), "agent starter chips hide material actions without a selected material and avoid clipped long labels") expect(notesAgentSource.contains("let availableWidth = max(agentPaneWidth, 1)") && notesAgentSource.contains("private enum AgentChatLayoutMetrics") - && notesAgentSource.contains("static let wideMaxWidth: CGFloat = 1600") + && notesAgentSource.contains("static let wideMaxWidth: CGFloat = 920") && notesAgentSource.contains("static let compactMaxWidth: CGFloat = 560") && notesAgentSource.contains("AgentChatLayoutMetrics.contentWidth(") && notesAgentSource.contains("isImmersiveConversation") @@ -4275,7 +4291,7 @@ if let selectionStart = notesAgentSource.range(of: "struct FloatingSelectionAgen expect(notesAgentSource.contains("private func agentInputTray(wide: Bool, contentWidth: CGFloat)"), "agent pane uses a dedicated input tray") expect(notesAgentSource.contains("private var agentContentMaxWidth: CGFloat?") && notesAgentSource.contains("private enum AgentChatLayoutMetrics") - && notesAgentSource.contains("static let wideComposerHeight: CGFloat = 148") + && notesAgentSource.contains("static let wideComposerHeight: CGFloat = 188") && notesAgentSource.contains("static let compactComposerHeight: CGFloat = 52") && notesAgentSource.contains("layout == .immersiveConversation") && notesAgentSource.contains("let isUser = message.role == .user") @@ -4297,7 +4313,7 @@ expect(notesAgentSource.contains("private var agentContentMaxWidth: CGFloat?") && workspaceStoreSource.contains("func openAgentCitation") && workspaceStoreSource.contains("resolveStudyItem(matchingCitationTitle:") && workspaceStoreSource.contains("keepFloatingSelectionForAnswer") - && workspaceStoreSource.contains("SelectionAskThread"), "agent uses one standard centered reading column; immersive chat is 1600×148, three-pane is 560×52, selection-ask float keeps answers") + && workspaceStoreSource.contains("SelectionAskThread"), "agent uses one centered reading column; immersive Codex-like chat is 920×188, three-pane is 560×52") expect(notesAgentSource.contains("private let agentBottomAnchorID = \"agentConversationBottom\"") && notesAgentSource.contains(".id(agentBottomAnchorID)") && notesAgentSource.contains("proxy.scrollTo(agentBottomAnchorID, anchor: .bottom)") @@ -4311,9 +4327,10 @@ expect(notesAgentSource.contains("// No scrollTargetLayout / scrollPosition / mi expect(notesAgentSource.contains("private var agentInputMaxWidth: CGFloat?") && notesAgentSource.contains("AgentChatLayoutMetrics.contentWidth(") && notesAgentSource.contains("composerFieldHeight") - && notesAgentSource.contains("static let wideComposerHeight: CGFloat = 148") - && notesAgentSource.contains(".frame(width: contentWidth, height: fieldHeight, alignment: .bottom)") - && notesAgentSource.contains("agent-input-tray-wide"), "agent composer matches reading column width with a fixed immersive height") + && notesAgentSource.contains("static let wideComposerHeight: CGFloat = 188") + && notesAgentSource.contains("showsModelFooter: wide") + && notesAgentSource.contains(".frame(width: contentWidth, alignment: .bottom)") + && notesAgentSource.contains("agent-input-tray-wide"), "agent composer matches reading column width with Codex-like immersive height and model footer") expect(notesAgentSource.contains(".contentShape(Rectangle())") && notesAgentSource.contains("focused.wrappedValue = true") && notesAgentSource.components(separatedBy: "AgentComposerField(").count >= 3 @@ -4328,18 +4345,18 @@ expect(notesAgentSource.contains("ScrollView(showsIndicators: true)") && notesAgentSource.contains("AgentPaneWidthKey") && !notesAgentSource.contains("GeometryReader { paneGeometry in") && !notesAgentSource.contains("onMarkdownHeightChange: message.id == store.messages.last?.id"), "agent conversation keeps a light scroll affordance and follows the latest turn without WebView height thrash") -expect(notesAgentSource.contains("WeiBeiGlassHeaderBackground(") && notesAgentSource.contains("WeiBeiTheme.glassTint.opacity(0.34)"), "agent input tray uses paper glass fade instead of a hard white strip") +expect(notesAgentSource.contains("WeiBeiGlassHeaderBackground(") && notesAgentSource.contains("WeiBeiTheme.glassTint.opacity(0.40)"), "agent input tray uses paper glass fade instead of a hard white strip") expect(notesAgentSource.contains("WeiBeiTheme.ink.opacity(0.42), WeiBeiTheme.ink.opacity(0.78)") && !notesAgentSource.contains(".black.opacity(0.72), .black"), "agent input tray fade mask uses semantic ink instead of a fixed black ramp") -expect(notesAgentSource.contains("lineLimit: wide ? 1...12 : 1...6") - && notesAgentSource.contains(".padding(.trailing, showsControl ? trailingPadding : 0)") - && notesAgentSource.contains(".frame(width: contentWidth, height: fieldHeight, alignment: .bottom)") +expect(notesAgentSource.contains("lineLimit: wide ? 1...16 : 1...6") + && notesAgentSource.contains("showsModelFooter: wide") + && notesAgentSource.contains(".frame(width: contentWidth, alignment: .bottom)") && notesAgentSource.contains("height: fieldHeight") && notesAgentSource.contains("prompt: agentPrompt") && notesAgentSource.contains("WeiBeiIconButtonStyle(size: sendButtonSize, prominence: store.isAskingAgent ? .neutral : .primary)") - && notesAgentSource.contains("sendButtonSize: wide ? 38 : 28") - && notesAgentSource.contains("sendBottom: wide ? 24 : 8") - && notesAgentSource.contains("let locksHeight = height >= 72"), "main agent input uses a fixed-height composer in wide chat and keeps send inside the field edge") + && notesAgentSource.contains("sendButtonSize: wide ? 36 : 28") + && notesAgentSource.contains("sendBottom: wide ? 14 : 8") + && notesAgentSource.contains("let locksHeight = height >= 72"), "main agent input uses a fixed-height Codex-like composer in wide chat with model footer and send control") expect(notesAgentSource.contains("Image(systemName: store.isAskingAgent ? \"stop.fill\" : \"paperplane.fill\")") && notesAgentSource.contains("store.isAskingAgent ? store.cancelAgentRequest() : submit()") && !notesAgentSource.contains("Image(systemName: \"arrow.up\")")