From b15ef55be14c0005c82422930ee64b41f94505cb Mon Sep 17 00:00:00 2001 From: Asish Kumar Date: Fri, 24 Apr 2026 02:47:49 +0530 Subject: [PATCH] devtools: refresh scheduled tasks after trigger or cancel Closes #32861 Triggering or cancelling a scheduled task from the DevTools Scheduled Tasks page previously left the table showing the pre-action state, so users had to refresh the browser (which also reset the plugin selector) to see the new status. Switch `useScheduledTasks` to `useAsyncRetry` so it exposes a `refresh` function, and call it after each trigger/cancel action in `ScheduledTasksContent`. The refresh happens in a `finally` block so the table also updates when the action itself fails, reflecting whatever the backend ended up recording. Signed-off-by: Asish Kumar --- .changeset/devtools-refresh-after-scheduled-task-action.md | 5 +++++ .../ScheduledTasksContent/ScheduledTasksContent.tsx | 7 ++++++- plugins/devtools/src/hooks/useScheduledTasks.ts | 7 +++++-- 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 .changeset/devtools-refresh-after-scheduled-task-action.md diff --git a/.changeset/devtools-refresh-after-scheduled-task-action.md b/.changeset/devtools-refresh-after-scheduled-task-action.md new file mode 100644 index 0000000000..07e4dc1f8a --- /dev/null +++ b/.changeset/devtools-refresh-after-scheduled-task-action.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-devtools': patch +--- + +Scheduled Tasks page now refreshes its table automatically after a task is triggered or cancelled, so the updated status is visible without reloading the browser. diff --git a/plugins/devtools/src/components/Content/ScheduledTasksContent/ScheduledTasksContent.tsx b/plugins/devtools/src/components/Content/ScheduledTasksContent/ScheduledTasksContent.tsx index af86b9b237..35e218dbc1 100644 --- a/plugins/devtools/src/components/Content/ScheduledTasksContent/ScheduledTasksContent.tsx +++ b/plugins/devtools/src/components/Content/ScheduledTasksContent/ScheduledTasksContent.tsx @@ -105,7 +105,8 @@ export const ScheduledTasksContent = () => { const plugins = configApi.getOptionalStringArray('devTools.scheduledTasks.plugins') || []; const [selectedPlugin, setSelectedPlugin] = useState(plugins[0] || ''); - const { scheduledTasks, loading, error } = useScheduledTasks(selectedPlugin); + const { scheduledTasks, loading, error, refresh } = + useScheduledTasks(selectedPlugin); const { triggerTask, cancelTask, isLoading } = useScheduledTasksOperations(); const [inputValue, setInputValue] = useState(''); @@ -227,6 +228,8 @@ export const ScheduledTasksContent = () => { message: `Error triggering task ${rowData.taskId}: ${e.message}`, severity: 'error', }); + } finally { + refresh(); } }} > @@ -249,6 +252,8 @@ export const ScheduledTasksContent = () => { message: `Error cancelling task ${rowData.taskId}: ${e.message}`, severity: 'error', }); + } finally { + refresh(); } }} > diff --git a/plugins/devtools/src/hooks/useScheduledTasks.ts b/plugins/devtools/src/hooks/useScheduledTasks.ts index 2797526dec..77f888a28e 100644 --- a/plugins/devtools/src/hooks/useScheduledTasks.ts +++ b/plugins/devtools/src/hooks/useScheduledTasks.ts @@ -15,7 +15,7 @@ */ import { devToolsApiRef } from '../api'; import { useApi } from '@backstage/core-plugin-api'; -import useAsync from 'react-use/esm/useAsync'; +import useAsyncRetry from 'react-use/esm/useAsyncRetry'; export const useScheduledTasks = (plugin: string) => { const api = useApi(devToolsApiRef); @@ -24,7 +24,8 @@ export const useScheduledTasks = (plugin: string) => { value, loading, error: asyncError, - } = useAsync(async () => { + retry: refresh, + } = useAsyncRetry(async () => { return api.getScheduledTasksByPlugin(plugin); }, [api, plugin]); @@ -33,6 +34,7 @@ export const useScheduledTasks = (plugin: string) => { scheduledTasks: undefined, loading: false, error: asyncError.message, + refresh, }; } @@ -40,5 +42,6 @@ export const useScheduledTasks = (plugin: string) => { scheduledTasks: value?.scheduledTasks, loading, error: value?.error, + refresh, }; };