feat: edit existing secrets in-place for sops-nix and agenix - #658
feat: edit existing secrets in-place for sops-nix and agenix#658Scott McMaster (scottmcmaster) wants to merge 2 commits into
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.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
📋 PR Overview
🔬 Coverage
|
🎨 Storybook previewUpdated for c78dc70 🧭 Story changesCompared to ✏️ Changed stories (8)
|
There was a problem hiding this comment.
Pull request overview
This PR wires up the previously stubbed "edit secret value" flow for both the sops-nix and agenix backends. On the backend it adds an edit_secret command that decrypts the existing encrypted file, replaces the requested value in place (preserving the declaration, file location, backend, and recipients), re-encrypts, runs a dry darwin-rebuild check, and commits — with best-effort rollback on failure. On the frontend it reuses AddSecretView in an "edit" mode that hides the add-only controls, and replaces the "not implemented" edit button with a real one. It also extracts the YAML helpers (replace_yaml_path, remove_yaml_path, validate_yaml_syntax) into a new shared yaml_utils module.
Changes:
- New Rust
edit_secretbackend (SOPS + agenix), including conservative recovery of a SOPS repo source file from its evaluated/nix/storepath, plus theeditSecretorpc route andEditSecretResultshared type. - Frontend edit flow:
AddSecretViewgains an optionalsecretprop /buildEditRequest,SecretDetailViewexposesonEdit, andSecretsManagementroutes the neweditview toeditSecret. - Refactor: YAML utilities moved to
yaml_utils.rswith expanded unit tests.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/native/src-tauri/src/secrets/secrets_management.rs | Adds edit_secret/edit_sops_secret/edit_age_secret, SOPS store-path source recovery, and tests |
| apps/native/src-tauri/src/yaml_utils.rs | New module hosting YAML path replace/remove/validate helpers + tests |
| apps/native/src-tauri/src/evolve/file_ops.rs | Moves validate_yaml_syntax (and its tests) into yaml_utils |
| apps/native/src-tauri/src/main.rs | Declares the new yaml_utils top-level module |
| apps/native/src-tauri/src/orpc/secrets.rs | Adds editSecret input type, handler, and route |
| apps/native/src-tauri/src/shared_types/secrets_management.rs | Adds EditSecretResult |
| apps/native/src/ipc/orpc-bindings.ts | Generated EditSecretInput/EditSecretResult + editSecret client |
| apps/native/src/components/widget/secrets/add-secret-view.tsx | Edit mode support and buildEditRequest |
| apps/native/src/components/widget/secrets/add-secret-view.test.ts | Tests for buildEditRequest |
| apps/native/src/components/widget/secrets/secret-detail-view.tsx | Replaces stub edit button with real onEdit; removes canEdit |
| apps/native/src/components/widget/secrets/secrets-management.tsx | Routes edit view and calls editSecret |
| apps/native/src/components/widget/secrets/types.ts | Adds edit view kind and edit apply origin |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
I addressed the two gaps:
|






Summary
Hook up the edit functionality for secrets for both SOPS and agenix.
ATTENTION
a. For age, the updated value keeps the same recipients.
b. For SOPS, we use what's currently in the repo's .sops.yaml.
Also did some refactoring of the YAML-related utility methods, and enhanced some of the unit tests.
Screenshots (note that I hid all of the extra controls from the "add" flow since they were distracting and not directly relevant to the "edit" flow but per prelint comments recipients are included):
Test Plan
New unit tests in Rust and TypeScript, manually tested the SOPS and age paths in the UI.
Docs