fix(control-bar): fix race condition for displaying notification & running state

This commit is contained in:
Waleed Latif
2025-03-26 17:25:11 -07:00
parent c47d704160
commit b881eff7b8
3 changed files with 955 additions and 1071 deletions
@@ -331,6 +331,9 @@ export function ControlBar() {
setIsMultiRunning(true)
setShowRunProgress(runCount > 1)
let result = null
let workflowError = null
try {
// Run the workflow multiple times sequentially
for (let i = 0; i < runCount; i++) {
@@ -351,14 +354,19 @@ export function ControlBar() {
}
}
} catch (error) {
workflowError = error
logger.error('Error during multiple workflow runs:', { error })
addNotification('error', 'Failed to complete all workflow runs', activeWorkflowId)
} finally {
setIsMultiRunning(false)
// Keep progress visible for a moment after completion
if (runCount > 1) {
setTimeout(() => setShowRunProgress(false), 2000)
}
// Show notification after state is updated
if (workflowError) {
addNotification('error', 'Failed to complete all workflow runs', activeWorkflowId)
}
}
}
+946 -1064
View File
File diff suppressed because it is too large Load Diff
-6
View File
@@ -45,15 +45,10 @@ export const userTool: ToolConfig<XUserParams, XUserResponse> = {
},
transformResponse: async (response, params) => {
if (!params) {
throw new Error('Missing required parameters')
}
// Handle rate limit issues (429 status code)
if (response.status === 429) {
logger.warn('X API rate limit exceeded', {
status: response.status,
username: params.username,
headers: Object.fromEntries(response.headers.entries()),
})
@@ -111,7 +106,6 @@ export const userTool: ToolConfig<XUserParams, XUserResponse> = {
logger.error('Error processing X API response', {
error,
status: response.status,
username: params.username,
})
throw error
}