Skip to content

fix(crypto): open encrypted note after setting a passphrase from the unlock prompt - #56

Draft
kodinkod wants to merge 1 commit into
mainfrom
claude/lucid-newton-1zahjf
Draft

kodinkod wants to merge 1 commit into
mainfrom
claude/lucid-newton-1zahjf

Conversation

@kodinkod

Copy link
Copy Markdown
Member

Summary

Fixes a bug where clicking a locked encrypted note (.md.age), being prompted to set a password, setting it, and then having the note silently fail to open — nothing happened.

Clicking a .md.age note while the vault is locked calls requireUnlock (src/stores/crypto.ts), which registers a pending promise and opens the crypto panel. When that panel opens in setup / set-passphrase mode (this device isn't enrolled yet, or no passphrase is set), the user sets a password rather than unlocking.

Both crypto_setup and crypto_set_passphrase auto-unlock the vault on the Rust side, but only the store's unlock() resolved the pending promise. So after a successful setup the form's onDone closed the panel, closePanel rejected the pending promise as if it were a user cancel, and openNote bailed out silently — the note never opened.

The fix resolves the pending unlock from setup and setPassphrase too (once a status refresh confirms the vault is unlocked), via a shared resolvePendingUnlock helper now also used by unlock.

Related issues

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / chore
  • Breaking change

How was this tested?

  • npm run lint passes
  • npm run build passes (tsc && vite build, exit 0)
  • cargo fmt --check && cargo clippy — not run (no Rust changes)
  • cargo test — not run (no Rust changes)
  • Traced the affected flow: setup/set-passphrase now resolve the requireUnlock promise so openNote proceeds to note_read instead of treating the panel close as a cancel

Screenshots / recordings

Contributor License Agreement

  • I have read the Mycel CLA and I agree to it for this and all my future contributions.
  • My contribution is my original work, or I have clearly identified any third-party material and its license.

🤖 Generated with Claude Code

https://claude.ai/code/session_01M2CsK2HG7jUuJBVi94t7Jk


Generated by Claude Code

…unlock prompt

Clicking a `.md.age` note while the vault is locked calls `requireUnlock`,
which registers a pending promise and opens the crypto panel. When that
panel opens in setup / set-passphrase mode (device not yet enrolled, or
no passphrase set), the user "sets a password" instead of "unlocking".

Both `crypto_setup` and `crypto_set_passphrase` auto-unlock the vault in
Rust, but only the store's `unlock()` resolved the pending promise. So
after a successful setup the form's `onDone` closed the panel,
`closePanel` rejected the pending promise as a cancel, and `openNote`
silently bailed out — the note never opened and nothing happened.

Resolve the pending unlock from `setup` and `setPassphrase` too (once a
status refresh confirms the vault is unlocked), via a shared
`resolvePendingUnlock` helper now also used by `unlock`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M2CsK2HG7jUuJBVi94t7Jk
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

3 participants