Skip to content

fix(dpns): say what helps when the username key is not on this device - #1076

Merged
lklimek merged 5 commits into
v1.0-devfrom
fix/username-missing-key-restore-hint
Oct 12, 2026
Merged

lklimek merged 5 commits into
v1.0-devfrom
fix/username-missing-key-restore-hint

Conversation

@Claudius-Maginificent

@Claudius-Maginificent Claudius-Maginificent commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR: After an update, an identity could show a disabled "Get a username" button with the advice "Add a key to this identity to register usernames." That advice was wrong whenever the identity already had a suitable key that simply was not on this device. The card now says what actually helps and, when the earlier version saved the key, offers to restore it right there.

User story

As a user who updated Dash Evo Tool and wants a username, I want the app to tell me why the button is disabled and let me fix it from where I am, so that I do not go looking for a way to add a key I already have.

Scenario

Base flow

  1. Update from an earlier version. The identity is there, but its signing key did not come across.
  2. Open the identity's Settings tab and look at the Usernames card.

Actual behavior

  • "Get a username" is disabled and the card says "Add a key to this identity to register usernames."
  • Adding a key is not what helps. The fix is Settings → Restore from Previous Version, which nothing points to.

Expected behavior

The card says why the button is disabled and what helps:

Situation Guidance Action in place
The identity has no suitable key at all "Add a key to this identity to register usernames." (unchanged) Add a key
The earlier version saved the key "The key this identity needs to register usernames is not on this device yet. Restore your keys to register usernames." the existing restore offer with Restore keys
Updated install, nothing to restore in place (for example the wallet itself is missing) "…open Settings and use Restore from Previous Version to bring back missing wallets and keys." Open Settings, Open keys
New install "…Open this identity's keys and enter the key to use it here." Open keys

After a restore the button is enabled. The username registration screen shows the same sentence and links.

Detailed discussion

What was done

  • The check behind the button only looked at the keys held on this device, so one message covered three different situations. A new pure model function, registration_key_status (src/model/dpns_usernames.rs), separates "no suitable key" from "key not on this device" using the keys the identity publishes.
  • No second detection was added. The Usernames card reuses the existing per-identity recovery (LegacyRecoveryState, host_offer, CheckLegacyRecovery, RecoverLegacyIdentityData) unchanged; the identity hub becomes its fourth host. plan_restores_registration_key only asks whether the plan that detection already returned contains a key that can register.
  • The detection task is sent from the hub on a frame with no other action, because AppAction |= keeps only the last action and a background task must not displace a click.
  • The Settings restore is linked, not triggered from the card: its description warns that removed wallets and keys may come back, and that warning should not be bypassed.
  • The registration screen shows the same sentence and links but does not host the offer.
  • Migration is not changed. Reading the current code found no path where a clean update from v0.9.3 loses keys. Pre-release builds before feat(identity): add wallet-derived keys to existing identities #980 could drop keys that did not come from the wallet when identities were rediscovered; records damaged that way are repaired by the restore this PR now points to.
  • docs/user-stories.md (DPN-001) and the usernames redesign spec (USR-FR-005, USR-TC-024) describe the new guidance.

Known limitations:

  • On an updated install the Settings sentence shows for a few frames until detection answers, then the offer appears.
  • Switching to another identity while a restore runs loses the "keys have been restored" notice; the restore itself completes.

Out of scope, not changed here:

  • A saved key that cannot be restored because its wallet is missing is reported with the same reason as a replaced key, and that message is misleading for the missing-wallet case.
  • The button is enabled when the device holds a key entry, without checking that the secret behind it can actually be reached.

Testing

  • cargo test --all-features --test kittest (whole binary): 442 passed.
  • cargo test --all-features --lib -- ui::identity:: model::dpns_usernames recover_legacy_keys: 414 passed.
  • cargo clippy --all-features --profile test --lib --test kittest -- -D warnings: clean.
  • Proven red against the old code first, each failing on the guidance assertion: upgraded_install_without_an_offer_points_to_the_settings_restore, identity_without_its_key_on_this_device_is_told_to_enter_it, usernames_card_without_the_key_on_this_device_offers_to_enter_it, card_offers_the_restore_when_the_previous_version_holds_the_key, card_ignores_a_restore_offer_for_another_identity.
  • card_enables_registration_once_the_restore_completes covers the success path through the hub: after the restore completes the guidance and the offer are gone and "Get a username" opens the registration screen. It fails when the hub stops routing the completed result, when the Settings tab stops re-reading the identity, and when the card never drops its recovery state. The backend restore is not run in it; the stored identity is rewritten with the key.
  • Green from the start (regression guards): identity_without_a_suitable_key_is_told_to_add_one, no_recovery_check_without_a_missing_key_or_previous_version_data, and restoring_a_stranded_signing_key_lets_the_identity_register_usernames, which reproduces the reported state in the backend (record without keys, earlier data holding the key → restore → registration allowed).
  • Not verified: the card was not checked on a real display, and no real updated profile was used. The full library suite was not run locally; CI runs it.

Breaking changes

None.

Prior work

🤖 Co-authored by Claudius the Magnificent AI Agent

🤖 Generated with Claude Code

https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw

PR Hygiene · 6be1b19

  • Bots — coderabbitai skipped by lklimek · thepastaclaw skipped by lklimek
  • Self-review — not asked of a bot author
  • Build green
  • Approvals
    • files with no dedicated owner (CHANGELOG.md, docs/ai-design/2026-10-01-usernames-redesign/01-requirements.md, docs/ai-design/2026-10-01-usernames-redesign/03-test-case-spec.md and 12 more) — approved by lklimek

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

