feat(ui): 实现全卡堆叠趋势与单页资源进程布局

This commit is contained in:
2026-11-15 17:59:52 +08:00
parent 469766892d
commit 99e558625b
37 changed files with 579 additions and 195 deletions
+3 -3
View File
@@ -1,18 +1,18 @@
# Kymo # Kymo
Kymo 是 macOS 菜单栏资源监控工具。菜单栏常驻品牌图标,点击打开概览 / 进程双页面板,每次打开默认进入概览。 Kymo 是 macOS 菜单栏资源监控工具。菜单栏常驻品牌图标,点击打开资源卡片与进程同页的监控面板。
## 当前功能 ## 当前功能
- CPU:总占用、用户态与系统态趋势、按核型分行的逐核细条与悬浮数值、温度;设备信息与开机时间位于公共底栏。 - CPU:总占用、用户态与系统态趋势、按核型分行的逐核细条与悬浮数值、温度;设备信息与开机时间位于公共底栏。
- GPU:总占用与 Renderer / Tiler 趋势、核心数、温度和风扇转速。 - GPU:占用 / 空闲堆叠趋势,Renderer / Tiler 历史提示、核心数、温度和风扇转速。
- 内存:已用与总量、应用 / 联动 / 压缩分类、缓存、可用量、压力与 Swap。 - 内存:已用与总量、应用 / 联动 / 压缩分类、缓存、可用量、压力与 Swap。
- 存储:主目录所在卷容量、块设备读写速率、各本地卷容量、可读取的 SMART 寿命与通电时间。 - 存储:主目录所在卷容量、块设备读写速率、各本地卷容量、可读取的 SMART 寿命与通电时间。
- 电池:电量、功率、电源状态、健康度、循环次数、放电时间估计。 - 电池:电量、功率、电源状态、健康度、循环次数、放电时间估计。
- 网络:接口切换、收发速率与累计字节、路径状态、本地和公网 IP 及复制。 - 网络:接口切换、收发速率与累计字节、路径状态、本地和公网 IP 及复制。
- 进程:PID、名称、CPU、内存 footprint、CPU 平均功率、线程数和路径;支持搜索、列排序及复制,功率缺失始终排末。 - 进程:PID、名称、CPU、内存 footprint、CPU 平均功率、线程数和路径;支持搜索、列排序及复制,功率缺失始终排末。
面板支持固定显示、保持唤醒、暂停 / 恢复采样。概览采用三列两行网格,首行 CPU / GPU / 内存,次行电池 / 存储 / 网络,同一行卡片等高;常规 648×448pt,小屏退为两列或单列,高度不足时滚动;进程页独占内容区。概览停止进程 / footprint / 功率读取,进程页卸载资源图表并停用概览慢读取与公网任务,基础趋势跨页连续。彩色卡片采用大数值与底部背景趋势,淡色面积按真实连续段绘制,悬浮可查询各序列历史;数字、曲线和进度条随采样直接更新,不播放应用自定义动画或背景模糊特效;后台记录独立控制。面板刷新默认 2 秒;默认隐藏停止采样,可显式开启后台趋势并配置间隔(新配置 30 秒)。设置窗口提供系统 / 浅色 / 深色外观、简体中文 / 繁體中文 / English 和关于信息。 面板支持固定显示、保持唤醒、暂停 / 恢复采样。首行 CPU / GPU / 内存,次行电池 / 存储 / 网络,第三行进程表跨满内容区;默认三行均高 176pt,面板 648×630pt,小屏退为两列或单列并滚动。趋势覆盖卡片全宽全高,文字叠放其上;CPU 系统 / 用户、内存应用 / 联动 / 压缩、GPU 占用 / 空闲按分量堆叠,悬浮查询原始历史。逐核为方块竖柱;风扇图标沿用转速档位旋转,暂停、隐藏或系统减弱动态效果时停转。数字与曲线直接更新,无背景模糊。资源和进程同时按可见性采样,后台趋势独立控制。面板刷新默认 2 秒;默认隐藏停止采样,可显式开启后台趋势并配置间隔(新配置 30 秒)。设置窗口提供系统 / 浅色 / 深色外观、简体中文 / 繁體中文 / English 和关于信息。
部分硬件指标依赖机型、驱动与权限,缺失值显示为 `--` 或对应状态。GPU 不提供逐核占用;耗电进程显示系统归属的 CPU 能量区间平均功率,注明可读覆盖范围,不代表完整应用总耗电。指标口径和限制见[监控指标](docs/monitoring.md)。 部分硬件指标依赖机型、驱动与权限,缺失值显示为 `--` 或对应状态。GPU 不提供逐核占用;耗电进程显示系统归属的 CPU 能量区间平均功率,注明可读覆盖范围,不代表完整应用总耗电。指标口径和限制见[监控指标](docs/monitoring.md)。
+1 -1
View File
@@ -9,7 +9,7 @@
| [开发指南](development.md) | 构建、修改入口、本地化和诊断参数 | | [开发指南](development.md) | 构建、修改入口、本地化和诊断参数 |
| [测试与验证](testing.md) | 统一检查入口、覆盖范围、实际交互与验收边界 | | [测试与验证](testing.md) | 统一检查入口、覆盖范围、实际交互与验收边界 |
| [测试分发](free-test-distribution.md) | 本地 Release 打包、签名与安装支持范围 | | [测试分发](free-test-distribution.md) | 本地 Release 打包、签名与安装支持范围 |
| [UI 设计规范](ui-design-standard.md) | 概览卡片尺寸、字体、颜色、背景趋势、交互与信息契约 | | [UI 设计规范](ui-design-standard.md) | 单页布局、卡片尺寸、字体、颜色、堆叠背景、风扇动效与信息契约 |
| [卡片背景趋势设计稿](designs/card-background-trends-v1/README.md) | 已采纳的浅色 / 深色风格参考,具体实现以设计规范和代码为准 | | [卡片背景趋势设计稿](designs/card-background-trends-v1/README.md) | 已采纳的浅色 / 深色风格参考,具体实现以设计规范和代码为准 |
修改实现时直接更新相应主题;大型变更的临时方案按 [AGENTS.md](../AGENTS.md) 存放在本目录,完成后将有效结论归入主题文档并清理失效记录。 修改实现时直接更新相应主题;大型变更的临时方案按 [AGENTS.md](../AGENTS.md) 存放在本目录,完成后将有效结论归入主题文档并清理失效记录。
+14 -10
View File
@@ -5,7 +5,7 @@
| 位置 | 当前职责 | | 位置 | 当前职责 |
| --- | --- | | --- | --- |
| `kymo/App` | AppKit 入口、生命周期、依赖装配、主菜单和 SwiftUI Settings 场景 | | `kymo/App` | AppKit 入口、生命周期、依赖装配、主菜单和 SwiftUI Settings 场景 |
| `kymo/Features/MenuBar` | 状态项、监控 NSPanel、概览卡片、进程表、业务展示投影与本地验证驱动 | | `kymo/Features/MenuBar` | 状态项、监控 NSPanel、资源卡片、进程表、业务展示投影与本地验证驱动 |
| `kymo/Features/Settings` | 通用 / 关于设置页、窗口焦点和 Dock 生命周期 | | `kymo/Features/Settings` | 通用 / 关于设置页、窗口焦点和 Dock 生命周期 |
| `kymo/Core/Monitors` | 系统采样、报告解析与 SystemSampler actor | | `kymo/Core/Monitors` | 系统采样、报告解析与 SystemSampler actor |
| `kymo/Core/Services` | MetricsStore、偏好、XPC 客户端、网络地址、保持唤醒与诊断 | | `kymo/Core/Services` | MetricsStore、偏好、XPC 客户端、网络地址、保持唤醒与诊断 |
@@ -20,11 +20,11 @@ App 装配依赖,方向为 Features → UI → Core → 系统 API。Features
入口 kymoApp.main() 启动 NSApplication,由 ApplicationLifecycle 管理;应用以 accessory 模式启动,通过 NSHostingSceneRepresentation 注册 Settings。 入口 kymoApp.main() 启动 NSApplication,由 ApplicationLifecycle 管理;应用以 accessory 模式启动,通过 NSHostingSceneRepresentation 注册 Settings。
MenuPanelController 拥有模板品牌 NSStatusItem 和无边框、可成为 key 的非激活 MonitoringPanel。左键切换面板,右键提供打开 / 隐藏、设置和退出。窗口以状态项所在屏幕可见区域为边界,水平居中,边缘至少留 16pt;最大宽 648pt,常规高 448pt,按卡片内容预算调整,最大高 800pt,并受实际屏幕限制。 MenuPanelController 拥有模板品牌 NSStatusItem 和无边框、可成为 key 的非激活 MonitoringPanel。左键切换面板,右键提供打开 / 隐藏、设置和退出。窗口以状态项所在屏幕可见区域为边界,水平居中,边缘至少留 16pt;最大宽 648pt,常规高 630pt,按卡片内容预算调整,最大高 800pt,并受实际屏幕限制。
每次显式打开进入概览。概览采用三列两行网格:首行 CPU / GPU / 内存,次行电池 / 存储 / 网络。同一行按最高卡片的内容预算等高对齐;两行 CPU 核型细条与一行风扇时,两行卡片均高 176pt,列宽 205⅓pt;标题、主数值、前景详情和底部 48pt 背景曲线采用统一几何规范。宽度小于 620pt 退为两列三行,小于 430pt 退为单列;小于 560pt 时页签另放一行。重排保持上述逐行阅读顺序,高度不足时滚动。进程页独占中间内容区,两页共用窗口尺寸。底栏显示设备信息、开机时间和刷新间隔。 单页面板首行 CPU / GPU / 内存,次行电池 / 存储 / 网络,第三行进程表跨满内容区。所有行按最高资源卡片的结构预算等高,默认均为 176pt;资源卡片宽 205⅓pt。32pt 顶栏只放品牌和操作,26pt 底栏显示设备、开机时间和刷新间隔。宽度小于 620pt 退为两列资源网格,小于 430pt 退为单列;进程始终放在资源之后,高度不足时中间区域整体滚动,表格保留自身滚动。
核心数由静态拓扑、硬件核数及快照共同确定;按核型纵向分行,每核保留独立占用细条与悬浮 / 辅助功能数值,核心较多时按宽度换行。风扇在本次打开保留已发现槽位。实际卡片宽度和窗口 contentLayoutRect 驱动布局;仅结构预算变化才请求调整窗口高度。 核心数由静态拓扑、硬件核数及快照共同确定;核型分组横向排列,各核心为四个 6×6pt 方块组成的 30pt 竖柱,从底部按真实比例填充,保留悬浮 / 辅助功能数值。核心较多时换行,每增加一行结构预算增加 34pt;风扇超过一行后每行增加 14pt,本次打开保留已发现槽位。实际卡片宽度和窗口 contentLayoutRect 驱动布局,仅结构预算变化才请求调整窗口高度。
固定按钮切换 normal / floating 层级。未固定时外部交互或应用失活收起;固定仍可显式关闭。进程表 Esc 依次清空搜索、清除选择、退出搜索焦点,然后关闭面板。隐藏卸载内容、关闭底层窗口资源并移除外部鼠标监听,控制器保留窗口对象供重开。presentation.isOpen 控制内容装配,采样可见性同时要求窗口 isVisible 与 occlusionState 可见;完全遮挡降级采样而保留内容及交互状态。 固定按钮切换 normal / floating 层级。未固定时外部交互或应用失活收起;固定仍可显式关闭。进程表 Esc 依次清空搜索、清除选择、退出搜索焦点,然后关闭面板。隐藏卸载内容、关闭底层窗口资源并移除外部鼠标监听,控制器保留窗口对象供重开。presentation.isOpen 控制内容装配,采样可见性同时要求窗口 isVisible 与 occlusionState 可见;完全遮挡降级采样而保留内容及交互状态。
@@ -34,14 +34,14 @@ MenuPanelController 拥有模板品牌 NSStatusItem 和无边框、可成为 key
```text ```text
系统 API → SystemSampler actor → MetricsSnapshot → MetricsStore(MainActor) 系统 API → SystemSampler actor → MetricsSnapshot → MetricsStore(MainActor)
│ ├─ snapshot → 概览 │ ├─ snapshot → 资源卡片
├─ 慢任务缓存 ├─ processSnapshot / energy → 进程表 ├─ 慢任务缓存 ├─ processSnapshot / energy → 进程表
└─ 单在途进程任务 └─ MetricHistory → 趋势图 └─ 单在途进程任务 └─ MetricHistory → 趋势图
SMARTService(XPC)→ 只读客户端 → 慢缓存 / 进程任务 SMARTService(XPC)→ 只读客户端 → 慢缓存 / 进程任务
实际可见性、页面需求、睡眠与偏好 → MetricsStore 调度 实际可见性、详情需求、睡眠与偏好 → MetricsStore 调度
``` ```
MetricsStore 是 MainActor 可观察状态。App 将 PanelPage 转换为 setDetailDemand(processes:slowMetrics:);Core 不依赖页面类型。概览不枚举进程或读取进程 footprint / 能量;进程页不新发起概览传感器、卷、慢报告和公网请求。两页继续基础系统采样与历史,不因切页重置 CPU / 网络 / 磁盘 IO 基线或制造断点。 MetricsStore 是 MainActor 可观察状态。App 装配时通过 setDetailDemand(processes: true, slowMetrics: true) 同时请求进程和慢指标,Core 只接收需求布尔值,不依赖界面类型。实际可见性、暂停与睡眠统一决定是否执行;隐藏默认停止采样,显式后台趋势仅延续基础历史,不启动进程、footprint、能量或慢报告。
新配置隐藏不采样;显式启用后台趋势后使用后台间隔,默认 30 秒。已有数值后台间隔且没有显式开关时保留启用状态,显式关闭优先。面板可见默认 2 秒,范围与各指标周期见[监控指标](monitoring.md)。周期按单调时钟从每轮开始安排,不补跑错过轮次;配置变化参考上次发布时间。允许 10% 周期容差,前台最多 200ms、后台最多 1 秒,速率仍按实际经过时间差分。 新配置隐藏不采样;显式启用后台趋势后使用后台间隔,默认 30 秒。已有数值后台间隔且没有显式开关时保留启用状态,显式关闭优先。面板可见默认 2 秒,范围与各指标周期见[监控指标](monitoring.md)。周期按单调时钟从每轮开始安排,不补跑错过轮次;配置变化参考上次发布时间。允许 10% 周期容差,前台最多 200ms、后台最多 1 秒,速率仍按实际经过时间差分。
@@ -55,9 +55,13 @@ SystemSampler actor 持有差分基线。CPU / 内存 Mach 查询取得的 host
## 展示与本地状态 ## 展示与本地状态
ResourceCard 通过 NativeContentHost 使用固定尺寸的独立 NSHostingView,完整传递字体、颜色、语言及外观环境;更新沿用挂载身份,卸载清空子宿主内容。图表锚点和提示层在同一卡片宿主内处理。NativePanelCurve 绘制静态曲线、逐连续段闭合的低透明度实色面积和悬浮标记,只在数据、几何或外观变化时更新;悬浮沿用曲线 / 面积几何。ResourceCard 独立排列标题、大数值和详情,将 48pt 趋势贴合卡片底部,并统一 16pt 圆角、10pt 内边距和静态轻阴影。概览不显示常驻图例、坐标轴、网格或起止时间;CPU / GPU / 内存 / 电池仅绘制主序列,存储 / 网络绘制双序列,全部已有序列仍可悬浮查询。数字和进度条直接展示最终值;曲线绘图不创建动画、渐变或遮罩图层,卡片圆角裁切由宿主处理,不使用背景模糊。样式、指标前景契约和异常状态见 [UI 设计规范](ui-design-standard.md)。 ResourceCard 通过 NativeContentHost 使用固定尺寸的独立 NSHostingView,传递字体、颜色、语言及外观环境;更新沿用挂载身份,卸载清空子宿主内容。背景绘图区覆盖卡片全宽全高:底边为 0,顶边为 100% / 内存物理总量 / 自动速率上限,文字和控件叠放其上。统一 16pt 圆角、10pt 前景内边距和静态轻阴影,图表锚点和提示在同一宿主内处理;不显示常驻图例、坐标轴、网格或起止时间。
概览与设置共享 NeutralTabPicker,使用静态 AppKit 按钮组;保留 tabGroup / tabButton 语义、选中值与键盘导航。绑定仅传递选择,页面和采样生命周期由上层负责。 StackedSeries 仅在渲染时构建累计上下边界:CPU 自下而上为系统 / 用户,内存为应用 / 联动 / 压缩,GPU 为总占用 / 空闲(相加为 100%,Renderer / Tiler 保留原始提示读数)。任一必要分量缺失或无效时不构造部分总量,原始历史不变。NativePanelCurve 按连续段在匹配的上下边界间闭合面积,保留真实断点;悬浮使用缓存累计边界定位,而提示读取原始分量。电池绘制电量,存储 / 网络绘制双速率曲线。
数字、曲线和进度条直接更新,曲线不创建动画、渐变或遮罩图层,不使用背景模糊。风扇是唯一持续动效:FanRotor 使用原生 Core Animation 旋转 SF Symbol,按历史 RPM 档位映射 90 / 180 / 300 / 450°/s,切档保留相位;零 / 无效 / 缺失值、系统减弱动态效果、暂停、隐藏、遮挡、睡眠或卸载时停止。没有新增帧计时器。样式与异常状态见 [UI 设计规范](ui-design-standard.md)。
设置使用 NeutralTabPicker 静态 AppKit 按钮组,保留 tabGroup / tabButton 语义、选中值与键盘导航。
进程列表使用 view-based NSTableView,只创建可见单元格并原地更新。ProcessTableProjection 负责搜索、排序及悬停 / 选择 / 搜索期间的顺序保持。选择由完整 ProcessIdentity 同步,原生委托回调之后才写回 SwiftUI。列依次为 PID、名称、CPU、内存、CPU 功率、线程数、路径;路径末列可横向滚动,支持排序及复制。ProcessIconCache 保存 30×30 像素缩略图,最多 128 项 / 1 MiB,30 秒过期、LRU 淘汰、内存压力清空,无轮询任务。 进程列表使用 view-based NSTableView,只创建可见单元格并原地更新。ProcessTableProjection 负责搜索、排序及悬停 / 选择 / 搜索期间的顺序保持。选择由完整 ProcessIdentity 同步,原生委托回调之后才写回 SwiftUI。列依次为 PID、名称、CPU、内存、CPU 功率、线程数、路径;路径末列可横向滚动,支持排序及复制。ProcessIconCache 保存 30×30 像素缩略图,最多 128 项 / 1 MiB,30 秒过期、LRU 淘汰、内存压力清空,无轮询任务。
@@ -71,7 +75,7 @@ ServiceRequest 统一一次性完成响应、错误、中断、超时和取消
system_profiler / diskutil 共用 BoundedProcess,流式保留最多 256 KiB,额外至多读 1 字节检测溢出;10 秒截止、超限或调用 Task 取消时终止并回收本轮直接子进程。取消管道唤醒 poll,无周期检查计时器,不杀其他进程。XPC 断开尚不保证取消已进入服务的报告任务。 system_profiler / diskutil 共用 BoundedProcess,流式保留最多 256 KiB,额外至多读 1 字节检测溢出;10 秒截止、超限或调用 Task 取消时终止并回收本轮直接子进程。取消管道唤醒 poll,无周期检查计时器,不杀其他进程。XPC 断开尚不保证取消已进入服务的报告任务。
PanelPublicIPRefresh 由概览挂载并控制请求及等待生命周期。路由键包含主接口候选、路径状态和全部活动地址,地址变化可能触发额外刷新。PublicIPAddressService 使用专用 ephemeral URLSession,禁用 URLCache、Cookie 和凭据存储;600 秒成功 / 30 秒失败缓存仅在内存。取消结果不缓存或发布。该约束不覆盖 macOS 容器元数据、日志、崩溃报告或旧版遗留数据。 PanelPublicIPRefresh 由网络卡片挂载并控制请求及等待生命周期。路由键包含主接口候选、路径状态和全部活动地址,地址变化可能触发额外刷新。PublicIPAddressService 使用专用 ephemeral URLSession,禁用 URLCache、Cookie 和凭据存储;600 秒成功 / 30 秒失败缓存仅在内存。取消结果不缓存或发布。该约束不覆盖 macOS 容器元数据、日志、崩溃报告或旧版遗留数据。
保持唤醒使用两个进程级 IOPM 断言阻止用户空闲息屏与系统空闲睡眠;失败、关闭或退出释放。Release 与服务配置 Hardened Runtime;本地 ad-hoc 签名不等同于 Developer ID 和 Apple 公证,详见[测试分发](free-test-distribution.md)。 保持唤醒使用两个进程级 IOPM 断言阻止用户空闲息屏与系统空闲睡眠;失败、关闭或退出释放。Release 与服务配置 Hardened Runtime;本地 ad-hoc 签名不等同于 Developer ID 和 Apple 公证,详见[测试分发](free-test-distribution.md)。
+2 -3
View File
@@ -19,12 +19,12 @@ kymo/ 使用文件系统同步组,源码自动纳入应用;新增非源码
| --- | --- | | --- | --- |
| 入口与装配 | kymo/App/kymoApp.swift | | 入口与装配 | kymo/App/kymoApp.swift |
| 状态项 / 窗口 / 布局 | MenuPanelController.swift、PanelLayout.swift、PanelWindowObserver.swift | | 状态项 / 窗口 / 布局 | MenuPanelController.swift、PanelLayout.swift、PanelWindowObserver.swift |
| 概览 | MenuPanelView.swift 及 ResourceCards / Network 扩展 | | 单页资源布局 | MenuPanelView.swift 及 ResourceCards / Network 扩展 |
| 进程 | ProcessTableView.swift、ProcessTableProjection.swift、NativeProcessTable.swift | | 进程 | ProcessTableView.swift、ProcessTableProjection.swift、NativeProcessTable.swift |
| 采样 | MetricsStore.swift、SystemSampler.swift | | 采样 | MetricsStore.swift、SystemSampler.swift |
| 设置 | AppearanceSettingsView.swift、SettingsWindowLifecycle.swift | | 设置 | AppearanceSettingsView.swift、SettingsWindowLifecycle.swift |
通常启动仅显示菜单栏图标;打开设置时临时显示 Dock 图标。面板底栏修改可见采样间隔,通用设置控制后台趋势与后台间隔。概览和进程的按页需求由 App 转为 Core 布尔开关。 通常启动仅显示菜单栏图标;打开设置时临时显示 Dock 图标。面板底栏修改可见采样间隔,通用设置控制后台趋势与后台间隔。App 同时启用 Core 的进程与慢指标需求,由实际可见性、暂停与睡眠控制执行。
颜色与图片放入 Assets.xcassets;字符串位于 Resources 的 Localizable、CPUDetails、Process、StatusItem 四个目录,支持简体中文、繁体中文、英文及跟随系统。SwiftUI 文案使用当前 locale,原生文案通过 AppLocalization 读取。新增文案同步三语、格式参数并检查真实布局: 颜色与图片放入 Assets.xcassets;字符串位于 Resources 的 Localizable、CPUDetails、Process、StatusItem 四个目录,支持简体中文、繁体中文、英文及跟随系统。SwiftUI 文案使用当前 locale,原生文案通过 AppLocalization 读取。新增文案同步三语、格式参数并检查真实布局:
@@ -47,7 +47,6 @@ Debug 或显式 KYMO_AUDIT 构建可设置 KYMO_RESOURCE_AUDIT=1 驱动三轮真
| 参数 | 行为 | | 参数 | 行为 |
| --- | --- | | --- | --- |
| KYMO_AUDIT_QUICK=1 | 缩短隐藏等待并跳过暂停阶段 | | KYMO_AUDIT_QUICK=1 | 缩短隐藏等待并跳过暂停阶段 |
| KYMO_AUDIT_PAGE=processes | 每轮打开后进入进程页 |
| KYMO_AUDIT_CAPTURE=1 | 第一轮打开 10 秒后输出本应用面板 PNG 的 JSON 事件;与 INTERACTIVE / SIZE 组合时截取对应视口 | | KYMO_AUDIT_CAPTURE=1 | 第一轮打开 10 秒后输出本应用面板 PNG 的 JSON 事件;与 INTERACTIVE / SIZE 组合时截取对应视口 |
| KYMO_AUDIT_INTERACTIVE=1 | 打开固定面板供人工 / UI 工具操作,不自动退出 | | KYMO_AUDIT_INTERACTIVE=1 | 打开固定面板供人工 / UI 工具操作,不自动退出 |
| KYMO_AUDIT_SIZE=480x500 | 交互模式限制测试视口,不覆盖自动尺寸;最小 360×360pt | | KYMO_AUDIT_SIZE=480x500 | 交互模式限制测试视口,不覆盖自动尺寸;最小 360×360pt |
+8 -6
View File
@@ -4,7 +4,7 @@
趋势图跳过无值节点,按真实时间连接前后有效点;有效 0 仍绘制,暂停 / 休眠等显式断点及真实采样空档仍断线。连接只影响曲线外观:缺失时刻悬浮读数为 `--`,原历史不补值。 趋势图跳过无值节点,按真实时间连接前后有效点;有效 0 仍绘制,暂停 / 休眠等显式断点及真实采样空档仍断线。连接只影响曲线外观:缺失时刻悬浮读数为 `--`,原历史不补值。
概览趋势贴合卡片底部,不显示常驻坐标轴、网格或图例。CPU / GPU / 内存 / 电池默认显示总量或电量主曲线,悬浮保留各原有序列读数(电池功率独立标 W);存储与网络显示读写 / 收发双曲线。静态淡色面积仅在真实连续段内闭合,不跨暂停或长空档;单点只显示真实点。悬浮不会替换上方实时主数值。 趋势覆盖整张卡片,底边为 0、顶边为 100% / 物理内存总量 / 自动速率上限,文字和控件叠放其上。CPU 自下而上堆叠系统态 / 用户态,内存堆叠应用 / 联动 / 压缩,GPU 堆叠占用 / 空闲(相加为 100%);Renderer / Tiler 可能重叠,仅保留原始历史提示。电池显示电量,功率提示独立标 W;存储与网络显示读写 / 收发双曲线。不显示常驻坐标轴、网格或图例。静态淡色面积在匹配的累计上下边界间按真实连续段闭合,不跨暂停或长空档;单点只显示真实点,必要分量缺失不构造部分总量。悬浮不会替换上方实时主数值。
## 数据来源 ## 数据来源
@@ -46,10 +46,10 @@
| CPU / GPU 温度、风扇 | 一次批量请求中只读取到期类别;各类别成功后至少 10 秒再读,失败独立退避 60–600 秒 | | CPU / GPU 温度、风扇 | 一次批量请求中只读取到期类别;各类别成功后至少 10 秒再读,失败独立退避 60–600 秒 |
| 卷列表 | 读取结束后至少 30 秒 | | 卷列表 | 读取结束后至少 30 秒 |
| SMART / 电池健康 | 成功后至少 3600 秒;失败后至少 600 秒 | | SMART / 电池健康 | 成功后至少 3600 秒;失败后至少 600 秒 |
| 公网 IP | 同一路由键成功缓存 600 秒,失败缓存 30 秒,请求超时 5 秒;概览可见时按缓存到期持续刷新,路由键变化、暂停或面板隐藏取消请求及等待,取消不缓存;有效期使用单调时间 | | 公网 IP | 同一路由键成功缓存 600 秒,失败缓存 30 秒,请求超时 5 秒;面板可见时按缓存到期持续刷新,路由键变化、暂停或面板隐藏取消请求及等待,取消不缓存;有效期使用单调时间 |
| 趋势 | 全局与每接口最多各 60 点,仅内存保存 | | 趋势 | 全局与每接口最多各 60 点,仅内存保存 |
传感器、卷与慢报告只在请求概览慢指标的可见采样轮次检查是否到期;后台趋势不启动这些慢读取。快照中的慢指标可能来自之前的缓存。暂停停止发布,不保证取消已进入系统调用的工作。 传感器、卷与慢报告只在请求慢指标的可见采样轮次检查是否到期;后台趋势不启动这些慢读取。快照中的慢指标可能来自之前的缓存。暂停停止发布,不保证取消已进入系统调用的工作。
常规周期允许系统在配置周期 10% 的容差内合并唤醒,前台最多 200ms、后台最多 1 秒;不是严格实时截止。差分的时间分母始终取实际经过的单调时间,历史保留真实采样日期,配置周期不被改写。 常规周期允许系统在配置周期 10% 的容差内合并唤醒,前台最多 200ms、后台最多 1 秒;不是严格实时截止。差分的时间分母始终取实际经过的单调时间,历史保留真实采样日期,配置周期不被改写。
@@ -65,7 +65,7 @@ AppleSMC 和 GPU 驱动字段不是稳定公开的跨机型指标接口,缺失
该口径是系统归属的 CPU 能量,参考 [Apple XNU task.c](https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/kern/task.c) 和 [recount.c](https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/kern/recount.c);开源主线不保证与目标系统二进制完全一致。它不含完整 GPU / 屏幕 / 网络 / 整机功耗,不聚合应用子进程,不等于活动监视器 Energy Impact。进程表以 W/mW 显示 CPU 平均功率,列头可切换升降序;缺失值显示 -- 并始终排末。悬浮功率单元格可查看实际统计窗口。 该口径是系统归属的 CPU 能量,参考 [Apple XNU task.c](https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/kern/task.c) 和 [recount.c](https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/kern/recount.c);开源主线不保证与目标系统二进制完全一致。它不含完整 GPU / 屏幕 / 网络 / 整机功耗,不聚合应用子进程,不等于活动监视器 Energy Impact。进程表以 W/mW 显示 CPU 平均功率,列头可切换升降序;缺失值显示 -- 并始终排末。悬浮功率单元格可查看实际统计窗口。
按全部可测候选的有效能量差分排名。权限受限、进程退出和截止会降低覆盖率;进程页显示已形成差分数 / 枚举总数,首帧等待,失败或不支持明确显示状态。零增量只有连续两帧有效时才代表 0 W。身份变化、计数回退、无效时间和超过允许窗口均不形成排名。超大进程集合在总截止下可能只覆盖部分批次,尚未验证极端规模下的公平轮转。 按全部可测候选的有效能量差分排名。权限受限、进程退出和截止会降低覆盖率;进程区域显示已形成差分数 / 枚举总数,首帧等待,失败或不支持明确显示状态。零增量只有连续两帧有效时才代表 0 W。身份变化、计数回退、无效时间和超过允许窗口均不形成排名。超大进程集合在总截止下可能只覆盖部分批次,尚未验证极端规模下的公平轮转。
进程 CPU 的 `pti_total_user` / `pti_total_system` 是 task absolute CPU 时间:累计值先做整数差分,经本机 `mach_timebase_info` 转为纳秒,再除以单调时钟间隔;单逻辑核满载为 100%,多线程可超过 100%。不按整机核心数再平均。真实 CPU 能量采用独立 nJ 计数差分。 进程 CPU 的 `pti_total_user` / `pti_total_system` 是 task absolute CPU 时间:累计值先做整数差分,经本机 `mach_timebase_info` 转为纳秒,再除以单调时钟间隔;单逻辑核满载为 100%,多线程可超过 100%。不按整机核心数再平均。真实 CPU 能量采用独立 nJ 计数差分。
@@ -77,6 +77,8 @@ AppleSMC 和 GPU 驱动字段不是稳定公开的跨机型指标接口,缺失
公网 IP 网络会话使用 ephemeral 配置并关闭 URLCache、Cookie 与凭据存储;已有 600 秒 / 30 秒缓存是进程内数据,不写磁盘。签名沙盒网络检查直接调用生产服务,核对重复 / 新路由 HTTPS 查询后持久网络目录未新增或变更文件。 公网 IP 网络会话使用 ephemeral 配置并关闭 URLCache、Cookie 与凭据存储;已有 600 秒 / 30 秒缓存是进程内数据,不写磁盘。签名沙盒网络检查直接调用生产服务,核对重复 / 新路由 HTTPS 查询后持久网络目录未新增或变更文件。
## 页面采样需求 ## 单页采样需求
概览只采集系统资源,不进行进程枚举、footprint 或进程 CPU 能量读取。进入进程页才启用这些读取并重新建立进程差分基线;功率至少需要两次有效读取,现有成功间隔下限 5 秒不变。离开即清除已发布进程 / 能量并拒绝旧代次回写。进程页保留基础资源采样以延续趋势,但不发起概览慢传感器 / 报告或公网 IP 请求;已开始的慢读取可自行结束。基础采样间隔、后台趋势开关、暂停与睡眠规则保持独立。 App 同时请求进程与慢指标,面板实际可见且未暂停 / 睡眠时执行。进程、footprint 与 CPU 能量读取保留单在途约束及独立发布;功率至少需要两次有效读取,成功间隔下限 5 秒不变。隐藏时清除进程 / 能量发布并拒绝旧代次回写;后台趋势只延续基础系统采样,不启动上述详情。基础采样间隔、后台开关、暂停与睡眠规则保持独立。
风扇图标沿用视觉速度档位:正值 <2000 / <4000 / <6000 / 其余 RPM 对应 90 / 180 / 300 / 450°/s,不模拟物理 RPM。零、缺失 / 无效、系统减弱动态效果、暂停、不可见、睡眠或卸载时停止;实际转速文本口径不变。
+14 -4
View File
@@ -44,7 +44,17 @@
## 进度 ## 进度
- [x] GPU 口径由用户确认;历史风扇档位已从源码历史核实。 - [x] GPU 口径由用户确认;历史风扇档位已从源码历史核实。
- [ ] 堆叠 / 全卡图区。 - [x] 堆叠 / 全卡图区。
- [ ] 方块竖柱 / 风扇。 - [x] 方块竖柱 / 风扇。
- [ ] 单页装配 / 需求 / 文档。 - [x] 单页装配 / 需求 / 文档。
- [ ] 构建、检查、实际验证与打包。 - [x] 构建、检查、实际验证与打包。
## 本轮验证结果(2026-11-15)
- Debug 构建通过;仅有未使用 AppIntents 的元数据提取提示。隔离 Debug 副本最初因调试 dylib 的 ad-hoc 库验证失败而退出;改用 ENABLE_DEBUG_DYLIB=NO 构建后正常运行,应用沙盒与权限配置保持不变。
- 15 项独立检查通过:StackedSeries、CPUCoreGrid、Fan、PanelLayout、DetailDemand、ResourceCard、NativeMetricDrawing、FanRotor、PanelWindow、NativeProcessTable、BackgroundTrend、PanelCurve、Memory、GPUStatistics、ProcessSection;目录 160 键的三语与参数检查通过。
- 实际隔离应用:浅色简体中文 / 深色英文均同时显示六卡与进程;六个原生绘图区实际均为整卡 176pt 高,宽度约 205⅓pt。搜索 kymo、内存排序、暂停 / 恢复均通过 AX 状态核对。发现英文两行范围说明压缩表格,已修正扩展约束;新增生产 ProcessSection 检查覆盖 176pt、三语 / 浅深色、340 / 628pt 宽下表格占满剩余高度,修正后真实截图等高。
- 繁体 360×500pt 窄屏可整体滚至底部进程表,外层滚动值到 1;表格独立滚动值变化且保留外层位置。锁屏曾暂停后续操作,用户解锁后完成上述验证。
- Release 打包到 dist/stacked-dashboard-v1;原始与解压包签名、Hardened Runtime、沙盒 / 网络权限、压缩包内容及 SHA-256 校验通过。版本 1.2 (14),arm64,macOS 27.0 起;本地 ad-hoc,未公证。
- 验证边界:原生组件检查已核对累计悬浮标记、缓存与缺失值;实际 AX 点击背景不能证明真实鼠标悬浮已投递。真实鼠标提示、主观动效手感、多屏 / 刘海屏与长期能耗仍由相应场景验收。未宣称完成全量回归或长期性能验证。
- 清理本轮隔离副本、截图、脚本、日志、容器及临时构建,保留用户预先运行的 /Applications/kymo.app。
+11 -8
View File
@@ -25,25 +25,28 @@ python3 tools/check.py --list
| 检查 | 覆盖范围 | | 检查 | 覆盖范围 |
| --- | --- | | --- | --- |
| SamplingChecks、SamplingIntervalChecks、DetailDemandChecks | 差分首帧与重置、间隔与旧偏好、暂停 / 恢复、隐藏零采样、分页需求、独立进程发布与需求代次 | | SamplingChecks、SamplingIntervalChecks、DetailDemandChecks | 差分首帧与重置、间隔与旧偏好、暂停 / 恢复、隐藏零采样、同时详情需求与需求撤回、独立进程发布与需求代次 |
| StackedSeriesChecks | CPU / 内存 / GPU 累计上下边界、分量缺失 / 无效 / 负值 / 溢出拒绝、零值、GPU 总和与共同断点 |
| BackgroundTrendChecks、PanelCurveChecks | 真实时间域、周期切换、短暂隐藏连续性、60 点有界历史、缺失与非有限点、有效 0、显式停采及真实空档 | | BackgroundTrendChecks、PanelCurveChecks | 真实时间域、周期切换、短暂隐藏连续性、60 点有界历史、缺失与非有限点、有效 0、显式停采及真实空档 |
| UnifiedPanelChecks、StageCChecks | 本机采样边界、网络汇总与接口历史、电池估时及系统报告解析 | | UnifiedPanelChecks、StageCChecks | 本机采样边界、网络汇总与接口历史、电池估时及系统报告解析 |
| MachPortChecks | CPU / 内存各 1,000 轮后 host 发送权引用无增长 | | MachPortChecks | CPU / 内存各 1,000 轮后 host 发送权引用无增长 |
| MemoryChecks、MemoryHeaderChecks | 分类守恒、二进制容量、压力 / 缓存 / Swap 标题及三语缺失 / 零值 | | MemoryChecks、MemoryHeaderChecks | 分类守恒、二进制容量、压力 / 缓存 / Swap 标题及三语缺失 / 零值 |
| GPUStatisticsChecks、CPUTemperatureChecks、FanChecks、DiskHealthChecks | 当前 GPU 利用率与历史、温度范围与解码、风扇零值 / 无效值、SMART 边界与多物理存储拒绝合并 | | GPUStatisticsChecks、CPUTemperatureChecks、FanChecks、DiskHealthChecks | 当前 GPU 利用率与历史、温度范围与解码、风扇零值 / 无效值、历史速度边界与切档相位、SMART 边界与多物理存储拒绝合并 |
| SensorScheduleChecks、BoundedProcessChecks | 各能力独立退避;真实受控子进程输出上限、超时、取消、异常退出与回收 | | SensorScheduleChecks、BoundedProcessChecks | 各能力独立退避;真实受控子进程输出上限、超时、取消、异常退出与回收 |
| ProcessEnergyChecks、ProcessEnergyReaderChecks、ProcessCPULiveChecks | UInt64 能量差分、身份 / UID / 缺失 / 回退 / 时间边界、受控本机能量增长和 Mach 时基 CPU 差分 | | ProcessEnergyChecks、ProcessEnergyReaderChecks、ProcessCPULiveChecks | UInt64 能量差分、身份 / UID / 缺失 / 回退 / 时间边界、受控本机能量增长和 Mach 时基 CPU 差分 |
| ProcessSelectionChecks、PanelLayoutChecks、CPUCoreGridChecks | 退出与 PID 复用、搜索 / 排序、648pt 三列两行 / 两列及单列窄屏预算、等高行与滚动边界、核心行数与边界 | | ProcessSelectionChecks、PanelLayoutChecks、CPUCoreGridChecks | 退出与 PID 复用、搜索 / 排序、648pt 三列资源及第三行进程 / 两列及单列窄屏预算、全行等高与滚动边界、逐核竖柱行数与部分方块填充边界 |
| PublicIPAddressChecks | 隔离 URLProtocol、600 秒成功 / 30 秒失败缓存、单调时间、持续刷新及取消,不发送真实请求 | | PublicIPAddressChecks | 隔离 URLProtocol、600 秒成功 / 30 秒失败缓存、单调时间、持续刷新及取消,不发送真实请求 |
| NetworkAddressChecks、ProcessIconCacheChecks | 沙盒下地址格式 / 速率;图标位图、尺寸、共享、过期、LRU 与严格预算 | | NetworkAddressChecks、ProcessIconCacheChecks | 沙盒下地址格式 / 速率;图标位图、尺寸、共享、过期、LRU 与严格预算 |
| AppearancePreferencesChecks、LocalizationChecks、PresentationChecks | 外观与偏好隔离、语言持久化、编译资源、窗口显式 / 系统外观切换 | | AppearancePreferencesChecks、LocalizationChecks、PresentationChecks | 外观与偏好隔离、语言持久化、编译资源、窗口显式 / 系统外观切换 |
| CodeIdentityChecks、PanelAssetChecks、KeepAwakeChecks | 签名身份拒绝边界、编译颜色及对比度、真实 IOPM 断言开关与释放 | | CodeIdentityChecks、PanelAssetChecks、KeepAwakeChecks | 签名身份拒绝边界、编译颜色及对比度、真实 IOPM 断言开关与释放 |
| NativeMetricDrawingChecks(--gui) | 实际曲线 / 静态面积像素、单点无虚构填充、隐藏序列隔离、缺失点接续与真实断点、悬浮缓存、无动画 / 渐变 / 遮罩、卸载 | | NativeMetricDrawingChecks(--gui) | 实际曲线 / 堆叠色带面积像素和累计边界定位、单点无虚构填充、隐藏序列隔离、缺失点接续与真实断点、悬浮缓存、无动画 / 渐变 / 遮罩、卸载 |
| ResourceCardChecks(--gui) | 生产卡片与曲线真实挂载,190 / 205⅓ / 400pt、浅深色及三语下的贴边图区、前景隔离、实际内存容量条像素与卸载;比较 AppKit 实际尺寸,允许分数点窗口尺寸取整 | | FanRotorChecks(--gui) | 原生旋转动画时长、无效 / 零 / 缺失、非活动 / 减弱动态效果及卸载停转 |
| ResourceCardChecks(--gui) | 生产卡片与曲线真实挂载,190 / 205⅓ / 400pt、浅深色及三语下的全宽全高图区、前景覆盖、实际内存容量条像素与卸载;比较 AppKit 实际尺寸,允许分数点窗口尺寸取整 |
| ProcessSectionChecks(--gui) | 生产进程区域固定 176pt,三语 / 浅深色及 340 / 628pt 下说明换行后表格仍占满剩余高度 |
| NativeContentHostChecks(--gui) | 数字更新、父环境继承、挂载身份、有限尺寸和卸载 | | NativeContentHostChecks(--gui) | 数字更新、父环境继承、挂载身份、有限尺寸和卸载 |
| NativeProcessTableChecks(--gui) | 原生虚拟表格、原地更新、身份选择、排序 / 列序 / 复制 / 三语列头、合成 Esc 投递 | | NativeProcessTableChecks(--gui) | 原生虚拟表格、原地更新、身份选择、排序 / 列序 / 复制 / 三语列头、合成 Esc 投递 |
| TabPickerChecks、LanguageScopeChecks、SettingsWindowChecks(--gui) | 原生页签选择与键盘、已挂载语言即时切换、设置焦点 / 最小化恢复 / Dock 生命周期 | | TabPickerChecks、LanguageScopeChecks、SettingsWindowChecks(--gui) | 原生页签选择与键盘、已挂载语言即时切换、设置焦点 / 最小化恢复 / Dock 生命周期 |
| PanelWindowChecks(--gui) | 真实 NSPanel 居中、尺寸反馈、固定、遮挡可见性、显式关闭重开默认概览和退出复位 | | PanelWindowChecks(--gui) | 真实 NSPanel 居中、尺寸反馈、固定、遮挡可见性、显式关闭重开和退出复位 |
| ReleaseServiceChecks(--services) | 临时 hardened sandbox 主程序调用本轮实际嵌入服务,核对同 UID footprint / 能量与传感器 | | ReleaseServiceChecks(--services) | 临时 hardened sandbox 主程序调用本轮实际嵌入服务,核对同 UID footprint / 能量与传感器 |
| SandboxNetworkChecks(--network) | 使用实际主应用 entitlement 访问产品 HTTPS 端点,核对持久网络目录无新增或变更文件 | | SandboxNetworkChecks(--network) | 使用实际主应用 entitlement 访问产品 HTTPS 端点,核对持久网络目录无新增或变更文件 |
@@ -54,9 +57,9 @@ LocalizationCatalogChecks.py 检查全部保留键的三语完整性与格式参
自动检查可验证模型、原生组件和窗口策略,不能代替正式应用事件。代码改动涉及相应路径时,应在本机完成: 自动检查可验证模型、原生组件和窗口策略,不能代替正式应用事件。代码改动涉及相应路径时,应在本机完成:
- 菜单栏左键打开 / 收起、右键菜单、设置入口与退出。 - 菜单栏左键打开 / 收起、右键菜单、设置入口与退出。
- 概览六张卡片、三列两行 / 窄屏两列及单列和滚动,进程分页与关闭重开默认概览。 - 六张资源卡片与等高通栏进程同页,三列资源 / 窄屏两列及单列和整体滚动,关闭重开。
- 固定 / 取消固定、外部点击、Esc 分层处理,图表悬浮、复制、缺失值。 - 固定 / 取消固定、外部点击、Esc 分层处理,图表悬浮、复制、缺失值。
- 底栏刷新间隔、后台趋势、暂停 / 恢复;概览停止进程读取,进程页停止概览慢读取,基础趋势延续。 - 底栏刷新间隔、后台趋势、暂停 / 恢复;同时详情需求,隐藏 / 暂停停止进程及慢读取,显式后台仅延续基础趋势。
- 实际签名沙盒应用的 GPU、温度、风扇、SMART、电池、网络、footprint 和 CPU 功率来源 / 单位 / 不可用状态。 - 实际签名沙盒应用的 GPU、温度、风扇、SMART、电池、网络、footprint 和 CPU 功率来源 / 单位 / 不可用状态。
- 三语即时切换、浅深色与系统跟随、重启持久化、设置焦点与 Dock 显隐。 - 三语即时切换、浅深色与系统跟随、重启持久化、设置焦点与 Dock 显隐。
+21 -17
View File
@@ -1,10 +1,10 @@
# Kymo 界面设计规范 v1.1 # Kymo 界面设计规范 v1.2
2026-11-15 根据用户确认的[背景趋势设计稿](designs/card-background-trends-v1/README.md)制定,并按后续反馈将首版卡片宽、高缩至 2/3,恢复图稿中的紧凑左对齐排布。本文为实现与验收标准,效果图中的示例数据、品牌重绘与核心格子不作为数据或素材依据。 2026-11-15 根据用户确认的[背景趋势设计稿](designs/card-background-trends-v1/README.md)制定,并按后续反馈将首版卡片宽、高缩至 2/3,恢复图稿中的紧凑左对齐排布;本轮将图表扩展到整卡、采用分量堆叠,并合并进程为第三行。本文为实现与验收标准,效果图中的示例数据、品牌重绘与核心格子不作为数据或素材依据。
## 适用范围与原则 ## 适用范围与原则
统一概览六张资源卡片,保留三列两行、页签、工具栏、公共底栏及按页采样生命周期。Settings 与进程表保持现有交互;共用外观、语言与控件语义。依赖方向继续为 Features → UI → Core。 单页面板包括三列两行资源卡片及第三行通栏进程表,顶部移除概览 / 进程页签,保留工具栏与公共底栏。Settings 与进程表保留原有交互;共用外观、语言与控件语义。依赖方向继续为 Features → UI → Core。
按确认图稿保持数值层级、左对齐信息行与曲线背景,并在用户指定尺寸内实现。所有缺失值显示 -- 或既有明确状态,不推导不存在的指标、不以装饰波形代替历史。无采样间的数值过渡、动态波纹、发光和背景模糊。 按确认图稿保持数值层级、左对齐信息行与曲线背景,并在用户指定尺寸内实现。所有缺失值显示 -- 或既有明确状态,不推导不存在的指标、不以装饰波形代替历史。无采样间的数值过渡、动态波纹、发光和背景模糊。
@@ -12,22 +12,22 @@
| 项目 | 标准 | | 项目 | 标准 |
| --- | --- | | --- | --- |
| 面板 | 最大宽 648,最大高 800;屏幕边缘至少 16;常规高 448 | | 面板 | 最大宽 648,最大高 800;屏幕边缘至少 16;常规高 630 |
| 网格 | ≥620 宽为三列;430–619 为两列;<430 为单列;不足高时仅中间区域滚动 | | 网格 | ≥620 宽为三列;430–619 为两列;<430 为单列;不足高时仅中间区域滚动 |
| 顺序 | CPU / GPU / 内存 / 电池 / 存储 / 网络,按行阅读,同行等高 | | 顺序 | CPU / GPU / 内存 / 电池 / 存储 / 网络,按行阅读;进程位于资源之后,所有资源行与进程行等高 |
| 面板内边距 / 卡片间距 | 10 / 6;常规卡片宽 205⅓ | | 面板内边距 / 卡片间距 | 10 / 6;常规卡片宽 205⅓ |
| 卡片 | 基础高 176,圆角 16,前景内边距 10 | | 卡片 | 基础高 176,圆角 16,前景内边距 10 |
| 动态高度 | CPU 按核型纵向分组,两行细条基础预算,超出每行增加 14;GPU 超过一行风扇后每行增加 14;不裁掉硬件数据 | | 动态高度 | CPU 核型横向分组,逐核竖柱一行基础预算,超出每行增加 34;GPU 超过一行风扇后每行增加 14;所有行采用最大结构预算,不裁掉硬件数据 |
| 标题 / 主值区域 | 标题行 14,主值行 34,区域间距 4 | | 标题 / 主值区域 | 标题行 14,主值行 34,区域间距 4 |
| 背景趋势 | 卡片底部 48,横向贴边,按卡片圆角裁切;前景和图层预留独立空间 | | 背景趋势 | 覆盖全卡宽高,底边 0、顶边 100% / 物理内存总量 / 速率上限;文字与控件覆盖其上,按卡片圆角裁切 |
| 逐核格子 | 8×8、圆角 2;按核型左对齐,各格独立表达该核心占用,核型短标签宽 44 | | 逐核格子 | 每核四个 6×6 方块,间距 2,柱高 30;底部先填充,最后一格部分填充保留真实比例;核型短标签在柱上方 |
| 顶栏 / 底栏 | 沿用 32(窄屏 64)/ 26;页签与操作可键盘访问 | | 顶栏 / 底栏 | 32 / 26;操作可键盘访问 |
## 字体、颜色与层级 ## 字体、颜色与层级
- 使用系统字体、现有品牌图像和 SF Symbols;数值使用等宽数字。 - 使用系统字体、现有品牌图像和 SF Symbols;数值使用等宽数字。
- 卡片标题 11 semibold,主数值 28 semibold,单位 12 medium;双指标网络主数值 16、单位 9,避免挤压。必要时主值最多缩至 75%,全文保留为辅助说明。 - 卡片标题 11 semibold,主数值 28 semibold,单位 12 medium;双指标网络主数值 16、单位 9,避免挤压。必要时主值最多缩至 75%,全文保留为辅助说明。
- 辅助指标 8–9;强调值 medium;悬浮提示 9。辅助内容使用紧凑左对齐信息行,不能被背景曲线穿过。 - 辅助指标 8–9;强调值 medium;悬浮提示 9。辅助内容使用紧凑左对齐信息行,低透明背景曲线可穿过文字区域,须保持可读。
- 主数值使用 primary,提高浅深色对比度;网络仅方向箭头着色。CPU 青绿(MetricCPU)、GPU 玫红(MetricGPU)、内存蓝(MemoryApplication)、电池绿(MetricBattery)、存储琥珀(MetricDisk)、下载蓝(MetricMemory)、上传琥珀(SeriesUpload)。所有颜色来自 Assets。 - 主数值使用 primary,提高浅深色对比度;网络仅方向箭头着色。CPU 青绿(MetricCPU)、GPU 玫红(MetricGPU)、内存蓝(MemoryApplication)、电池绿(MetricBattery)、存储琥珀(MetricDisk)、下载蓝(MetricMemory)、上传琥珀(SeriesUpload)。所有颜色来自 Assets。
- 温度在标题右侧;CPU ≥90°C 使用红色和既有高温说明。内存压力沿用正常 / 警告 / 严重颜色和文字,不能仅靠颜色传达状态。 - 温度在标题右侧;CPU ≥90°C 使用红色和既有高温说明。内存压力沿用正常 / 警告 / 严重颜色和文字,不能仅靠颜色传达状态。
- 卡片采用 PanelCard、面板采用 PanelBackground 的浅深色资源。边框为 primary 浅色 2.5% / 深色 6%;静态轻阴影半径 4、纵偏移 1,不给文字或曲线单独加阴影。 - 卡片采用 PanelCard、面板采用 PanelBackground 的浅深色资源。边框为 primary 浅色 2.5% / 深色 6%;静态轻阴影半径 4、纵偏移 1,不给文字或曲线单独加阴影。
@@ -35,19 +35,19 @@
## 曲线与悬浮 ## 曲线与悬浮
- 移除常驻图例、坐标轴、网格、起止时间与独立图框。背景曲线线宽 1.4,填充为同色静态实色透明度:浅色 12%、深色 16%;不使用渐变层、遮罩层或动画层。 - 移除常驻图例、坐标轴、网格、起止时间与独立图框。背景曲线线宽 1.4,填充为同色静态实色透明度:浅色 12%、深色 16%;不使用渐变层、遮罩层或动画层。
- CPU / GPU / 内存显示总量主曲线,保留其全部历史序列供悬浮查询。电池背景显示电量,功率在悬浮中单独注明 W,不能与电量共用未解释的尺度。存储与网络显示双曲线、共用速率尺度。 - CPU 自下而上堆叠系统态 / 用户态;内存堆叠应用 / 联动 / 压缩,顶边为物理总量、空余为可用空间;GPU 堆叠占用 / 空闲至 100%,Renderer / Tiler 仅保留原始提示读数,不叠加为总占用。电池背景显示电量,功率在悬浮中单独注明 W,不能与电量共用未解释的尺度。存储与网络显示双曲线、共用速率尺度。
- 百分比固定 0–100%;内存固定当前物理总量;速率保留既有自动范围及延迟缩小策略,不为视觉任意改变振幅。 - 百分比固定 0–100%;内存固定当前物理总量;速率保留既有自动范围及延迟缩小策略,不为视觉任意改变振幅。
- 时间使用真实采样日期;有效 0 保留,nil / 非有限数值不补值。沿用既有缺失节点接续与显式断点 / 长空档策略。面积按每个连续段分别闭合,不能填过暂停空档。 - 时间使用真实采样日期;有效 0 保留,nil / 非有限数值不补值。沿用既有缺失节点接续与显式断点 / 长空档策略。堆叠缺少任一必要分量时不构造部分总量;面积在匹配上下边界之间按每个连续段分别闭合,不能填过暂停空档。
- 单点历史仅显示真实点,不绘制虚构面积。全缺失无曲线和填充。 - 单点历史仅显示真实点,不绘制虚构面积。全缺失无曲线和填充。
- 悬浮仅响应背景趋势区域:按最近采样时间显示时间、各序列名称与数值;仅为有效可见序列绘制定位点,缺失显示 --。主数值保持最新值。 - 悬浮响应全卡背景中未被交互控件占用的区域:按最近采样时间显示时间、各序列名称与数值;仅为有效可见序列绘制定位点,堆叠标记位于累计边界,缺失显示 --。主数值保持最新值。
- 定位线和提示仅随指针更新,不重建曲线 / 面积几何。提示保持在卡片内,不遮挡标题、主值及主要按钮,不拦截鼠标事件;离开绘图区清除。 - 定位线和提示仅随指针更新,不重建曲线 / 面积几何。提示保持在卡片内,不遮挡标题、主值及主要按钮,不拦截鼠标事件;离开绘图区清除。
## 各卡片信息契约 ## 各卡片信息契约
| 卡片 | 必须保留的前景与入口 | | 卡片 | 必须保留的前景与入口 |
| --- | --- | | --- | --- |
| CPU | 总占用、温度 / 高温状态、左对齐用户 / 系统;按核型纵向分行的独立逐核细条,数值通过悬浮和辅助功能提供;禁止把核数画成亮灯计数 | | CPU | 总占用、温度 / 高温状态、左对齐用户 / 系统;核型横向分组、每核独立方块竖柱,数值通过悬浮和辅助功能提供;禁止把核数画成亮灯计数 |
| GPU | 总占用、温度;主值下一行核心数与 Renderer / Tiler,再显示风扇转速或等待状态 | | GPU | 总占用、温度;主值下一行核心数,再显示旋转风扇图标与转速或等待状态;Renderer / Tiler 保留在历史提示 |
| 内存 | 已用 / 总量 GiB、压力标签;应用 / 联动 / 压缩单行、容量条、可用量;占用率、缓存和 Swap 保留在压力提示中 | | 内存 | 已用 / 总量 GiB、压力标签;应用 / 联动 / 压缩单行、容量条、可用量;占用率、缓存和 Swap 保留在压力提示中 |
| 电池 | 电量;电源在标题右侧;功率、健康 / 循环、估时依次左对齐;保留无电池、失败和不适用状态 | | 电池 | 电量;电源在标题右侧;功率、健康 / 循环、估时依次左对齐;保留无电池、失败和不适用状态 |
| 存储 | 已用 / 总量 GB;本地卷入口在标题右侧;可用、读写、寿命 / 通电依次左对齐;保留卷弹出层与口径说明 | | 存储 | 已用 / 总量 GB;本地卷入口在标题右侧;可用、读写、寿命 / 通电依次左对齐;保留卷弹出层与口径说明 |
@@ -55,8 +55,12 @@
三语必须复用或补齐资源键;单位延续现有口径。长 IPv6、设备名和大数值可截断,但通过悬浮或复制取得完整内容。固定、暂停、保持唤醒与设置流程维持原语义。 三语必须复用或补齐资源键;单位延续现有口径。长 IPv6、设备名和大数值可截断,但通过悬浮或复制取得完整内容。固定、暂停、保持唤醒与设置流程维持原语义。
## 风扇动效
仅风扇 SF Symbol 使用原生循环旋转:正值 <2000 RPM 为 90°/s,<4000 为 180°/s,<6000 为 300°/s,更高为 450°/s;这是沿用的视觉映射,不是物理 RPM。切档保持角度连续。零 / 缺失 / 无效值、暂停、隐藏 / 遮挡、睡眠、卸载及系统减弱动态效果时停转;数值、图表和进度条不增加动画。
## 性能与验收 ## 性能与验收
沿用独立 NativeContentHost 与 NativePanelCurve;六张卡片共用样式与几何规范,不增加依赖、背景轮询或历史容量。颜色、外观、数据或尺寸变化才更新相应图层;隐藏、分页卸载仍释放图表和提示。 沿用独立 NativeContentHost 与 NativePanelCurve;六张卡片共用样式与几何规范,不增加依赖、背景轮询或历史容量。颜色、外观、数据或尺寸变化才更新相应图层;隐藏卸载仍释放图表和提示。
必须验证构建、布局预算、实际曲线 / 面积像素、显式空档无填充、缺失悬浮、悬浮几何缓存、浅深色、三语、大数值与窄屏;实际应用检查分页、接口、卷详情、复制、暂停 / 恢复及关闭重开。真实多屏与长期能耗需对应环境,不用单次快照代替。 必须验证构建、布局预算、实际曲线 / 面积像素、显式空档无填充、缺失悬浮、悬浮几何缓存、浅深色、三语、大数值与窄屏;实际应用检查同页资源 / 进程、接口、卷详情、复制、暂停 / 恢复及关闭重开。真实多屏与长期能耗需对应环境,不用单次快照代替。
+1 -3
View File
@@ -46,10 +46,8 @@ import AppKit
scenes = settings scenes = settings
openSettingsAction = { settings.environment.openSettings() } openSettingsAction = { settings.environment.openSettings() }
configureMainMenu() configureMainMenu()
metrics.setDetailDemand(processes: true, slowMetrics: true)
menuBar = MenuPanelController(visibility: { [metrics] in metrics.setPanelVisible($0) }, menuBar = MenuPanelController(visibility: { [metrics] in metrics.setPanelVisible($0) },
pageChanged: { [metrics] page in
metrics.setDetailDemand(processes: page == .processes, slowMetrics: page == .overview)
},
menuTitle: { [language] key in menuTitle: { [language] key in
AppLocalization.string("status." + key, locale: language.locale, table: "StatusItem") AppLocalization.string("status." + key, locale: language.locale, table: "StatusItem")
}, openSettings: { [weak self] in self?.settingsCommand() }) { [self] panel in }, openSettings: { [weak self] in self?.settingsCommand() }) { [self] panel in
+18 -18
View File
@@ -1,6 +1,6 @@
import SwiftUI import SwiftUI
/// One row per core kind; every equal-width meter represents one real core. /// Core-kind columns contain one vertical segmented meter per real core.
struct CPUCoreGrid: View { struct CPUCoreGrid: View {
let values: [Double] let values: [Double]
let kinds: [Int: CPUCoreTopology.Kind] let kinds: [Int: CPUCoreTopology.Kind]
@@ -40,34 +40,34 @@ struct CPUCoreGrid: View {
return order.map { kind in (0..<max(0, count)).filter { kinds[$0] == kind } }.filter { !$0.isEmpty } return order.map { kind in (0..<max(0, count)).filter { kinds[$0] == kind } }.filter { !$0.isEmpty }
} }
static let labelWidth: CGFloat = 44
static func groupWidths(groups: [[Int]], width: CGFloat) -> [CGFloat] { static func groupWidths(groups: [[Int]], width: CGFloat) -> [CGFloat] {
let available = width.isFinite ? max(0, width - labelWidth - 6) : 0 guard !groups.isEmpty else { return [] }
return Array(repeating: available, count: groups.count) let available = width.isFinite ? max(0, width - CGFloat(groups.count - 1) * 8) : 0
let minimum = min(44, available / CGFloat(groups.count))
let remaining = max(0, available - minimum * CGFloat(groups.count))
let total = max(1, groups.reduce(0) { $0 + $1.count })
return groups.map { minimum + remaining * CGFloat($0.count) / CGFloat(total) }
} }
var body: some View { var body: some View {
let groups = Self.groups(count: values.count, kinds: kinds) let groups = Self.groups(count: values.count, kinds: kinds)
GeometryReader { geometry in GeometryReader { geometry in
let widths = Self.groupWidths(groups: groups, width: geometry.size.width) let widths = Self.groupWidths(groups: groups, width: geometry.size.width)
VStack(alignment: .leading, spacing: 4) { HStack(alignment: .top, spacing: 8) {
ForEach(groups.indices, id: \.self) { group in ForEach(groups.indices, id: \.self) { group in
HStack(alignment: .top, spacing: 6) { VStack(alignment: .leading, spacing: 4) {
HStack(spacing: 2) { HStack(spacing: 2) {
Circle().fill(color(kinds[groups[group][0]])).frame(width: 3, height: 3) Circle().fill(color(kinds[groups[group][0]])).frame(width: 3, height: 3)
if let kind = kinds[groups[group][0]] { label(kind, compact: true) } if let kind = kinds[groups[group][0]] { label(kind, compact: true) }
else { Text("cpu.core") } else { Text("cpu.core") }
Text(verbatim: "\(groups[group].count)").foregroundStyle(.secondary) Text(verbatim: "\(groups[group].count)").foregroundStyle(.secondary)
} }
.font(.system(size: 8, weight: .medium)) .font(.system(size: 8, weight: .medium)).lineLimit(1).minimumScaleFactor(0.65)
.lineLimit(1).minimumScaleFactor(0.65) .frame(height: 10)
.frame(width: Self.labelWidth, height: CPUCoreGridLayout.rowHeight, alignment: .leading)
CPUCoreGridLayout { CPUCoreGridLayout {
ForEach(groups[group], id: \.self) { index in core(index: index) } ForEach(groups[group], id: \.self) { index in core(index: index) }
} }
.frame(width: widths[group]) }.frame(width: widths[group], alignment: .topLeading)
}
} }
} }
} }
@@ -78,15 +78,15 @@ struct CPUCoreGrid: View {
private func gridHeight(groups: [[Int]]) -> CGFloat { private func gridHeight(groups: [[Int]]) -> CGFloat {
let widths = Self.groupWidths(groups: groups, width: availableWidth) let widths = Self.groupWidths(groups: groups, width: availableWidth)
let rows = zip(groups, widths).map { CPUCoreGridLayout.rowCounts(count: $0.0.count, width: $0.1).count }.reduce(0, +) let rows = zip(groups, widths).map { CPUCoreGridLayout.rowCounts(count: $0.0.count, width: $0.1).count }.max() ?? 0
return CGFloat(rows) * CPUCoreGridLayout.rowHeight + CGFloat(max(0, rows - 1)) * CPUCoreGridLayout.rowSpacing return 14 + CGFloat(rows) * CPUCoreGridLayout.rowHeight + CGFloat(max(0, rows - 1)) * CPUCoreGridLayout.rowSpacing
} }
private func core(index: Int) -> some View { private func core(index: Int) -> some View {
let kind = kinds[index] let kind = kinds[index]
let measured = values[index].isFinite ? values[index] : nil let measured = values[index].isFinite ? values[index] : nil
return MetricProgressBar(value: measured ?? 0, color: color(kind), cornerRadius: 2) return SegmentedCoreBar(value: measured, color: color(kind))
.frame(height: 8) .frame(height: 30)
.frame(maxWidth: .infinity, maxHeight: .infinity) .frame(maxWidth: .infinity, maxHeight: .infinity)
.help(Text("\(kind.map { label($0) } ?? Text("cpu.core")) · \(index + 1): \(MetricFormat.percent(measured))")) .help(Text("\(kind.map { label($0) } ?? Text("cpu.core")) · \(index + 1): \(MetricFormat.percent(measured))"))
.accessibilityElement(children: .ignore) .accessibilityElement(children: .ignore)
@@ -98,8 +98,8 @@ struct CPUCoreGrid: View {
struct CPUCoreGridLayout: Layout { struct CPUCoreGridLayout: Layout {
static let columnSpacing: CGFloat = 3 static let columnSpacing: CGFloat = 3
static let rowSpacing: CGFloat = 4 static let rowSpacing: CGFloat = 4
static let rowHeight: CGFloat = 10 static let rowHeight: CGFloat = 30
static let minimumCellWidth: CGFloat = 8 static let minimumCellWidth: CGFloat = 6
static func rowCounts(count: Int, width: CGFloat) -> [Int] { static func rowCounts(count: Int, width: CGFloat) -> [Int] {
guard count > 0 else { return [] } guard count > 0 else { return [] }
@@ -2,14 +2,10 @@ import AppKit
import SwiftUI import SwiftUI
import Observation import Observation
enum PanelPage: Hashable { case overview, processes }
@MainActor @Observable final class PanelPresentation { @MainActor @Observable final class PanelPresentation {
fileprivate(set) var isOpen = false fileprivate(set) var isOpen = false
var isPinned = false { didSet { onPinChange?(isPinned) } } var isPinned = false { didSet { onPinChange?(isPinned) } }
var page: PanelPage = .overview { didSet { if oldValue != page { onPageChange?(page) } } }
@ObservationIgnored var onPinChange: ((Bool) -> Void)? @ObservationIgnored var onPinChange: ((Bool) -> Void)?
@ObservationIgnored var onPageChange: ((PanelPage) -> Void)?
} }
/// Owns only status-item/window behavior. Sampling and settings are injected by App. /// Owns only status-item/window behavior. Sampling and settings are injected by App.
@@ -33,7 +29,6 @@ enum PanelPage: Hashable { case overview, processes }
private var preferredContentHeight = PanelLayout.defaultHeight private var preferredContentHeight = PanelLayout.defaultHeight
init<Content: View>(installStatusItem: Bool = true, visibility: @escaping (Bool) -> Void, init<Content: View>(installStatusItem: Bool = true, visibility: @escaping (Bool) -> Void,
pageChanged: @escaping (PanelPage) -> Void = { _ in },
menuTitle: @escaping (String) -> String = { $0 }, menuTitle: @escaping (String) -> String = { $0 },
openSettings: @escaping () -> Void = {}, openSettings: @escaping () -> Void = {},
@ViewBuilder content: @escaping (PanelPresentation) -> Content) { @ViewBuilder content: @escaping (PanelPresentation) -> Content) {
@@ -57,7 +52,6 @@ enum PanelPage: Hashable { case overview, processes }
panel.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary] panel.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
panel.dismiss = { [weak self] in self?.hide() } panel.dismiss = { [weak self] in self?.hide() }
presentation.onPinChange = { [weak self] pinned in self?.panel.level = pinned ? .floating : .normal } presentation.onPinChange = { [weak self] pinned in self?.panel.level = pinned ? .floating : .normal }
presentation.onPageChange = pageChanged
if installStatusItem { if installStatusItem {
let item = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength) let item = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
item.button?.image = NSImage(named: "BrandMark") item.button?.image = NSImage(named: "BrandMark")
@@ -123,7 +117,6 @@ enum PanelPage: Hashable { case overview, processes }
func show() { func show() {
guard !panel.isVisible else { panel.makeKeyAndOrderFront(nil); return } guard !panel.isVisible else { panel.makeKeyAndOrderFront(nil); return }
place() place()
presentation.page = .overview
presentation.isOpen = true presentation.isOpen = true
panel.contentView = content(presentation) panel.contentView = content(presentation)
panel.level = presentation.isPinned ? .floating : .normal panel.level = presentation.isPinned ? .floating : .normal
@@ -39,7 +39,7 @@ extension MenuPanelView {
second: samples.map(\.cpuUser), third: samples.map(\.cpuSystem), second: samples.map(\.cpuUser), third: samples.map(\.cpuSystem),
color: Color("MetricCPU"), secondColor: Color("SeriesUser"), thirdColor: Color("SeriesSystem"), color: Color("MetricCPU"), secondColor: Color("SeriesUser"), thirdColor: Color("SeriesSystem"),
firstLabel: "gpu.totalUtilization", secondLabel: "cpu.user", thirdLabel: "cpu.system", expectedInterval: chartInterval, firstLabel: "gpu.totalUtilization", secondLabel: "cpu.user", thirdLabel: "cpu.system", expectedInterval: chartInterval,
boundaryDates: chartBoundaries, intervals: chartIntervals) boundaryDates: chartBoundaries, intervals: chartIntervals, stackOrder: [2, 1])
} }
) { ) {
HStack(spacing: 5) { HStack(spacing: 5) {
@@ -64,10 +64,12 @@ extension MenuPanelView {
chart: { chart: {
PanelTrendChart( PanelTrendChart(
dates: samples.map(\.date), first: samples.map(\.gpu), dates: samples.map(\.date), first: samples.map(\.gpu),
second: samples.map(\.gpuRenderer), third: samples.map(\.gpuTiler), second: samples.map { $0.gpu.map { max(0, 1 - $0) } },
color: Color("MetricGPU"), secondColor: Color("MetricCPU"), thirdColor: Color("SeriesSystem"), third: samples.map(\.gpuRenderer), fourth: samples.map(\.gpuTiler),
firstLabel: "gpu.totalUtilization", secondLabel: "gpu.renderer", thirdLabel: "gpu.tiler", color: Color("MetricGPU"), secondColor: Color("MemoryAvailable"),
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals) thirdColor: Color("MetricCPU"), fourthColor: Color("SeriesSystem"),
firstLabel: "gpu.totalUtilization", secondLabel: "gpu.idle", thirdLabel: "gpu.renderer", fourthLabel: "gpu.tiler",
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals, stackOrder: [0, 1])
} }
) { ) {
HStack(spacing: 5) { HStack(spacing: 5) {
@@ -75,8 +77,6 @@ extension MenuPanelView {
Text(verbatim: String(format: AppLocalization.string("gpu.coreCountFormat", locale: locale), count)) Text(verbatim: String(format: AppLocalization.string("gpu.coreCountFormat", locale: locale), count))
.foregroundStyle(.secondary) .foregroundStyle(.secondary)
} }
inlineMetric("gpu.renderer", MetricFormat.percent(snapshot.gpu?.renderer))
inlineMetric("gpu.tiler", MetricFormat.percent(snapshot.gpu?.tiler))
}.font(.system(size: 9)).lineLimit(1).minimumScaleFactor(0.75).frame(height: 12) }.font(.system(size: 9)).lineLimit(1).minimumScaleFactor(0.75).frame(height: 12)
let fans = displayedFans let fans = displayedFans
if !fans.isEmpty { if !fans.isEmpty {
@@ -85,7 +85,8 @@ extension MenuPanelView {
FanSpeedIndicator( FanSpeedIndicator(
title: fans.count == 2 title: fans.count == 2
? (fan.id == 0 ? Text("gpu.fanLeft") : Text("gpu.fanRight")) ? (fan.id == 0 ? Text("gpu.fanLeft") : Text("gpu.fanRight"))
: Text("gpu.fanNumber \(fan.id + 1)"), rpm: fan.rpm) : Text("gpu.fanNumber \(fan.id + 1)"), rpm: fan.rpm,
isActive: metrics.isPanelVisible && !metrics.isPaused && !metrics.isSystemSleeping && !metrics.isDisplaySleeping)
.frame(height: 12) .frame(height: 12)
} }
} }
@@ -114,7 +115,7 @@ extension MenuPanelView {
thirdColor: Color("MemoryWired"), fourthColor: Color("MemoryCompressed"), fixedScale: Double(snapshot.memory?.total ?? 1), thirdColor: Color("MemoryWired"), fourthColor: Color("MemoryCompressed"), fixedScale: Double(snapshot.memory?.total ?? 1),
firstValueFormat: .memory, firstLabel: "gpu.totalUtilization", firstValueFormat: .memory, firstLabel: "gpu.totalUtilization",
secondLabel: "memory.app", thirdLabel: "memory.wired", fourthLabel: "memory.compressed", secondLabel: "memory.app", thirdLabel: "memory.wired", fourthLabel: "memory.compressed",
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals) expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals, stackOrder: [1, 2, 3])
} }
) { ) {
if let memory = snapshot.memory { if let memory = snapshot.memory {
+15 -24
View File
@@ -35,7 +35,7 @@ struct MenuPanelView: View {
let coreCount = max(CPUCoreTopology.cores.count, ProcessInfo.processInfo.processorCount, snapshot.cpu?.cores.count ?? 0) let coreCount = max(CPUCoreTopology.cores.count, ProcessInfo.processInfo.processorCount, snapshot.cpu?.cores.count ?? 0)
let groups = CPUCoreGrid.groups(count: coreCount, kinds: CPUCoreTopology.cores) let groups = CPUCoreGrid.groups(count: coreCount, kinds: CPUCoreTopology.cores)
let widths = CPUCoreGrid.groupWidths(groups: groups, width: cardContentWidth) let widths = CPUCoreGrid.groupWidths(groups: groups, width: cardContentWidth)
let coreRows = zip(groups, widths).map { CPUCoreGridLayout.rowCounts(count: $0.0.count, width: $0.1).count }.reduce(0, +) let coreRows = zip(groups, widths).map { CPUCoreGridLayout.rowCounts(count: $0.0.count, width: $0.1).count }.max() ?? 0
let fanCount = reservedFanCount > 0 ? max(reservedFanCount, snapshot.fans?.count ?? 0) : snapshot.fans?.count let fanCount = reservedFanCount > 0 ? max(reservedFanCount, snapshot.fans?.count ?? 0) : snapshot.fans?.count
return PanelLayout.cardHeights(coreRows: coreRows, fanCount: fanCount) return PanelLayout.cardHeights(coreRows: coreRows, fanCount: fanCount)
} }
@@ -51,17 +51,11 @@ struct MenuPanelView: View {
var body: some View { var body: some View {
VStack(spacing: PanelStyle.gap) { VStack(spacing: PanelStyle.gap) {
header header
if presentation.page == .overview { if PanelLayout.needsDashboardScroll(size: panelSize, heights: cardHeights) {
if PanelLayout.needsResourceScroll(size: panelSize, heights: cardHeights) { ScrollView { dashboard }
ScrollView { resourceGrid }
.frame(maxWidth: .infinity, maxHeight: .infinity) .frame(maxWidth: .infinity, maxHeight: .infinity)
} else { } else {
resourceGrid dashboard.frame(maxHeight: .infinity, alignment: .top)
.frame(maxHeight: .infinity, alignment: .top)
}
} else if presentation.isOpen {
PanelProcessSection(metrics: metrics, state: processState)
.frame(maxWidth: .infinity, maxHeight: .infinity)
} }
footer footer
} }
@@ -91,6 +85,17 @@ struct MenuPanelView: View {
.modifier(AppearanceStyle(preferences: preferences)) .modifier(AppearanceStyle(preferences: preferences))
} }
private var dashboard: some View {
VStack(spacing: PanelStyle.gap) {
resourceGrid
if presentation.isOpen {
PanelProcessSection(metrics: metrics, state: processState)
.frame(maxWidth: .infinity)
.frame(height: PanelLayout.processHeight(heights: cardHeights))
}
}
}
private var resourceGrid: some View { private var resourceGrid: some View {
let rows = PanelLayout.cardRows(columns: columns) let rows = PanelLayout.cardRows(columns: columns)
let heights = PanelLayout.rowHeights(columns: columns, heights: cardHeights) let heights = PanelLayout.rowHeights(columns: columns, heights: cardHeights)
@@ -130,26 +135,12 @@ struct MenuPanelView: View {
} }
} }
private var pagePicker: some View {
NeutralTabPicker(title: "panel.page", selection: Binding(get: { presentation.page }, set: { presentation.page = $0 }),
options: [(.overview, "panel.overview"), (.processes, "panel.processes")])
.frame(width: 164)
.accessibilityIdentifier("panel.tabs")
}
private var header: some View { private var header: some View {
VStack(spacing: 4) {
HStack(spacing: 8) { HStack(spacing: 8) {
brand brand
Spacer(minLength: 8) Spacer(minLength: 8)
controls controls
} }
.frame(height: 32)
.overlay {
if panelSize.width >= 560 { pagePicker }
}
if panelSize.width < 560 { pagePicker.frame(maxWidth: .infinity).frame(height: 28) }
}
.frame(height: PanelLayout.headerHeight(width: panelSize.width)) .frame(height: PanelLayout.headerHeight(width: panelSize.width))
.padding(.horizontal, 4) .padding(.horizontal, 4)
} }
+15 -9
View File
@@ -9,7 +9,7 @@ nonisolated enum PanelLayout {
static let footerHeight: CGFloat = 26 static let footerHeight: CGFloat = 26
static let maximumWidth: CGFloat = ResourceCardMetrics.preferredWidth * 3 + 32 static let maximumWidth: CGFloat = ResourceCardMetrics.preferredWidth * 3 + 32
static let maximumHeight: CGFloat = 800 static let maximumHeight: CGFloat = 800
static func headerHeight(width: CGFloat) -> CGFloat { width >= 560 ? 32 : 64 } static func headerHeight(width: CGFloat) -> CGFloat { 32 }
static func columns(width: CGFloat) -> Int { width >= 620 ? 3 : width >= 430 ? 2 : 1 } static func columns(width: CGFloat) -> Int { width >= 620 ? 3 : width >= 430 ? 2 : 1 }
static func cardWidth(size: CGSize) -> CGFloat { static func cardWidth(size: CGSize) -> CGFloat {
let count = columns(width: size.width) let count = columns(width: size.width)
@@ -25,19 +25,21 @@ nonisolated enum PanelLayout {
} }
} }
/// Foreground details and the edge-to-edge background trend have separate budgets. /// Structural foreground height determines the full-height background chart.
static func cardHeights(coreRows: Int, fanCount: Int?) -> [PanelCard: CGFloat] { static func cardHeights(coreRows: Int, fanCount: Int?) -> [PanelCard: CGFloat] {
let base = ResourceCardMetrics.minimumHeight let base = ResourceCardMetrics.minimumHeight
let fanRows = fanCount.map { (max(0, $0) + 1) / 2 } ?? 1 let fanRows = fanCount.map { (max(0, $0) + 1) / 2 } ?? 1
return [.cpu: base + CGFloat(max(0, coreRows - 2)) * 14, return [.cpu: base + CGFloat(max(0, coreRows - 1)) * 34,
.gpu: base + CGFloat(max(0, fanRows - 1)) * 14, .gpu: base + CGFloat(max(0, fanRows - 1)) * 14,
.memory: base, .battery: base, .storage: base, .network: base] .memory: base, .battery: base, .storage: base, .network: base]
} }
static func rowHeights(columns: Int, heights: [PanelCard: CGFloat]) -> [CGFloat] { static func rowHeights(columns: Int, heights: [PanelCard: CGFloat]) -> [CGFloat] {
cardRows(columns: columns).map { cards in Array(repeating: processHeight(heights: heights), count: cardRows(columns: columns).count)
cards.map { heights[$0] ?? 0 }.max() ?? 0
} }
static func processHeight(heights: [PanelCard: CGFloat]) -> CGFloat {
heights.values.max() ?? ResourceCardMetrics.minimumHeight
} }
static func resourceHeight(columns: Int, heights: [PanelCard: CGFloat]) -> CGFloat { static func resourceHeight(columns: Int, heights: [PanelCard: CGFloat]) -> CGFloat {
@@ -45,17 +47,21 @@ nonisolated enum PanelLayout {
return rows.reduce(0, +) + CGFloat(max(0, rows.count - 1)) * 6 return rows.reduce(0, +) + CGFloat(max(0, rows.count - 1)) * 6
} }
static func dashboardHeight(columns: Int, heights: [PanelCard: CGFloat]) -> CGFloat {
resourceHeight(columns: columns, heights: heights) + 6 + processHeight(heights: heights)
}
static func preferredHeight(width: CGFloat, heights: [PanelCard: CGFloat]) -> CGFloat { static func preferredHeight(width: CGFloat, heights: [PanelCard: CGFloat]) -> CGFloat {
min(maximumHeight, resourceHeight(columns: columns(width: width), heights: heights) min(maximumHeight, dashboardHeight(columns: columns(width: width), heights: heights)
+ 20 + headerHeight(width: width) + footerHeight + 12) + 20 + headerHeight(width: width) + footerHeight + 12)
} }
static var defaultHeight: CGFloat { static var defaultHeight: CGFloat {
preferredHeight(width: maximumWidth, heights: cardHeights(coreRows: 2, fanCount: nil)) preferredHeight(width: maximumWidth, heights: cardHeights(coreRows: 1, fanCount: nil))
} }
static func needsResourceScroll(size: CGSize, heights: [PanelCard: CGFloat]) -> Bool { static func needsDashboardScroll(size: CGSize, heights: [PanelCard: CGFloat]) -> Bool {
resourceHeight(columns: columns(width: size.width), heights: heights) dashboardHeight(columns: columns(width: size.width), heights: heights)
> size.height - 20 - headerHeight(width: size.width) - footerHeight - 12 > size.height - 20 - headerHeight(width: size.width) - footerHeight - 12
} }
@@ -58,7 +58,6 @@ import AppKit
mark("hidden10") mark("hidden10")
for cycle in 1...3 { for cycle in 1...3 {
controller.show() controller.show()
if ProcessInfo.processInfo.environment["KYMO_AUDIT_PAGE"] == "processes" { controller.presentation.page = .processes }
mark("open\(cycle).0") mark("open\(cycle).0")
await wait(1); mark("open\(cycle).1") await wait(1); mark("open\(cycle).1")
await wait(9); mark("open\(cycle).10") await wait(9); mark("open\(cycle).10")
@@ -39,11 +39,13 @@ struct ProcessTableView: View {
if snapshot?.failed == true { Text("panel.processFailed") } if snapshot?.failed == true { Text("panel.processFailed") }
else if snapshot == nil { Text("metric.waiting").foregroundStyle(.secondary) } else if snapshot == nil { Text("metric.waiting").foregroundStyle(.secondary) }
NativeProcessTable(rows: rows, selection: $state.selected, sorting: $state.sortOrder, locale: locale, onExit: handleExit) NativeProcessTable(rows: rows, selection: $state.selected, sorting: $state.sortOrder, locale: locale, onExit: handleExit)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.overlay { if snapshot != nil && rows.isEmpty && snapshot?.failed != true { Text("panel.noResults").foregroundStyle(.secondary).allowsHitTesting(false) } } .overlay { if snapshot != nil && rows.isEmpty && snapshot?.failed != true { Text("panel.noResults").foregroundStyle(.secondary).allowsHitTesting(false) } }
if exitedSelection != nil, let departed = state.departed { if exitedSelection != nil, let departed = state.departed {
HStack { Text(verbatim: departed.name); Text("panel.exited"); Button("panel.dismiss") { state.selected = nil; state.departed = nil } } HStack { Text(verbatim: departed.name); Text("panel.exited"); Button("panel.dismiss") { state.selected = nil; state.departed = nil } }
} }
} }
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
.font(.system(size: 12)).padding(10) .font(.system(size: 12)).padding(10)
.modifier(CardSurface()) .modifier(CardSurface())
.onAppear { rebuild(retainOrder: false) } .onAppear { rebuild(retainOrder: false) }
+22
View File
@@ -1,6 +1,28 @@
{ {
"sourceLanguage" : "en", "sourceLanguage" : "en",
"strings" : { "strings" : {
"gpu.idle" : {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Idle"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "空闲"
}
},
"zh-Hant": {
"stringUnit": {
"state": "translated",
"value": "閒置"
}
}
}
},
"disk.lifeShort" : { "disk.lifeShort" : {
"localizations": { "localizations": {
"en": { "en": {
+22 -11
View File
@@ -10,6 +10,7 @@ struct NativePanelCurve: NSViewRepresentable {
var hoveredIndex: Int? = nil var hoveredIndex: Int? = nil
var visibleSeriesCount: Int? = nil var visibleSeriesCount: Int? = nil
var filledSeriesCount = 1 var filledSeriesCount = 1
var stacked = false
func sizeThatFits(_ proposal: ProposedViewSize, nsView: PlotView, context: Context) -> CGSize? { func sizeThatFits(_ proposal: ProposedViewSize, nsView: PlotView, context: Context) -> CGSize? {
CGSize(width: proposal.width.flatMap { $0.isFinite ? $0 : nil } ?? 10, CGSize(width: proposal.width.flatMap { $0.isFinite ? $0 : nil } ?? 10,
@@ -18,7 +19,7 @@ struct NativePanelCurve: NSViewRepresentable {
func makeNSView(context: Context) -> PlotView { PlotView() } func makeNSView(context: Context) -> PlotView { PlotView() }
func updateNSView(_ view: PlotView, context: Context) { func updateNSView(_ view: PlotView, context: Context) {
view.configure(Input(frame: frame, colors: colors, scales: scales, maximumGap: maximumGap, view.configure(Input(frame: frame, colors: colors, scales: scales, maximumGap: maximumGap,
hoveredIndex: hoveredIndex, visibleSeriesCount: visibleSeriesCount, filledSeriesCount: filledSeriesCount)) hoveredIndex: hoveredIndex, visibleSeriesCount: visibleSeriesCount, filledSeriesCount: filledSeriesCount, stacked: stacked))
} }
struct Input: Equatable { struct Input: Equatable {
let frame: PanelCurveFrame let frame: PanelCurveFrame
@@ -28,6 +29,7 @@ struct NativePanelCurve: NSViewRepresentable {
var hoveredIndex: Int? = nil var hoveredIndex: Int? = nil
var visibleSeriesCount: Int? = nil var visibleSeriesCount: Int? = nil
var filledSeriesCount = 1 var filledSeriesCount = 1
var stacked = false
} }
final class PlotView: NSView { final class PlotView: NSView {
private(set) var input: Input? private(set) var input: Input?
@@ -38,6 +40,7 @@ struct NativePanelCurve: NSViewRepresentable {
private var hoverDots: [CAShapeLayer] = [] private var hoverDots: [CAShapeLayer] = []
private var seriesLayers: [SeriesLayer] = [] private var seriesLayers: [SeriesLayer] = []
private var palette: [NSColor] = [] private var palette: [NSColor] = []
private var plottedBands: [StackedSeries.Band] = []
override var isFlipped: Bool { true } override var isFlipped: Bool { true }
override func hitTest(_ point: NSPoint) -> NSView? { nil } override func hitTest(_ point: NSPoint) -> NSView? { nil }
@@ -67,7 +70,7 @@ struct NativePanelCurve: NSViewRepresentable {
for index in seriesLayers.indices { for index in seriesLayers.indices {
seriesLayers[index].root.isHidden = index >= (value.visibleSeriesCount ?? value.frame.series.count) seriesLayers[index].root.isHidden = index >= (value.visibleSeriesCount ?? value.frame.series.count)
} }
if frameChanged || old?.scales != value.scales || old?.maximumGap != value.maximumGap { if frameChanged || old?.scales != value.scales || old?.maximumGap != value.maximumGap || old?.stacked != value.stacked {
rebuildPaths() rebuildPaths()
} }
updateHover() updateHover()
@@ -122,13 +125,16 @@ struct NativePanelCurve: NSViewRepresentable {
} }
let domain = PanelCurveFrame.domain(begin: first, end: last) let domain = PanelCurveFrame.domain(begin: first, end: last)
let frame = input.frame let frame = input.frame
plottedBands = input.stacked ? StackedSeries.bands(frame.series, count: frame.dates.count, limit: input.scales.first) : []
for index in frame.series.indices { for index in frame.series.indices {
let series = seriesLayers[index] let series = seriesLayers[index]
series.resize(bounds) series.resize(bounds)
let value = input.scales[min(index, input.scales.count - 1)] let value = input.scales[input.stacked ? 0 : min(index, input.scales.count - 1)]
let scale = value.isFinite && value > 0 ? value : 1 let scale = value.isFinite && value > 0 ? value : 1
let runs = PanelCurveGeometry.runs(dates: frame.dates, values: frame.series[index], maximumGap: input.maximumGap, let upper = input.stacked ? plottedBands[index].upper : frame.series[index]
boundaryDates: frame.boundaryDates, intervals: frame.intervals) let lower = input.stacked ? plottedBands[index].lower : nil
let runs = PanelCurveGeometry.runs(dates: frame.dates, values: upper, maximumGap: input.maximumGap,
boundaryDates: frame.boundaryDates, intervals: frame.intervals, lowerValues: lower)
let line = CGMutablePath(), dots = CGMutablePath(), area = CGMutablePath() let line = CGMutablePath(), dots = CGMutablePath(), area = CGMutablePath()
for run in runs { for run in runs {
let points = run.map { CGPoint(x: bounds.width * domain.position($0.date), let points = run.map { CGPoint(x: bounds.width * domain.position($0.date),
@@ -143,11 +149,16 @@ struct NativePanelCurve: NSViewRepresentable {
segment.addCurve(to: b, control1: CGPoint(x: mid, y: a.y), control2: CGPoint(x: mid, y: b.y)) segment.addCurve(to: b, control1: CGPoint(x: mid, y: a.y), control2: CGPoint(x: mid, y: b.y))
} }
line.addPath(segment) line.addPath(segment)
// Each continuous run closes against its own baseline, preserving real gaps. // Close against the matching lower boundary, never against another run or missing component.
let lowerPoints = run.reversed().map { CGPoint(x: bounds.width * domain.position($0.date),
y: bounds.height * (1 - min(1, max(0, $0.lower / scale)))) }
let fill = CGMutablePath(); fill.addPath(segment) let fill = CGMutablePath(); fill.addPath(segment)
fill.addLine(to: CGPoint(x: points.last!.x, y: bounds.height)) if let lowerStart = lowerPoints.first { fill.addLine(to: lowerStart) }
fill.addLine(to: CGPoint(x: start.x, y: bounds.height)); fill.closeSubpath() for (a, b) in zip(lowerPoints, lowerPoints.dropFirst()) {
area.addPath(fill) let mid = (a.x + b.x) / 2
fill.addCurve(to: b, control1: CGPoint(x: mid, y: a.y), control2: CGPoint(x: mid, y: b.y))
}
fill.closeSubpath(); area.addPath(fill)
} }
series.line.path = line series.line.path = line
series.points.path = dots series.points.path = dots
@@ -164,9 +175,9 @@ struct NativePanelCurve: NSViewRepresentable {
let path = CGMutablePath(); path.move(to: CGPoint(x: x, y: 0)); path.addLine(to: CGPoint(x: x, y: bounds.height)); hoverLine.path = path let path = CGMutablePath(); path.move(to: CGPoint(x: x, y: 0)); path.addLine(to: CGPoint(x: x, y: bounds.height)); hoverLine.path = path
for series in input.frame.series.indices { for series in input.frame.series.indices {
guard series < (input.visibleSeriesCount ?? input.frame.series.count) else { continue } guard series < (input.visibleSeriesCount ?? input.frame.series.count) else { continue }
let values = input.frame.series[series] let values = input.stacked && plottedBands.indices.contains(series) ? plottedBands[series].upper : input.frame.series[series]
guard values.indices.contains(index), let value = values[index], value.isFinite else { continue } guard values.indices.contains(index), let value = values[index], value.isFinite else { continue }
let scale = input.scales[min(series, input.scales.count - 1)] let scale = input.scales[input.stacked ? 0 : min(series, input.scales.count - 1)]
let y = bounds.height * (1 - min(1, max(0, value / (scale.isFinite && scale > 0 ? scale : 1)))) let y = bounds.height * (1 - min(1, max(0, value / (scale.isFinite && scale > 0 ? scale : 1))))
hoverDots[series].path = CGPath(ellipseIn: CGRect(x: x - 2.5, y: y - 2.5, width: 5, height: 5), transform: nil) hoverDots[series].path = CGPath(ellipseIn: CGRect(x: x - 2.5, y: y - 2.5, width: 5, height: 5), transform: nil)
} }
+8 -2
View File
@@ -4,6 +4,7 @@ nonisolated enum PanelCurveGeometry {
struct Sample { struct Sample {
let date: Date let date: Date
let value: Double let value: Double
var lower: Double = 0
} }
static func allowedGap(at index: Int, intervals: [TimeInterval], fallback: TimeInterval) -> TimeInterval { static func allowedGap(at index: Int, intervals: [TimeInterval], fallback: TimeInterval) -> TimeInterval {
@@ -12,7 +13,7 @@ nonisolated enum PanelCurveGeometry {
return interval.isFinite && interval > 0 ? max(5, interval * 2) : fallback return interval.isFinite && interval > 0 ? max(5, interval * 2) : fallback
} }
static func runs(dates: [Date], values: [Double?], maximumGap: TimeInterval = 5, boundaryDates: Set<Date> = [], intervals: [TimeInterval] = []) -> [[Sample]] { static func runs(dates: [Date], values: [Double?], maximumGap: TimeInterval = 5, boundaryDates: Set<Date> = [], intervals: [TimeInterval] = [], lowerValues: [Double?]? = nil) -> [[Sample]] {
var result: [[Sample]] = [] var result: [[Sample]] = []
var run: [Sample] = [] var run: [Sample] = []
func flush() { if !run.isEmpty { result.append(run); run.removeAll(keepingCapacity: true) } } func flush() { if !run.isEmpty { result.append(run); run.removeAll(keepingCapacity: true) } }
@@ -20,7 +21,12 @@ nonisolated enum PanelCurveGeometry {
if index > 0 && (boundaryDates.contains(dates[index]) || dates[index].timeIntervalSince(dates[index - 1]) > allowedGap(at: index, intervals: intervals, fallback: maximumGap) || dates[index] <= dates[index - 1]) { flush() } if index > 0 && (boundaryDates.contains(dates[index]) || dates[index].timeIntervalSince(dates[index - 1]) > allowedGap(at: index, intervals: intervals, fallback: maximumGap) || dates[index] <= dates[index - 1]) { flush() }
// Missing values do not create vertices, but their timestamps can still carry a real break. // Missing values do not create vertices, but their timestamps can still carry a real break.
guard index < values.count, let value = values[index], value.isFinite else { continue } guard index < values.count, let value = values[index], value.isFinite else { continue }
run.append(Sample(date: dates[index], value: value)) var lower = 0.0
if let lowerValues {
guard lowerValues.indices.contains(index), let base = lowerValues[index], base.isFinite else { continue }
lower = base
}
run.append(Sample(date: dates[index], value: value, lower: lower))
} }
flush() flush()
return result return result
+21 -4
View File
@@ -31,6 +31,7 @@ struct PanelTrendChart: View {
var boundaryDates: Set<Date> = [] var boundaryDates: Set<Date> = []
var intervals: [TimeInterval] = [] var intervals: [TimeInterval] = []
var visibleSeriesCount = 1 var visibleSeriesCount = 1
var stackOrder: [Int] = []
@State private var retainedScale: Double = 1 @State private var retainedScale: Double = 1
@State private var smallSamples = 0 @State private var smallSamples = 0
@State private var retainedSecondScale: Double = 1 @State private var retainedSecondScale: Double = 1
@@ -45,7 +46,22 @@ struct PanelTrendChart: View {
intervals: intervals.count == dates.count ? intervals : Array(repeating: expectedInterval, count: dates.count), intervals: intervals.count == dates.count ? intervals : Array(repeating: expectedInterval, count: dates.count),
boundaryDates: boundaryDates) boundaryDates: boundaryDates)
} }
private var maximum: Double { max(1, (first + second + third + fourth).compactMap { $0 }.filter(\.isFinite).max() ?? 1) } private var renderFrame: PanelCurveFrame {
let raw = inputFrame
guard !stackOrder.isEmpty else { return raw }
return PanelCurveFrame(dates: raw.dates, series: stackOrder.map { index in
raw.series.indices.contains(index) ? raw.series[index] : Array(repeating: nil, count: raw.dates.count)
}, intervals: raw.intervals, boundaryDates: raw.boundaryDates)
}
private var renderColors: [Color] {
let colors = [color, secondColor, thirdColor, fourthColor]
return stackOrder.isEmpty ? colors : stackOrder.map { colors[min(max(0, $0), colors.count - 1)] }
}
private var maximum: Double {
let values = stackOrder.isEmpty ? first + second + third + fourth
: StackedSeries.bands(renderFrame.series, count: dates.count).last?.upper ?? []
return max(1, values.compactMap { $0 }.filter(\.isFinite).max() ?? 1)
}
private var secondMaximum: Double { max(1, second.compactMap { $0 }.filter(\.isFinite).max() ?? 1) } private var secondMaximum: Double { max(1, second.compactMap { $0 }.filter(\.isFinite).max() ?? 1) }
private var scale: Double { max(0.0001, fixedScale ?? retainedScale) } private var scale: Double { max(0.0001, fixedScale ?? retainedScale) }
private var secondaryScale: Double { max(0.0001, retainedSecondScale) } private var secondaryScale: Double { max(0.0001, retainedSecondScale) }
@@ -94,10 +110,11 @@ struct PanelTrendChart: View {
var body: some View { var body: some View {
GeometryReader { proxy in GeometryReader { proxy in
NativePanelCurve(frame: inputFrame, colors: [color, secondColor, thirdColor, fourthColor], NativePanelCurve(frame: renderFrame, colors: renderColors,
scales: [scale, hasSecondaryScale ? secondaryScale : scale, scale, scale], scales: [scale, hasSecondaryScale ? secondaryScale : scale, scale, scale],
maximumGap: max(5, expectedInterval * 2), hoveredIndex: hoveredDate == nil ? nil : index, maximumGap: max(5, expectedInterval * 2), hoveredIndex: hoveredDate == nil ? nil : index,
visibleSeriesCount: visibleSeriesCount, filledSeriesCount: visibleSeriesCount) visibleSeriesCount: stackOrder.isEmpty ? visibleSeriesCount : stackOrder.count,
filledSeriesCount: stackOrder.isEmpty ? visibleSeriesCount : stackOrder.count, stacked: !stackOrder.isEmpty)
.contentShape(Rectangle()) .contentShape(Rectangle())
.onContinuousHover { phase in .onContinuousHover { phase in
switch phase { switch phase {
@@ -114,7 +131,7 @@ struct PanelTrendChart: View {
return ChartTooltipPresentation(plot: plot, point: hoverPoint, content: AnyView(tooltip(index: index))) return ChartTooltipPresentation(plot: plot, point: hoverPoint, content: AnyView(tooltip(index: index)))
} }
} }
.frame(height: ResourceCardMetrics.plotHeight) .frame(maxWidth: .infinity, maxHeight: .infinity)
.onAppear { .onAppear {
retainedScale = maximum retainedScale = maximum
retainedSecondScale = secondMaximum retainedSecondScale = secondMaximum
+32
View File
@@ -0,0 +1,32 @@
import Foundation
/// Additive components retain their raw values; only render boundaries are cumulative.
nonisolated enum StackedSeries {
struct Band {
var lower: [Double?]
var upper: [Double?]
}
static func bands(_ components: [[Double?]], count: Int, limit: Double? = nil) -> [Band] {
var result = components.map { _ in Band(lower: Array(repeating: nil, count: count), upper: Array(repeating: nil, count: count)) }
guard !components.isEmpty else { return result }
for point in 0..<count {
var values: [Double] = []
for component in components {
guard component.indices.contains(point), let value = component[point], value.isFinite, value >= 0 else { break }
values.append(value)
}
guard values.count == components.count else { continue }
let total = values.reduce(0, +)
guard total.isFinite else { continue }
if let limit, limit.isFinite, limit > 0, total > limit + max(1, limit) * 1e-12 { continue }
var lower = 0.0
for (series, value) in values.enumerated() {
result[series].lower[point] = lower
lower += value
result[series].upper[point] = lower
}
}
return result
}
}
+94 -1
View File
@@ -1,11 +1,43 @@
import AppKit
import SwiftUI import SwiftUI
/// Historical visual speed tiers; they deliberately do not reproduce physical RPM.
nonisolated struct FanRotation {
private(set) var phase: Double = 0
private(set) var speed: Double = 0
private var reference: TimeInterval = 0
static func speed(rpm: Double?, reducedMotion: Bool) -> Double {
guard !reducedMotion, let rpm, rpm.isFinite, rpm > 0 else { return 0 }
switch rpm {
case ..<2000: return 90
case ..<4000: return 180
case ..<6000: return 300
default: return 450
}
}
func angle(at time: TimeInterval) -> Double {
(phase + max(0, time - reference) * speed).truncatingRemainder(dividingBy: 360)
}
mutating func update(rpm: Double?, reducedMotion: Bool, at time: TimeInterval) {
phase = angle(at: time)
reference = time
speed = Self.speed(rpm: rpm, reducedMotion: reducedMotion)
}
}
struct FanSpeedIndicator: View { struct FanSpeedIndicator: View {
let title: Text let title: Text
let rpm: Double? let rpm: Double?
var isActive = true
@Environment(\.accessibilityReduceMotion) private var reduceMotion
var body: some View { var body: some View {
HStack(spacing: 4) { HStack(spacing: 3) {
FanRotor(rpm: rpm, isActive: isActive, reduceMotion: reduceMotion)
.frame(width: 11, height: 11).accessibilityHidden(true)
title.foregroundStyle(.secondary) title.foregroundStyle(.secondary)
MetricText(value: rpm.map { "\(Int($0.rounded())) RPM" } ?? "-- RPM") MetricText(value: rpm.map { "\(Int($0.rounded())) RPM" } ?? "-- RPM")
.monospacedDigit().fontWeight(.medium) .monospacedDigit().fontWeight(.medium)
@@ -13,3 +45,64 @@ struct FanSpeedIndicator: View {
.font(.system(size: 9)).lineLimit(1).minimumScaleFactor(0.7) .font(.system(size: 9)).lineLimit(1).minimumScaleFactor(0.7)
} }
} }
/// Only this native icon animates; sampling updates do not create display timers.
struct FanRotor: NSViewRepresentable {
let rpm: Double?
let isActive: Bool
let reduceMotion: Bool
func makeNSView(context: Context) -> RotorView { RotorView() }
func updateNSView(_ view: RotorView, context: Context) {
view.configure(rpm: rpm, active: isActive, reducedMotion: reduceMotion)
}
static func dismantleNSView(_ view: RotorView, coordinator: ()) { view.stop() }
final class RotorView: NSImageView {
static let animationKey = "fan.rotation"
private var rpm: Double?
private var active = false
private var reducedMotion = false
private(set) var rotation = FanRotation()
init() {
super.init(frame: .zero)
wantsLayer = true
image = NSImage(systemSymbolName: "fanblades.fill", accessibilityDescription: nil)
contentTintColor = .secondaryLabelColor
imageScaling = .scaleProportionallyUpOrDown
setAccessibilityElement(false)
}
required init?(coder: NSCoder) { nil }
func configure(rpm: Double?, active: Bool, reducedMotion: Bool) {
self.rpm = rpm; self.active = active; self.reducedMotion = reducedMotion
refresh()
}
func stop() {
active = false; refresh()
layer?.removeAnimation(forKey: Self.animationKey)
}
override func viewDidMoveToWindow() { super.viewDidMoveToWindow(); refresh() }
private func refresh() {
let readable = active && window != nil ? rpm : nil
let speed = FanRotation.speed(rpm: readable, reducedMotion: reducedMotion)
guard speed != rotation.speed else { return }
rotation.update(rpm: readable, reducedMotion: reducedMotion, at: CACurrentMediaTime())
let radians = rotation.phase * .pi / 180
CATransaction.begin(); CATransaction.setDisableActions(true)
layer?.removeAnimation(forKey: Self.animationKey)
layer?.transform = CATransform3DMakeRotation(radians, 0, 0, 1)
if speed > 0 {
let animation = CABasicAnimation(keyPath: "transform.rotation.z")
animation.fromValue = radians; animation.toValue = radians + .pi * 2
animation.duration = 360 / speed
animation.repeatCount = .infinity
animation.timingFunction = CAMediaTimingFunction(name: .linear)
layer?.add(animation, forKey: Self.animationKey)
}
CATransaction.commit()
}
}
}
+2 -2
View File
@@ -28,8 +28,8 @@ struct CardField<Content: View>: View {
struct CardSurface: ViewModifier { struct CardSurface: ViewModifier {
func body(content: Content) -> some View { func body(content: Content) -> some View {
content.modifier(PanelCardBackground(radius: 10)) content.modifier(PanelCardBackground(radius: ResourceCardMetrics.radius))
.overlay(RoundedRectangle(cornerRadius: 10).strokeBorder(.primary.opacity(0.14))) .overlay(RoundedRectangle(cornerRadius: ResourceCardMetrics.radius).strokeBorder(.primary.opacity(0.06)))
} }
} }
+1 -2
View File
@@ -26,7 +26,7 @@ struct ResourceCard<Chart: View, Content: View>: View {
GeometryReader { bounds in GeometryReader { bounds in
ZStack(alignment: .bottomLeading) { ZStack(alignment: .bottomLeading) {
chart() chart()
.frame(width: bounds.size.width, height: ResourceCardMetrics.plotHeight) .frame(width: bounds.size.width, height: bounds.size.height)
VStack(alignment: .leading, spacing: ResourceCardMetrics.gap) { VStack(alignment: .leading, spacing: ResourceCardMetrics.gap) {
header header
HStack(alignment: .firstTextBaseline, spacing: 6) { HStack(alignment: .firstTextBaseline, spacing: 6) {
@@ -42,7 +42,6 @@ struct ResourceCard<Chart: View, Content: View>: View {
} }
.font(.system(size: 9)) .font(.system(size: 9))
.padding(ResourceCardMetrics.padding) .padding(ResourceCardMetrics.padding)
.padding(.bottom, ResourceCardMetrics.plotHeight - ResourceCardMetrics.padding)
.frame(width: bounds.size.width, height: bounds.size.height, alignment: .topLeading) .frame(width: bounds.size.width, height: bounds.size.height, alignment: .topLeading)
} }
.background(Color("PanelCard")) .background(Color("PanelCard"))
@@ -6,7 +6,6 @@ nonisolated enum ResourceCardMetrics {
static let minimumHeight: CGFloat = 176 static let minimumHeight: CGFloat = 176
static let padding: CGFloat = 10 static let padding: CGFloat = 10
static let radius: CGFloat = 16 static let radius: CGFloat = 16
static let plotHeight: CGFloat = 48
static let titleHeight: CGFloat = 14 static let titleHeight: CGFloat = 14
static let headlineHeight: CGFloat = 34 static let headlineHeight: CGFloat = 34
static let gap: CGFloat = 4 static let gap: CGFloat = 4
+27
View File
@@ -0,0 +1,27 @@
import SwiftUI
/// Four square blocks fill from bottom to top; partial blocks retain the actual fraction.
struct SegmentedCoreBar: View {
let value: Double?
let color: Color
static func portions(_ value: Double?, count: Int = 4) -> [Double] {
guard count > 0 else { return [] }
let fraction = value.flatMap { $0.isFinite ? min(1, max(0, $0)) : nil } ?? 0
return (0..<count).map { min(1, max(0, fraction * Double(count) - Double($0))) }
}
var body: some View {
let fills = Self.portions(value)
VStack(spacing: 2) {
ForEach(Array(fills.indices.reversed()), id: \.self) { index in
ZStack(alignment: .bottom) {
Rectangle().fill(color.opacity(0.15))
Rectangle().fill(color).frame(height: 6 * fills[index])
}.frame(width: 6, height: 6).clipped()
}
}
.accessibilityHidden(true)
.transaction { $0.animation = nil; $0.disablesAnimations = true }
}
}
+8 -2
View File
@@ -10,14 +10,14 @@ import SwiftUI
precondition(last > 0 && first - last <= 1) precondition(last > 0 && first - last <= 1)
let columns = rows.max()! let columns = rows.max()!
let cellWidth = (width - Double(columns - 1) * 3) / Double(columns) let cellWidth = (width - Double(columns - 1) * 3) / Double(columns)
precondition(cellWidth >= 8, "Each real core needs its own visible meter cell") precondition(cellWidth >= 6, "Each real core needs its own visible meter cell")
} }
} }
} }
precondition(CPUCoreGridLayout.rowCounts(count: 18, width: 430) == [18]) precondition(CPUCoreGridLayout.rowCounts(count: 18, width: 430) == [18])
precondition(CPUCoreGridLayout.rowCounts(count: 18, width: 280) == [18]) precondition(CPUCoreGridLayout.rowCounts(count: 18, width: 280) == [18])
precondition(CPUCoreGridLayout.rowCounts(count: 32, width: 430) == [32]) precondition(CPUCoreGridLayout.rowCounts(count: 32, width: 430) == [32])
precondition(CPUCoreGridLayout.rowCounts(count: 48, width: 430) == [24, 24]) precondition(CPUCoreGridLayout.rowCounts(count: 48, width: 430) == [48])
for count in [0, 1, 4, 8, 14, 18, 24, 32, 48, 128] { for count in [0, 1, 4, 8, 14, 18, 24, 32, 48, 128] {
let kinds = Dictionary(uniqueKeysWithValues: (0..<count).map { ($0, $0 < count / 3 ? CPUCoreTopology.Kind.efficiency : .performance) }) let kinds = Dictionary(uniqueKeysWithValues: (0..<count).map { ($0, $0 < count / 3 ? CPUCoreTopology.Kind.efficiency : .performance) })
let groups = CPUCoreGrid.groups(count: count, kinds: kinds) let groups = CPUCoreGrid.groups(count: count, kinds: kinds)
@@ -26,6 +26,7 @@ import SwiftUI
let widths = CPUCoreGrid.groupWidths(groups: groups, width: width) let widths = CPUCoreGrid.groupWidths(groups: groups, width: width)
precondition(widths.allSatisfy { $0 >= 0 && $0.isFinite }) precondition(widths.allSatisfy { $0 >= 0 && $0.isFinite })
precondition(widths.allSatisfy { $0 <= width }) precondition(widths.allSatisfy { $0 <= width })
if !groups.isEmpty { precondition(abs(widths.reduce(0, +) + Double(groups.count - 1) * 8 - width) < 1e-9) }
for (group, groupWidth) in zip(groups, widths) { for (group, groupWidth) in zip(groups, widths) {
let rows = CPUCoreGridLayout.rowCounts(count: group.count, width: groupWidth) let rows = CPUCoreGridLayout.rowCounts(count: group.count, width: groupWidth)
precondition(rows.reduce(0, +) == group.count) precondition(rows.reduce(0, +) == group.count)
@@ -36,6 +37,11 @@ import SwiftUI
precondition(CPUCoreGridLayout.rowCounts(count: 128, width: width).reduce(0, +) == 128) precondition(CPUCoreGridLayout.rowCounts(count: 128, width: width).reduce(0, +) == 128)
} }
precondition(CPUCoreGrid.groups(count: 3, kinds: [0: .efficiency]).count == 2) precondition(CPUCoreGrid.groups(count: 3, kinds: [0: .efficiency]).count == 2)
precondition(SegmentedCoreBar.portions(0) == [0,0,0,0])
precondition(SegmentedCoreBar.portions(0.125) == [0.5,0,0,0])
precondition(SegmentedCoreBar.portions(0.5) == [1,1,0,0])
precondition(SegmentedCoreBar.portions(1) == [1,1,1,1])
for invalid: Double? in [nil,.nan,-1] { precondition(SegmentedCoreBar.portions(invalid) == [0,0,0,0]) }
print("PASS: compact per-core meters with intact identities and bounded wrapping at multiple widths/counts") print("PASS: compact per-core meters with intact identities and bounded wrapping at multiple widths/counts")
} }
} }
+6 -6
View File
@@ -13,17 +13,17 @@ import Foundation
store.setPanelVisible(true) store.setPanelVisible(true)
try await until { store.history.samples.count >= 2 } try await until { store.history.samples.count >= 2 }
precondition(probe.count == 0 && store.processSnapshot == nil && store.energy == nil, precondition(probe.count == 0 && store.processSnapshot == nil && store.energy == nil,
"Overview must not enumerate processes or publish process power") "Disabled process demand must not enumerate processes or publish process power")
store.setDetailDemand(processes: true, slowMetrics: false) store.setDetailDemand(processes: true, slowMetrics: true)
try await until { probe.count > 0 } try await until { probe.count > 0 }
// Withdraw demand while the synchronous OS read still holds the single slot. // Withdraw demand while the synchronous OS read still holds the single slot.
store.setDetailDemand(processes: false, slowMetrics: true) store.setDetailDemand(processes: false, slowMetrics: true)
try await Task.sleep(for: .milliseconds(350)) try await Task.sleep(for: .milliseconds(350))
precondition(store.processSnapshot == nil, "A completion from the previous page must not publish") precondition(store.processSnapshot == nil, "A completion from the withdrawn demand must not publish")
let stopped = probe.count let stopped = probe.count
try await Task.sleep(for: .milliseconds(650)) try await Task.sleep(for: .milliseconds(650))
precondition(probe.count == stopped && store.snapshot.cpu != nil) precondition(probe.count == stopped && store.snapshot.cpu != nil)
store.setDetailDemand(processes: true, slowMetrics: false) store.setDetailDemand(processes: true, slowMetrics: true)
try await until { store.processSnapshot != nil } try await until { store.processSnapshot != nil }
precondition(probe.peak == 1) precondition(probe.peak == 1)
precondition(store.history.samples.dropFirst().allSatisfy { !$0.breakBefore && $0.cpu != nil }, precondition(store.history.samples.dropFirst().allSatisfy { !$0.breakBefore && $0.cpu != nil },
@@ -32,7 +32,7 @@ import Foundation
precondition(store.processSnapshot == nil && store.energy == nil) precondition(store.processSnapshot == nil && store.energy == nil)
store.togglePause() store.togglePause()
let pausedCount = store.history.samples.count let pausedCount = store.history.samples.count
store.setDetailDemand(processes: true, slowMetrics: false) store.setDetailDemand(processes: true, slowMetrics: true)
try await Task.sleep(for: .milliseconds(650)) try await Task.sleep(for: .milliseconds(650))
precondition(store.history.samples.count == pausedCount && store.processSnapshot == nil) precondition(store.history.samples.count == pausedCount && store.processSnapshot == nil)
store.togglePause() store.togglePause()
@@ -40,7 +40,7 @@ import Foundation
store.setPanelVisible(false) store.setPanelVisible(false)
precondition(store.processSnapshot == nil && store.energy == nil) precondition(store.processSnapshot == nil && store.energy == nil)
store.togglePause() store.togglePause()
print("PASS: overview performs no process reads, page withdrawal rejects stale completion, single in-flight read, continuous base history and pause/hidden precedence") print("PASS: disabled demand performs no process reads, unified demand supports both details, withdrawal rejects stale completion, single in-flight read, continuous base history and pause/hidden precedence")
} }
@MainActor private static func until(_ condition: () -> Bool) async throws { @MainActor private static func until(_ condition: () -> Bool) async throws {
+12 -1
View File
@@ -10,7 +10,18 @@ import Foundation
precondition(CPUTemperatureMonitor.decodeSensorNumber(type: 0, bytes: []) == nil) precondition(CPUTemperatureMonitor.decodeSensorNumber(type: 0, bytes: []) == nil)
precondition(FanMetrics.validRPM(0) == 0) precondition(FanMetrics.validRPM(0) == 0)
for value in [Double.nan, .infinity, -1, 30_001] { precondition(FanMetrics.validRPM(value) == nil) } for value in [Double.nan, .infinity, -1, 30_001] { precondition(FanMetrics.validRPM(value) == nil) }
print("PASS: fan decoding, invalid RPM and static indicator data") for (rpm, speed) in [(1.0,90.0), (1999,90), (2000,180), (3999,180), (4000,300), (5999,300), (6000,450)] {
precondition(FanRotation.speed(rpm: rpm, reducedMotion: false) == speed)
precondition(FanRotation.speed(rpm: rpm, reducedMotion: true) == 0)
}
var rotation = FanRotation()
rotation.update(rpm: 1000, reducedMotion: false, at: 10)
precondition(rotation.angle(at: 11) == 90)
rotation.update(rpm: 3000, reducedMotion: false, at: 11)
precondition(rotation.angle(at: 11) == 90 && rotation.angle(at: 12) == 270)
rotation.update(rpm: 0, reducedMotion: false, at: 12)
precondition(rotation.angle(at: 100) == 270)
print("PASS: fan decoding, invalid RPM, historical speed boundaries and continuous phase")
print("Live fan RPM:", CPUTemperatureMonitor().sampleFans() as Any) print("Live fan RPM:", CPUTemperatureMonitor().sampleFans() as Any)
} }
} }
+36
View File
@@ -0,0 +1,36 @@
import AppKit
import SwiftUI
@main struct FanRotorChecks {
@MainActor static func main() {
_ = NSApplication.shared; NSApp.setActivationPolicy(.accessory)
Task { @MainActor in
let window = NSWindow(contentRect: NSRect(x: 30, y: 30, width: 40, height: 40), styleMask: [.borderless], backing: .buffered, defer: false)
window.isReleasedWhenClosed = false
let rotor = FanRotor.RotorView(); rotor.frame = NSRect(x: 4, y: 4, width: 20, height: 20)
window.contentView!.addSubview(rotor); window.orderFrontRegardless()
try? await Task.sleep(for: .milliseconds(100))
for (rpm, duration) in [(1000.0,4.0),(2000,2),(4000,1.2),(6000,0.8)] {
rotor.configure(rpm: rpm, active: true, reducedMotion: false)
precondition(abs(rotor.layer!.animation(forKey: FanRotor.RotorView.animationKey)!.duration - duration) < 1e-9)
}
for rpm: Double? in [0,nil,.nan,-1] {
rotor.configure(rpm: rpm, active: true, reducedMotion: false)
precondition(rotor.layer!.animationKeys()?.isEmpty != false)
}
rotor.configure(rpm: 3000, active: true, reducedMotion: false)
precondition(rotor.layer!.animationKeys()?.isEmpty == false)
rotor.configure(rpm: 3000, active: false, reducedMotion: false)
precondition(rotor.layer!.animationKeys()?.isEmpty != false)
rotor.configure(rpm: 3000, active: true, reducedMotion: true)
precondition(rotor.layer!.animationKeys()?.isEmpty != false)
rotor.configure(rpm: 3000, active: true, reducedMotion: false)
rotor.removeFromSuperview()
precondition(rotor.layer!.animationKeys()?.isEmpty != false, "Detached fans must stop rotating")
window.orderOut(nil); window.close()
print("PASS: native rotor speed tiers, nil/zero/invalid readings, inactive/reduced motion and detach stop")
NSApp.terminate(nil)
}
NSApp.run()
}
}
+31 -1
View File
@@ -99,10 +99,40 @@ import QuartzCore
plot.configure(.init(frame: PanelCurveFrame(dates: dates, series: [[nil,nil,nil,nil], [0.5,0.5,0.5,0.5]], plot.configure(.init(frame: PanelCurveFrame(dates: dates, series: [[nil,nil,nil,nil], [0.5,0.5,0.5,0.5]],
intervals: [2,2,2,2], boundaryDates: []), colors: [.red], scales: [1], maximumGap: 5)) intervals: [2,2,2,2], boundaryDates: []), colors: [.red], scales: [1], maximumGap: 5))
precondition(redPixels(bitmap(plot), from: 0.4, to: 0.6) > 10) precondition(redPixels(bitmap(plot), from: 0.4, to: 0.6) > 10)
// Distinct cumulative bands must meet at 30%, with 70% total at the full plot scale.
var stack = NativePanelCurve.Input(frame: .init(dates: dates,
series: [Array(repeating: 0.3, count: 4), Array(repeating: 0.4, count: 4)],
intervals: [2,2,2,2], boundaryDates: []), colors: [.red,.blue], scales: [1], maximumGap: 5,
filledSeriesCount: 2, stacked: true)
plot.configure(stack)
let upperArea = (plot.curves.sublayers![1].sublayers![0] as! CAShapeLayer).path!.boundingBoxOfPath
precondition(abs(upperArea.minY - 18) < 1e-9 && abs(upperArea.maxY - 42) < 1e-9,
"The upper component must fill only between cumulative boundaries")
let stackedBitmap = bitmap(plot)
var redBand = 0, blueBand = 0
for y in 0..<stackedBitmap.pixelsHigh {
let c = stackedBitmap.colorAt(x: stackedBitmap.pixelsWide / 2, y: y)!.usingColorSpace(.deviceRGB)!
guard c.alphaComponent > 0.1 && c.alphaComponent < 0.18 else { continue }
if c.redComponent > c.blueComponent + 0.2 { redBand += 1 }
if c.blueComponent > c.redComponent + 0.2 { blueBand += 1 }
}
precondition(redBand > 20 && blueBand > 30, "Both components must produce separate translucent area pixels")
let stackedBuilds = plot.pathBuildCount
stack.hoveredIndex = 1; plot.configure(stack)
let cumulativeDot = plot.layer!.sublayers!.last as! CAShapeLayer
precondition(abs(cumulativeDot.path!.boundingBoxOfPath.midY - 18) < 1e-9)
precondition(plot.pathBuildCount == stackedBuilds)
stack = .init(frame: .init(dates: dates,
series: [Array(repeating: 0.3, count: 4), Array(repeating: 0.4, count: 4)],
intervals: [2,2,2,2], boundaryDates: [dates[2]]), colors: [.red,.blue], scales: [1], maximumGap: 5,
filledSeriesCount: 2, stacked: true)
plot.configure(stack)
precondition(redPixels(bitmap(plot), from: 0.4, to: 0.6) == 0,
"Every stack band must respect the same real sampling break")
assertStatic(plot.layer!) assertStatic(plot.layer!)
plot.removeFromSuperview() plot.removeFromSuperview()
window.orderOut(nil); window.close() window.orderOut(nil); window.close()
print("PASS: static background lines/area pixels, no single-point fill, hidden-series isolation, immediate stable updates, no animation/material/gradient layers, real gaps, hover cache, palette growth, appearance, full history and unmount") print("PASS: stacked component pixels and cumulative hover, static background lines/area pixels, no single-point fill, hidden-series isolation, immediate stable updates, no animation/material/gradient layers, real gaps, hover cache, palette growth, appearance, full history and unmount")
fflush(stdout); NSApp.terminate(nil) fflush(stdout); NSApp.terminate(nil)
} }
NSApp.run() NSApp.run()
+24 -21
View File
@@ -3,7 +3,7 @@ import CoreGraphics
@main struct PanelLayoutChecks { @main struct PanelLayoutChecks {
static func main() { static func main() {
precondition(PanelLayout.contentSize(visible: CGRect(x: 0, y: 0, width: 1512, height: 900)) == CGSize(width: 648, height: 448)) precondition(PanelLayout.contentSize(visible: CGRect(x: 0, y: 0, width: 1512, height: 900)) == CGSize(width: 648, height: 630))
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)] { 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)) 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) precondition(content.width + 4 <= visible.width - 32 && content.height + 12 <= visible.height - 32)
@@ -14,7 +14,7 @@ import CoreGraphics
precondition(visible.insetBy(dx: 16, dy: 16).contains(centered)) precondition(visible.insetBy(dx: 16, dy: 16).contains(centered))
} }
} }
let compact = PanelLayout.cardHeights(coreRows: 2, fanCount: 2) let compact = PanelLayout.cardHeights(coreRows: 1, fanCount: 2)
precondition(PanelLayout.cardRows(columns: 3) == [[.cpu, .gpu, .memory], [.battery, .storage, .network]]) precondition(PanelLayout.cardRows(columns: 3) == [[.cpu, .gpu, .memory], [.battery, .storage, .network]])
precondition(PanelLayout.cardRows(columns: 2) == [[.cpu, .gpu], [.memory, .battery], [.storage, .network]]) precondition(PanelLayout.cardRows(columns: 2) == [[.cpu, .gpu], [.memory, .battery], [.storage, .network]])
precondition(PanelLayout.cardRows(columns: 1) == PanelCard.allCases.map { [$0] }) precondition(PanelLayout.cardRows(columns: 1) == PanelCard.allCases.map { [$0] })
@@ -29,39 +29,42 @@ import CoreGraphics
for (row, height) in zip(rows, PanelLayout.rowHeights(columns: columns, heights: compact)) { for (row, height) in zip(rows, PanelLayout.rowHeights(columns: columns, heights: compact)) {
precondition(row.allSatisfy { (compact[$0] ?? 0) <= height }, "Every card must fit its aligned row") precondition(row.allSatisfy { (compact[$0] ?? 0) <= height }, "Every card must fit its aligned row")
} }
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: width, height: 400), heights: compact)) precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: width, height: 400), heights: compact))
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: width, height: 2400), heights: compact)) precondition(!PanelLayout.needsDashboardScroll(size: CGSize(width: width, height: 2400), heights: compact))
} }
precondition(PanelLayout.rowHeights(columns: 3, heights: compact) == [176, 176]) precondition(PanelLayout.rowHeights(columns: 3, heights: compact) == [176, 176])
precondition(PanelLayout.rowHeights(columns: 2, heights: compact) == [176, 176, 176]) precondition(PanelLayout.rowHeights(columns: 2, heights: compact) == [176, 176, 176])
precondition(PanelLayout.cardWidth(size: CGSize(width: 648, height: 448)) == ResourceCardMetrics.preferredWidth, precondition(PanelLayout.cardWidth(size: CGSize(width: 648, height: 630)) == ResourceCardMetrics.preferredWidth,
"Three columns must retain readable card widths") "Three columns must retain readable card widths")
precondition(PanelLayout.preferredHeight(width: 648, heights: compact) == 448) precondition(PanelLayout.preferredHeight(width: 648, heights: compact) == 630)
precondition(PanelLayout.preferredHeight(width: 520, heights: compact) == 662) precondition(PanelLayout.preferredHeight(width: 520, heights: compact) == 800)
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: 648, height: 448), heights: compact)) precondition(!PanelLayout.needsDashboardScroll(size: CGSize(width: 648, height: 630), heights: compact))
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 648, height: 447), heights: compact)) precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: 648, height: 629), heights: compact))
precondition(!PanelLayout.needsResourceScroll(size: CGSize(width: 520, height: 662), heights: compact)) precondition(!PanelLayout.needsDashboardScroll(size: CGSize(width: 520, height: 812), heights: compact))
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 520, height: 661), heights: compact)) precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: 520, height: 811), heights: compact))
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 360, height: 800), heights: compact)) precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: 360, height: 800), heights: compact))
precondition(PanelLayout.columns(width: 648) == 3 && PanelLayout.columns(width: 620) == 3) precondition(PanelLayout.columns(width: 648) == 3 && PanelLayout.columns(width: 620) == 3)
precondition(PanelLayout.columns(width: 619) == 2 && PanelLayout.columns(width: 430) == 2 && PanelLayout.columns(width: 429) == 1) precondition(PanelLayout.columns(width: 619) == 2 && PanelLayout.columns(width: 430) == 2 && PanelLayout.columns(width: 429) == 1)
let tallerCPU = PanelLayout.cardHeights(coreRows: 6, fanCount: 2) let tallerCPU = PanelLayout.cardHeights(coreRows: 6, fanCount: 2)
precondition(PanelLayout.rowHeights(columns: 3, heights: tallerCPU) == [232, 176], precondition(PanelLayout.rowHeights(columns: 3, heights: tallerCPU) == [346, 346],
"Extra CPU rows must grow the first grid row without changing the second") "All resource rows must share the maximum structural card height")
let moreFans = PanelLayout.cardHeights(coreRows: 2, fanCount: 10) let moreFans = PanelLayout.cardHeights(coreRows: 1, fanCount: 10)
precondition(moreFans[.gpu]! > compact[.gpu]! && moreFans[.storage] == compact[.storage]) precondition(moreFans[.gpu]! > compact[.gpu]! && moreFans[.storage] == compact[.storage])
precondition(PanelLayout.rowHeights(columns: 3, heights: moreFans) == [232, 176]) precondition(PanelLayout.rowHeights(columns: 3, heights: moreFans) == [232, 232])
let noFans = PanelLayout.cardHeights(coreRows: 2, fanCount: 0) let noFans = PanelLayout.cardHeights(coreRows: 1, fanCount: 0)
precondition(noFans[.gpu] == 176 && PanelLayout.rowHeights(columns: 3, heights: noFans) == [176, 176]) precondition(noFans[.gpu] == 176 && PanelLayout.rowHeights(columns: 3, heights: noFans) == [176, 176])
precondition(PanelLayout.preferredHeight(width: 648, heights: noFans) == 448, precondition(PanelLayout.preferredHeight(width: 648, heights: noFans) == 630,
"A fanless GPU must keep row alignment with CPU and memory") "A fanless GPU must keep row alignment with CPU and memory")
precondition(PanelLayout.cardHeights(coreRows: 2, fanCount: nil) == compact, precondition(PanelLayout.cardHeights(coreRows: 1, fanCount: nil) == compact,
"Discovery placeholders must reserve the ordinary fan row") "Discovery placeholders must reserve the ordinary fan row")
let manyCores = PanelLayout.cardHeights(coreRows: 30, fanCount: 10) let manyCores = PanelLayout.cardHeights(coreRows: 30, fanCount: 10)
precondition(PanelLayout.preferredHeight(width: 648, heights: manyCores) == 800) precondition(PanelLayout.preferredHeight(width: 648, heights: manyCores) == 800)
precondition(PanelLayout.needsResourceScroll(size: CGSize(width: 648, height: 800), heights: manyCores)) precondition(PanelLayout.needsDashboardScroll(size: CGSize(width: 648, height: 800), heights: manyCores))
let requested = PanelLayout.contentSize(visible: CGRect(x: 0, y: 0, width: 1512, height: 900), preferredHeight: 732) let requested = PanelLayout.contentSize(visible: CGRect(x: 0, y: 0, width: 1512, height: 900), preferredHeight: 732)
precondition(requested.height == 732, "A hardware-driven height above the default must be preserved") precondition(requested.height == 732, "A hardware-driven height above the default must be preserved")
precondition(PanelLayout.processHeight(heights: compact) == 176)
precondition(PanelLayout.dashboardHeight(columns: 3, heights: compact) == 540)
precondition(PanelLayout.processHeight(heights: tallerCPU) == 346)
let input: [ProcessMetrics] = (0..<2000).map { (index: Int) -> ProcessMetrics in let input: [ProcessMetrics] = (0..<2000).map { (index: Int) -> ProcessMetrics in
let id = ProcessIdentity(pid: Int32(index + 1), seconds: 1, microseconds: 0) let id = ProcessIdentity(pid: Int32(index + 1), seconds: 1, microseconds: 0)
let path: String? = index == 42 ? "/test/needle" : nil let path: String? = index == 42 ? "/test/needle" : nil
@@ -89,6 +92,6 @@ import CoreGraphics
} }
let pidSorted = ProcessTableProjection.rows(input, query: "", sorting: [ProcessSort(key: .pid)], order: []) let pidSorted = ProcessTableProjection.rows(input, query: "", sorting: [ProcessSort(key: .pid)], order: [])
precondition(pidSorted.first?.id.pid == 2000) precondition(pidSorted.first?.id.pid == 2000)
print("PASS: three-column/two-row grid, aligned hardware-driven row heights, responsive reading order, scroll and screen limits, column breakpoints, width conservation, visible-frame bounds/chrome/negative origins, 2000-row CPU/footprint projection, frozen order, path search and empty results") print("PASS: three-column resource grid plus equal-height process row, aligned hardware-driven row heights, responsive reading order, scroll and screen limits, column breakpoints, width conservation, visible-frame bounds/chrome/negative origins, 2000-row CPU/footprint projection, frozen order, path search and empty results")
} }
} }
-2
View File
@@ -43,7 +43,6 @@ import SwiftUI
// Geometry reports and centering run on subsequent main-queue turns. // Geometry reports and centering run on subsequent main-queue turns.
try? await Task.sleep(for: .milliseconds(200)) try? await Task.sleep(for: .milliseconds(200))
controller.presentation.isPinned = true controller.presentation.isPinned = true
controller.presentation.page = .processes
let cover = NSWindow(contentRect: controller.panel.frame.insetBy(dx: -8, dy: -8), let cover = NSWindow(contentRect: controller.panel.frame.insetBy(dx: -8, dy: -8),
styleMask: [.borderless], backing: .buffered, defer: false) styleMask: [.borderless], backing: .buffered, defer: false)
cover.isReleasedWhenClosed = false cover.isReleasedWhenClosed = false
@@ -75,7 +74,6 @@ import SwiftUI
precondition(!controller.panel.isVisible && !visible) precondition(!controller.panel.isVisible && !visible)
controller.togglePanel() controller.togglePanel()
precondition(controller.panel.isVisible && visible) precondition(controller.panel.isVisible && visible)
precondition(controller.presentation.page == .overview, "Explicit reopening must select overview")
controller.statusMenu().performActionForItem(at: 1) controller.statusMenu().performActionForItem(at: 1)
precondition(settingsRequests == 1 && !controller.panel.isVisible) precondition(settingsRequests == 1 && !controller.panel.isVisible)
controller.show() controller.show()
+44
View File
@@ -0,0 +1,44 @@
import AppKit
import SwiftUI
/// Verify the production section fills its assigned row even when the scope note wraps.
@main struct ProcessSectionChecks {
@MainActor static func main() {
_ = NSApplication.shared; NSApp.setActivationPolicy(.accessory)
Task { @MainActor in
let window = NSWindow(contentRect: NSRect(x: 30, y: 30, width: 628, height: 176),
styleMask: [.borderless], backing: .buffered, defer: false)
window.isReleasedWhenClosed = false; window.level = .floating
let host = NSHostingView(rootView: AnyView(EmptyView())); host.sizingOptions = []
window.contentView = host; window.orderFrontRegardless()
let rows = (0..<100).map { ProcessMetrics(id: .init(pid: Int32($0 + 1), seconds: 1, microseconds: 0),
name: "worker-\($0)", path: "/fixture/worker", cpu: 0.1, footprintBytes: 1 << 20, threads: 2, restricted: false) }
let snapshot = ProcessSnapshot(date: Date(), enumerated: 100, readable: 100, rows: rows, failed: false)
let energy = ProcessEnergySnapshot(date: Date(), candidates: 100, readable: 100, rows: [], state: .available)
for dark in [false,true] {
window.appearance = NSAppearance(named: dark ? .darkAqua : .aqua)
for language in ["zh-Hans","zh-Hant","en"] {
for width: CGFloat in [340,628] {
window.setContentSize(NSSize(width: width, height: 176))
host.rootView = AnyView(ProcessTableView(snapshot: snapshot, energy: energy, state: ProcessTableState())
.environment(\.locale, Locale(identifier: language))
.environment(\.colorScheme, dark ? .dark : .light))
try? await Task.sleep(for: .milliseconds(100)); host.layoutSubtreeIfNeeded()
let scrolls = descendants(host).compactMap { $0 as? NSScrollView }.filter { $0.documentView is NSTableView }
precondition(scrolls.count == 1)
let scroll = scrolls[0], rect = scroll.convert(scroll.bounds, to: host)
let topRect = host.isFlipped ? rect : CGRect(x: rect.minX, y: host.bounds.height - rect.maxY, width: rect.width, height: rect.height)
precondition(abs(topRect.maxY - 166) < 1 && topRect.height > 75,
"The native table must fill the equal-height row down to its 10pt inset: \(language), \(width), \(topRect)")
precondition(abs(topRect.minX - 10) < 1 && abs(topRect.maxX - (width - 10)) < 1)
}
}
}
host.rootView = AnyView(EmptyView()); window.orderOut(nil); window.close()
print("PASS: production process section at 176pt, wrapped scope notes, full remaining table height, two widths, three languages and light/dark")
NSApp.terminate(nil)
}
NSApp.run()
}
@MainActor private static func descendants(_ view: NSView) -> [NSView] { [view] + view.subviews.flatMap(descendants) }
}
+6 -6
View File
@@ -27,14 +27,14 @@ import SwiftUI
precondition(plots.count == 1) precondition(plots.count == 1)
let plot = plots[0] let plot = plots[0]
precondition(abs(host.bounds.width - width) < 1, "AppKit may round fractional content sizes to a point") precondition(abs(host.bounds.width - width) < 1, "AppKit may round fractional content sizes to a point")
precondition(abs(plot.bounds.width - host.bounds.width) < 0.5 && plot.bounds.height == 48, precondition(abs(plot.bounds.width - host.bounds.width) < 0.5 && abs(plot.bounds.height - host.bounds.height) < 0.5,
"The background chart must occupy the full card width, without axes or plot insets") "The background chart must occupy the full card width and height, without axes or plot insets")
let graph = topRect(plot, in: host) let graph = topRect(plot, in: host)
precondition(abs(graph.maxY - host.bounds.height) < 0.5, precondition(abs(graph.minY) < 0.5 && abs(graph.maxY - host.bounds.height) < 0.5,
"The background chart must end at the card bottom") "The background chart must end at the card bottom")
let detail = topRect(probe.view!, in: host) let detail = topRect(probe.view!, in: host)
precondition(detail.maxY <= graph.minY + 0.5 && detail.width <= host.bounds.width - 20 + 0.5, precondition(detail.minY >= 0 && detail.maxY <= host.bounds.height && detail.width <= host.bounds.width - 20 + 0.5,
"Foreground details must stay above the graph, including narrow/localized cards") "Foreground details must overlay the full-height graph within card bounds, including narrow/localized cards")
precondition(plot.grid.isHidden && plot.input?.visibleSeriesCount == 1) precondition(plot.grid.isHidden && plot.input?.visibleSeriesCount == 1)
} }
} }
@@ -64,7 +64,7 @@ import SwiftUI
try? await Task.sleep(for: .milliseconds(100)) try? await Task.sleep(for: .milliseconds(100))
precondition(descendants(host).allSatisfy { !($0 is NativePanelCurve.PlotView) }) precondition(descendants(host).allSatisfy { !($0 is NativePanelCurve.PlotView) })
window.orderOut(nil); window.contentView = nil; window.close() window.orderOut(nil); window.contentView = nil; window.close()
print("PASS: production card geometry at 190/205⅓/400pt, light/dark, three languages, foreground separation, memory distribution pixels and unmount") print("PASS: production card geometry at 190/205⅓/400pt, light/dark, three languages, full-height chart overlay, memory distribution pixels and unmount")
NSApp.terminate(nil) NSApp.terminate(nil)
} }
NSApp.run() NSApp.run()
+27
View File
@@ -0,0 +1,27 @@
import Foundation
@main struct StackedSeriesChecks {
static func main() {
let components: [[Double?]] = [[0.2,0,nil,0.4,Double.nan,-0.1], [0.3,0,0.1,0.2,0.1,0.2]]
let bands = StackedSeries.bands(components, count: 6, limit: 1)
precondition(bands[0].lower[0] == 0 && bands[0].upper[0] == 0.2)
precondition(bands[1].lower[0] == 0.2 && bands[1].upper[0] == 0.5)
precondition(bands[1].upper[1] == 0, "Real zero must remain a measured stack")
for index in [2,4,5] {
precondition(bands.allSatisfy { $0.lower[index] == nil && $0.upper[index] == nil },
"Missing or invalid components must not invent partial totals")
}
let memory = StackedSeries.bands([[22,24], [3,4], [1,2]], count: 2, limit: 48)
precondition(memory[2].lower == [25,28] && memory[2].upper == [26,30])
let gpu = StackedSeries.bands([[0,0.7,1], [1,0.3,0]], count: 3, limit: 1)
precondition(gpu.last!.upper == [1,1,1])
precondition(StackedSeries.bands([[0.8],[0.4]], count: 1, limit: 1).allSatisfy { $0.upper == [nil] })
precondition(StackedSeries.bands([[Double.greatestFiniteMagnitude],[Double.greatestFiniteMagnitude]], count: 1).allSatisfy { $0.upper == [nil] })
let dates = (0..<4).map { Date(timeIntervalSinceReferenceDate: Double($0 * 2)) }
let pair = StackedSeries.bands([[0.2,nil,nil,0.3],[0.3,nil,nil,0.2]], count: 4)
let runs = PanelCurveGeometry.runs(dates: dates, values: pair[1].upper, boundaryDates: [dates[2]], lowerValues: pair[1].lower)
precondition(runs.count == 2 && runs[0][0].lower == 0.2 && runs[1][0].lower == 0.3)
precondition(runs.flatMap { $0 }.map(\.date) == [dates[0],dates[3]])
print("PASS: cumulative component boundaries, CPU/memory/GPU sums, zero/missing/invalid/overflow, paired lower boundaries and sampling breaks")
}
}
+15 -4
View File
@@ -25,7 +25,7 @@ CHECKS.update({
"BoundedProcessChecks": ["kymo/Core/Services/BoundedProcess.swift"], "BoundedProcessChecks": ["kymo/Core/Services/BoundedProcess.swift"],
"SensorScheduleChecks": ["kymo/Core/Services/SensorSchedule.swift"], "SensorScheduleChecks": ["kymo/Core/Services/SensorSchedule.swift"],
"CPUCoreGridChecks": ["kymo/Features/MenuBar/CPUCoreGrid.swift", "kymo/Core/Services/CPUCoreTopology.swift", "CPUCoreGridChecks": ["kymo/Features/MenuBar/CPUCoreGrid.swift", "kymo/Core/Services/CPUCoreTopology.swift",
"kymo/Core/Extensions/MetricFormat.swift", "kymo/UI/Components/MetricProgressBar.swift"], "kymo/Core/Extensions/MetricFormat.swift", "kymo/UI/Components/MetricProgressBar.swift", "kymo/UI/Components/SegmentedCoreBar.swift"],
"CPUTemperatureChecks": ["kymo/Core/Monitors/CPUTemperatureMonitor.swift"], "CPUTemperatureChecks": ["kymo/Core/Monitors/CPUTemperatureMonitor.swift"],
"DiskHealthChecks": ["kymo/Core/Models/DiskHealthMetrics.swift", "kymo/Core/Monitors/DiskHealthReport.swift"], "DiskHealthChecks": ["kymo/Core/Models/DiskHealthMetrics.swift", "kymo/Core/Monitors/DiskHealthReport.swift"],
"PublicIPAddressChecks": ["kymo/Core/Services/PublicIPAddressService.swift"], "PublicIPAddressChecks": ["kymo/Core/Services/PublicIPAddressService.swift"],
@@ -76,7 +76,18 @@ CHECKS["ResourceCardChecks"] = list(dict.fromkeys(CORE + CHECKS["ResourceCardChe
for name in ("PanelLayoutChecks", "PanelWindowChecks"): for name in ("PanelLayoutChecks", "PanelWindowChecks"):
CHECKS[name].append("kymo/UI/Components/ResourceCardMetrics.swift") CHECKS[name].append("kymo/UI/Components/ResourceCardMetrics.swift")
GUI = {"ResourceCardChecks", "NativeMetricDrawingChecks", "NativeContentHostChecks", "NativeProcessTableChecks", "LanguageScopeChecks", "SettingsWindowChecks", "PanelWindowChecks", "TabPickerChecks"} for name in ("NativeMetricDrawingChecks", "ResourceCardChecks"):
CHECKS[name].append("kymo/UI/Charts/StackedSeries.swift")
CHECKS["StackedSeriesChecks"] = ["kymo/UI/Charts/StackedSeries.swift", "kymo/UI/Charts/PanelCurveGeometry.swift"]
CHECKS["FanRotorChecks"] = ["kymo/UI/Components/FanSpeedIndicator.swift", "kymo/UI/Components/MetricText.swift"]
CHECKS["ProcessSectionChecks"] = CHECKS["NativeProcessTableChecks"] + [
"kymo/Core/Models/ProcessEnergy.swift", "kymo/Features/MenuBar/ProcessTableView.swift",
"kymo/UI/Components/NativeSearchField.swift", "kymo/UI/Components/PanelStyle.swift",
"kymo/UI/Components/ResourceCardMetrics.swift", "kymo/UI/Components/MetricText.swift",
]
GUI = {"ProcessSectionChecks", "FanRotorChecks", "ResourceCardChecks", "NativeMetricDrawingChecks", "NativeContentHostChecks", "NativeProcessTableChecks", "LanguageScopeChecks", "SettingsWindowChecks", "PanelWindowChecks", "TabPickerChecks"}
NETWORK = {"SandboxNetworkChecks"} NETWORK = {"SandboxNetworkChecks"}
SERVICES = {"ReleaseServiceChecks"} SERVICES = {"ReleaseServiceChecks"}
@@ -110,7 +121,7 @@ def test_bundle(work, name, executable, host_entitlements=None, resources=None,
(contents / "Info.plist").write_bytes(plistlib.dumps({ (contents / "Info.plist").write_bytes(plistlib.dumps({
"CFBundleIdentifier": "cn.airnan.kymo.checks." + uuid.uuid4().hex, "CFBundleIdentifier": "cn.airnan.kymo.checks." + uuid.uuid4().hex,
"CFBundleExecutable": name, "CFBundlePackageType": "APPL", "CFBundleExecutable": name, "CFBundlePackageType": "APPL",
"LSUIElement": name in {"ResourceCardChecks", "PanelWindowChecks", "NativeMetricDrawingChecks", "NativeContentHostChecks", "NativeProcessTableChecks", "NetworkAddressChecks", "SandboxNetworkChecks", "TabPickerChecks"}, "LSUIElement": name in {"ProcessSectionChecks", "FanRotorChecks", "ResourceCardChecks", "PanelWindowChecks", "NativeMetricDrawingChecks", "NativeContentHostChecks", "NativeProcessTableChecks", "NetworkAddressChecks", "SandboxNetworkChecks", "TabPickerChecks"},
})) }))
if resources: if resources:
shutil.copytree(resources, contents / "Resources") shutil.copytree(resources, contents / "Resources")
@@ -191,7 +202,7 @@ def main():
run(["swiftc", "-parse-as-library", "-module-cache-path", work / "cache", *CHECKS[name], run(["swiftc", "-parse-as-library", "-module-cache-path", work / "cache", *CHECKS[name],
f"kymoTests/{name}.swift", "-o", executable]) f"kymoTests/{name}.swift", "-o", executable])
if name in GUI: if name in GUI:
bundle = test_bundle(work, name, executable, resources=app / "Contents/Resources" if name in {"ResourceCardChecks", "NativeProcessTableChecks", "TabPickerChecks"} else None) bundle = test_bundle(work, name, executable, resources=app / "Contents/Resources" if name in {"ProcessSectionChecks", "ResourceCardChecks", "NativeProcessTableChecks", "TabPickerChecks"} else None)
# Open the complete app for native activation semantics, while collecting its output. # Open the complete app for native activation semantics, while collecting its output.
output = work / (name + ".out") output = work / (name + ".out")
error = work / (name + ".err") error = work / (name + ".err")