From a4251150866b71bce1ded7e13246cd6ad3234d1c Mon Sep 17 00:00:00 2001 From: Tim Disney Date: Sat, 25 Jul 2026 19:48:16 -0700 Subject: [PATCH] fix bug when submiting request --- packages/ui/src/lib/components/NewRequest.svelte | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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) -- 2.51.2