Files
vibe-kanban/crates
Alex Netsch 036dd802d8 Force push (vibe-kanban) (#1350)
* Excellent! All tasks completed successfully. Here's a summary of the changes:

I've successfully added typed error handling to the push method following the same pattern as `CreatePrError`. Here's what was implemented:

1. **Created `PushError` enum** in `crates/server/src/routes/task_attempts.rs:608-613`
   - Single variant: `ForcePushRequired`
   - Uses proper derives for TypeScript generation

2. **Updated push handler signature** in `crates/server/src/routes/task_attempts.rs:596`
   - Changed return type to `Result<ResponseJson<ApiResponse<(), PushError>>, ApiError>`

3. **Registered error type** in `crates/server/src/bin/generate_types.rs:140`
   - Added `PushError::decl()` to the type declarations

4. **Generated TypeScript type** in `shared/types.ts:301`
   - Type: `export type PushError = { "type": "force_push_required" }`

5. **Updated frontend API** in `frontend/src/lib/api.ts`
   - Imported `PushError` type
   - Changed `push` method to return `Result<void, PushError>`
   - Uses `handleApiResponseAsResult` for proper error handling

6. **Updated `usePush` hook** in `frontend/src/hooks/usePush.ts`
   - Created custom `PushErrorWithData` class to properly pass error data
   - Updated signature to pass `errorData` to `onError` callback

7. **Updated component error handling** in `frontend/src/hooks/useGitOperations.ts:47-52`
   - Added handling for `force_push_required` error type
   - Displays user-friendly message: "Force push required. The remote branch has diverged."

All checks pass successfully! The implementation is ready for future force push functionality.

Cleanup script changes for task attempt 982f21cc-f0a3-455d-8b30-3a9911c2889f

Excellent! All tasks completed successfully. Here's a summary of the force push implementation:

I've successfully implemented a complete force push feature with user confirmation. Here's what was done:

1. **Updated Git CLI** (`crates/services/src/services/git/cli.rs:318`)
   - Added `force: bool` parameter to `push()` method
   - Uses `+refs/heads/{branch}` refspec when force is true

2. **Updated Git Service** (`crates/services/src/services/git.rs:1615`)
   - Added `force: bool` parameter to `push_to_github()` method
   - Passes force flag to Git CLI

3. **Added Force Push Endpoint** (`crates/server/src/routes/task_attempts.rs:608`)
   - New handler: `force_push_task_attempt_branch`
   - Calls `push_to_github()` with `force: true`
   - Regular push endpoint now passes `force: false`

4. **Added Route** (`crates/server/src/routes/task_attempts.rs:1581`)
   - Route: `POST /api/task-attempts/:id/push/force`

5. **API Client** (`frontend/src/lib/api.ts:561`)
   - Added `forcePush()` method
   - Returns `Result<void, PushError>`

6. **Created useForcePush Hook** (`frontend/src/hooks/useForcePush.ts`)
   - React Query mutation for force push
   - Handles typed errors
   - Invalidates branch status on success

7. **Created ForcePushDialog** (`frontend/src/components/dialogs/git/ForcePushDialog.tsx`)
   - Destructive variant with warning icon
   - Clear warning about overwriting remote changes
   - Buttons: "Cancel" and "Force Push"

8. **Integrated Dialog Flow** (`frontend/src/hooks/useGitOperations.ts:58-85`)
   - When regular push fails with `force_push_required` error:
     - Shows ForcePushDialog to confirm
     - If user confirms, executes force push
     - Handles errors from force push operation

1. User attempts to push
2. If remote has diverged, backend returns `force_push_required` error
3. Frontend shows confirmation dialog explaining the consequences
4. User can cancel or confirm force push
5. If confirmed, force push is executed
6. Success/error feedback is shown

All checks pass successfully! The feature is ready to use.

Cleanup script changes for task attempt 982f21cc-f0a3-455d-8b30-3a9911c2889f

Perfect! The fix is complete and all checks pass. Here's what was changed:

**Problem:** The `push_task_attempt_branch` endpoint was using the `?` operator which converted `GitServiceError::GitCLI(GitCliError::PushRejected(_))` into a generic `ApiError`, preventing the frontend from receiving the typed `PushError::ForcePushRequired` error.

**Solution:** Updated the endpoint in `crates/server/src/routes/task_attempts.rs:602-613` to use a `match` statement that:
1. Returns success on `Ok(_)`
2. Detects `GitServiceError::GitCLI(GitCliError::PushRejected(_))` and returns the typed error `ApiResponse::error_with_data(PushError::ForcePushRequired)`
3. Returns generic `ApiError::GitService(e)` for other errors

Now when a push is rejected due to non-fast-forward, the backend will return:
```json
{
  "success": false,
  "error_data": {
    "type": "force_push_required"
  }
}
```

This will trigger the force push confirmation dialog in the frontend, allowing the user to choose whether to force push or cancel.

Cleanup script changes for task attempt 982f21cc-f0a3-455d-8b30-3a9911c2889f

Perfect! The fix is complete and all checks pass. Here's what was changed:

**Problem:** The ForcePushDialog was not closing after the user clicked "Force Push" or "Cancel" because it only called `modal.resolve()` without calling `modal.hide()`.

**Solution:** Added `modal.hide()` calls to both handlers in `frontend/src/components/dialogs/git/ForcePushDialog.tsx`:

- **Line 24:** Added `modal.hide()` after `modal.resolve('confirmed')` in `handleConfirm`
- **Line 29:** Added `modal.hide()` after `modal.resolve('canceled')` in `handleCancel`

Now the dialog will properly close when the user clicks either button. This follows the correct NiceModal pattern where you need both:
1. `modal.resolve()` - to resolve the promise with a result
2. `modal.hide()` - to actually hide the dialog

The force push feature should now work end-to-end: push rejection → confirmation dialog → force push → dialog closes.

Perfect! All checks pass. Here's what was fixed:

The force push dialog now follows the same pattern as all other async dialogs in the codebase.

**Added:**
- `attemptId` prop (required) to identify which task attempt to force push
- `useForcePush` hook usage internally
- Loading state with `forcePush.isPending`
- Error state displayed in the dialog
- Loader spinner and "Force Pushing..." button text during operation
- Disabled buttons during operation
- Dialog stays open until operation completes

**Behavior:**
- User clicks "Force Push" → button shows spinner and "Force Pushing..."
- On success → dialog closes automatically
- On error → error shown in dialog, stays open, user can retry or cancel

**Changed:**
- Removed the manual force push call after dialog confirmation
- Now passes `attemptId` to the dialog: `ForcePushDialog.show({ attemptId })`
- Dialog handles the entire force push operation internally

1. User attempts push
2. Push rejected with `force_push_required` error
3. Dialog appears with warning
4. User clicks "Force Push"
5. **Button shows spinner and "Force Pushing..."** ← New!
6. **Buttons disabled during operation** ← New!
7. On success: dialog closes
8. On error: error displayed in dialog, user can retry

This matches the pattern used by CreatePRDialog, GhCliSetupDialog, and other async dialogs in the codebase.

* Force push i18n (vibe-kanban 5519a7db)

Run @scripts/check-i18n.sh until it passes. Make sure to check the script and set GITHUB_BASE_REF to vk/607c-add-pre-flight-c

Force push i18n (vibe-kanban 5519a7db)

Run @scripts/check-i18n.sh until it passes. Make sure to check the script and set GITHUB_BASE_REF to vk/607c-add-pre-flight-c

* fix tests
2025-11-24 15:52:05 +00:00
..
2025-11-20 10:52:34 +00:00
2025-11-20 10:52:34 +00:00
2025-11-24 15:52:05 +00:00
2025-11-24 15:52:05 +00:00
2025-11-20 16:38:28 +00:00