open-swe/agent/utils/dashboard_links.py
Johannes du Plessis bd5d5b24d4
fix: point reviewer "Open in Web" link to the review page (#1519)
The top-level review comment's "Open in Web" link pointed at the
agent thread (/agents/{thread_id}). Point it at the dashboard review
detail page (/agents/reviews/{owner}/{repo}/{number}) instead.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-06-12 14:15:58 -07:00

29 lines
977 B
Python

"""Shared builders for dashboard ("Open in Web") URLs."""
import os
from urllib.parse import quote
_DEFAULT_DASHBOARD_BASE_URL = "https://openswe.vercel.app"
def _dashboard_base_url() -> str:
return os.environ.get("DASHBOARD_BASE_URL", _DEFAULT_DASHBOARD_BASE_URL).strip().rstrip("/")
def dashboard_thread_url(thread_id: str) -> str | None:
"""Build the dashboard thread URL for a given thread id."""
base_url = _dashboard_base_url()
if not base_url or not thread_id:
return None
return f"{base_url}/agents/{quote(thread_id, safe='')}"
def dashboard_review_url(owner: str, repo: str, pr_number: int) -> str | None:
"""Build the dashboard review-detail URL for a PR."""
base_url = _dashboard_base_url()
if not base_url or not owner or not repo or not pr_number:
return None
return (
f"{base_url}/agents/reviews/"
f"{quote(owner, safe='')}/{quote(repo, safe='')}/{quote(str(pr_number), safe='')}"
)