feat(menubar): 实现统一资源面板与独立滚动进程表

This commit is contained in:
2026-11-02 23:08:33 +08:00
parent 604086bbbb
commit ef358794dc
24 changed files with 1640 additions and 173 deletions
+17
View File
@@ -0,0 +1,17 @@
import AppKit
@main struct PanelAssetChecks {
static func main() {
let bundle = Bundle(path: CommandLine.arguments[1])!
for appearance in [NSAppearance.Name.aqua, .darkAqua] {
NSAppearance(named: appearance)!.performAsCurrentDrawingAppearance {
for name in ["PanelCard", "MetricCPU", "MetricGPU", "MetricMemory", "MetricNetwork", "MetricDisk", "MetricBattery"] {
guard let color = NSColor(named: NSColor.Name(name), bundle: bundle)?.usingColorSpace(.sRGB) else { fatalError("Missing color: \(name)") }
precondition(abs(color.alphaComponent - 1) < 0.001, "Transparent \(name)")
if name == "MetricGPU" && appearance == .darkAqua { precondition(color.blueComponent > 0.99) }
}
}
}
print("PASS: compiled light/dark semantic colors exist, fully opaque, GPU blue component is normalized")
}
}
+30
View File
@@ -0,0 +1,30 @@
import Foundation
import CoreGraphics
@main struct PanelLayoutChecks {
static func main() {
for visible in [CGRect(x: 0, y: 67, width: 1512, height: 882), CGRect(x: -1440, y: -200, width: 1440, height: 800), CGRect(x: 0, y: 24, width: 800, height: 600)] {
let content = PanelLayout.contentSize(visible: visible, chrome: CGSize(width: 4, height: 12))
precondition(content.width + 4 <= visible.width - 32 && content.height + 12 <= visible.height - 32)
for frame in [CGRect(x: -500, y: 500, width: 1240, height: 820), CGRect(x: 1400, y: -800, width: 2000, height: 1200)] {
precondition(visible.insetBy(dx: 16, dy: 16).contains(PanelLayout.constrainedFrame(frame, visible: visible)))
}
}
let input: [ProcessMetrics] = (0..<2000).map { (index: Int) -> ProcessMetrics in
let id = ProcessIdentity(pid: Int32(index + 1), seconds: 1, microseconds: 0)
let path: String? = index == 42 ? "/test/needle" : nil
return ProcessMetrics(id: id, name: "worker-\(index)",
path: path, cpu: Double(index), residentBytes: UInt64(2000 - index), threads: 1, restricted: false)
}
let cpu = ProcessTableProjection.rows(input, query: "", byMemory: false, order: [])
precondition(cpu.first?.id.pid == 2000 && cpu.count == 2000)
let memory = ProcessTableProjection.rows(input, query: "", byMemory: true, order: [])
precondition(memory.first?.id.pid == 1)
let held = ProcessTableProjection.rows(input, query: "", byMemory: true, order: cpu.map(\.id))
precondition(held.map(\.id) == cpu.map(\.id))
let matched = ProcessTableProjection.rows(input, query: "needle", byMemory: false, order: [])
precondition(matched.count == 1 && matched[0].id.pid == 43)
precondition(ProcessTableProjection.rows(input, query: "does-not-exist", byMemory: false, order: []).isEmpty)
print("PASS: visible-frame bounds/chrome/negative origins, 2000-row CPU/RSS projection, frozen order, path search and empty results")
}
}
+27
View File
@@ -108,3 +108,30 @@ swiftc -module-cache-path /private/tmp/kymo-settings-cache \
```
将临时可执行文件放入带 Info.plist 并已完成代码签名的临时 `.app/Contents/MacOS`,再用 `open -n -W` 启动。检查首次展示、焦点恢复、隐藏重开、最小化恢复、普通窗口层级及关闭生命周期;不替代实际多窗口场景与视觉验收。
## 统一面板数据检查
```bash
swiftc -module-cache-path /private/tmp/kymo-unified-cache \
kymo/Core/Models/*.swift kymo/Core/Monitors/*.swift \
kymo/Core/Services/*.swift kymo/Core/Extensions/*.swift \
kymoTests/UnifiedPanelChecks.swift -o /private/tmp/kymo-unified-checks
/private/tmp/kymo-unified-checks
```
覆盖进程 CPU 首帧/差分与可见性基线、GPU 数值范围、VPN 防双计和接口历史容量。签名沙盒包、三语资源与真实 UI 的验证边界见 [统一面板验证](../docs/unified-panel-validation.md)。无 Xcode 测试 Target,不能将上述程序称为 xcodebuild test。
布局和列表投影边界、实际编译颜色检查:
```bash
swiftc -module-cache-path /private/tmp/kymo-unified-cache \
kymo/Core/Models/ProcessMetrics.swift kymo/Features/MenuBar/PanelLayout.swift \
kymo/Features/MenuBar/ProcessTableProjection.swift kymoTests/PanelLayoutChecks.swift \
-o /private/tmp/kymo-panel-layout-checks
/private/tmp/kymo-panel-layout-checks
swiftc -parse-as-library -module-cache-path /private/tmp/kymo-unified-cache \
kymoTests/PanelAssetChecks.swift -o /private/tmp/kymo-panel-asset-checks
/private/tmp/kymo-panel-asset-checks /absolute/path/to/kymo.app
```
前者覆盖屏幕预算、边界约束和 2000 行投影,不证明原生定位或滚动手感;后者读取编译资源,防止整数色值被解释为 1/255。