Repository navigation
feat(fetcher): extend system kind with CPU/memory/kernel/DMI/env identifiers - #225
Conversation
…entifiers Adds 25 single-Text `kind` variants to the omnibus `system` fetcher, covering the static identifier reads listed in #62: - CPU: cpu_model / cpu_cores / cpu_frequency / cpu_vendor (sysinfo, with a /proc/cpuinfo fallback for cpu_frequency on WSL and containers where sysinfo reports 0) - Memory: memory_total / swap_total (sysinfo, cached via OnceLock) - Kernel: kernel / kernel_version - DMI hardware IDs: host_model / host_vendor / host_serial / board_vendor / board_model / bios_vendor / bios_version / bios_date / chassis (Linux reads /sys/class/dmi/id/*; non-Linux returns "n/a"; chassis_type code mapped via the SMBIOS 7.4.1 table) - Locale / TZ: locale (LC_ALL > LC_CTYPE > LANG, fallback "C"), timezone ($TZ then /etc/localtime symlink) - Env tools: editor / visual / pager ($EDITOR / $VISUAL / $PAGER, file basename, "(unset)" fallback) - Desktop: de ($XDG_CURRENT_DESKTOP family, "tty" fallback), wm ($XDG_SESSION_DESKTOP with wayland/x11 detection), init_system (/proc/1/comm on Linux, launchd/wininit elsewhere) Static identifier reads (CPU model/vendor/freq, memory/swap totals) are cached in OnceLocks since they don't change after boot. DMI reads live in a new `system_dmi` module so the per-platform conditionals stay isolated. GPU (`gpu_model` / `gpu_vendor` / `gpu_driver`) and `keymap` are deferred to a follow-up: GPU needs NVML or a PCI ID lookup table, keymap needs /etc/vconsole.conf parsing on Linux only. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR expands SystemFetcher to expose CPU, memory, kernel, DMI/SMBIOS hardware IDs, and environment/locale settings by adding a DMI reader module, extending SystemKind with many new variants, and wiring detection helpers with tests. ChangesHost Identity Detection Expansion
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/fetcher/system.rs (1)
207-240:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAvoid per-frame filesystem reads in realtime
systemtext kinds.
resolve_system_kindroutes realtime text kinds to helpers that hit disk (system_dmi::*,/etc/localtimepath resolution). That breaks the realtime no-I/O contract and can introduce frame jitter.Suggested direction
+// cache static identifiers once; clone on read +fn cached_timezone() -> String { + static TZ: OnceLock<String> = OnceLock::new(); + TZ.get_or_init(detect_timezone_uncached).clone() +} + +fn cached_dmi(kind: SystemKind) -> String { + // one OnceLock per DMI field (or a single struct cache) + // fill from system_dmi::* once, then reuse +}- SystemKind::Timezone => detect_timezone(), - SystemKind::HostModel => dmi_or_na(system_dmi::host_model()), + SystemKind::Timezone => cached_timezone(), + SystemKind::HostModel => cached_host_model(),
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e7d0b9b8-d12c-461f-95e0-5749c1d656f0
📒 Files selected for processing (3)
src/fetcher/mod.rssrc/fetcher/system.rssrc/fetcher/system_dmi.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #225 +/- ##
==========================================
- Coverage 95.28% 95.16% -0.13%
==========================================
Files 160 161 +1
Lines 47769 48131 +362
==========================================
+ Hits 45518 45805 +287
- Misses 2251 2326 +75
🚀 New features to boost your workflow:
|
`fetch_uses_current_repo_for_default_and_explicit_shapes` calls `open_repo()` which reads `std::env::current_dir()`. Other tests in the crate (latest_tag, recent_commits, contributors, code::loc, code::todos, ...) mutate the process-wide CWD via `set_current_dir` inside `TEST_ENV_LOCK`; this one didn't take the lock, so when the scheduler interleaved them on CI the stash_count test would observe a tempdir CWD and fail with `'/tmp/.tmpXxxx/.git/objects' wasn't a directory`. Mirror the lock pattern used by `latest_tag.rs::fetch_opens_cwd_repo_for_default_and_entries_shapes`. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Adds 25 single-Text
kindvariants to the omnibussystemfetcher, ticking the Extendsystemkindcheckbox in #62. Covers static identifier reads grouped as: CPU (model / cores / frequency / vendor), memory totals (memory / swap), kernel (name / version), Linux DMI hardware IDs (host / board / BIOS / chassis), locale / timezone, env tools ($EDITOR/$VISUAL/$PAGER), and desktop session (DE / WM / init system).OnceLocksince they don't change after boot.cpu_frequencyfalls back to/proc/cpuinfowhen sysinfo returns 0 (WSL, some containers).system_dmimodule isolating the Linux-specific/sys/class/dmi/id/*paths; macOS / Windows return"n/a"until IOKit / WMI bindings land.chassis_typemapped via the SMBIOS 7.4.1 code table."(unset)"so labels and values don't collide visually.Deferred to follow-up:
gpu_model/gpu_vendor/gpu_driver(needs NVML or a PCI ID lookup table) andkeymap(Linux/etc/vconsole.confparser).Reference
kindvalues addedcpu_model,cpu_cores,cpu_frequency,cpu_vendormemory_total,swap_totalkernel,kernel_versionhost_model,host_vendor,host_serial,board_vendor,board_model,bios_vendor,bios_version,bios_date,chassislocale,timezoneeditor,visual,pagerde,wm,init_systemSample output (WSL2 host)
Reference page (auto-generated):
docs-site/src/content/docs/reference/fetchers/system/system.md.Test plan
cargo fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo test(2200 tests, all green)cargo run --bin splashboard -- catalog fetcher systemshows the expandedkindschema.splashboard/dashboard.tomlwithcargo run --bin splashboardon a WSL2 host: every variant renders without panic; sysinfo-cached reads return real values; DMI falls back to"n/a"as designed🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests