Add dynamic PR toast actions to Git actions flow#41

closed1
main
codething/3a47e5fc
openedFeb 14, 2026byJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 26d ago

Summary

  • refactored Git action execution into a shared executeGitAction path for both modal and immediate actions
  • added dynamic progress toast CTA logic via getGitProgressToastAction to show either Open PR or Create PR based on post-run state
  • extracted reusable PR-eligibility checks (canCreatePrFromStatus) and reused them in menu-item gating
  • removed the separate immediate-action mutation and aligned run-state handling with the modal action runner
  • added unit coverage for toast-action selection behavior in apps/web/src/git-actions-control.test.ts

Testing

  • Added unit tests for getGitProgressToastAction covering:
  • returns Open PR when openPrUrl exists
  • returns Create PR after commit_push when branch status is PR-eligible
  • returns null for non-push actions
  • returns null while running or when an error is present
  • Lint: Not run
  • Full app/integration tests: Not run

Open with Devin

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced Git workflow with improved multi-step progress tracking for commits, pushes, and pull requests
    • Added toast notifications with quick actions to open existing pull requests or create new ones
    • Improved pull request eligibility detection and handling
  • Tests

    • Added comprehensive unit tests for Git action workflows

Added 1 commit

  • Add dynamic PR toast actions for Git run results84ee10d
Synced from GitHub

Walkthrough

Refactors Git action control flow in the web component by introducing a generalized executeGitAction function that orchestrates commit, push, and PR steps with progress tracking. Adds new getGitProgressToastAction function to determine toast actions based on run state and PR eligibility, and includes comprehensive unit tests.

Changes

Cohort / File(s)Summary
Git Actions Control Component
apps/web/src/components/GitActionsControl.tsx
Introduces new executeGitAction function orchestrating multi-step Git operations (commit, push, PR) with progress updates and error handling. Adds getGitProgressToastAction function to determine toast action type (open/create PR). Refactors PR eligibility logic with canCreatePrFromStatus helper. Updates Git progress initialization with optional generate step flag. Removes previous mutation-based immediate action path and adjusts UI wiring for new action flow.
Git Actions Control Tests
apps/web/src/git-actions-control.test.ts
New test file covering getGitProgressToastAction function with test cases for PR URL availability, push eligibility, running/error states, and non-push actions. Includes helper builders for mocking Git status and action results.

Sequence Diagram(s)

mermaid
1sequenceDiagram
2 participant User as User Action
3 participant Component as GitActionsControl Component
4 participant Executor as executeGitAction
5 participant Git as Git Operations
6 participant Toast as Progress Toast
7
8 User->>Component: Trigger runGitActionImmediately()
9 Component->>Executor: executeGitAction() with steps
10 Executor->>Toast: Show progress (starting)
11
12 Executor->>Git: Commit changes
13 Git-->>Executor: Commit result
14 Executor->>Toast: Update progress
15
16 Executor->>Git: Push to remote
17 Git-->>Executor: Push result
18 Executor->>Toast: Update progress
19
20 Executor->>Git: Create/Open PR
21 Git-->>Executor: PR result
22 Executor->>Toast: Update final status
23
24 Toast->>Component: getGitProgressToastAction()
25 Component-->>Toast: Determine action (open_pr/create_pr/null)
26 Toast-->>User: Display with action

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'Add dynamic PR toast actions to Git actions flow' accurately summarizes the main change: introducing dynamic toast CTA logic to show contextual PR actions.
Merge Conflict Detection✅ Passed✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codething/3a47e5fc

Comment @coderabbitai help to get the list of available commands and usage tips.

Synced from GitHub

Add dynamic progress toast actions to Git actions flow and update GitActionsControl in GitActionsControl.tsx

Introduce GitProgressToastAction for toast buttons, add getGitProgressToastAction and canCreatePrFromStatus helpers, refactor GitActionsControl to use a unified executeGitAction, and adjust initialGitProgressSteps to take a boolean. Tests cover toast action selection in git-actions-control.test.ts.

📍Where to Start

Start with executeGitAction and toast action calculation in GitActionsControl.tsx.


Macroscope summarized 84ee10d.

Synced from GitHub

Greptile Overview

Greptile Summary

Refactored Git action execution to use a unified executeGitAction function that replaces the previous mutation-based approach for immediate actions. The key improvements include:

  • Extracted canCreatePrFromStatus helper for reusable PR-eligibility checks
  • Added getGitProgressToastAction to dynamically determine toast button actions based on post-run state (Open PR vs Create PR)
  • Unified executeGitAction handles both modal and immediate actions with configurable modal closing
  • Removed runImmediateGitActionMutation mutation and replaced with direct executeGitAction calls
  • Changed initialGitProgressSteps parameter from commitMessage string to includeGenerateStep boolean for clarity
  • Removed "Running..." text from Git actions button to keep it static
  • Removed unnecessary void from onClick handler since runGitAction already handles the promise

The refactor improves code organization by consolidating Git action logic into a single execution path while maintaining all existing functionality.

Confidence Score: 4/5

  • Safe to merge with minor considerations around edge case handling
  • The refactoring consolidates Git action execution into a cleaner architecture with proper test coverage. The logic is sound and well-tested, though there's a subtle behavioral difference in the canCreatePrFromStatus check that now prevents PR creation when there are working tree changes, which may or may not be intentional.
  • No files require special attention

Important Files Changed

FilenameOverview
apps/web/src/components/GitActionsControl.tsxRefactored Git action execution into unified executeGitAction path with dynamic toast actions. Removed mutation-based immediate actions in favor of shared execution flow.
apps/web/src/git-actions-control.test.tsAdded comprehensive unit tests for getGitProgressToastAction covering all branches including open PR, create PR, and null return conditions.

Flowchart

mermaid
1flowchart TD
2 Start[User triggers Git action] --> CheckModal{Modal or<br/>Immediate?}
3
4 CheckModal -->|Modal| RunGitAction[runGitAction<br/>with user inputs]
5 CheckModal -->|Immediate| RunImmediate[runGitActionImmediately<br/>no commit message]
6
7 RunGitAction --> ExecuteGitAction[executeGitAction]
8 RunImmediate --> ExecuteGitAction
9
10 ExecuteGitAction --> CloseModal{closeModal<br/>param?}
11 CloseModal -->|true| CloseIt[Close modal]
12 CloseModal -->|false| ShowToast[Show progress toast]
13 CloseIt --> ShowToast
14
15 ShowToast --> RunCommit[Run commit action]
16 RunCommit --> CheckAction{Action type?}
17
18 CheckAction -->|commit| Done[Complete]
19 CheckAction -->|commit_push| RunPush[Run push action]
20 CheckAction -->|commit_push_pr| RunPush
21
22 RunPush --> CheckPR{commit_push_pr?}
23 CheckPR -->|yes| RunPRAction[Run PR action]
24 CheckPR -->|no| RefreshStatus[Refresh git status]
25 RunPRAction --> RefreshStatus
26
27 RefreshStatus --> ComputeToastAction[getGitProgressToastAction]
28 ComputeToastAction --> CheckToastResult{Toast action?}
29
30 CheckToastResult -->|openPrUrl exists| ShowOpenPR[Show 'Open PR' button]
31 CheckToastResult -->|commit_push + eligible| ShowCreatePR[Show 'Create PR' button]
32 CheckToastResult -->|otherwise| NoButton[No button shown]
33
34 ShowOpenPR --> Done
35 ShowCreatePR --> Done
36 NoButton --> Done

Last reviewed commit: 84ee10d

CcoderabbitaiBotreviewed · 1 inline threadFeb 14, 2026
Synced from GitHub

Actionable comments posted: 1

🤖 Fix all issues with AI agents
1In `@apps/web/src/components/GitActionsControl.tsx`:
2- Around line 875-889: Replace the button's disabled prop with an
3accessibility-preserving pattern: remove disabled={isGitModalActionRunning}, add
4aria-disabled={isGitModalActionRunning} and keep the visual disabled styling
5(opacity/disabled classes); guard the onClick handler so it returns early when
6isGitModalActionRunning is true (i.e., do nothing if isGitModalActionRunning)
7before calling openPrFromToast() or runGitActionImmediately("commit_push_pr");
8also ensure keyboard activation is blocked when aria-disabled is true by
9checking isGitModalActionRunning at the top of any click/key handlers related to
10the GitActionsControl button using the existing symbols isGitModalActionRunning,
11gitProgressToastAction, openPrFromToast, and runGitActionImmediately.
🧹 Nitpick comments (1)
apps/web/src/components/GitActionsControl.tsx (1)

422-576: Consider swapping manual running state for useTransition.
This keeps pending UI state aligned with project guidance; if you still need explicit async lifecycle tracking, add a short comment explaining why.

Based on learnings: Use useTransition for async actions instead of manually managing pending state. Replace manual pending state management with startTransition callback pattern.

Also applies to: 844-849

……@@ -821,14 +872,20 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
830887 >
831- Open PR
888+ {gitProgressToastAction.label}
832889 </button>
CcoderabbitaiBoton lines 875–889Feb 14, 2026

⚠️ Potential issue | 🟡 Minor

Avoid disabled on the toast action button.
Use aria-disabled + click-guard to preserve accessibility/tooltips while still preventing action.

🔧 Suggested adjustment
diff
1- <button
2+ <button
3 type="button"
4- className="rounded-md bg-foreground px-2.5 py-1 text-xs font-medium text-background transition-colors duration-150 hover:bg-foreground/90 disabled:cursor-not-allowed disabled:opacity-60"
5+ className={`rounded-md bg-foreground px-2.5 py-1 text-xs font-medium text-background transition-colors duration-150 hover:bg-foreground/90 ${
6+ isGitModalActionRunning ? "cursor-not-allowed opacity-60" : ""
7+ }`}
8 onClick={() => {
9+ if (isGitModalActionRunning) return;
10 if (gitProgressToastAction.kind === "open_pr") {
11 openPrFromToast();
12 return;
13 }
14 runGitActionImmediately("commit_push_pr");
15 }}
16- disabled={isGitModalActionRunning}
17+ aria-disabled={isGitModalActionRunning}
18 >
Based on learnings: Avoid using disabled props on buttons as they harm accessibility and break tooltips. Instead, use styling (e.g., opacity, hover states) and handle the disabled state through click handlers.
🤖 Prompt for AI Agents
1In `@apps/web/src/components/GitActionsControl.tsx` around lines 875 - 889,
2Replace the button's disabled prop with an accessibility-preserving pattern:
3remove disabled={isGitModalActionRunning}, add
4aria-disabled={isGitModalActionRunning} and keep the visual disabled styling
5(opacity/disabled classes); guard the onClick handler so it returns early when
6isGitModalActionRunning is true (i.e., do nothing if isGitModalActionRunning)
7before calling openPrFromToast() or runGitActionImmediately("commit_push_pr");
8also ensure keyboard activation is blocked when aria-disabled is true by
9checking isGitModalActionRunning at the top of any click/key handlers related to
10the GitActionsControl button using the existing symbols isGitModalActionRunning,
11gitProgressToastAction, openPrFromToast, and runGitActionImmediately.