Skip to content

[PM-9420] - add cipher$ observable to cipher service#21383

Draft
jaasen-livefront wants to merge 1 commit into
mainfrom
PM-9420
Draft

[PM-9420] - add cipher$ observable to cipher service#21383
jaasen-livefront wants to merge 1 commit into
mainfrom
PM-9420

Conversation

@jaasen-livefront

Copy link
Copy Markdown
Collaborator

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-9420

📔 Objective

This PR adds a shared cipherView$ method to CipherService for retrieving a single decrypted CipherView from local vault state by cipher ID.

It replaces several direct get + decrypt call sites with cipherView$, ensuring consumers use the already-decrypted local cipher views and receive updates consistently when vault state changes.

Changes include:

  • Added cipherView$(userId, cipherId) to the cipher service abstraction and implementation.
  • Updated browser and web vault flows to use cipherView$.
  • Updated vault item dialog refresh/cancel behavior to reload from local decrypted state.
  • Added unit coverage for matching, missing, and nullish cipher view state.

📸 Screenshots

N/A

@jaasen-livefront jaasen-livefront requested a review from a team as a code owner June 19, 2026 01:24
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the new cipherView$(userId, cipherId) method added to CipherService (abstraction + implementation) and the call sites migrated from the get + decrypt pattern across browser, web, and the shared vault-item dialog. The refactor is consistent, the new method has unit coverage for matching, missing, and nullish (cipherViews$ === null) cases, and the behavioral differences at each call site are equivalent to or an improvement over the prior code.

Code Review Details

No findings at or above the reporting threshold.

Notes from the analysis (no action required):

  • The new cipherView$ can emit undefined for a missing cipher. Several call sites (open-attachments, web vault getPasswordFromCipherViewLike, vault-item-dialog.processChanges) dereference the result without a null guard, but each already dereferenced an effectively-equivalent unguarded result in the prior get + decrypt code, so this is not a newly introduced regression.
  • assign-collections.component.ts adds filter((cipher): cipher is CipherView => cipher != null), which correctly waits for a valid decrypted cipher before the downstream combineLatest fires.
  • All consumers wrap cipherView$ in firstValueFrom, taking only the first emission, which is the correct usage for these one-shot reads.

@sonarqubecloud

Copy link
Copy Markdown

@jaasen-livefront jaasen-livefront marked this pull request as draft June 19, 2026 06:17
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.

1 participant