mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-07 16:19:09 +00:00
Port six upstream commits onto dev:
- c03a6be7 (already ported): keep plan guidance high-level
- 546042a4: add workflow approval UI with diff preview, approval URLs,
web review links, and polling for approval status during active runs
- 216cf181: remove workflow token elevation; approved pushes pass
through directly without proxy token rewriting
- 3dbc0282: preserve plan redirects after login by accepting relative
same-origin redirect_to values and rejecting blocked paths
- bb104d93: submit plan comments with cmd+enter
- 90cb6caa: terse Slack replies, shared content via save_plan outside
plan mode (PLAN_STATUS_SHARED), reject shared-content mutations
Refs: #135
45 lines
1.6 KiB
Python
45 lines
1.6 KiB
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_plan_url(thread_id: str) -> str | None:
|
|
"""Build the dashboard plan-review 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='')}/plan"
|
|
|
|
|
|
def dashboard_workflow_approval_url(thread_id: str, fingerprint: str) -> str | None:
|
|
"""Build the dashboard workflow approval URL for a thread/fingerprint."""
|
|
thread_url = dashboard_thread_url(thread_id)
|
|
if not thread_url or not fingerprint:
|
|
return thread_url
|
|
return f"{thread_url}?workflowApproval={quote(fingerprint, 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='')}"
|
|
)
|