Skip to content

[PM-37884] fix: Show the scan card button when editing a card - #3015

Merged
matt-livefront merged 2 commits into
mainfrom
pm-37884-card-scan-button-in-edit-mode
Sep 10, 2026
Merged

[PM-37884] fix: Show the scan card button when editing a card#3015
matt-livefront merged 2 commits into
mainfrom
pm-37884-card-scan-button-in-edit-mode

Conversation

@andrebispo5

@andrebispo5 andrebispo5 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🎟️ Tracking

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

📔 Objective

The "Scan card" button never showed up when editing an existing card, only when adding a new one.

  • The edit screen listens for cipher updates, and every update rebuilt the card state straight from the cipher
  • That rebuild threw away cardScannerEnabled, which the feature flag had just set, so the button disappeared before anyone could see it
  • Adding a card was fine because that flow has no cipher to stream yet
  • The card state now carries the scanner values over when it's rebuilt, so the button sticks around (and an incoming sync no longer closes the scanner sheet mid-scan)
  • Added tests on both CipherItemState and AddEditItemProcessor that fail without the fix

📸 Screenshots

Before After

@github-actions github-actions Bot added app:password-manager Bitwarden Password Manager app context t:bug Change Type - Bug labels Sep 2, 2026
@andrebispo5
andrebispo5 marked this pull request as ready for review September 2, 2026 15:56
Copilot AI lite review requested due to automatic review settings September 2, 2026 15:56
@andrebispo5
andrebispo5 requested review from a team and matt-livefront as code owners September 2, 2026 15:56
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed a targeted bug fix that keeps the card scanner's UI-only state (cardScannerEnabled, isCardScannerPresented) intact when CipherItemState.apply(cipherView:) rebuilds cardItemState from a streamed cipher update. The new preservingCardScannerState(from:) helper reads the existing (defaulted) cardItemState, so the clone and existing: initializers are unaffected and only the streaming path changes behavior. No security, zero-knowledge, or data-handling concerns: no vault data is logged, persisted, or newly exposed, and the preserved fields are presentation flags. Both new tests target the regression directly at the CipherItemState and AddEditItemProcessor layers and would fail without the fix.

Code Review Details

No findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The fix is localized, aligns with the stated root cause, and includes targeted regression tests covering both the state update and streaming update path.

Pull request overview

Fixes a regression in the Add/Edit Card flow where the “Scan card” button (and ongoing scanner sheet) would disappear during edit due to cipher detail streaming rebuilding CipherItemState from CipherView and dropping scanner-related UI/feature-flag state.

Changes:

  • Preserve card scanner UI/feature-flag state when rebuilding CipherItemState from an updated CipherView.
  • Add unit coverage to ensure CipherItemState.update(from:) and the .streamCipherDetails flow retain scanner state across cipher updates.
File summaries
File Description
BitwardenShared/UI/Vault/VaultItem/CipherItemState.swift Preserves scanner state when re-deriving cardItemState from CipherView.
BitwardenShared/UI/Vault/VaultItem/AddEditItem/AddEditCardItem/CardItemState.swift Adds helper to carry scanner-related fields across state rebuilds.
BitwardenShared/UI/Vault/VaultItem/CipherItemStateTests.swift Adds test verifying update(from:) keeps scanner state while still updating card fields.
BitwardenShared/UI/Vault/VaultItem/AddEditItem/AddEditItemProcessorTests.swift Adds test verifying streaming cipher updates don’t clear scanner state during edit.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.88%. Comparing base (3eba708) to head (b067736).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3015      +/-   ##
==========================================
+ Coverage   79.60%   81.88%   +2.27%     
==========================================
  Files        1169     1046     -123     
  Lines       75195    67904    -7291     
==========================================
- Hits        59862    55603    -4259     
+ Misses      15333    12301    -3032     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@speedy1804

Copy link
Copy Markdown

@andrebispo5 @matt-livefront
Hi, sorry to bother you, but I have a question:
The initial pull requests for the "camera scan" feature were merged quite a while ago, yet the feature still isn't available in the Bitwarden app (the button is missing). Is this intentional—meaning the feature flag simply hasn't been disabled yet—or is it a bug?
I’d really appreciate an answer.
Regards, Speedy 😃

@matt-livefront
matt-livefront merged commit b5e799b into main Sep 10, 2026
24 of 25 checks passed
@matt-livefront
matt-livefront deleted the pm-37884-card-scan-button-in-edit-mode branch September 10, 2026 16:51
@matt-livefront

Copy link
Copy Markdown
Collaborator

@andrebispo5 @matt-livefront Hi, sorry to bother you, but I have a question: The initial pull requests for the "camera scan" feature were merged quite a while ago, yet the feature still isn't available in the Bitwarden app (the button is missing). Is this intentional—meaning the feature flag simply hasn't been disabled yet—or is it a bug? I’d really appreciate an answer. Regards, Speedy 😃

@speedy1804 Yes, this feature is still behind a feature flag which is currently off. I'm not sure if we're waiting on anything else other than this fix to enable it, but I will check.

@speedy1804

Copy link
Copy Markdown

@matt-livefront Thank you so much for your reply and the clarity!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app:password-manager Bitwarden Password Manager app context t:bug Change Type - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants