fix(join): read a pasted community DID as a DID, not a broken invitation - #347
Merged
Merged
Conversation
`[Ctrl+V]` on the join entry page read the clipboard and handed whatever it found to the invitation loader. Pasting the community's DID — the commonest thing anyone pastes on that page — came back "Pasted text is not valid JSON", while the identical text delivered as a bracketed paste went into the field correctly, because that path sniffed for a leading brace and the clipboard path did not. The two had drifted, and the comment on the clipboard key still claimed they did the same thing. Both now go through one `apply_entry_paste`, on the component that owns the input: a JSON object is an invitation, anything else is the DID or agent name. `Ctrl+V` reads the clipboard there and applies it, so only the read *failure* still needs the loop — `JoinPasteFromClipboard` becomes `JoinClipboardFailed(String)`, which is all it ever really was. The sniff is on the shape of the text, not on whether it parses. A DID never opens a brace, and text that does and then fails to parse is a broken invitation — which `load_pasted_vic` reports as one. Sniffing by "does it parse as JSON" would report a mangled VIC as a malformed DID. The page also now leads with the community. The invitation block moves below the input, ahead of the examples. It led the page (issue #29) while this was the only screen that mentioned invitations and one pasted here was easy to miss; what #29 actually caught was an affordance that was dim, unnamed and last, and the named `[Ctrl+V]` row that fixed it stays. Since the join learned to list the ways in, an invitation is offered again on the following step — counted, matched against the community, and with a paste row of its own — so leading with it here only pushed the DID prompt down the page. Pasting one still fills in a DID you may not have, which is what its copy now says. The prompt stays the last line above the input: the invitation went between them at first, and `the_input_keeps_its_row_across_states_and_widths` caught it. Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while running the vetting dry-run guide: pasting the community's DID on the join entry page answered "Pasted text is not valid JSON".
The bug
The two paste routes had drifted apart:
{…}[Ctrl+V](JoinPasteFromClipboard)The clipboard key handed its text to the invitation loader whatever it was. Its
own comment said "same validation as a bracketed paste", which had stopped
being true.
The fix
One
apply_entry_pasteon the component that owns the input, called by bothroutes, so they cannot disagree again. A JSON object is an invitation; anything
else is the community's DID or agent name.
Ctrl+Vnow reads the clipboard where the input lives and applies the textitself, so only the read failure still needs the loop —
JoinPasteFromClipboardbecomesJoinClipboardFailed(String), which is all itever really carried. Reading the clipboard synchronously in a key handler
matches what the vetting panel already does for its copy keys.
The sniff is on the shape of the text, not on whether it parses. A DID never
opens a brace, and text that does open one and then fails to parse is a broken
invitation — which
load_pasted_vicalready reports as one, naming what iswrong with it. Sniffing by "does it parse as JSON" would report a mangled VIC as
a malformed DID, which is the less useful of the two errors.
The page now leads with the community
The DID prompt and its input come first; the invitation block moves below the
input, still ahead of the examples.
This reverses part of issue #29, so the reasoning matters. The invitation led
the page while this was the only screen that mentioned invitations at all, and
one pasted here was easy to miss. What #29 actually caught was an affordance
that was dim, unnamed and last — and the named
[Ctrl+V]row that fixedthat stays exactly where it can be seen. Since #342 the join lists the ways in
on the following step, where an invitation is offered counted and matched
against the community, with a paste row of its own. Leading with it here buys
nothing now and pushes the DID prompt down the page.
The copy changed to match what it actually does: "Don't have the DID? … it names
the community, so it fills the DID in for you."
A regression the suite caught
Putting the invitation between the prompt and the input broke
the_input_keeps_its_row_across_states_and_widths— the prompt has to be thelast line above the input. That is why the block sits below the input rather
than merely after the prompt.
Testing
cargo fmt --all,cargo clippy --all-targets --all-features— cleancargo test --all-features— all greenRUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features— cleanThe replaced
ctrl_v_asks_for_the_clipboard_rather_than_typingasserted the oldaction. It is now two tests:
ctrl_v_never_types_a_v— whatever the clipboard holds, the key itself neverlands in the field. It deliberately asserts nothing about what was pasted:
that depends on the machine's clipboard, and a test reading it would pass or
fail on what the developer last copied.
a_pasted_did_goes_in_the_field_and_an_invitation_is_loaded— drivesapply_entry_pastewith text of its own: a DID and an agent name land in thefield with no action sent, a JSON object is loaded as an invitation and does
not overwrite what is being typed.
Not yet run against the live community — the guide run that found this is the
next thing to re-try it on.