| ... | ... | @@ -58,6 +58,8 @@ interface PendingDefaultBranchAction { |
| 58 | 58 | onConfirmed?: () => void; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | type GitActionToastId = ReturnType<typeof toastManager.add>; |
| 62 | |
| 61 | 63 | function getMenuActionDisabledReason( |
| 62 | 64 | item: GitActionMenuItem, |
| 63 | 65 | gitStatus: GitStatusResult | null, |
| ... | ... | @@ -245,6 +247,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 245 | 247 | skipDefaultBranchPrompt = false, |
| 246 | 248 | statusOverride, |
| 247 | 249 | isDefaultBranchOverride, |
| 250 | progressToastId, |
| 248 | 251 | }: { |
| 249 | 252 | action: GitStackedAction; |
| 250 | 253 | commitMessage?: string; |
| ... | ... | @@ -253,6 +256,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 253 | 256 | skipDefaultBranchPrompt?: boolean; |
| 254 | 257 | statusOverride?: GitStatusResult | null; |
| 255 | 258 | isDefaultBranchOverride?: boolean; |
| 259 | progressToastId?: GitActionToastId; |
| 256 | 260 | }) => { |
| 257 | 261 | const actionStatus = statusOverride ?? gitStatusForActions; |
| 258 | 262 | const actionIsDefaultBranch = isDefaultBranchOverride ?? isDefaultBranch; |
| ... | ... | @@ -284,17 +288,28 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 284 | 288 | forcePushOnly: forcePushOnlyProgress, |
| 285 | 289 | ...(pushTarget ? { pushTarget } : {}), |
| 286 | 290 | }); |
| 287 | | const progressToastId = toastManager.add({ |
| 288 | | type: "loading", |
| 289 | | title: progressStages[0] ?? "Running git action...", |
| 290 | | timeout: 0, |
| 291 | | data: threadToastData, |
| 292 | | }); |
| 291 | const resolvedProgressToastId = |
| 292 | progressToastId ?? |
| 293 | toastManager.add({ |
| 294 | type: "loading", |
| 295 | title: progressStages[0] ?? "Running git action...", |
| 296 | timeout: 0, |
| 297 | data: threadToastData, |
| 298 | }); |
| 299 | |
| 300 | if (progressToastId) { |
| 301 | toastManager.update(progressToastId, { |
| 302 | type: "loading", |
| 303 | title: progressStages[0] ?? "Running git action...", |
| 304 | timeout: 0, |
| 305 | data: threadToastData, |
| 306 | }); |
| 307 | } |
| 293 | 308 | |
| 294 | 309 | let stageIndex = 0; |
| 295 | 310 | const stageInterval = setInterval(() => { |
| 296 | 311 | stageIndex = Math.min(stageIndex + 1, progressStages.length - 1); |
| 297 | | toastManager.update(progressToastId, { |
| 312 | toastManager.update(resolvedProgressToastId, { |
| 298 | 313 | title: progressStages[stageIndex] ?? "Running git action...", |
| 299 | 314 | type: "loading", |
| 300 | 315 | timeout: 0, |
| ... | ... | @@ -329,10 +344,10 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 329 | 344 | result.push.status === "pushed" && |
| 330 | 345 | !actionIsDefaultBranch; |
| 331 | 346 | const closeResultToast = () => { |
| 332 | | toastManager.close(progressToastId); |
| 347 | toastManager.close(resolvedProgressToastId); |
| 333 | 348 | }; |
| 334 | 349 | |
| 335 | | toastManager.update(progressToastId, { |
| 350 | toastManager.update(resolvedProgressToastId, { |
| 336 | 351 | type: "success", |
| 337 | 352 | title: resultToast.title, |
| 338 | 353 | description: resultToast.description, |
| ... | ... | @@ -386,7 +401,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 386 | 401 | }); |
| 387 | 402 | } catch (err) { |
| 388 | 403 | stopProgressUpdates(); |
| 389 | | toastManager.update(progressToastId, { |
| 404 | toastManager.update(resolvedProgressToastId, { |
| 390 | 405 | type: "error", |
| 391 | 406 | title: "Action failed", |
| 392 | 407 | description: err instanceof Error ? err.message : "An error occurred.", |
| ... | ... | @@ -429,17 +444,11 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 429 | 444 | ); |
| 430 | 445 | |
| 431 | 446 | const checkoutPromise = createBranchAndCheckoutMutation.mutateAsync(branchName); |
| 432 | | toastManager.promise(checkoutPromise, { |
| 433 | | loading: { title: `Creating ${branchName}...`, data: threadToastData }, |
| 434 | | success: () => ({ |
| 435 | | title: `Checked out ${branchName}`, |
| 436 | | data: threadToastData, |
| 437 | | }), |
| 438 | | error: (error) => ({ |
| 439 | | title: "Failed to checkout feature branch", |
| 440 | | description: error instanceof Error ? error.message : "An error occurred.", |
| 441 | | data: threadToastData, |
| 442 | | }), |
| 447 | const checkoutToastId = toastManager.add({ |
| 448 | type: "loading", |
| 449 | title: `Creating ${branchName}...`, |
| 450 | timeout: 0, |
| 451 | data: threadToastData, |
| 443 | 452 | }); |
| 444 | 453 | |
| 445 | 454 | void checkoutPromise |
| ... | ... | @@ -459,9 +468,17 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 459 | 468 | skipDefaultBranchPrompt: true, |
| 460 | 469 | statusOverride, |
| 461 | 470 | isDefaultBranchOverride: false, |
| 471 | progressToastId: checkoutToastId, |
| 462 | 472 | }); |
| 463 | 473 | }) |
| 464 | | .catch(() => undefined); |
| 474 | .catch((error) => { |
| 475 | toastManager.update(checkoutToastId, { |
| 476 | type: "error", |
| 477 | title: "Failed to checkout feature branch", |
| 478 | description: error instanceof Error ? error.message : "An error occurred.", |
| 479 | data: threadToastData, |
| 480 | }); |
| 481 | }); |
| 465 | 482 | }, |
| 466 | 483 | [ |
| 467 | 484 | branchList?.branches, |