Skip to content

Commit 6f14249

Browse files
committed
fix(ui): reset the assistant form when pollTask response is 404
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent 70af875 commit 6f14249

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

src/assistant.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,16 @@ export async function openAssistantForm({
149149
view.showSyncTaskRunning = false
150150
emit('assistant:task:updated', finishedTask)
151151
}).catch(error => {
152-
console.debug('[assistant] poll error', error)
152+
console.debug('[assistant] poll error', error.message)
153+
if (error.message === 'task-not-found') {
154+
view.loading = false
155+
view.showSyncTaskRunning = false
156+
view.isNotifyEnabled = false
157+
view.outputs = null
158+
view.selectedTaskId = null
159+
lastTask = null
160+
showError(t('assistant', 'The current Assistant task could not be found'))
161+
}
153162
})
154163
})
155164
.catch(error => {
@@ -228,6 +237,15 @@ export async function openAssistantForm({
228237
emit('assistant:task:updated', finishedTask)
229238
}).catch(error => {
230239
console.debug('[assistant] poll error', error)
240+
if (error.message === 'task-not-found') {
241+
view.loading = false
242+
view.showSyncTaskRunning = false
243+
view.isNotifyEnabled = false
244+
view.outputs = null
245+
view.selectedTaskId = null
246+
lastTask = null
247+
showError(t('assistant', 'The current Assistant task could not be found'))
248+
}
231249
})
232250
}).catch(error => {
233251
console.error(error)
@@ -289,6 +307,11 @@ export async function pollTask(taskId, setProgress) {
289307
}
290308
}).catch(error => {
291309
console.debug('[assistant] poll request failed', error)
310+
if (error.status === 404) {
311+
clearInterval(window.assistantPollTimerId)
312+
reject(new Error('task-not-found'))
313+
return
314+
}
292315
reject(new Error('pollTask request failed'))
293316
})
294317
}, 2000)
@@ -543,6 +566,14 @@ export async function openAssistantTask(
543566
}).catch(error => {
544567
console.debug('[assistant] poll error', error)
545568
view.outputs = null
569+
if (error.message === 'task-not-found') {
570+
view.loading = false
571+
view.showSyncTaskRunning = false
572+
view.isNotifyEnabled = false
573+
view.selectedTaskId = null
574+
lastTask = null
575+
showError(t('assistant', 'The current Assistant task could not be found'))
576+
}
546577
})
547578
})
548579
.catch(error => {
@@ -618,6 +649,15 @@ export async function openAssistantTask(
618649
emit('assistant:task:updated', finishedTask)
619650
}).catch(error => {
620651
console.debug('[assistant] poll error', error)
652+
if (error.message === 'task-not-found') {
653+
view.loading = false
654+
view.showSyncTaskRunning = false
655+
view.isNotifyEnabled = false
656+
view.outputs = null
657+
view.selectedTaskId = null
658+
lastTask = null
659+
showError(t('assistant', 'The current Assistant task could not be found'))
660+
}
621661
})
622662
}).catch(error => {
623663
console.error(error)

src/views/AssistantPage.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@ export default {
135135
emit('assistant:task:updated', finishedTask)
136136
}).catch(error => {
137137
console.debug('[assistant] poll error', error)
138+
if (error.message === 'task-not-found') {
139+
this.loading = false
140+
this.showSyncTaskRunning = false
141+
this.isNotifyEnabled = false
142+
this.task.status = TASK_STATUS_STRING.unknown
143+
this.task.output = null
144+
this.task.id = null
145+
showError(t('assistant', 'The current Assistant task could not be found'))
146+
}
138147
})
139148
})
140149
.catch(error => {
@@ -201,6 +210,15 @@ export default {
201210
emit('assistant:task:updated', finishedTask)
202211
}).catch(error => {
203212
console.debug('Assistant poll error', error)
213+
if (error.message === 'task-not-found') {
214+
this.loading = false
215+
this.showSyncTaskRunning = false
216+
this.isNotifyEnabled = false
217+
this.task.status = TASK_STATUS_STRING.unknown
218+
this.task.output = null
219+
this.task.id = null
220+
showError(t('assistant', 'The current Assistant task could not be found'))
221+
}
204222
})
205223
}).catch(error => {
206224
console.error(error)

0 commit comments

Comments
 (0)