Skip to content

[BWA-99] feat: Add preview next TOTP code setting#6840

Closed
aj-rosado wants to merge 4 commits intomainfrom
BWA-99/add-preview-next-totp-code-setting
Closed

[BWA-99] feat: Add preview next TOTP code setting#6840
aj-rosado wants to merge 4 commits intomainfrom
BWA-99/add-preview-next-totp-code-setting

Conversation

@aj-rosado
Copy link
Copy Markdown
Contributor

🎟️ Tracking

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

📔 Objective

Adds a user-controlled toggle in the Authenticator Settings screen that, when enabled, displays the upcoming TOTP code below the current code for each item in the authenticator list. The next code appears only in the last 10 seconds of the current period, giving users a heads-up before rollover without cluttering the UI throughout the full 30-second window.

Changes by layer:

  • PersistenceSettingsDiskSource/SettingsRepository: new showNextTotpCode: Boolean setting stored in SharedPreferences (default false), exposed as a StateFlow.
  • TOTP managerTotpCodeManagerImpl: on code regeneration, calls generateTotp(uri, issueTime + periodSeconds) to populate VerificationCodeItem.nextCode for TOTP items; HOTP items are excluded.
  • MappingVerificationCodeItemExtensions.toDisplayItem(): maps nextCode → nextAuthCode only when showNextTotpCode = true and timeLeftSeconds ≤ 10.
  • ViewModel wiringItemListingViewModel: caches getLocalVerificationCodesFlow() as a class property (fixes a bug where re-creating the flow on each call returned DataState.Loading); observes showNextTotpCodeStateFlow via an internal action.
  • Settings UISettingsViewModel/SettingsScreen: new BitwardenSwitch with label "Show next code" / sublabel "See incoming codes in the list".
  • List item UIVaultVerificationCodeItem: renders next code below the current code when nextAuthCode is non-null, with localized TalkBack content description ("Next code, [code]").

📸 Screenshots

Adds a user-controlled "Show next code" toggle in authenticator
settings. When enabled, the upcoming TOTP code is rendered below the
current code for each TOTP item in the list, letting users see incoming
codes without waiting for the rollover. HOTP items are excluded since
next-code generation requires advancing the counter.
- Localize next-code contentDescription via stringResource (next_code_x)
- Use startsWith instead of contains for HOTP URI prefix check
- Remove no-op nextCode assignment in copy() time-update branch
…g bug

- Cache getLocalVerificationCodesFlow() as a class property so
  handleShowNextTotpCodeReceive reads from the already-subscribed
  flow instead of a new unsubscribed instance that always returns
  DataState.Loading (which caused the next code to never appear)
- Add 10-second threshold: next code is only shown when timeLeftSeconds
  is at or below 10 seconds remaining in the current period
- Update tests for the threshold (timeLeftSeconds = 5 / 10 / 11 cases)
@aj-rosado aj-rosado added the ai-review-vnext Request a Claude code review using the vNext workflow label Apr 27, 2026
@aj-rosado aj-rosado closed this May 8, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant