set app button loading state to true before worker execution (#7493)

This commit is contained in:
Guilhem
2026-01-05 22:28:20 +00:00
committed by GitHub
parent eeb4feb13c
commit bce64bbf48
2 changed files with 23 additions and 6 deletions
@@ -167,14 +167,30 @@
if (iterContext && listInputs) {
listInputs.set(id, inputOutput)
}
if (preclickAction) {
await preclickAction()
// Set loading state immediately for immediate visual feedback
// This ensures the spinner appears right away, even before the API request completes
if (runnableComponent) {
loading = true
}
if (!runnableComponent) {
runnableWrapper?.handleSideEffect(true)
} else {
await runnableComponent?.runComponent()
try {
if (preclickAction) {
await preclickAction()
}
if (!runnableComponent) {
runnableWrapper?.handleSideEffect(true)
} else {
await runnableComponent?.runComponent()
}
} catch (error) {
// If an error occurs before the job starts, reset loading state
// (If the job started, RunnableComponent will handle resetting loading)
if (runnableComponent) {
loading = false
}
throw error
}
}
@@ -557,6 +557,7 @@
let error = e?.body ?? e?.message
updateResult({ error })
$errorByComponent[id] = { error }
loading = false // Ensure loading is reset on any error
}
}