Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
f8e740d
feat: 统一文件导入确认流程
taekchef Sep 28, 2026
13aa1af
test: 修正导入计划断言
taekchef Sep 28, 2026
0ec638d
fix: 补齐统一导入边界行为
taekchef Sep 28, 2026
eb53832
fix: 根治统一导入剩余边界
taekchef Sep 28, 2026
9ab59c9
fix: 按界面语言显示导入限制
taekchef Sep 28, 2026
deb71f0
fix: 按导入入口区分 Markdown 资料与笔记
taekchef Sep 28, 2026
2a6cc5e
test: 明确写闸门无基线场景
taekchef Sep 28, 2026
bd2b0e7
收紧统一导入确认面板布局
taekchef Sep 28, 2026
db39261
让导入面板按正文高度收缩
taekchef Sep 28, 2026
e4b556b
修复导入面板固有高度裁切
taekchef Sep 28, 2026
436fb51
同步测量导入面板正文高度
taekchef Sep 29, 2026
2365177
清理导入布局临时诊断
taekchef Sep 29, 2026
be1649b
记录导入弹窗完整尺寸链
taekchef Sep 29, 2026
ec28145
让导入弹窗持续跟随首选尺寸
taekchef Sep 29, 2026
6ce3600
拆分导入弹窗诊断表达式
taekchef Sep 29, 2026
2535bd5
按原生附属窗口同步导入弹窗尺寸
taekchef Sep 29, 2026
7791118
修正 Markdown 文件选择类型
taekchef Sep 29, 2026
a46f083
记录导入附属窗口原生几何
taekchef Sep 29, 2026
e5c78db
按独立场景同步导入弹窗尺寸
taekchef Sep 29, 2026
cddfde2
同步独立场景的导入窗口边界
taekchef Sep 29, 2026
7ad96aa
移除导入弹窗无意义分隔线
taekchef Sep 29, 2026
7ff0ebb
精简新建课程窗口并统一弹窗样式
taekchef Sep 29, 2026
231bf86
清理动态弹窗尺寸诊断
taekchef Sep 29, 2026
812cc6b
精简导入与新建课程弹窗信息层级
taekchef Sep 29, 2026
0920437
精简导入失败结果说明
taekchef Sep 29, 2026
ca05a4b
拒绝过期弹窗尺寸请求
taekchef Sep 29, 2026
953bcc4
恢复连续弹窗尺寸更新
taekchef Sep 29, 2026
4aff336
按内容几何调整弹窗尺寸
taekchef Sep 29, 2026
85de655
收拢确认导入窗口结构
taekchef Sep 29, 2026
741cf6f
移除弹窗尺寸的冗余状态标记
taekchef Sep 29, 2026
dc4a9db
补全导入范围与结果动作语义
taekchef Sep 29, 2026
4efbc81
复用文本父类型覆盖资料格式
taekchef Sep 29, 2026
f061bbb
按自然内容尺寸更新弹窗
taekchef Sep 29, 2026
74d5092
记录弹窗尺寸请求时序
taekchef Sep 29, 2026
778e733
同步弹窗内部视口尺寸
taekchef Sep 29, 2026
98635a2
通知弹窗宿主更新内容尺寸
taekchef Sep 29, 2026
41f8bbd
采样验收弹窗外层原生窗口尺寸
taekchef Sep 29, 2026
b17b1cf
清理弹窗尺寸临时诊断
taekchef Sep 29, 2026
fcef856
refine confirmed import completion flow
taekchef Sep 29, 2026
306bf1c
reveal imported batches in sidebar
taekchef Sep 29, 2026
d912835
修复课程笔记加载完成后仍转圈
taekchef Sep 29, 2026
215bdcf
fix: 发布课程笔记读盘完成状态
taekchef Sep 29, 2026
41fea83
fix: avoid conflicts when note snapshot matches disk
taekchef Sep 29, 2026
a71f324
修复原生选择窗中文件与目录混选
taekchef Sep 29, 2026
2f254c1
Prepare PR518 against restored main for acceptance
Oct 1, 2026
ab1a01f
test: cover confirmed import duplicate recovery boundaries
codex Oct 1, 2026
ead5649
fix: recover confirmed import duplicates after representative failures
codex Oct 1, 2026
62e2d34
Merge accepted pane and main changes into PR518 repair
codex Oct 1, 2026
96a7039
Merge branch 'codex/report-package-size-20261001' into codex/prepare-…
Oct 1, 2026
fa10670
test: await initial Mermaid preview before measuring typing debounce
Oct 1, 2026
28da939
test: verify confirmed import through the real Catalyst sheet
taekchef Oct 2, 2026
f9d637e
fix(import): secure confirmed import queue and copying
taekchef Oct 2, 2026
1636396
Merge accepted interaction and floating checks into confirmed import
taekchef Oct 2, 2026
dcf6639
Keep queued import metadata and verify reopened editor content
taekchef Oct 2, 2026
1b120a3
Merge remote-tracking branch 'refs/remotes/origin/main' into codex/pr…
taekchef Oct 2, 2026
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
2 changes: 1 addition & 1 deletion App/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ struct CatalystWeiBeiApp: App {
private var workspaceContent: some View {
// Native size restrictions own the minimum; scrolling panes extend under the toolbar.
CatalystWorkspaceRoot(store: AppDelegate.workspace, appDelegate: appDelegate)
.onOpenURL { AppDelegate.workspace.importFiles([$0]) }
.onOpenURL { AppDelegate.workspace.receiveExternalFileForConfirmedImport($0) }
#if WEIBEI_ACCEPTANCE_CHECKS
.task {
if CommandLine.arguments.contains("--drag-profile"),
Expand Down
46 changes: 42 additions & 4 deletions App/Sources/CatalystBusinessCheck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ enum CatalystBusinessCheck {
store.continueLastWork()
store.ensureAllStudySessionMessagesLoaded()
try await until("reopened note editor") { !store.activeNoteIsLoading && store.noteText.contains(noteMarker) }
let renderedMarker = String(decoding: try JSONEncoder().encode(finalMarker), as: UTF8.self)
try await until("reopened note editor content") {
guard let webView = await editor(documentID: store.activeNoteEditorDocumentID) else { return false }
return (try? await webView.evaluateJavaScript("document.querySelector('.ProseMirror')?.textContent?.includes(\(renderedMarker)) === true") as? Bool) == true
}
let history = store.studySessions.flatMap(\.messages)
try check("reopen_original_note_and_session_files",
store.noteText.contains(finalMarker) && history.contains { $0.text.contains(finalMarker) && $0.completionState == .completed }
Expand Down Expand Up @@ -432,12 +437,45 @@ enum CatalystBusinessCheck {
try "# 阅读位置\n\n候选独立合成资料:内容增长时保留同一处文字。材料标记 WB452_SOURCE。\n".write(to: materialURL, atomically: true, encoding: .utf8)
let noteURL = inputs.appendingPathComponent("候选验证笔记.md")
try "# 候选验证笔记\n\n这是独立测试资料,不是用户笔记。\n".write(to: noteURL, atomically: true, encoding: .utf8)
let materials: [StudyItem] = await withCheckedContinuation { done in
store.importFiles([materialURL]) { done.resume(returning: $0) }
var confirmedItems: [StudyItem] = []
let importSheet = {
UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }
.flatMap(\.windows).flatMap(descendants)
.compactMap { $0 as? CatalystIndependentSheetSizingProbe.Probe }
.first { $0.window != nil && !$0.isHidden && $0.contentSize != nil }
}
let notes: [StudyItem] = await withCheckedContinuation { done in
store.importFiles([noteURL], markdownAsNotes: true) { done.resume(returning: $0) }
for (url, asNotes) in [(materialURL, false), (noteURL, true)] {
let previousIDs = Set(store.importedItems.map(\.id))
store.prepareConfirmedFileImport([url], asNotes: asNotes)
try await until("confirmed import review and fitted native sheet") {
guard store.confirmedFileImport?.stage == .reviewing,
let sheet = importSheet(), let size = sheet.contentSize,
let window = sheet.window, !window.isHidden else { return false }
return abs(window.bounds.width - size.width) < 1
&& abs(window.bounds.height - size.height) < 1
&& size.width > 100 && size.height > 100
}
if !asNotes, let window = importSheet()?.window {
let snapshot = UIGraphicsImageRenderer(bounds: window.bounds).image { _ in
window.drawHierarchy(in: window.bounds, afterScreenUpdates: true)
}
try snapshot.pngData()?.write(to: LabMetrics.directory.appendingPathComponent("confirmed-import.png"))
}
store.confirmFileImport()
try await until("confirmed import completes and dismisses") {
store.confirmedFileImport == nil && importSheet() == nil
}
let added = store.importedItems.filter { !previousIDs.contains($0.id) }
guard added.count == 1, let imported = added.first,
let copiedURL = store.resolvedLibraryURL(for: imported),
try Data(contentsOf: copiedURL) == Data(contentsOf: url) else {
throw Failure("confirmed import did not preserve the material/note")
}
confirmedItems.append(imported)
}
let materials = Array(confirmedItems.prefix(1))
let notes = Array(confirmedItems.suffix(1))
try check("confirmed_import_review_copy_and_dismiss", confirmedItems.count == 2)
guard let material = materials.first, let note = notes.first,
let persistedNote = store.resolvedLibraryURL(for: note) else { throw Failure("original import returned no material/note") }
store.openCourseNote(note.id)
Expand Down
158 changes: 156 additions & 2 deletions App/Sources/CatalystWorkspaceChrome.swift
Original file line number Diff line number Diff line change
Expand Up @@ -594,13 +594,49 @@ struct CatalystWindowChrome: UIViewRepresentable {
}

// SwiftUI's Mac Catalyst sheet is hosted in a separate UIKit window.
struct CatalystSheetBackground: UIViewRepresentable {
struct CatalystIndependentSheetFitting: ViewModifier {
let color: UIColor
@State private var contentSize = CGSize.zero

func body(content: Content) -> some View {
content
.onGeometryChange(for: CGSize.self) { proxy in
proxy.size
} action: { size in
contentSize = size
}
.background(CatalystIndependentSheetSizingProbe(
color: color,
contentSize: contentSize
))
}
}

struct CatalystIndependentSheetSizingProbe: UIViewRepresentable {
let color: UIColor
var contentSize: CGSize?

init(color: UIColor, contentSize: CGSize? = nil) {
self.color = color
self.contentSize = contentSize
}

func makeUIView(context: Context) -> Probe { Probe() }
func updateUIView(_ view: Probe, context: Context) { view.color = color; view.configure() }

func updateUIView(_ view: Probe, context: Context) {
view.color = color
view.contentSize = contentSize
view.configure()
}

final class Probe: UIView {
var color = UIColor.clear
var contentSize: CGSize?
private var lastGeometryRequestSignature: String?

override func didMoveToWindow() { super.didMoveToWindow(); configure() }
override func layoutSubviews() { super.layoutSubviews(); configure() }

func configure() {
guard let window else { return }
window.backgroundColor = color
Expand All @@ -611,6 +647,124 @@ struct CatalystSheetBackground: UIViewRepresentable {
}
responder = current.next
}
guard let contentSize else { return }
resizeSheetIfNeeded(window: window, targetSize: contentSize)
}

private func resizeSheetIfNeeded(window: UIWindow, targetSize: CGSize) {
guard targetSize.width.isFinite, targetSize.height.isFinite,
targetSize.width > 0, targetSize.height > 0,
!Self.sameSize(window.bounds.size, targetSize),
let scene = window.windowScene else { return }
let sourceFrame = scene.effectiveGeometry.systemFrame
let rootedWindows = scene.windows.filter { $0.rootViewController != nil }
guard Self.sameSize(sourceFrame.size, window.bounds.size),
rootedWindows.count == 1,
rootedWindows[0] === window else { return }
let targetFrame = Self.centeredFrame(size: targetSize, in: sourceFrame)
let signature = "\(sourceFrame)|\(targetFrame)"
guard signature != lastGeometryRequestSignature else { return }
lastGeometryRequestSignature = signature
DispatchQueue.main.async { [weak self, weak window, weak scene] in
guard let self else { return }
guard let window, let scene, window.windowScene === scene else {
self.clearGeometryRequest(signature)
return
}
self.requestGeometryUpdate(
window: window,
scene: scene,
targetSize: targetSize,
signature: signature
)
}
}

private func requestGeometryUpdate(
window: UIWindow,
scene: UIWindowScene,
targetSize: CGSize,
signature: String
) {
guard self.window === window,
let contentSize,
Self.sameSize(contentSize, targetSize) else {
clearGeometryRequest(signature)
return
}
let sourceFrame = scene.effectiveGeometry.systemFrame
let rootedWindows = scene.windows.filter { $0.rootViewController != nil }
guard !Self.sameSize(window.bounds.size, targetSize),
Self.sameSize(sourceFrame.size, window.bounds.size),
rootedWindows.count == 1,
rootedWindows[0] === window else {
clearGeometryRequest(signature)
return
}
let targetFrame = Self.centeredFrame(size: targetSize, in: sourceFrame)
scene.requestGeometryUpdate(.Mac(systemFrame: targetFrame)) { [weak self] _ in
self?.clearGeometryRequest(signature)
}
DispatchQueue.main.async { [weak self, weak window, weak scene] in
guard let self, let window, let scene else { return }
self.synchronizeWindowWithSceneIfNeeded(
window: window,
scene: scene,
targetSize: targetSize
)
}
}

private func synchronizeWindowWithSceneIfNeeded(
window: UIWindow,
scene: UIWindowScene,
targetSize: CGSize
) {
let effectiveFrame = scene.effectiveGeometry.systemFrame
let rootedWindows = scene.windows.filter { $0.rootViewController != nil }
guard self.window === window,
window.windowScene === scene,
rootedWindows.count == 1,
rootedWindows[0] === window,
Self.sameSize(effectiveFrame.size, targetSize),
let rootViewController = window.rootViewController,
let presentationController = rootViewController.presentationController,
presentationController.presentedViewController === rootViewController,
let containerView = presentationController.containerView else { return }
rootViewController.preferredContentSize = targetSize
presentationController.preferredContentSizeDidChange(
forChildContentContainer: rootViewController
)
containerView.setNeedsLayout()
containerView.layoutIfNeeded()
DispatchQueue.main.async { [weak self, weak window, weak scene] in
guard let self, let window, let scene,
self.window === window,
window.windowScene === scene else { return }
guard let contentSize,
!Self.sameSize(contentSize, targetSize) else { return }
self.configure()
}
}

private func clearGeometryRequest(_ signature: String) {
if lastGeometryRequestSignature == signature {
lastGeometryRequestSignature = nil
}
}

private static func sameSize(_ lhs: CGSize, _ rhs: CGSize) -> Bool {
abs(lhs.width - rhs.width) < 1 && abs(lhs.height - rhs.height) < 1
}

private static func centeredFrame(size: CGSize, in frame: CGRect) -> CGRect {
CGRect(
x: frame.midX - size.width / 2,
y: frame.midY - size.height / 2,
width: size.width,
height: size.height
)
}

}
}
4 changes: 4 additions & 0 deletions App/WeiBei.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
9E35B424552BEC714D64E69B /* HTMLResourceImport.swift in Sources */ = {isa = PBXBuildFile; fileRef = E587D2C74173406238893D89 /* HTMLResourceImport.swift */; };
9E82B06347DF8AAD02442C3D /* WorkspaceStore+NativeAgent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D3DDD62890E2095AE206E6 /* WorkspaceStore+NativeAgent.swift */; };
9FB05F925099B527532D6EB2 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C114483E09D9B95115B4EF5 /* ContentView.swift */; };
CF1A00000000000000000001 /* ConfirmedFileImportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF1A00000000000000000002 /* ConfirmedFileImportView.swift */; };
9FD230DCC3C1CCEE79F5B1C1 /* EmptyWorkspaceInspiration.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA378A62D30B6A6251AD9DA6 /* EmptyWorkspaceInspiration.swift */; };
9FF041C038C5AB9C8A27287A /* PDFReaderOpenSafety.swift in Sources */ = {isa = PBXBuildFile; fileRef = 178A366B5659AC7A47E7AA30 /* PDFReaderOpenSafety.swift */; };
A29105E5484EFF5BE88B2979 /* PaneSeatMotion.swift in Sources */ = {isa = PBXBuildFile; fileRef = A434A3C22BC374DD87D0E041 /* PaneSeatMotion.swift */; };
Expand Down Expand Up @@ -348,6 +349,7 @@
4639CC2F72655275FF9EF5C5 /* WorkspaceStore+GlobalSearch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WorkspaceStore+GlobalSearch.swift"; sourceTree = "<group>"; };
4787853DDB4CD028D2FABC51 /* ContentRailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentRailView.swift; sourceTree = "<group>"; };
4C114483E09D9B95115B4EF5 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
CF1A00000000000000000002 /* ConfirmedFileImportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfirmedFileImportView.swift; sourceTree = "<group>"; };
4CDF85F80AC46C5FE414E777 /* NativeAgentSSE.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeAgentSSE.swift; sourceTree = "<group>"; };
4D52600F1258F2C0DAB31B39 /* ConversationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationController.swift; sourceTree = "<group>"; };
50D90DFD2794222AD19D98DD /* WeiBeiUpdateService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeiBeiUpdateService.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -746,6 +748,7 @@
BCFA6009ED31791018CA93D2 /* ComposerView.swift */,
4787853DDB4CD028D2FABC51 /* ContentRailView.swift */,
4C114483E09D9B95115B4EF5 /* ContentView.swift */,
CF1A00000000000000000002 /* ConfirmedFileImportView.swift */,
E51AB9EF50CCEDB319397D8C /* ContextualContentPicker.swift */,
E59061F53CCAA6551A4ABABC /* ConversationWebClippingView.swift */,
ED28080243B8A8B552763344 /* CourseDocNoteWorkspaceView.swift */,
Expand Down Expand Up @@ -1271,6 +1274,7 @@
90A2214DC79342A465A01D96 /* ComposerView.swift in Sources */,
186031B66D5FC7464EB6CB2C /* ContentRailView.swift in Sources */,
9FB05F925099B527532D6EB2 /* ContentView.swift in Sources */,
CF1A00000000000000000001 /* ConfirmedFileImportView.swift in Sources */,
24D17FE22AAD67D99C583D71 /* ContextualContentPicker.swift in Sources */,
82A9C07B68A5A0E9C1844E14 /* ConversationController.swift in Sources */,
C2683F836E4926D9F60998FD /* ConversationData.swift in Sources */,
Expand Down
76 changes: 76 additions & 0 deletions App/WindowBridge/NativeWindowBridge.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import AppKit
import Combine
import UniformTypeIdentifiers

/// Native window services and Sparkle use this bridge; content stays in Catalyst.
@objc(WeiBeiCatalystWindowBridge)
Expand All @@ -8,6 +9,7 @@ final class NativeWindowBridge: NSObject, CatalystWindowBridge {
private var intensity = 1.0
private let materials = NSMapTable<NSWindow, NSVisualEffectView>.weakToStrongObjects()
private var observers: [NSObjectProtocol] = []
private var activeOpenPanel: NSOpenPanel?
@MainActor private lazy var updateService = WeiBeiUpdateService()
@MainActor private var updateObservation: AnyCancellable?

Expand Down Expand Up @@ -115,6 +117,80 @@ final class NativeWindowBridge: NSObject, CatalystWindowBridge {
func open(_ url: URL) -> Bool { NSWorkspace.shared.open(url) }
func reveal(_ url: URL) { NSWorkspace.shared.activateFileViewerSelecting([url]) }
func materialWindowCount() -> Int { materials.count }
@MainActor func presentOpenPanel(
title: String,
contentTypeIdentifiers: [String],
allowsMultipleSelection: Bool,
canChooseDirectories: Bool,
canChooseFiles: Bool,
presentationToolbar: NSObject?,
completion: @MainActor @escaping ([URL], NSError?) -> Void
) {
guard activeOpenPanel == nil else {
completeOpenPanelFailure(
code: 1,
completion: completion
)
return
}
let owner: NSWindow
if let toolbar = presentationToolbar as? NSToolbar {
let roots = NSApp.windows.filter { $0.toolbar === toolbar }
guard roots.count == 1, let root = roots.first, root.isVisible else {
completeOpenPanelFailure(
code: 2,
completion: completion
)
return
}
var presentationWindow = root
while let sheet = presentationWindow.attachedSheet { presentationWindow = sheet }
owner = presentationWindow
} else {
guard let keyWindow = NSApp.keyWindow,
keyWindow.isVisible,
!keyWindow.isMiniaturized,
keyWindow.attachedSheet == nil else {
completeOpenPanelFailure(
code: 3,
completion: completion
)
return
}
owner = keyWindow
}
guard !(owner is NSOpenPanel) else {
completeOpenPanelFailure(
code: 4,
completion: completion
)
return
}

let panel = NSOpenPanel()
panel.title = title
panel.canChooseDirectories = canChooseDirectories
panel.canChooseFiles = canChooseFiles
panel.allowsMultipleSelection = allowsMultipleSelection
panel.allowedContentTypes = contentTypeIdentifiers.map { UTType($0) ?? UTType(importedAs: $0) }
activeOpenPanel = panel
panel.beginSheetModal(for: owner) { [weak self] response in
let urls = response == .OK ? panel.urls : []
self?.activeOpenPanel = nil
// Resume Catalyst on the next main-loop turn, after AppKit has detached the sheet.
DispatchQueue.main.async { completion(urls, nil) }
}
}
@MainActor private func completeOpenPanelFailure(
code: Int,
completion: @MainActor ([URL], NSError?) -> Void
) {
WeiBeiLog.workspace.error("code=native_open_panel_failed reason=\(code, privacy: .public)")
completion([], NSError(
domain: "WeiBei.NativeOpenPanel",
code: code
))
}
@MainActor func observeUpdates(_ observer: @escaping (String, String?, [String], Bool, URL?) -> Void) {
updateObservation = updateService.$status.combineLatest(updateService.$availableUpdate)
.sink { status, update in
Expand Down
Loading
Loading