-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CLI] shared recovery invitation #9232
Conversation
ed656aa
to
28dfa32
Compare
f406ad7
to
820b8f3
Compare
81d10b2
to
5f75424
Compare
b41fb88
to
0c36db4
Compare
} | ||
}; | ||
|
||
let final_ctx = loop { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the server is offline and the user keep retrying it could go forever :/
I do not see a newsfragment, that expected? |
0c36db4
to
7801005
Compare
newsfragments/9180.feature.rst
Outdated
@@ -0,0 +1 @@ | |||
[CLI] Implement invite claim and greet for shared recovery. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those newsfragments are meant to be user oriented. I think we should have only one of them for the whole #6090 meta-issue, introducing the shared recovery feature in general
7801005
to
38f1758
Compare
@@ -214,6 +346,34 @@ async fn step4_device(ctx: DeviceClaimInProgress3Ctx) -> anyhow::Result<DeviceCl | |||
Ok(ctx) | |||
} | |||
|
|||
/// Step 4: retrieve device |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retrieve share
let selection = Select::new() | ||
.default(0) | ||
.with_prompt("Choose a person to contact now") | ||
.items(&human_recipients) | ||
.interact()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we ask the user to pick the next recipient but we do not display the current progress (like 2 out of 3 shares already retrieved
). Also, we don't show how the number of shares owned by each recipient.
For reference, see the v2 interaction:
parsec-cloud/parsec/core/cli/invitation.py
Lines 505 to 532 in 7bd32eb
async def _choose_recipient( | |
prelude_ctx: ShamirRecoveryClaimPreludeCtx, | |
) -> ShamirRecoveryRecipient: | |
styled_current_shares = click.style(len(prelude_ctx.shares), fg="yellow") | |
styled_threshold = click.style(prelude_ctx.threshold, fg="yellow") | |
if len(prelude_ctx.shares) == 0: | |
click.echo(f"A total of {styled_threshold} shares are necessary to recover the device.") | |
elif len(prelude_ctx.shares) == 1: | |
click.echo( | |
f"Out of the {styled_threshold} necessary shares, {styled_current_shares} share has been retrieved so far." | |
) | |
else: | |
click.echo( | |
f"Out of the {styled_threshold} necessary shares, {styled_current_shares} shares have been retrieved so far." | |
) | |
for i, recipient in enumerate(prelude_ctx.remaining_recipients): | |
assert recipient.human_handle is not None | |
styled_human_handle = click.style(recipient.human_handle.str, fg="yellow") | |
styled_share_number = click.style(recipient.shares, fg="yellow") | |
styled_share_number = ( | |
f"{styled_share_number} share" | |
if recipient.shares == 1 | |
else f"{styled_share_number} shares" | |
) | |
click.echo(f" {i} - {styled_human_handle} ({styled_share_number})") | |
choices = [str(x) for x in range(len(prelude_ctx.recipients))] | |
choice_index = await async_prompt("Next user to contact", type=click.Choice(choices)) | |
return prelude_ctx.recipients[int(choice_index)] |
Fix #9180