Skip to content

fix(hosts): keep a saved secret that can't be decrypted when editing a host - #89

Merged
AndreaCovelli merged 1 commit into
mainfrom
fix/host-edit-keep-unreadable-secret
Nov 5, 2026
Merged

AndreaCovelli merged 1 commit into
mainfrom
fix/host-edit-keep-unreadable-secret

Conversation

@AndreaCovelli

Copy link
Copy Markdown
Owner

Summary

Fixes #88. Editing any field of a host, even just its name, erased a saved password or key passphrase that couldn't be decrypted. The host then stopped being reported as unreadable, so backups exported it without its secret.

  • Saving: HostProfileDao keeps the stored value when an empty one is saved over a secret that can't be opened. A typed value still replaces it, and an empty value still clears a secret that opens normally.
  • Clearing: only the new Clear button erases an unreadable secret, on Save, through replaceDiscarding. Turning the passphrase switch off or picking another key no longer erases one.
  • Notice: the Authentication section reports each unreadable secret whichever auth method is selected, because such a host blocks backup export even when the secret isn't in use.
  • Copying: sealed values are bound to their row, so a copy can't carry the secret. Its form says the secret wasn't copied, with no Clear button, and the original host is unchanged.

UnsavedGeneratedKey is the generated-key cleanup moved out of AddServerViewModel, with no behaviour change. The new method put the class at Detekt's function limit.

Deleting an SSH key still clears the passphrase of hosts that use it through clearKeyReference, readable or not. I left that as is, since the passphrase has no key left to unlock.

Testing

  • mise run check passes.
  • New SealedDaoTest cases cover keeping, replacing, discarding, and clearing a readable secret. With the old overwrite temporarily restored, the keeping and replacing tests fail.
  • New AddServerFormTest cases cover the notices and the clear state.
  • Not run: no device was available, so the notice and the Clear button haven't been seen on screen, the view model's load and save wiring has no direct test, and the instrumented tests were only compiled. The native bridge, SSH, Mosh, and the terminal aren't touched.

🤖 Generated with Claude Code

…a host

Reading a host turned a secret that can't be opened into an empty string, so
saving the edit form replaced the stored ciphertext with nothing. Editing any
field did this, and the host then stopped being reported as unreadable, so
backups exported it without its secret.

The DAO now keeps the stored value when an empty one is saved over a secret
that can't be opened. Erasing it takes an explicit discard, which the form's
new Clear button requests. The form reports each unreadable secret whichever
auth method is selected, and a copied host says the secret wasn't copied.

The generated key cleanup moves to UnsavedGeneratedKey, unchanged, to keep
AddServerViewModel under Detekt's function limit.

Fixes #88

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AndreaCovelli
AndreaCovelli merged commit 5e7c9c3 into main Nov 5, 2026
5 checks passed
@AndreaCovelli
AndreaCovelli deleted the fix/host-edit-keep-unreadable-secret branch November 5, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix host edit erasing a secret that can't be decrypted

1 participant