|
1 | 1 | """Build the call-to-action footer appended to the architecture-diff PR comment. |
2 | 2 |
|
3 | | -The footer links into CodeBoarding's click proxy (so owner/repo/pr are tracked) |
4 | | -and currently drives straight to the VS Code/Cursor **extension**: an "open this |
| 3 | +The footer drives straight to the VS Code/Cursor **extension**: an "open this |
5 | 4 | architecture in your editor" link (editor-specific) plus an "install the |
6 | | -extension" link, and a warning banner when real health findings exist. A |
| 5 | +extension" link, and a warning banner when real health findings exist. When a |
| 6 | +click proxy (``cta_base``) is set the links route through it so owner/repo/pr are |
| 7 | +tracked; otherwise they point at the final destinations directly — the editor |
| 8 | +``<scheme>:extension/...`` deep link and the Marketplace listing. A |
7 | 9 | no-install hosted-webview ("explore in browser") tier is intentionally deferred |
8 | 10 | (see docs/COMMIT_STRATEGY.md) — the committed analysis already supports it later. |
9 | 11 |
|
@@ -45,33 +47,42 @@ def detect_editors(repo_path: Path) -> list[str]: |
45 | 47 |
|
46 | 48 | _EDITOR_LABEL = {"vscode": "VS Code", "cursor": "Cursor"} |
47 | 49 |
|
| 50 | +# No-proxy fallback targets: the final destinations the click proxy would route to. |
| 51 | +_EXTENSION_ID = "Codeboarding.codeboarding" |
| 52 | +_EDITOR_DEEPLINK = {e: f"{e}:extension/{_EXTENSION_ID}" for e in _EDITOR_LABEL} |
| 53 | +_MARKETPLACE_URL = f"https://marketplace.visualstudio.com/items?itemName={_EXTENSION_ID}" |
| 54 | + |
48 | 55 |
|
49 | 56 | def build_cta(cta_base: str, owner: str, repo: str, pr: str, repo_path: Path, issues: int = 0) -> str: |
50 | | - """Return the markdown CTA footer (the warning banner shows even without a proxy URL). |
| 57 | + """Return the markdown CTA footer: a health-warning banner plus editor/extension links. |
51 | 58 |
|
52 | | - The ⚠️ health banner is informational and needs no proxy, so it renders |
53 | | - whenever ``issues > 0``; the editor/marketplace links require ``cta_base``. |
54 | | - Returns '' only when there's nothing to show. |
| 59 | + With a ``cta_base`` proxy the links route through it (owner/repo/pr tracked); |
| 60 | + without one they point straight to the destinations the proxy would route to — |
| 61 | + the editor's ``<scheme>:extension/...`` deep link and the Marketplace listing. |
| 62 | + The ⚠️ banner shows whenever ``issues > 0``. |
55 | 63 | """ |
56 | 64 | parts: list[str] = [] |
57 | 65 | if issues > 0: |
58 | 66 | noun = "issue" if issues == 1 else "issues" |
59 | 67 | parts.append(f"⚠️ **{issues} architecture {noun} found** — open CodeBoarding to explore them.") |
60 | 68 |
|
| 69 | + editors = detect_editors(repo_path) |
61 | 70 | if cta_base: |
62 | 71 | base = cta_base.rstrip("/") |
63 | 72 |
|
64 | 73 | def link(path: str, **extra: str) -> str: |
65 | 74 | return f"{base}/{path}?" + urlencode({"owner": owner, "repo": repo, "pr": pr, **extra}) |
66 | 75 |
|
67 | | - editor_links = " · ".join( |
68 | | - f"[**Open in {_EDITOR_LABEL[e]} →**]({link('open-in-editor', editor=e)})" for e in detect_editors(repo_path) |
69 | | - ) |
70 | | - parts.append(f"See this architecture in your editor: {editor_links}") |
71 | | - parts.append(f"💡 New to CodeBoarding? [**Get the extension →**]({link('use-marketplace')})") |
| 76 | + editor_href = {e: link("open-in-editor", editor=e) for e in editors} |
| 77 | + extension_href = link("use-marketplace") |
| 78 | + else: |
| 79 | + editor_href = {e: _EDITOR_DEEPLINK[e] for e in editors} |
| 80 | + extension_href = _MARKETPLACE_URL |
| 81 | + |
| 82 | + editor_links = " · ".join(f"[**Open in {_EDITOR_LABEL[e]} →**]({editor_href[e]})" for e in editors) |
| 83 | + parts.append(f"See this architecture in your editor: {editor_links}") |
| 84 | + parts.append(f"💡 New to CodeBoarding? [**Get the extension →**]({extension_href})") |
72 | 85 |
|
73 | | - if not parts: |
74 | | - return "" |
75 | 86 | lines = ["", "---"] |
76 | 87 | for p in parts: |
77 | 88 | lines += ["", p] |
|
0 commit comments