diff --git a/packages/ui/src/lib/components/NewRequest.svelte b/packages/ui/src/lib/components/NewRequest.svelte index 8843b0f..804bbf1 100644 --- a/packages/ui/src/lib/components/NewRequest.svelte +++ b/packages/ui/src/lib/components/NewRequest.svelte @@ -77,18 +77,24 @@ error = '' try { const result = await write(requestArgs(draft, { brief, assignee })) + // Everything this card still has to say about the draft is read BEFORE it is closed. `draft` is + // a prop of the view that owns the compose state, so `closeDraft()` does not merely hide the + // card — it makes `draft` undefined on the very next read, and `lands` is derived from it. + const requested = draft.type + const system = lands + const named = assignee ? space.directory.get(assignee) : undefined closeDraft() - if (lands) { + if (system) { // The one case that navigates: a capture's row lands in System, not in the goal this card // was opened from, and a toast over an unchanged list would be the app saying something // happened somewhere the reader cannot see. `write` has already re-read the author's repo, // so the row is there — and a unit with nothing landed is keyed by its request (§3.7). - toast(wroteCapture(draft.type)) - await goto(unitHref(systemHref(lands), { key: result.primary.uri })) + toast(wroteCapture(requested)) + await goto(unitHref(systemHref(system), { key: result.primary.uri })) } else { // No navigation: the request is a new row in the list this card is sitting on top of, and // `write` has already re-read the author's repo, so it is there by the time the card closes. - toast(wroteRequest(draft.type, assignee ? space.directory.get(assignee) : undefined)) + toast(wroteRequest(requested, named)) } } catch (failure) { error = failure instanceof Error ? failure.message : String(failure)