**Issue:**
Branch was being created and immediately checked for differences, but the check was reading the OLD currentBranch ref instead of the newly created branch, causing false "no changes" errors.
**Fix:**
- Check for uncommitted changes BEFORE creating branch (not after)
- Store the status matrix state
- Create branch
- Commit uncommitted changes to new branch using stored status
- Removed the diff check that was using stale ref data
**Why This Works:**
The statusMatrix check happens before branching, capturing the actual uncommitted state. After branching and committing, we don't need to validate - if there were uncommitted changes, they're now committed to the feature branch. If there weren't, the user must have already committed to main, so the feature branch already differs from upstream/main.
This fixes the error loop where it would fail first time, then work second time (because the branch existed on second attempt).
**Critical Fix:**
When auto-creating a feature branch from main/master:
1. Create the feature branch first
2. Checkout the feature branch
3. Commit uncommitted changes to the feature branch
4. This ensures main and feature branch differ (required for PRs)
**Previous Bug:**
- Was committing to main, then branching
- Result: main and feature-branch at same commit = no diff = "head: invalid"
**New Flow:**
- Branch from main (both at same commit)
- Checkout feature branch
- Commit changes to feature branch
- Result: feature-branch ahead of main = valid PR
**Added Logging:**
- Shows head ref format being used
- Logs PR data being sent to API
- Helps debug "head: invalid" errors
**Validation:**
- Checks if branch and main are at same commit
- Shows error if no changes to submit
- Prevents empty PRs
This fixes the "Validation Failed - head: invalid" error when creating PRs from main/master.
**New Behavior:**
When users try to create a PR while on main/master branch, automatically:
- Generate a feature branch name from the PR title
- Sanitize title (lowercase, hyphens, remove special chars)
- Add timestamp suffix for uniqueness (e.g., "fix-bug-ab3d")
- Create and checkout the new branch
- Continue with PR creation on the new branch
**UX Improvements:**
- Alert shown: "You're on the main branch. A feature branch will be automatically created..."
- Visual indicator in branch comparison section
- Toast notification when branch is created
- Clear error if branch creation fails
**Benefits:**
- Non-technical users don't need to understand branches
- Prevents accidental commits to main/master
- Follows Git best practices automatically
- Smooth workflow: make changes → create PR → done
**Example:**
PR Title: "Fix login button styling"
Generated branch: "fix-login-button-styling-k7m2"
This makes contributing to open source as simple as filling out a form, with all Git complexity handled automatically.
**Fixed:** PR creation now properly pushes branch to fork before creating PR
**Enhanced Error Messages:**
- GitHub/GitLab API errors now show detailed validation messages
- Error field details and documentation URLs included
- Whitespace preserved for multi-line error messages
- Clear explanations for common issues
**Fork Workflow Improvements:**
- Automatically detects and configures fork remote
- Pushes branch to fork before creating PR
- Handles remote configuration (origin/fork/upstream)
- Better logging for debugging workflow issues
**Detailed Error Handling:**
- Extracts error.errors array for validation details
- Shows field-specific error codes
- Includes API documentation URLs
- Explains common causes (uncommitted changes, auth issues, etc.)
This fixes the "Validation Failed" error by ensuring the branch exists in the fork before attempting to create the PR from it.
Enhanced the existing Git management dialog and PR system to support upstream contributions through automatic forking:
**Key Changes:**
- Extended PullRequestDialog to detect push permissions and auto-fork when needed
- Added permission checking via GitHub/GitLab APIs
- Created PullRequestForm component for tab-based PR creation
- Added "Pull Request" tab to GitManagementDialog
- Automatic fork creation and management when user lacks push access
- Cross-fork PR support with proper head ref formatting (owner:branch)
- UI indicators showing fork status and repository relationships
**Fork Workflow:**
1. Check if user has push permissions to upstream repo
2. If no access, check if fork exists or create one
3. Configure PR with proper head ref (fork_owner:branch)
4. Create PR from fork to upstream automatically
5. Show clear UI indicating fork-based contribution
**Integration:**
- Reuses existing Git credentials system
- Works with current GitHub/GitLab authentication
- Fits into existing branch management workflow
- No duplicate components - extends what's already there
This enables non-technical users to contribute to upstream projects through the existing Repository management UI without understanding forks or Git internals.