Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Sources/WeiBei/App/WeiBeiApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ struct WeiBeiApp: App {
.environmentObject(store.paneState)
.environmentObject(store.interaction)
.preferredColorScheme(store.appearanceMode.colorScheme)
.environment(\.weiBeiTextScale, store.interfaceTextScale.multiplier)
.modifier(WeiBeiAppearanceTransition(mode: store.appearanceMode))
.background(WindowChromeConfigurator(appearanceMode: store.appearanceMode))
.background(MainWindowReopenBridge(appDelegate: appDelegate))
Expand Down
30 changes: 15 additions & 15 deletions Sources/WeiBei/Resources/Editor/editor-entry.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Sources/WeiBei/Resources/Editor/editor-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"assets": [
{
"name": "editor-entry.js",
"bytes": 596111,
"sha256": "79faa6be2129b58f030ed5f062c1173d5b89363318dd6dbd41e150bde2c38a7e"
"bytes": 596257,
"sha256": "4ed73e076a6be9b724d57abf770e93b34b4230436709575663e9dbcdddb4fb9f"
},
{
"name": "editor.css",
Expand Down Expand Up @@ -313,8 +313,8 @@
},
{
"name": "index.html",
"bytes": 48872,
"sha256": "524797dc16aac196e1b9eb83e4571821692a0ba5edcd04af3bfe49a681dde423"
"bytes": 49020,
"sha256": "28437821549e01b3261c3bfb4322ef47d518484f6c97f1b0a0d97f92d9b54edb"
},
{
"name": "katex-runtime.js",
Expand All @@ -333,8 +333,8 @@
},
{
"name": "viewer-entry.js",
"bytes": 516818,
"sha256": "3a61bbdf17677d793ffb7de1dad4b62634ff5d54f46267a1d166b311848aabb4"
"bytes": 516964,
"sha256": "046c6a4312333e3e8a91a38bd8a14255d4a618117ef81e8b845bfa8b5717b843"
}
]
}
10 changes: 7 additions & 3 deletions Sources/WeiBei/Resources/Editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,14 @@
border-left-color: var(--cinnabar-line);
}

:root {
--weibei-text-scale: 1;
}

.ProseMirror {
outline: none;
min-height: calc(100vh - 92px);
font-size: 17px;
font-size: calc(17px * var(--weibei-text-scale));
line-height: 1.82;
caret-color: var(--cinnabar);
word-break: break-word;
Expand All @@ -390,12 +394,12 @@

:root[data-weibei-compact-preview="true"] .ProseMirror {
min-height: 0;
font-size: 14px;
font-size: calc(14px * var(--weibei-text-scale));
line-height: 1.68;
}

:root[data-weibei-chat-wide="true"] .ProseMirror {
font-size: 16px;
font-size: calc(16px * var(--weibei-text-scale));
line-height: 1.8;
}

Expand Down
16 changes: 8 additions & 8 deletions Sources/WeiBei/Resources/Editor/viewer-entry.js

Large diffs are not rendered by default.

66 changes: 33 additions & 33 deletions Sources/WeiBei/Stores/WorkspaceStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,8 @@ enum ContentSourceRemovalError: LocalizedError {
}
}

/// Isolated chrome state for the course drawer.
/// Kept off `WorkspaceStore`'s `@Published` surface so opening/closing the drawer
/// does not invalidate reader/agent/notes bodies (that was the multi-second pre-slide lag).
/// Isolated chrome state for the course drawer; kept off `WorkspaceStore`'s
/// `@Published` surface so open/close does not invalidate reader/agent/notes bodies.
@MainActor
final class LibraryDrawerState: ObservableObject {
@Published var isOpen = false
Expand Down Expand Up @@ -456,9 +455,8 @@ final class WorkspaceStore: ObservableObject {
readerSourceHighlightPageIndex = nil
}
}
/// Reader viewport (HTML section / PDF page). Scroll commits must not
/// auto-publish — every EnvironmentObject consumer (agent chat WKWebView
/// rows) would remasure and freeze the main thread (sample 2026-08-01).
/// Reader viewport (HTML section / PDF page). Scroll commits must not auto-publish:
/// every EnvironmentObject consumer would remasure and freeze main (sample 2026-08-01).
private var suppressReaderViewportPublish = false
private var readerLocationIDValue: String?
private var readerLocationTitleValue: String?
Expand Down Expand Up @@ -610,6 +608,7 @@ final class WorkspaceStore: ObservableObject {
@Published var motionPreference: WeiBeiMotionPreference = .system
@Published var adaptImportedDocumentColors = true
@Published var interfaceLanguage: WeiBeiInterfaceLanguage = .chinese
@Published var interfaceTextScale: WeiBeiTypography.TextScale = .standard
@Published var courseWorkspacePresented = false
@Published private(set) var courseWorkspaceCourseID: UUID?
@Published private(set) var courseWorkspaceDestination: CourseWorkspaceDestination = .hub
Expand Down Expand Up @@ -6886,9 +6885,8 @@ final class WorkspaceStore: ObservableObject {
mustBeInsideLibrary:
expectedCourse.sourceRootRelativePath != nil
)
// Trash path still refuses when the live folder cannot accept
// the latest portable state. Unregister-only must not require
// that write: the folder is already gone or unwritable.
// Trash path still refuses when the live folder cannot accept the
// latest portable state; unregister-only never requires that write.
guard await persistWorkspaceNow(),
!dirtyPortableCourseIDs.contains(courseID),
!blockedPortableCourseIDs.contains(courseID),
Expand Down Expand Up @@ -8399,10 +8397,8 @@ final class WorkspaceStore: ObservableObject {
}
}

