Repository navigation
fix(desktop): 状态栏内存详情按进程归属统计并重新排版 - #1926
Merged
Merged
Conversation
- 原生进程表:macOS 读 proc_pid_rusage 物理占用和负责进程,Windows 读专用工作集, Linux 读 /proc;不再每次启动 ps 或 PowerShell。 - 归属与汇总交给 Core processMemory.summarize:主进程、语言服务器、插件服务、 子进程和 macOS 的 WebKit 等系统辅助进程分开统计。 - 弹窗重排:总量和 ⓘ 说明、按类别堆叠的条、图例、占用最多的进程和其余项合计; 加宽到 340 不再截断数值,0 MB 的类别不显示,只有主进程时给出说明。 - 删除只为旧状态栏服务的 SampleProcessMemory、processTable、treeMemory 和 Status.MemoryValue。 - 修复启动时背景图恢复结果在窗口绑定唤醒前投递而丢失唤醒的问题:首帧发现已排队的结果时 主动请求一次唤醒(TestMissingBackgroundCopyShowsNoImageQuietly 偶发失败的根因)。 - Core 固定到 Lithe-core-rust#43 的 5e2a580。
# Conflicts: # scripts/desktop/build-desktop-core.sh
xiaoyumuxi
marked this pull request as ready for review
November 14, 2026 13:04
24 of 28 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Linked issue
submit-lithe-issue的规则,修复请求不等于授权建缺陷单,所以没有单独建;需要时可以补建。5e2a580)PR 类型 / Type
改动说明 / What changes
背景 / Why
状态栏内存详情的统计和显示都不对。截图里是“总计 302 / Lithe 302 / 语言服务器 0 / 插件服务 0”,下面写着“没有运行中的语言服务器或插件服务。”,右边的数值被截断:
MinWidth(300)比弹窗默认宽度 288 还宽,数值被截断;0 MB 的类别照样列出,只有主进程时提示文字也不准确。这个 PR 改为读取原生进程表,由 Core 判定每个进程属于哪一部分并汇总,弹窗按类别重新排版。
改动 / Changes
desktop/internal/sysinfo/process*.go,新增sysinfo.Processes()):proc_listallpids加proc_pid_rusage的ri_phys_footprint(与活动监视器的“内存”列同一口径),负责进程通过responsibility_get_pid_responsible_for_pid(dlsym 取得,取不到时为 0)。PROCESS_MEMORY_COUNTERS_EX2的专用工作集(与任务管理器的“内存”列同一口径)。/proc/<pid>/statm的常驻减共享页。ps或 PowerShell。sysinfo.Resident()和各平台的residentBytes已删除。desktop/internal/core/process_memory.go):Client.SummarizeProcessMemory调用processMemory.summarize,传入进程表和宿主登记的角色(语言服务器、插件服务及其名称)。归属规则在 Core 契约里:主进程、语言服务器、插件服务、子进程(按主进程的直接子进程分组)、系统辅助进程(macOS 负责进程是 Lithe 的进程,按最上层分组);进程号复用、父链成环都有处理。process_memory_test.go回放 Core 的共享 fixturememory-summary-v1.json。desktop/internal/workbench/memory_monitor.go):状态栏项绘制时检查,距上次读取超过 10 秒才读;详情打开时用RequestFrameIn每 2 秒刷新一次,关闭后不安排定时帧,没有空闲轮询。采样从beginPaint移到状态栏项自己的绘制里。读取失败时隐藏数值,不显示过时的数字。插件服务和语言服务器用插件名和语言命名(如“Quill Tools · Quill”)。pluginservice.SampleProcessMemory、processTable、treeMemory和 i18n 词条Status.MemoryValue。SampleProcessTree仍被运行窗口曲线使用,迁移见 [Feature] 运行窗口 CPU/内存曲线改用原生进程表与 Core 汇总,删除 ps/PowerShell 采样 #1925。memory-monitor.json更新证据路径和验证动作(对照活动监视器/任务管理器;从 Finder 或 Dock 启动,见下方限制)。tasks.go、root.go):New里的restoreBackground在窗口绑定唤醒之前就开始解码。解码先完成时,结果在 Viva 丢弃的那次唤醒里排队,要等别的唤醒才应用。现在首帧发现已有排队结果时主动请求一次唤醒。这也是TestMissingBackgroundCopyShowsNoImageQuietly在完整测试里约 1/6 概率失败的原因(preview 上同样会失败)。PINNED_CORE_REVISION升到 Lithe-core-rust#43 的5e2a580(在 mainf88bc49之上)。截图(无头渲染,测试注入虚构的语言服务器和系统辅助进程):
不在本 PR 范围内 / Out of scope
ps/PowerShell 和 RSS([Feature] 运行窗口 CPU/内存曲线改用原生进程表与 Core 汇总,删除 ps/PowerShell 采样 #1925)。make run dev)时,macOS 把 WebKit 辅助进程记在终端名下,所以“系统辅助进程”是 0;从 Finder 或 Dock 启动才能看到。这是系统的归属方式,不是统计错误,弹窗的 ⓘ 说明了这一点。PINNED_CORE_REVISION改成 main 上的 commit。类型专属:fix
复现与根因
0faecba49)的memory_monitor.go只读主进程 RSS 和登记了进程号的会话(见“背景”);详情内容MinWidth(300)超出弹窗默认宽度 288。背景图问题的根因是restoreBackground在窗口绑定Invalidator之前投递结果(Viva 文档写明此时的Invalidate不生效)。检查项
desktop/internal/workbench/memory_monitor_test.go(4 个)、desktop/internal/core/process_memory_test.go、desktop/internal/sysinfo/process_test.go针对新接口编写(Processes、SummarizeProcessMemory、新的弹窗内容),在旧代码上无法编译,所以没有修复前失败的输出;它们断言总量包含子进程和系统辅助进程、类别和名称、读取失败时隐藏数值、0 MB 类别不显示。TestBackgroundRestoredBeforeTheWindowOpensIsApplied(workbench_background_test.go):去掉修复后 5/5 失败,输出background restored before the window opened = {Set:true Name:gone.png ... Loading:true ... Status:正在载入背景图片…};修复后连续 30 次通过。SampleProcessMemory、Resident、residentBytes、Status.MemoryValue已无调用方;SampleProcessTree仍由run_performance.go使用,保留。.agents/notes/implemented/bug-fix/记录:归属规则写在 Core 契约和 fixture 里,回归测试覆盖了两个问题。范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/memory-monitor.json:两端实现状态 implemented、验证状态 pending(未在真机整机验收),证据路径和验证动作已更新./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/preview HEAD.artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空shared/i18n/;插件构建步骤和资源没有写进宿主统一日志系统 / Structured logging
界面文案 / i18n
shared/i18n/补齐中英词条并运行node scripts/i18n/generate-i18n.mjs,没有手改生成文件node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,没有放宽脚本或扩大豁免名单逻辑归属 / Logic placement
processMemory.summarize,契约和 fixture 在 Core PR 里;平台层只读原生进程表和绘制性能与内存 / Performance and memory
ps/PowerShell 子进程设置 / Settings
插件契约 / Plugin contract
N/A:不涉及插件契约、能力版本、插件函数协议和宿主方法;Core PR 只新增应用层命令
processMemory.summarize。发行包与资源 / Bundle and resources
./scripts/desktop/verify/verify-runtime-bundle-immutability.shdocs/assets/memory-details/,是文档资源无用代码与重构 / Dead code and refactoring
SampleProcessMemory、processTable、treeMemory、Resident、residentBytes、Status.MemoryValue)refactor标签的 Issue:[Feature] 运行窗口 CPU/内存曲线改用原生进程表与 Core 汇总,删除 ps/PowerShell 采样 #1925验证 / Verification
cargo test -p lithe-process -p lithe-corecargo fmt --all -- --check、cargo clippy -p lithe-process -p lithe-core --all-targets -- -D warnings、scripts/rust-core/verify-rust-core-comments.shLITHE_CORE_RUST_DIR=<Core 分支> scripts/desktop/desktop-go.sh test ./... -count=1scripts/desktop/desktop-go.sh test ./internal/workbench -count=4TestBackgroundRestoredBeforeTheWindowOpensIsApplied去掉修复 / 加上修复scripts/desktop/desktop-go.sh test ./... -count=1(固定到5e2a580)LITHE_VISUAL_OUTPUT_DIR=... scripts/desktop/desktop-go.sh test -tags vivahead,lithevisual ./internal/workbench -run '^TestVisualMemoryDetails$'GOOS=windows、GOOS=linux对./internal/sysinfo运行go vetnode scripts/i18n/verify-app-language-localization.mjs、node scripts/i18n/generate-i18n.mjs --checknode .agents/skills/write-stable-tests/scripts/verify-test-stability.mjs --base origin/preview./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/preview HEAD./scripts/desktop/verify/verify-runtime-bundle-immutability.sh未能执行的检查和原因:
pluginservice依赖 cgo,无法交叉 vet,只交叉 vet 了sysinfo并人工核对了 Windows 文件的导入);Toolhelp32 和专用工作集的读数需要在 Windows 真机对照任务管理器验证。pending。提交前确认 / Final checks
preview创建,并已合并最新 preview;目标分支preview.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图../.artifacts/desktop/bin/lithe来自主检出,不是本次启动的)