- Remove unused imports (Badge, PullRequestCheck)
- Fix React Hook dependency warnings by using useCallback
- Replace 'any' types with proper TypeScript interfaces
- Fix unused variable errors by prefixing with underscore
- Remove placeholder comments
- Consolidate duplicate type definitions at module level
- Add proper type definitions for API responses
- Fix const vs let issues
Use double type assertion (as unknown as) to properly convert the discriminated
union type from nip19.decode(). This resolves all TypeScript type compatibility
issues across different versions.
Add explicit type assertion to nip19.decode() result to avoid TypeScript
version differences in discriminated union handling. This ensures consistent
type checking across different TypeScript versions used in CI/CD vs local.
Use positive type guard (decoded.type === 'npub' && typeof decoded.data === 'string')
to properly narrow the union type. TypeScript requires both conditions to infer the
correct type for decoded.data when dealing with discriminated unions.
Use negative type guard (decoded.type !== 'npub') to properly narrow the
union type, allowing TypeScript to infer decoded.data as string when
type is 'npub'. This fixes the type overlap error.
- Fix duplicate useState import in GitManagementDialog
- Add missing hostTokens property to GitSettings in all test files
- Fix type narrowing issues in PullRequestDialog with proper type assertions
- Fix fetch headers to use Record<string, string> type
- Fix credentials type to GitCredential | undefined instead of null
- Fix auth callback to handle undefined credentials
- Fix patchLines array type annotation
- Fix git statusMatrix workdir type assertions
- All TypeScript compilation errors resolved
Fixed the issue where patch creation failed with "branches are identical" error.
The problem was comparing the head branch against local main/master instead of
the remote tracking branch (origin/main). For Nostr git repos, users typically
have local changes that differ from the remote, so we need to compare against
origin/baseBranch to find the unique commits.
Changes:
- Try to resolve origin/<baseBranch> first (e.g., origin/main)
- Fall back to local branch if remote tracking branch doesn't exist
- Log which reference is being used for comparison
- Update error message to show which branches were compared
This ensures patches include all commits that differ from the remote, not just
commits that differ from local main (which might be synced with the feature branch).
Modified patch creation workflow to automatically announce repositories if they
don't exist, eliminating the need for users to manually click "Announce Repository".
Key changes:
- Query for repository announcement before creating patch
- If not found, automatically create and publish kind 30617 event
- Use user's configured relay from Shakespeare settings
- Auto-detect earliest unique commit (euc) from git history
- Show toast notification when auto-announcing
- Fall back to manual announcement if auto-announce fails
The workflow is now seamless:
1. User clicks "Create Patch"
2. System checks for repository announcement
3. If missing, creates it automatically in background
4. Publishes patch with proper references
This ensures patches are always discoverable since the announcement is guaranteed
to exist on the same relay before the patch is published. Users no longer need to
understand the two-step process - it "just works".
Extended usePullRequests hook to fetch and display Nostr patches (kind 1617):
- Parse nostr:// URLs with npub/hex pubkey support
- Query patches created by current user using #a tag filter
- Convert patch events to PullRequest format for unified display
- Extract source/target branches from patch content
Updated GitDialog to show Nostr patches:
- Display "Your Patches" section for Nostr repos (like GitHub/GitLab PRs)
- Show patch title, number (first 8 chars of event ID), and branches
- Remove external link button for Nostr (event references aren't clickable URLs)
Enhanced debugging for troubleshooting patch discovery issues:
- Log repository announcement query filter and results
- Log event coordinates and relay information
- Provide verification instructions after publishing announcements
- Warn when repository announcement not found with helpful context
This helps diagnose why patches aren't showing in NostrHub - likely due to:
1. Repository announcement not published to same relay
2. Different relays between Shakespeare and NostrHub
3. Relay propagation delays
The patch implementation was missing several critical tags required by NIP-34:
1. Added 'r' tag with earliest unique commit (euc) from repository announcement
- This enables clients to subscribe to all patches for a specific repo
- Queries the repository's kind 30617 event to get the euc value
2. Improved patch content format to follow git format-patch style
- Includes proper From/Date/Subject headers
- Lists all unique commits with author info and messages
- Follows standard git patch format for better interoperability
3. Added commit-related tags for stable commit IDs:
- 'commit' tag with current HEAD commit ID
- 'parent-commit' tag with parent commit ID
- 'committer' tag with name, email, timestamp, and timezone
- Additional 'r' tag with commit ID for filtering
4. Query repository announcement for relay hints
- Publishes patches to relays specified in the repo's 'relays' tags
- Falls back to default relay if no announcement found
These changes ensure patches are properly discoverable by other Nostr git clients
and follow the complete NIP-34 specification for patch events (kind 1617).
- Change URL format from `nostr://<npub>/<domain>/<repo>` to `nostr://<hex-pubkey>/<repo-id>`
- Auto-convert npub to hex pubkey in URL parsing
- Fix hanging issue caused by invalid pubkey format in repository queries
- Update parseRepoUrl in types.ts to handle npub decoding
- Update PullRequestDialog to decode npub before querying
- Update NOSTR_GIT.md with correct URL format examples
The correct format is:
- `nostr://<hex-pubkey>/<repo-id>` (preferred)
- `nostr://<npub>/<repo-id>` (auto-converted to hex)
Fixes the issue where patch publishing would hang indefinitely when trying to query repositories with npub-formatted URLs.
- Implement NostrGitProvider following GitHostProvider interface
- Support nostr:// URL format (nostr://<pubkey>/<repo-id>)
- Create patches (kind 1617) as Nostr events per NIP-34
- Unified PR dialog works for GitHub, GitLab, and Nostr git
- Auto-detect platform and adapt UI (PR vs Patch terminology)
- No forking/credentials needed for Nostr - uses logged-in signer
- Publish patches to repository's designated relays
- Update detection logic to recognize Nostr git URLs
- Show "Patches" card for Nostr repos in main Git dialog
- Remove duplicate "Create Nostr Patch" button
- Add comprehensive NOSTR_GIT.md documentation
The UI flow is now consistent across all git platforms:
1. Click "Create Pull Request" (or "Create Patch" for Nostr)
2. Fill in title and description in the same form
3. System handles platform-specific logic behind the scenes
Moved checkPermissionsAndFork definition before the useEffect that references it in the dependency array. This fixes the "Cannot access before initialization" error that was causing the Git Management dialog to crash.
Added detailed console logging throughout the fork workflow:
- Fork info detection and state
- Permission checking results
- Fork creation process
- Head ref format being used
- Full request body sent to GitHub API
- Remote info parsing
This will help diagnose the "head: invalid" error by showing exactly what data is being sent and in what state the fork detection is.
Fixed useEffect dependency - checkPermissionsAndFork now runs AFTER remoteInfo is set, not before.
**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.
The PullRequestDialog was trying to access `credentials.token` which doesn't exist
in the GitCredential interface. The actual token is stored in the `password` field.
Additionally, GitLab's API requires the `PRIVATE-TOKEN` header for Personal Access
Tokens, not `Authorization: Bearer`. Updated both the GitHub and GitLab API calls
to use the correct credential field and proper authentication headers.
Changes:
- Changed credentials.token to credentials.password for both GitHub and GitLab
- Updated GitLab API calls to use PRIVATE-TOKEN header instead of Authorization Bearer
- Added comprehensive logging to help debug credential issues
- Added validation to check if token is empty and provide helpful error message
This fixes the "401 Unauthorized" error when creating merge requests on GitLab.
Fix issues with pull request creation by improving remote URL parsing and adding comprehensive error logging.
FIXES:
- Normalize URLs before parsing (remove .git suffix first)
- More flexible regex patterns (handle both http and https)
- Better owner/repo extraction
- Clearer error messages showing detected platform
IMPROVEMENTS:
- Console logging for debugging PR creation flow
- Show which platform was detected (GitHub/GitLab)
- Log API URLs and request data
- Better error messages with status codes and response text
- Credential detection logging
ERROR HANDLING:
- Parse API error responses properly
- Show full error details in console
- Display helpful error messages to users
- Include URL and platform info in error messages
This should fix the "Failed to get GitLab Project: 401" error by:
1. Correctly detecting GitHub URLs (not misidentifying as GitLab)
2. Providing clear logging to diagnose credential issues
3. Showing which credentials are being used