feat: direct system-defaults apply path, fix found issues in the existing system-defaults defs#406
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
📋 PR Overview
🔬 Coverage
|
There was a problem hiding this comment.
Pull request overview
This PR wires “system defaults” untracked items into a direct managed-edit apply flow (similar to Homebrew), rather than routing through prompt seeding, and hardens the macOS defaults scanner so its generated Nix matches nix-darwin option types (including null defaults and int→string mappings).
Changes:
- Added a refreshable
useSystemDefaultsScanhook and used it to re-scan after applying defaults. - Extended the Filesystem “Untracked” UI to support a direct “track/apply” path for system defaults candidates.
- Updated the Rust system-defaults scanner typing/comparison and Nix generation (null sentinel + int→string mapping support), plus unit tests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/native/src/hooks/use-system-defaults-scan.ts | Adds a memoized refresh() API and exposes it to callers. |
| apps/native/src/components/widget/filesystem/untracked-card.tsx | Routes “Track” actions to system-defaults direct apply when applicable, otherwise falls back to prompt seeding. |
| apps/native/src/components/widget/filesystem/filesystem-step.tsx | Implements onTrackSystemDefaults (direct apply) and refreshes the scan after applying. |
| apps/native/src/components/widget/filesystem/file-list.tsx | Plumbs the new system-defaults tracking handler through the file list. |
| apps/native/src/components/widget/filesystem/data.ts | Adds a helper to detect the system-defaults candidate section. |
| apps/native/src-tauri/src/system/scanner.rs | Adds NULL_FLAG, StringFromIntMap, updated comparison logic, and Nix generation enhancements with tests. |
Comments suppressed due to low confidence (1)
apps/native/src-tauri/src/system/scanner.rs:1617
default_valueis sent to the frontend as-is. When the factory default isNULL_FLAG, this leaks the internal sentinel string ("NULL") into UI strings like "default: …" and any previewed Nix snippet metadata. Consider translating the sentinel to something user-facing (e.g. "null") before returning it.
defaults.push(SystemDefault {
nix_key: def.nix_key.to_string(),
label: def.label.to_string(),
category: def.category.to_string(),
current_value: current.to_string(),
default_value: def.factory_default.to_string(),
});

Summary
The main business purpose of this change is to wire the system defaults edits up directly rather than applying them through the agent prompt. That wiring was actually more straightforward than I expected from the existing code. But when I started trying to build some actual changes based on this, I ran into other issues I had to fix:
defaultsas an int but defined as a string in nix-darwin. So I added a new ValType for mappings and updated the KeyDefs as appropriate.As of right now, then, everything is at least plausible enough to pass through nix-eval, although I think we need to have more discussion about how we maintain this code. I'll open that up separately.
Test Plan
Some minor unit test changes, and lots of manual testing including the aforementioned new code-based way to make sure that every option is typed correctly in the KeyDefs.
Docs