/// One-pass course → visible-item counts for the contextual browser.
/// Replaces per-course full-library rescans (`contextualBrowserItems`
/// re-filtered + ICU-sorted once per course) that made opening the
/// browser stutter on large libraries.
/// One-pass course → visible-item counts for the contextual browser; replaces
/// per-course full-library rescans that made opening stutter on large libraries.
func contextualBrowserItemCounts(
_ kind: ContextualContentKind
) -> [UUID: Int] {
Expand Down Expand Up @@ -12319,6 +12315,12 @@ final class WorkspaceStore: ObservableObject {
save()
}

func setInterfaceTextScale(_ scale: WeiBeiTypography.TextScale) {
guard interfaceTextScale != scale else { return }
interfaceTextScale = scale
save()
}

func setAgentAuthMethod(_ method: AgentAuthMethod) {
guard agentAuthMethod != method else { return }
agentAuthMethod = method
Expand Down Expand Up @@ -12892,9 +12894,8 @@ final class WorkspaceStore: ObservableObject {
let cleanedOwnerTitle = ownerTitle?.trimmingCharacters(in: .whitespacesAndNewlines)
let resolvedOwnerTitle = (cleanedOwnerTitle?.isEmpty == false ? cleanedOwnerTitle : nil) ?? selectionOwnerTitle(for: source)
let boundedText = Self.boundedSelectionText(cleaned)
// Multi-pane and immersive both get the selection capsule when there is an anchor.
// (Previously suppressed whenever the chat column was open — that made multi-pane
// look "broken" vs immersive reading.)
// Multi-pane and immersive both get the selection capsule when there is an anchor
// (previously suppressed whenever the chat column was open — looked "broken").
let shouldRevealSelectionPrompt = anchor != nil || pinnedFloatingAgent
let contentMatches = selectionContext.map {
$0.text == boundedText
Expand Down Expand Up @@ -19264,10 +19265,8 @@ final class WorkspaceStore: ObservableObject {
changed = true
continue
}
// Existing legacy workspaces are the local source of truth
// on first upgrade. An equal payload can establish the
// baseline without replaying the disk snapshot over local
// chats, memories, drafts, or shared canonical items.
// Legacy workspaces are the local source of truth on first upgrade;
// an equal payload just baselines without replaying the disk snapshot.
coursePortableStateRevisions[courseID] = state.revision
coursePortableStateDigests[courseID] = diskDigest
changed = true
Expand Down Expand Up @@ -19640,11 +19639,9 @@ final class WorkspaceStore: ObservableObject {
existingSharedPath == sharedRelativePath else {
throw CoursePortableStateError.crossCourseReference
}
// A shared item is one canonical workspace record used by
// every course. A single course's older portable snapshot
// may restore its membership, but it must not downgrade the
// canonical file URL, identity, bookmark, digest, or file
// metadata already verified by the workspace.
// A shared item is one canonical workspace record used by every course;
// a course's older portable snapshot may restore membership but must not
// downgrade canonical URL/identity/bookmark/digest/metadata already verified.
preservedExistingShared = existing
itemURL = existing.url
itemIdentity = existing.importedFileIdentity
Expand Down Expand Up @@ -20280,8 +20277,7 @@ final class WorkspaceStore: ObservableObject {
self.agentBaseURL = agentBaseURL
}
// Legacy field: still read so older workspaces restore immersion/multi-pane;
// free drag order lives in threePaneOrder and is the source of truth for columns.
// Unknown / retired strings only drop the layout field, never the workspace.
// threePaneOrder owns free drag order; retired strings only drop this field.
var migratedRetiredSplitLayout = false
if let persistedLayoutRaw = snapshot.workspaceLayout {
if let workspaceLayout = WorkspaceLayout.resolve(persistedValue: persistedLayoutRaw) {
Expand Down Expand Up @@ -20322,6 +20318,10 @@ final class WorkspaceStore: ObservableObject {
let interfaceLanguage = WeiBeiInterfaceLanguage(rawValue: interfaceLanguageRaw) {
self.interfaceLanguage = interfaceLanguage
}
if let interfaceTextScaleRaw = snapshot.interfaceTextScaleRaw,
let interfaceTextScale = WeiBeiTypography.TextScale(rawValue: interfaceTextScaleRaw) {
self.interfaceTextScale = interfaceTextScale
}
noteText = noteText(for: activeNoteItem)
}

Expand Down Expand Up @@ -20432,7 +20432,8 @@ final class WorkspaceStore: ObservableObject {
showDailyInspiration: showDailyInspiration,
appearanceModeRaw: appearanceMode.rawValue,
adaptImportedDocumentColors: adaptImportedDocumentColors,
interfaceLanguageRaw: interfaceLanguage.rawValue
interfaceLanguageRaw: interfaceLanguage.rawValue,
interfaceTextScaleRaw: interfaceTextScale.rawValue
),
resumePoints
)
Expand Down Expand Up @@ -20925,10 +20926,8 @@ final class WorkspaceStore: ObservableObject {
}
return merged
}
// A newer in-memory generation may arrive while this transaction is
// on disk. Keep the committed CAS baseline before building that next
// generation; otherwise it would compare against an obsolete revision
// and falsely report a conflict.
// A newer in-memory generation may arrive while this transaction is on disk;
// keep the committed CAS baseline or the next compare falsely reports conflict.
if hasNewerGeneration {
coursePortableStateRevisions = mergingDictionary(
result.portableStateRevisions,
Expand Down Expand Up @@ -21182,7 +21181,8 @@ final class WorkspaceStore: ObservableObject {
showDailyInspiration: showDailyInspiration,
appearanceModeRaw: appearanceMode.rawValue,
adaptImportedDocumentColors: adaptImportedDocumentColors,
interfaceLanguageRaw: interfaceLanguage.rawValue
interfaceLanguageRaw: interfaceLanguage.rawValue,
interfaceTextScaleRaw: interfaceTextScale.rawValue
)
let noteEditorSaveReceipt = makeNoteEditorWorkspaceSaveReceipt(snapshot)
do {
Expand Down
14 changes: 7 additions & 7 deletions Sources/WeiBei/Support/AgentMarkdownBlockFallback.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ struct AgentMarkdownBlockFallback: View {
switch block.kind {
case let .heading(level):
Text(inline(AgentMarkdownBlockParser.headingBody(block.lines.first ?? "")))
.font(.system(size: headingFontSize(level), weight: .semibold))
.weiBeiText(headingFontSize(level), weight: .semibold)
.foregroundStyle(WeiBeiTheme.ink)
.fixedSize(horizontal: false, vertical: true)
case .paragraph:
Text(inline(block.lines.joined(separator: "\n")))
.font(.system(size: compact ? 13.2 : 15))
.weiBeiText(compact ? 13.2 : 15)
.lineSpacing(compact ? 4.2 : 5.2)
.foregroundStyle(WeiBeiTheme.ink)
.fixedSize(horizontal: false, vertical: true)
Expand All @@ -71,10 +71,10 @@ struct AgentMarkdownBlockFallback: View {
ForEach(Array(block.lines.enumerated()), id: \.offset) { index, rawLine in
HStack(alignment: .firstTextBaseline, spacing: 7) {
Text(ordered ? "\(index + 1)." : "•")
.font(.system(size: compact ? 13.2 : 15))
.weiBeiText(compact ? 13.2 : 15)
.foregroundStyle(WeiBeiTheme.ink.opacity(0.72))
Text(inline(AgentMarkdownBlockParser.listItemBody(rawLine)))
.font(.system(size: compact ? 13.2 : 15))
.weiBeiText(compact ? 13.2 : 15)
.lineSpacing(compact ? 3.6 : 4.4)
.foregroundStyle(WeiBeiTheme.ink)
.fixedSize(horizontal: false, vertical: true)
Expand All @@ -89,12 +89,12 @@ struct AgentMarkdownBlockFallback: View {
VStack(alignment: .leading, spacing: 1.5) {
if let language, !language.isEmpty {
Text(language)
.font(.system(size: 10.5, weight: .medium))
.weiBeiText(10.5, weight: .medium)
.foregroundStyle(WeiBeiTheme.ink.opacity(0.55))
}
ForEach(Array(block.lines.enumerated()), id: \.offset) { _, line in
Text(line.isEmpty ? " " : line)
.font(.system(size: compact ? 11.6 : 12.4, design: .monospaced))
.weiBeiText(compact ? 11.6 : 12.4, design: .monospaced)
.foregroundStyle(WeiBeiTheme.ink.opacity(0.88))
.fixedSize(horizontal: false, vertical: true)
}
Expand All @@ -110,7 +110,7 @@ struct AgentMarkdownBlockFallback: View {
.fill(WeiBeiTheme.cinnabar.opacity(0.6))
.frame(width: 2.5)
Text(inline(block.lines.map(AgentMarkdownBlockParser.quoteBody).joined(separator: "\n")))
.font(.system(size: compact ? 13 : 14.6))
.weiBeiText(compact ? 13 : 14.6)
.lineSpacing(compact ? 3.8 : 4.6)
.foregroundStyle(WeiBeiTheme.ink.opacity(0.86))
.fixedSize(horizontal: false, vertical: true)
Expand Down
Loading