Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/app/services/auth/verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async def create_verification_session(discord_id: str) -> Optional[str]:
"""
supabase = get_supabase_client()

await cleanup_expired_tokens()
_cleanup_expired_sessions()

token = str(uuid.uuid4())
Expand Down
19 changes: 9 additions & 10 deletions backend/app/services/codegraph/repo_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,21 @@ async def index_repo(self, repo_input: str, discord_id: str) -> Dict[str, Any]:
"status": "error",
"message": f"Repository already indexed. Graph: `{repo_data['graph_name']}`"
}
elif status == 'pending':
return {
"status": "error",
"message": "Repository indexing in progress. Please wait."
}
# If failed, we'll allow re-indexing by updating the existing record

# Update existing failed record
logger.info(f"Updating existing failed record for {repo_info['full_name']}")

# if status is pending or failed --> restart indexing
logger.info(
f"Restarting indexing for {repo_info['full_name']} "
f"(previous status: {status})"
)

logger.info(f"Updating existing record for {repo_info['full_name']}")
await self.supabase.table("indexed_repositories").update({
"indexing_status": "pending",
"last_error": None,
"updated_at": datetime.now().isoformat()
}).eq("id", repo_data['id']).execute()
else:
# Insert new record
# Insert new record (new repository)
logger.info(f"Creating new record for {repo_info['full_name']}")
await self.supabase.table("indexed_repositories").insert({
"repository_full_name": repo_info['full_name'],
Expand Down
54 changes: 38 additions & 16 deletions backend/integrations/discord/cogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import discord
from discord import app_commands
from discord.ext import commands, tasks
from datetime import datetime, timezone

from app.agents.devrel.onboarding.messages import (
build_encourage_verification_message,
Expand Down Expand Up @@ -129,18 +130,40 @@ async def verify_github(self, interaction: discord.Interaction):
return

if user_profile.verification_token:
embed = discord.Embed(
title="⏳ Verification Pending",
description="You already have a verification in progress.",
color=discord.Color.orange()
)
embed.add_field(
name="What to do",
value="Please complete the existing verification or wait for it to expire (5 minutes).",
inline=False
)
await interaction.followup.send(embed=embed, ephemeral=True)
return
expires_at = user_profile.verification_token_expires_at
is_expired = False

if expires_at:
if isinstance(expires_at, str):
expires_at_dt = datetime.fromisoformat(expires_at)
else:
expires_at_dt = expires_at

if expires_at_dt.tzinfo is None:
expires_at_dt = expires_at_dt.replace(tzinfo=timezone.utc)

now_utc = datetime.now(timezone.utc)

if expires_at_dt < now_utc:
is_expired = True

else:
# token exists but no expiry → treat as expired
is_expired = True

if not is_expired:
embed = discord.Embed(
title="⏳ Verification Pending",
description="You already have a verification in progress.",
color=discord.Color.orange()
)
embed.add_field(
name="What to do",
value="Please complete the existing verification or wait for it to expire (5 minutes).",
inline=False
)
await interaction.followup.send(embed=embed, ephemeral=True)
return

session_id = await create_verification_session(str(interaction.user.id))
if not session_id:
Expand Down Expand Up @@ -199,7 +222,8 @@ async def index_repository(self, interaction: discord.Interaction, repository: s
title="🔄 Indexing Repository",
description=(
f"Indexing `{repository}`...\n\n"
"This typically takes 5-30 minutes depending on repository size."
"⏳ Note: For large repositories, indexing can take 30-35 minutes.\n"
"Please wait until the process completes."
),
color=discord.Color.blue()
)
Expand Down Expand Up @@ -252,7 +276,7 @@ async def _run_index_and_update():
error_msg = result.get("message", "Unknown error")
error_embed = discord.Embed(
title="❌ Indexing Failed",
description=f"Could not index `{repository}`",
description=f"Indexing did not complete `{repository}`",
color=discord.Color.red()
)
error_embed.add_field(
Expand All @@ -264,8 +288,6 @@ async def _run_index_and_update():
tip = None
if "already indexed" in error_msg.lower():
tip = "This repository is already indexed! You can query it directly."
elif "pending" in error_msg.lower():
tip = "Indexing is in progress. Check status with `/list_indexed_repos`"

if tip:
error_embed.add_field(
Expand Down