fix(sessions): hand back the PowerShell common parameters too

`RunForm` keeps `_wm_ps_*` out of `args` and puts them back only as it submits,
so handing `args` to the card dropped whatever the reader had chosen on the
page — ErrorAction among them, which falls back to Stop. The form now answers
with what a run would send.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Guilhem Lemouel
2026-10-07 08:54:27 -07:00
co-authored by Claude Opus 5
parent b824fe3ffe
commit 863dbb61e3
3 changed files with 9 additions and 2 deletions
@@ -65,6 +65,13 @@
return { scriptArgs, commonParams }
}
/** Everything the form is holding, as a run would send it: the schema's arguments and the
* PowerShell common parameters, which are kept apart from them in here and only put back
* on the way out. For a caller handing the form's contents somewhere else. */
export function heldArgs(): Record<string, any> {
return { ...args, ...psCommonParams }
}
export async function setArgs(nargs: Record<string, any>) {
const { scriptArgs, commonParams } = extractPsCommonParams(nargs)
args = scriptArgs
@@ -400,7 +400,7 @@
// tab closed while the item is still being fetched would otherwise hand the card an empty
// object and wipe the proposal it is still parked on.
onDestroy(() => {
if (args !== undefined) pendingRun?.handBack(args)
if (args !== undefined) pendingRun?.handBack(runForm?.heldArgs() ?? args)
})
// The dev workspace's editor is not one the session panel can host, so from a preview tab
@@ -449,7 +449,7 @@
// tab closed while the item is still being fetched would otherwise hand the card an empty
// object and wipe the proposal it is still parked on.
onDestroy(() => {
if (args !== undefined) pendingRun?.handBack(args)
if (args !== undefined) pendingRun?.handBack(runForm?.heldArgs() ?? args)
})
// Read once on purpose: these args seed the form, so tracking the fragment would