lklimek and others added 4 commits October 12, 2026 12:34
Add registration_key_status, which separates an identity that publishes
no key able to register a username from one whose suitable key is simply
not held on this device, and plan_restores_registration_key, which says
whether a previous-version recovery plan would bring such a key back.

Both are pure and read only data the record and the existing recovery
plan already carry, so the UI can pick the right guidance without a
second detection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The disabled "Get a username" button told every identity that could not
register to add a key. That is only right when the identity has no
suitable key at all. When the key exists but this device does not hold
it, adding a key is neither possible nor what the user needs.

The Usernames card now picks the guidance from the key status:

- no suitable key: unchanged, "Add a key" link;
- key saved by an earlier version and restorable: the existing restore
  offer is hosted in place, with its "Restore keys" button;
- updated install with nothing to offer in place: points to Restore
  from Previous Version, with "Open Settings" and "Open keys" links;
- new install: says to enter the key, with an "Open keys" link.

The identity hub becomes a fourth host of the existing offer. It reuses
LegacyRecoveryState and host_offer unchanged, sends the detection task
only on a frame with no other action so it never displaces a click, and
routes recovery results and errors back to the card. The register screen
shows the same sentence and links without hosting the offer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…istration

Reproduce the state behind the disabled username button after an update:
the identity publishes a key that can register usernames, the stored
record does not hold it, and the previous version's data does. Restore
from Previous Version is what makes the identity able to register.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record the new behaviour in the changelog, add the acceptance bullet to
DPN-001, and align USR-FR-005 and USR-TC-024 with the four cases the
Usernames card now tells apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: dashpay/dash-evo-tool/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 92944c68-4e7f-4a1c-9b09-5209467fab88

📥 Commits

Reviewing files that changed from the base of the PR and between fd1cac8 and 6be1b19.


📒 Files selected for processing (15)
  • CHANGELOG.md
  • docs/ai-design/2026-10-01-usernames-redesign/01-requirements.md
  • docs/ai-design/2026-10-01-usernames-redesign/03-test-case-spec.md
  • docs/user-stories.md
  • src/backend_task/identity/recover_legacy_keys.rs
  • src/context/test_support.rs
  • src/model/dpns_usernames.rs
  • src/ui/identity/hub_screen.rs
  • src/ui/identity/register_dpns_name_screen.rs
  • src/ui/identity/settings.rs
  • src/ui/identity/username_copy.rs
  • src/ui/identity/usernames_card.rs
  • tests/kittest/identity_usernames.rs
  • tests/kittest/main.rs
  • tests/kittest/username_key_hint.rs

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai skipped after its own rate limit · thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Oct 12, 2026
@thepastaclaw

thepastaclaw commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

⏹️ Not reviewed — PR is closed (merged) (commit 6be1b19)

@github-actions github-actions Bot added the bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. label Oct 12, 2026

@thepastaclaw thepastaclaw left a comment

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.

Final validation — Phase 2 only (no Phase 1 for this repository)

The supplied Phase-2 finding is valid: the new Usernames card tests cover restore dispatch and failure/retry, but not successful completion followed by registration-ready UI reconciliation. This is a non-blocking coverage improvement; no blocking defect was established. Verification was static, and the supplied exact-head CI snapshot reports successful Test Suite, Clippy, and platform-pin checks, with PR Hygiene pending.

🟡 1 suggestion(s)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This cross-cutting model and UI change adds registration-key classification and reuses existing recovery workflows, but does not itself change key storage, signing, cryptography, or migration logic.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `tests/kittest/username_key_hint.rs`:
- [SUGGESTION] tests/kittest/username_key_hint.rs:184-190: Cover the card becoming registration-ready after a successful restore
  This test verifies the restore offer, dispatched items, in-flight guard, and failure/retry transition, but never delivers a successful completion. The new hub host relies on SettingsTab re-reading the persisted identity on a subsequent frame and UsernamesCard then dropping its recovery state. The backend regression exercises the Settings-wide legacy_restore::run path, and the existing SettingsTab unit test checks identity replacement in isolation; neither covers this card-specific success transition. Add a companion test that updates the stored identity to hold the signing key, delivers LegacyRecoveryCompleted through display_backend_task_result using the dispatched context, renders subsequent frames, and asserts that the missing-key guidance and restore offer disappear and clicking "Get a username" emits the registration-screen action. This protects the PR's explicit promise that restoring the key enables registration without leaving the card.

Comment thread tests/kittest/username_key_hint.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Ready for review — files with no dedicated owner: lklimek.
Full checklist in the description.

@github-actions github-actions Bot added ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. and removed waiting-bots Waiting for the review bots to report on this head labels Oct 12, 2026
@github-actions
github-actions Bot requested a review from lklimek October 12, 2026 14:01
The card test delivered the restore offer, the dispatch and a failed
restore, but never a successful completion. Add the success path through
the identity hub: the stored record gains the key, the completion is
delivered on the dispatched context, and the card then drops the
guidance and the offer, confirms the restore, sends no further check of
the previous version's data, and opens the registration screen from
"Get a username".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Oct 12, 2026
@lklimek
lklimek enabled auto-merge (squash) October 12, 2026 14:18
@lklimek

lklimek commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

/skip-bots

@github-actions github-actions Bot added bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@lklimek
lklimek merged commit 2173481 into v1.0-dev Oct 12, 2026
12 checks passed
@lklimek
lklimek deleted the fix/username-missing-key-restore-hint branch October 12, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-review-skipped A required review bot did not report; it was skipped by the window or by a person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants