diff --git a/frontend/src/lib/components/Dev.svelte b/frontend/src/lib/components/Dev.svelte
index 915bc330a8..9c2134d927 100644
--- a/frontend/src/lib/components/Dev.svelte
+++ b/frontend/src/lib/components/Dev.svelte
@@ -166,7 +166,13 @@
currentScript.language,
args,
currentScript.tag,
- useLock ? currentScript.lock : undefined
+ useLock ? currentScript.lock : undefined,
+ undefined,
+ {
+ done(x) {
+ loadPastTests()
+ }
+ }
)
} else {
sendUserToast(`Bundle received ${lastCommandId} was obsolete, ignoring`, true)
@@ -221,56 +227,63 @@
})
async function testBundle(file: string, isTar: boolean) {
- jobLoader?.abstractRun(async () => {
- try {
- const form = new FormData()
- form.append(
- 'preview',
- JSON.stringify({
- content: currentScript?.content,
- kind: isTar ? 'tarbundle' : 'bundle',
- path: currentScript?.path,
- args,
- language: currentScript?.language,
- tag: currentScript?.tag
- })
- )
- // sendUserToast(JSON.stringify(file))
- if (isTar) {
- var array: number[] = []
- file = atob(file)
- for (var i = 0; i < file.length; i++) {
- array.push(file.charCodeAt(i))
- }
- let blob = new Blob([new Uint8Array(array)], { type: 'application/octet-stream' })
-
- form.append('file', blob)
- } else {
- form.append('file', file)
- }
-
- const url = '/api/w/' + workspace + '/jobs/run/preview_bundle'
-
- const req = await fetch(url, {
- method: 'POST',
- body: form,
- headers: {
- Authorization: 'Bearer ' + token
- }
- })
- if (req.status != 201) {
- throw Error(
- `Script snapshot creation was not successful: ${req.status} - ${
- req.statusText
- } - ${await req.text()}`
+ jobLoader?.abstractRun(
+ async () => {
+ try {
+ const form = new FormData()
+ form.append(
+ 'preview',
+ JSON.stringify({
+ content: currentScript?.content,
+ kind: isTar ? 'tarbundle' : 'bundle',
+ path: currentScript?.path,
+ args,
+ language: currentScript?.language,
+ tag: currentScript?.tag
+ })
)
+ // sendUserToast(JSON.stringify(file))
+ if (isTar) {
+ var array: number[] = []
+ file = atob(file)
+ for (var i = 0; i < file.length; i++) {
+ array.push(file.charCodeAt(i))
+ }
+ let blob = new Blob([new Uint8Array(array)], { type: 'application/octet-stream' })
+
+ form.append('file', blob)
+ } else {
+ form.append('file', file)
+ }
+
+ const url = '/api/w/' + workspace + '/jobs/run/preview_bundle'
+
+ const req = await fetch(url, {
+ method: 'POST',
+ body: form,
+ headers: {
+ Authorization: 'Bearer ' + token
+ }
+ })
+ if (req.status != 201) {
+ throw Error(
+ `Script snapshot creation was not successful: ${req.status} - ${
+ req.statusText
+ } - ${await req.text()}`
+ )
+ }
+ return await req.text()
+ } catch (e) {
+ sendUserToast(`Failed to send bundle ${e}`, true)
+ throw Error(e)
+ }
+ },
+ {
+ done(x) {
+ loadPastTests()
}
- return await req.text()
- } catch (e) {
- sendUserToast(`Failed to send bundle ${e}`, true)
- throw Error(e)
}
- })
+ )
loadingCodebaseButton = false
}
onDestroy(() => {
@@ -637,13 +650,7 @@
-
+
{#if mode == 'script'}
diff --git a/frontend/src/lib/components/JobLoader.svelte b/frontend/src/lib/components/JobLoader.svelte
index 04dee799a2..81f5612ebe 100644
--- a/frontend/src/lib/components/JobLoader.svelte
+++ b/frontend/src/lib/components/JobLoader.svelte
@@ -1,15 +1,27 @@
{#each Object.keys(components['jobiddisplaycomponent'].initialData.configuration) as key (key)}
@@ -95,12 +106,6 @@
bind:this={jobLoader}
bind:isLoading={testIsLoading}
bind:job={testJob}
- on:done={(e) => {
- outputs.loading.set(false)
- outputs.jobId.set(e.detail.id)
- outputs.result.set(e.detail.result)
- result = e.detail.result
- }}
/>
diff --git a/frontend/src/lib/components/apps/components/display/AppJobIdLogComponent.svelte b/frontend/src/lib/components/apps/components/display/AppJobIdLogComponent.svelte
index 5eb7c53889..eace729280 100644
--- a/frontend/src/lib/components/apps/components/display/AppJobIdLogComponent.svelte
+++ b/frontend/src/lib/components/apps/components/display/AppJobIdLogComponent.svelte
@@ -60,7 +60,14 @@
outputs.loading.set(true)
const jobId = resolvedConfig?.['jobId']
if (jobId) {
- jobLoader?.watchJob(jobId)
+ let callbacks = {
+ done(x) {
+ outputs.loading.set(false)
+ outputs.jobId.set(x.id)
+ outputs.result.set(x.result)
+ }
+ }
+ jobLoader?.watchJob(jobId, callbacks)
}
})
}
@@ -92,11 +99,6 @@
bind:this={jobLoader}
bind:isLoading={testIsLoading}
bind:job={testJob}
- on:done={(e) => {
- outputs.loading.set(false)
- outputs.jobId.set(e.detail.id)
- outputs.result.set(e.detail.result)
- }}
/>
diff --git a/frontend/src/lib/components/runs/JobPreview.svelte b/frontend/src/lib/components/runs/JobPreview.svelte
index ea9e939bb4..5ad5bc3dfa 100644
--- a/frontend/src/lib/components/runs/JobPreview.svelte
+++ b/frontend/src/lib/components/runs/JobPreview.svelte
@@ -30,8 +30,7 @@
let result: any = $state()
- function onDone(event: { detail: Job }) {
- job = event.detail
+ function onDone(job: Job) {
result = job['result']
}
@@ -56,7 +55,15 @@
}
})
$effect(() => {
- id && jobLoader && untrack(() => jobLoader?.watchJob(id))
+ id &&
+ jobLoader &&
+ untrack(() =>
+ jobLoader?.watchJob(id, {
+ done(x) {
+ onDone(x)
+ }
+ })
+ )
})
$effect(() => {
job?.logs == undefined && job && viewTab == 'logs' && untrack(() => jobLoader?.getLogs())
@@ -68,13 +75,7 @@
let jobLoader: JobLoader | undefined = $state(undefined)
-
+
{#if job}