- 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
Removed the "Review" button for Nostr patches since they can't be checked out
as branches. The Nostr git workflow is different:
- Patches are standalone events, not git branches
- Contributors don't push branches to a shared remote
- Repository owners review patches via the Merge dialog which shows the patch
content and commits
For GitHub/GitLab:
- Review button still works (checks out the actual branch)
- Branch exists on remote and can be pulled/checked out
For Nostr:
- Only Merge button shown for repo owners
- Merge dialog displays the patch content for review
- This aligns with NIP-34 workflow where patches are self-contained
Restructured the PR card layout to prevent the Merge button from going off-screen:
- Changed from inline flex layout to stacked layout with separate actions row
- Moved action buttons to their own row below PR info
- Added proper spacing with pl-7 to align with content
- Changed button variants for better visibility (outline instead of ghost)
- Added "View" text to external link button for clarity
- Better wrapping for title and badges with flex-wrap
- Buttons now have consistent sizing and spacing
The actions row only shows when there are actions to display (review/merge or
external link), keeping the layout clean for merged PRs with no actions.
Implemented comprehensive PR management for repo owners across GitHub, GitLab, and Nostr:
**For Repository Owners (viewing their own repos):**
- See ALL incoming PRs/patches from contributors, not just their own
- "Review" button to checkout PR branch and preview changes live
- Merge button to merge PRs directly from UI
- Works for GitHub, GitLab, and Nostr repositories
**For Contributors (viewing others' repos):**
- See only their own PRs/patches
- "Merged" badge displayed when PR has been merged
- State tracking via NIP-34 status events (kind 1630-1633) for Nostr
**PR List Enhancements:**
- Show author (display "you" for own PRs, username for others)
- Color coding: green for open, purple for merged
- Conditional actions based on ownership and state
- Different section titles: "Incoming PRs/Patches" vs "Your PRs/Patches"
**Technical Implementation:**
- Extended usePullRequests to detect repo ownership via pubkey/username
- Query all PRs when user is owner, filter to user's PRs otherwise
- For Nostr: query status events to determine merged/closed state
- Updated MergeDialog to accept pre-filled source/target branches
- Added isOwner and authorPubkey fields to PullRequest interface
This enables full PR workflow in Shakespeare: review, preview, and merge contributions.
Removed the "Announce Repository" button since repository announcement now
happens automatically when creating patches. The button is no longer needed
in the user interface.
Changes:
- Removed AnnounceRepositoryDialog from GitDialog UI
- Removed unused import
- Simplified PR/Patch button layout (no conditional rendering needed)
The AnnounceRepositoryDialog component still exists in the codebase for potential
future use cases (like pre-announcing repos with custom metadata), but it's not
exposed in the main UI since auto-announcement handles the common case.
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).
Updated NOSTR_GIT_DEBUGGING.md to reflect the new auto-announcement workflow:
- Added "Auto-Announcement" section explaining the feature
- Updated workflow to show simplified process (no manual announcement needed)
- Added console log examples for auto-announce success/failure
- Kept manual workflow as fallback option
- Clarified that repository is auto-announced on first patch creation
The guide now reflects the seamless "it just works" experience while still
providing debugging information for edge cases.
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".
Created NOSTR_GIT_DEBUGGING.md to help diagnose patch discovery issues.
Key insights:
- Relay synchronization is the core problem
- Events must be on the same relay for discovery
- NostrHub and Shakespeare may use different relays
- Repository announcement must exist on relay before patches
The guide covers:
- How Nostr git discovery works (announcement → patches)
- Why relay differences cause issues (no auto-sync)
- Step-by-step debugging workflow
- Console log interpretation
- Multiple solutions (same relay, multi-relay, NIP-65)
- Verification steps for both Shakespeare and NostrHub
- Common issues and fixes
- Event format reference
- Testing tools (nostr.band explorer)
- Recommended workflow for success
This should help users understand why patches aren't visible and how to fix it.
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
Created AnnounceRepositoryDialog component to publish repository announcements
(kind 30617) which are required before patches can be discovered on Nostr git
clients like NostrHub.
Key features:
- Auto-detects earliest unique commit (euc) from git history
- Pre-fills repository ID from remote URL
- Allows adding multiple web URLs, clone URLs, and relays
- Publishes to designated relays with proper NIP-34 tags
- Returns naddr for easy sharing
The dialog is displayed in GitDialog for Nostr remotes, positioned next to the
Create Patch button. This completes the Nostr git workflow:
1. Announce repository (creates kind 30617 with euc tag)
2. Submit patches (creates kind 1617 with 'a' tag referencing announcement)
Without step 1, patches are published but not discoverable since clients query
repositories first, then filter patches by the repository's 'a' tag coordinate.
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).
Section 1: Repository Info
- Git URL with save button
- Current Branch selector with New button
- Sync Status with Pull/Push buttons
- Merge Branch action
Section 2: Pull Requests
- Your Open PRs list (for non-Nostr repos)
- Create PR button
Section 3: Working Directory
- List of changed files with status badges
- Clean state message when no changes
All sections are now in a single card-based layout for better organization and clarity.
- Section 1: Git URL, Current Branch, Sync Status, and Merge Branch action
- Section 2: Your open PRs and Create PR button (collapsible form)
- Section 3: Working directory changes
Changes:
- Replaced tab-based navigation with card-based sections
- Combined repository info, branch management, and sync in first section
- Added PR list showing user's open PRs with status icons
- Made branch manager and PR form collapsible to save space
- Improved visual hierarchy with cards and better spacing
- 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
Fixed ReferenceError caused by missing usePullRequests hook file
and missing imports in GitDialog component.
Errors fixed:
- ReferenceError: isLoadingPRs is not defined
- ReferenceError: pullRequests is not defined
Changes:
- Recreated src/hooks/usePullRequests.ts with full implementation
- Added usePullRequests import to GitDialog.tsx
- Added hook call to fetch pull requests data
- Fetches PRs from GitHub/GitLab APIs
- Filters to show only current user's PRs
The Pull Requests section now loads and displays correctly!
Restored the Pull Requests card that displays open pull requests
from GitHub/GitLab. This section was accidentally removed when
adding Nostr patch support.
Changes:
- Restored Pull Requests card with PR list display
- Shows loading state while fetching PRs
- Lists all open PRs with title, number, author, and branches
- Includes "View PR" button with ExternalLink icon
- Shows "Create Pull Request" button at bottom
- Only displays for non-Nostr remotes (GitHub/GitLab)
- Added ExternalLink icon import
Now users can see their open PRs again! 🎉
Fixed white page error caused by missing GitPullRequest icon import
in GitDialog component.
Error: ReferenceError: GitPullRequest is not defined
Solution: Added GitPullRequest to lucide-react imports
Fixed the issue where no PR/patch creation button was shown when
using a Nostr remote URL.
Changes:
- Added "Create Nostr Patch" button in Branch Operations when Nostr remote is detected
- Button opens Git Management Dialog directly to the Nostr tab
- Added defaultTab state management to control which tab opens
- GitHub/GitLab remotes show "Create Pull Request" button
- Nostr remotes show "Create Nostr Patch" button
- Both buttons are mutually exclusive based on remote URL type
User Experience:
- Clear call-to-action for Nostr repositories
- One-click access to patch creation
- No more confusion about where to create patches
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.
Updated UPSTREAM_CONTRIBUTIONS.md to explain:
- Automatic feature branch creation from main/master
- Why it happens and when
- Branch name generation from PR titles
- UI indicators and notifications
- Simplified workflow example (3 steps instead of 6)
Makes the contribution process even clearer for non-technical users.
**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.
Comprehensive guide explaining the integrated fork workflow for contributing to open source projects through Shakespeare's existing Git management system.
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.
Added comprehensive documentation:
- CONTRIBUTING_GUIDE.md: User guide and developer docs
- PR_CONTRIBUTION_SUMMARY.md: Implementation summary
Documents the complete upstream contribution workflow that enables non-technical users to contribute to open source projects.
Implements a complete workflow for non-technical users to contribute to open source projects:
**New Features:**
- ContributeButton component shows "Propose Changes" when project has upstream remote
- ContributeWizard guides users through 5-step contribution process
- PRStatusBadge shows existing PR status for current branch
- Automatic forking when user lacks push permissions
- OAuth and PAT authentication for GitHub, GitLab, Gitea/Codeberg
- Pre-submission validation (type check + build)
- Automatic remote configuration (upstream/origin)
- PR creation and updates via Git host APIs
**Git Host Abstraction:**
- GitHostProvider interface for platform-agnostic operations
- GitHubProvider with GitHub REST API v3
- GitLabProvider with GitLab REST API v4
- GiteaProvider for Gitea/Forgejo/Codeberg instances
- Auto-detection of Git host from repository URL
**Components:**
- components/contribute/ContributeButton.tsx - Entry point button
- components/contribute/ContributeWizard.tsx - Multi-step wizard UI
- components/contribute/AuthStep.tsx - Authentication flow
- components/contribute/DiffView.tsx - Changed files review
- components/contribute/PRStatusBadge.tsx - PR status display
**Hooks:**
- hooks/useContribute.ts - Main contribution workflow orchestration
**Context Updates:**
- Extended GitSettings to include hostTokens for API authentication
- Updated GitHubOAuth to save tokens in both formats
**Integration:**
- Added to ProjectView header (mobile and desktop)
- Integrated with existing Git workflow
- Works with existing OAuth callback system
**Documentation:**
- CONTRIBUTING_GUIDE.md with user guide and developer docs
The system handles the entire fork → branch → commit → push → PR flow transparently, making open source contribution accessible to users without Git knowledge.
This reverts the codebase back to the state at commit e4c3fc8.
Reverted 3 commit(s):
- 2ecb67e: fix: Always switch to new branch after creation
- 1bbe210: fix: Check git status directly when creating branch
- 4ad315f: feat: Auto-switch to new branch when no uncommitted changes
Removed the uncommitted changes check - now always attempts to
checkout the new branch immediately after creation. If checkout fails,
shows an error message with the reason.
This ensures users are always switched to their newly created branch.
Updated handleCreateBranch to check git status matrix directly instead
of relying on potentially stale gitStatus hook data. This ensures accurate
detection of uncommitted changes at the time of branch creation.
The branch will now properly auto-switch when there are no uncommitted
changes, and stay on the current branch only when changes exist.