Skip to content

[BWA-99] feat: Add next TOTP code preview in Authenticator#6779

Open
SaintPatrck wants to merge 4 commits intomainfrom
bwa-99/next-totp-code-preview
Open

[BWA-99] feat: Add next TOTP code preview in Authenticator#6779
SaintPatrck wants to merge 4 commits intomainfrom
bwa-99/next-totp-code-preview

Conversation

@SaintPatrck
Copy link
Copy Markdown
Contributor

@SaintPatrck SaintPatrck commented Apr 9, 2026

🎟️ Tracking

https://bitwarden.atlassian.net/browse/BWA-99

📔 Objective

Add a "next TOTP code" preview to the Authenticator app. When a verification code is about to expire (< 10 seconds remaining), the upcoming code is displayed below the current one, allowing users to pre-read the next code without waiting for rotation.

Key behaviors:

  • Next code appears only when timeLeftSeconds < 10
  • Displayed in smaller, secondary-color text below the current code
  • Controlled by a "Show next code" toggle in Settings > Data (default: off)
  • Tapping an item still copies the current code

Implementation details:

  • Data layer: Second generateTotp() SDK call with currentTime + periodSeconds
  • Settings: Full DiskSource → Repository → ViewModel → Screen chain for the toggle
  • UI: Conditional rendering in VaultVerificationCodeItem composable
  • Wired through both ItemListingViewModel and ItemSearchViewModel

📸 Screenshots

Settings

Figma Actual

Disclaimer: Figma includes the new Switch row, but other settings are outdated.

Upcoming code

Screen_recording_20260410_090617.mp4

Allow users to see the upcoming TOTP code when the current code
is about to expire (< 10 seconds remaining). Controlled by a
"Show next code" toggle in Settings > Data, defaulting to off.
@SaintPatrck SaintPatrck added the ai-review-vnext Request a Claude code review using the vNext workflow label Apr 9, 2026
@github-actions github-actions bot added app:password-manager Bitwarden Password Manager app context app:authenticator Bitwarden Authenticator app context t:feature Change Type - Feature Development labels Apr 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR adds a "next TOTP code" preview feature to the Authenticator app, displaying the upcoming verification code when fewer than 10 seconds remain before rotation. The implementation spans the full stack: data layer (second generateTotp() SDK call), settings persistence (DiskSource through Repository through ViewModel), and UI (animated visibility with AnimateNullableContentVisibility). All changes follow established codebase patterns, and test coverage is thorough across all layers including threshold boundary conditions, toggle filtering, and failure handling.

Code Review Details

No findings. The implementation is clean and well-structured:

  • Data layer gracefully handles next code generation failures via getOrNull()?.code
  • Settings chain follows the exact pattern used by existing settings (crash logging, screen capture)
  • UI filtering via takeIf keeps the data layer setting-unaware
  • Test coverage addresses all key scenarios: positive case, disabled setting, above-threshold, and SDK failure

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 97.87234% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.41%. Comparing base (62ceab5) to head (f7f816f).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...data/platform/repository/SettingsRepositoryImpl.kt 88.88% 0 Missing and 1 partial ⚠️
...tor/ui/platform/feature/settings/SettingsScreen.kt 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6779      +/-   ##
==========================================
+ Coverage   84.69%   85.41%   +0.71%     
==========================================
  Files         850      958     +108     
  Lines       59258    61011    +1753     
  Branches     8598     8662      +64     
==========================================
+ Hits        50188    52111    +1923     
+ Misses       6070     5876     -194     
- Partials     3000     3024      +24     
Flag Coverage Δ
app-data 17.56% <0.00%> (+0.08%) ⬆️
app-ui-auth-tools 20.69% <0.00%> (+0.31%) ⬆️
app-ui-platform 15.87% <0.00%> (+0.58%) ⬆️
app-ui-vault 26.51% <0.00%> (+0.53%) ⬆️
authenticator 6.73% <97.87%> (+0.14%) ⬆️
lib-core-network-bridge 4.30% <0.00%> (+0.01%) ⬆️
lib-data-ui 1.04% <0.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Logo
Checkmarx One – Scan Summary & Detailsc3d3354a-6757-4131-b42c-fe085f2f3af1

Great job! No new security vulnerabilities introduced in this pull request

Cover SettingsDiskSourceImpl, SettingsRepositoryImpl, SettingsViewModel
toggle/update handlers, and TotpCodeManager next code failure fallback.
@SaintPatrck SaintPatrck marked this pull request as ready for review April 9, 2026 20:56
@SaintPatrck SaintPatrck requested review from a team and david-livefront as code owners April 9, 2026 20:56
@SaintPatrck SaintPatrck requested a review from RishikaSG-28 April 9, 2026 20:58
) {
val formattedNextCode = nextAuthCode
.chunked(size = 3) { "$it" }
.joinToString(separator = " ")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be:

val formattedNextCode = nextAuthCode
    .chunked(size = 3) { it.padEnd(length = 3, padChar = ' ') }
    .joinToString(separator = " ")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ohh, I didn't realize this is for the content description.

Do we want it chunked at all?

@SaintPatrck SaintPatrck force-pushed the bwa-99/next-totp-code-preview branch 2 times, most recently from e07396b to d2441b7 Compare April 10, 2026 13:04
@SaintPatrck SaintPatrck force-pushed the bwa-99/next-totp-code-preview branch from d2441b7 to f7f816f Compare April 10, 2026 13:41
* @property timeLeftSeconds The seconds remaining until a new code is required.
* @property issueTime The time the verification code was issued.
* @property id The cipher id of the item.
* @property username The username associated with the item.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was bugging me. Thank you for removing it. lol

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same 😆

<string name="allow_camera_access">Allow camera access</string>
<string name="to_scan_your_card_we_need_access_to_your_camera">To scan your card, we’ll need access to your camera. You can change this anytime in your device settings.</string>
<string name="show_next_code">Show next code</string>
<string name="see_incoming_codes_in_the_list">See incoming codes in the list</string>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this say See upcoming codes in the list?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This matches Figma (added a screenshot). "Upcoming" does sound a little better though. @RishikaSG-28 thoughts?

<string name="to_scan_your_card_we_need_access_to_your_camera">To scan your card, we’ll need access to your camera. You can change this anytime in your device settings.</string>
<string name="show_next_code">Show next code</string>
<string name="see_incoming_codes_in_the_list">See incoming codes in the list</string>
<string name="next_code_x">Next code, %1$s</string>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this be Next code: %1$s?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm. Probably. This was a last minute addition on Claude's part. @RishikaSG-28 thoughts?

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

Labels

ai-review-vnext Request a Claude code review using the vNext workflow app:authenticator Bitwarden Authenticator app context app:password-manager Bitwarden Password Manager app context t:feature Change Type - Feature Development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants