Add Nostr patch display and enhanced debugging for git operations

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
This commit is contained in:
shakespeare.diy committed 2025-10-15 00:27:37 -05:00
1 parent 166c2eb72c
commit 37fb176ea1
4 files changed
+167 -22

No files matched your search

+15 -11
View File
@@ -980,9 +980,11 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
Loading pull requests...
</div>
)}
{!originUrl.startsWith('nostr://') && !isLoadingPRs && pullRequests && pullRequests.length > 0 && (
{!isLoadingPRs && pullRequests && pullRequests.length > 0 && (
<div className="space-y-2 mb-3">
<div className="text-xs font-medium text-muted-foreground mb-2">Your Open PRs</div>
<div className="text-xs font-medium text-muted-foreground mb-2">
{originUrl.startsWith('nostr://') ? 'Your Patches' : 'Your Open PRs'}
</div>
{pullRequests.map((pr) => (
<div
key={pr.id}
@@ -996,17 +998,19 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
{pr.title}
</h4>
<p className="text-xs text-muted-foreground mt-1">
#{pr.number} by {pr.author} • {pr.sourceBranch} → {pr.targetBranch}
#{pr.number} • {pr.sourceBranch} → {pr.targetBranch}
</p>
</div>
<Button
variant="ghost"
size="sm"
className="h-8 shrink-0"
onClick={() => window.open(pr.url, '_blank')}
>
<ExternalLink className="h-3 w-3" />
</Button>
{!originUrl.startsWith('nostr://') && (
<Button
variant="ghost"
size="sm"
className="h-8 shrink-0"
onClick={() => window.open(pr.url, '_blank')}
>
<ExternalLink className="h-3 w-3" />
</Button>
)}
</div>
</div>
</div>
@@ -221,17 +221,22 @@ export function AnnounceRepositoryDialog({
created_at: Math.floor(Date.now() / 1000),
};
console.log('Creating repository announcement:', repoEvent);
console.log('=== ANNOUNCING REPOSITORY ===');
console.log('Repository ID:', repoId.trim());
console.log('Owner pubkey:', user.pubkey);
console.log('Creating repository announcement event:', repoEvent);
// Sign the event
const signedEvent = await user.signer.signEvent(repoEvent);
console.log('Signed repository announcement:', signedEvent);
console.log('Event coordinate:', `30617:${user.pubkey}:${repoId.trim()}`);
// Publish to Nostr relays
await nostr.event(signedEvent);
console.log('Published repository announcement to Nostr');
console.log('Published repository announcement to Nostr relays');
console.log('To verify: Query for kind 30617 with authors=[' + user.pubkey + '] and #d=[' + repoId.trim() + ']');
// Create naddr for the repository
const naddr = nip19.naddrEncode({
+16
View File
@@ -683,6 +683,13 @@ export function PullRequestDialog({
}
// Query for the repository announcement to get earliest unique commit (euc)
console.log('Querying for repository announcement with filter:', {
kinds: [30617],
authors: [info.owner],
'#d': [info.repo],
limit: 1,
});
const repoEvents = await nostr.query([
{
kinds: [30617],
@@ -692,17 +699,22 @@ export function PullRequestDialog({
}
]);
console.log(`Repository announcement query returned ${repoEvents.length} events`);
let earliestUniqueCommit: string | null = null;
let publishRelays = ['wss://relay.nostr.band']; // Default relay
if (repoEvents.length > 0) {
const repoEvent = repoEvents[0];
console.log('Found repository announcement event:', repoEvent);
// Get earliest unique commit from repository announcement
const eucTag = repoEvent.tags.find((t: string[]) => t[0] === 'r' && t[2] === 'euc');
if (eucTag) {
earliestUniqueCommit = eucTag[1];
console.log('Found earliest unique commit:', earliestUniqueCommit);
} else {
console.warn('No euc tag found in repository announcement');
}
// Get relay hints from repository announcement
@@ -710,9 +722,13 @@ export function PullRequestDialog({
if (relayTags.length > 0) {
publishRelays = relayTags.map((t: string[]) => t[1]);
console.log('Publishing to repository relays:', publishRelays);
} else {
console.log('No relay hints in repository announcement, using default relay');
}
} else {
console.warn('Repository announcement not found - patch may not be discoverable');
console.warn('Make sure to use "Announce Repository" button first to create kind 30617 event');
console.warn('The announcement must be on the same relay you are currently connected to');
}
// Generate git format-patch style content