diff --git a/ACCEPTANCE.md b/ACCEPTANCE.md index 7faafe8..1d2561c 100644 --- a/ACCEPTANCE.md +++ b/ACCEPTANCE.md @@ -29,6 +29,7 @@ Run on macOS 14+ with the released `Howler.dmg` (or `Howler.zip`). Mark each ite - [ ] 中文输入法:可正常输入拼音选词;选词过程中按 Esc 只取消组字,不关闭信纸 - [ ] ⌘V / ⌘C / ⌘A / ⌘Z 在输入框中可用 - [ ] Esc 或右下角火焰烧掉信纸并立即清空;火焰不遮挡页脚或正文;点击纸外或阴影只交出焦点,回答继续;其他应用中的 Esc 不影响信纸 +- [ ] 连续呼出信纸并按 Esc 至少三次。每次燃烧开始时,纸边、火漆印和正文都留在原位。 - [ ] 燃烧中再按 ⌥H:立即出现一张新的空白信纸 - [ ] 从菜单或火漆印打开 Settings:信纸直接收起并保留会话;从菜单打开信纸只唤回,不反向收起 - [ ] 多显示器:在鼠标所在屏幕上弹出 diff --git a/Sources/Howler/HowlerView.swift b/Sources/Howler/HowlerView.swift index e1b2159..cf14774 100644 --- a/Sources/Howler/HowlerView.swift +++ b/Sources/Howler/HowlerView.swift @@ -56,10 +56,11 @@ struct HowlerView: View { .padding(.bottom, 8).padding(.trailing, 8) } } + // 让展开动画的图层包含透明留白,保证燃烧快照沿用窗口原点。 + .padding(margins) .scaleEffect(unfolded ? 1 : 0.97, anchor: .top) .rotation3DEffect(.degrees(unfolded ? 0 : 10), axis: (x: 1, y: 0, z: 0), anchor: .top, perspective: 0.5) .opacity(unfolded ? 1 : 0) - .padding(margins) .environment(\.parchment, parchment) .environment(\.copyText, viewModel.copyText) .onAppear { diff --git a/Tests/HowlerAppTests/LetterLifecycleTests.swift b/Tests/HowlerAppTests/LetterLifecycleTests.swift index 2e13c46..048323c 100644 --- a/Tests/HowlerAppTests/LetterLifecycleTests.swift +++ b/Tests/HowlerAppTests/LetterLifecycleTests.swift @@ -161,6 +161,53 @@ final class LetterLifecycleTests: XCTestCase { XCTAssertEqual(settings.screenshotHotKey, .screenshot) } + func testOpeningBurnFrameKeepsTheWaxSealInPlace() async throws { + try XCTSkipIf(NSWorkspace.shared.accessibilityDisplayShouldReduceMotion) + _ = NSApplication.shared + let defaults = try XCTUnwrap(DemoDefaults(suiteName: "HowlerTests.BurnPosition")) + let settings = AppSettings(defaults: defaults, keys: MemoryKeys().access) + settings.useDemoService(.anthropic) + let controller = PanelController(settings: settings, openSettings: {}) + defer { controller.conceal() } + for cycle in 1...3 { + controller.show() + try await Task.sleep(nanoseconds: 650_000_000) + let originalFrame = controller.panel.frame + let liveSeal = try waxSealCenter(in: controller.panel) + + controller.panel.cancelOperation(nil) + + XCTAssertTrue(controller.isVisible, "应显示燃烧动画") + XCTAssertEqual(controller.panel.frame, originalFrame, "第 \(cycle) 次燃烧") + let burningSeal = try waxSealCenter(in: controller.panel) + XCTAssertEqual(burningSeal.x, liveSeal.x, accuracy: 2, "第 \(cycle) 次燃烧") + XCTAssertEqual(burningSeal.y, liveSeal.y, accuracy: 2, "第 \(cycle) 次燃烧") + try await waitUntil("燃烧结束后窗口应隐藏") { !controller.isVisible } + } + } + + private func waxSealCenter(in panel: NSPanel) throws -> CGPoint { + let content = try XCTUnwrap(panel.contentView) + content.layoutSubtreeIfNeeded() + let bitmap = try XCTUnwrap(content.bitmapImageRepForCachingDisplay(in: content.bounds)) + content.cacheDisplay(in: content.bounds, to: bitmap) + let scale = CGFloat(bitmap.pixelsWide) / content.bounds.width + var count = 0 + var sum = CGPoint.zero + for y in 0.. 0.9, color.redComponent > color.greenComponent * 2, + color.redComponent > color.blueComponent * 2 else { continue } + sum.x += CGFloat(x) + sum.y += CGFloat(y) + count += 1 + } + } + let sampleCount = try XCTUnwrap(count > 0 ? count : nil, "应能在纸张左上角找到火漆印") + return CGPoint(x: sum.x / CGFloat(sampleCount) / scale, y: sum.y / CGFloat(sampleCount) / scale) + } + func testBurningSnapshotDoesNotLeaveShadowOrScorchInMargins() throws { _ = NSApplication.shared let margins = EdgeInsets(