@@ -290,6 +290,10 @@ export async function openAssistantForm({
290290
291291 if ( [ TASK_STATUS_STRING . scheduled , TASK_STATUS_STRING . running ] . includes ( task ?. status ) ) {
292292 getTask ( task . id ) . then ( response => {
293+ if ( task . id !== view . selectedTaskId ) {
294+ console . debug ( '[assistant] ignoring stale getTask response for task' , task . id , 'selected is' , view . selectedTaskId )
295+ return
296+ }
293297 const updatedTask = response . data ?. ocs ?. data ?. task
294298
295299 if ( ! [ TASK_STATUS_STRING . scheduled , TASK_STATUS_STRING . running ] . includes ( updatedTask ?. status ) ) {
@@ -303,6 +307,9 @@ export async function openAssistantForm({
303307 }
304308
305309 getNotifyReady ( task . id ) . then ( response => {
310+ if ( task . id !== view . selectedTaskId ) {
311+ return
312+ }
306313 view . isNotifyEnabled = ! ! response . data ?. ocs ?. data ?. id
307314 } ) . catch ( error => {
308315 console . error ( '[assistant] get task notification status error' , error )
@@ -922,6 +929,10 @@ export async function openAssistantTask(
922929
923930 if ( [ TASK_STATUS_STRING . scheduled , TASK_STATUS_STRING . running ] . includes ( task ?. status ) ) {
924931 getTask ( task . id ) . then ( response => {
932+ if ( task . id !== view . selectedTaskId ) {
933+ console . debug ( '[assistant] ignoring stale getTask response for task' , task . id , 'selected is' , view . selectedTaskId )
934+ return
935+ }
925936 const updatedTask = response . data ?. ocs ?. data ?. task
926937
927938 if ( ! [ TASK_STATUS_STRING . scheduled , TASK_STATUS_STRING . running ] . includes ( updatedTask ?. status ) ) {
@@ -935,6 +946,9 @@ export async function openAssistantTask(
935946 }
936947
937948 getNotifyReady ( task . id ) . then ( response => {
949+ if ( task . id !== view . selectedTaskId ) {
950+ return
951+ }
938952 view . isNotifyEnabled = ! ! response . data ?. ocs ?. data ?. id
939953 } ) . catch ( error => {
940954 console . error ( '[assistant] get task notification status error' , error )
0 commit comments