fix(sessions): keep the submitted arguments on screen after Run

Pressing Run settles the call, so the draft the form reads stops answering
before the job exists: the form emptied for as long as the start took, and
stayed empty when the server refused it — leaving the reader the run to make
again with nothing to make it from. It falls back to what it submitted.

The note on the PowerShell split also claimed the unoffered keys travel to the
job. `SchemaForm` holds the arguments to the keys the schema declares, so they
do not.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Guilhem Lemouel
2026-10-07 09:39:07 -07:00
co-authored by Claude Opus 5
parent 9577c913a7
commit 463c2aa9a5
3 changed files with 16 additions and 5 deletions
+4 -3
View File
@@ -66,9 +66,10 @@
}
export async function setArgs(nargs: Record<string, any>) {
// Only when this form is the one offering them. Unoffered, they stay in the arguments
// and travel with them: `enforceDisabledDefaults` copies every key, so the job still
// receives them, and taking them out here would drop them from whoever owns `args`.
// Only when this form is the one offering them: taking them aside is what lets the
// section edit them, and a form without that section has nowhere to put them back
// from. It does not keep them — `SchemaForm` holds `args` to the keys the schema
// declares — so a form that hides the section neither offers these nor carries them.
const { scriptArgs, commonParams } = showPsCommonParams
? extractPsCommonParams(nargs)
: { scriptArgs: nargs, commonParams: {} }
@@ -347,7 +347,10 @@
// card edits — rather than a copy of it. There is then nothing to keep in step and nothing
// to carry back: whatever is typed on either surface is what the call runs with.
let ownArgs: Record<string, any> | undefined = $state(undefined)
const args = $derived(pendingRun ? pendingRun.draftArgs : ownArgs)
// Falls back once the draft is gone: pressing Run settles the call, and the form must go
// on showing what it submitted while the job starts — and still show it if the start is
// refused, which leaves the reader on the page with the run to make again.
const args = $derived(pendingRun?.draftArgs ?? ownArgs)
function setArgs(next: Record<string, any> | undefined) {
if (pendingRun) pendingRun.setDraftArgs(next ?? {})
else ownArgs = next
@@ -390,6 +393,8 @@
const call = pendingRun
if (!call) return runFlow
return (_scheduledForStr: string | undefined, a: Record<string, any>) => {
// Kept for the moment the draft stops answering, just below.
ownArgs = a
if (!call.submit(a)) {
sendUserToast('That request is no longer waiting on this form', true)
}
@@ -422,7 +422,10 @@
// card edits — rather than a copy of it. There is then nothing to keep in step and nothing
// to carry back: whatever is typed on either surface is what the call runs with.
let ownArgs: Record<string, any> | undefined = $state(undefined)
const args = $derived(pendingRun ? pendingRun.draftArgs : ownArgs)
// Falls back once the draft is gone: pressing Run settles the call, and the form must go
// on showing what it submitted while the job starts — and still show it if the start is
// refused, which leaves the reader on the page with the run to make again.
const args = $derived(pendingRun?.draftArgs ?? ownArgs)
function setArgs(next: Record<string, any> | undefined) {
if (pendingRun) pendingRun.setDraftArgs(next ?? {})
else ownArgs = next
@@ -439,6 +442,8 @@
const call = pendingRun
if (!call) return runScript
return (_scheduledForStr: string | undefined, a: Record<string, any>) => {
// Kept for the moment the draft stops answering, just below.
ownArgs = a
if (!call.submit(a)) {
sendUserToast('That request is no longer waiting on this form', true)
}