From 4df6401fa7fd4b94fe3bee5e590cea7dceb9f338 Mon Sep 17 00:00:00 2001 From: zeno Date: Fri, 24 Jul 2026 00:38:48 +0800 Subject: [PATCH] feat: link share pages to GitHub --- deploy/cloudflare-worker/src/index.js | 65 ++++++++++++++++++--- deploy/cloudflare-worker/test/index.test.js | 6 ++ 2 files changed, 64 insertions(+), 7 deletions(-) diff --git a/deploy/cloudflare-worker/src/index.js b/deploy/cloudflare-worker/src/index.js index 36c2172..cc2c28c 100644 --- a/deploy/cloudflare-worker/src/index.js +++ b/deploy/cloudflare-worker/src/index.js @@ -27,6 +27,7 @@ const SHARE_PAGE_COPY = { agentsKicker: "FOR AGENTS", restoreTitle: "Restore locally", restoreCopy: "Choose Codex or Claude Code and import the complete session as a new native thread or session.", + githubLabel: "View Agent Capsule on GitHub", languageLabel: "Language", englishLanguage: "English", chineseLanguage: "Chinese (Simplified)", @@ -130,6 +131,7 @@ const SHARE_PAGE_COPY = { agentsKicker: "给 AGENT", restoreTitle: "恢复到本地", restoreCopy: "选择 Codex 或 Claude Code,将完整会话导入为新的本地 thread 或 session。", + githubLabel: "在 GitHub 查看 Agent Capsule", languageLabel: "语言", englishLanguage: "English", chineseLanguage: "简体中文", @@ -768,13 +770,26 @@ function sharePageHTML(request, manifest, id, locale = "en") {

${escapeHTML(copy.previewKicker)}

- +
+ + + + +

${escapeHTML(title)}

${escapeHTML(copy.previewSubtitle)}

@@ -889,6 +904,38 @@ button, a { font: inherit; } font-weight: 700; letter-spacing: .01em; } +.preview-toolbar-actions { + display: flex; + align-items: end; + gap: 10px; +} +.github-link { + display: inline-grid; + place-items: center; + width: 38px; + height: 38px; + border: 1px solid var(--line-strong); + border-radius: 8px; + background: #fff; + color: var(--ink); + text-decoration: none; +} +.github-link:hover { + border-color: #b8c0c7; + background: #f8fafb; +} +.github-link:active { + transform: translateY(1px); +} +.github-link:focus-visible { + outline: 2px solid rgba(47, 111, 102, .32); + outline-offset: 2px; +} +.github-link svg { + display: block; + width: 19px; + height: 19px; +} .select-control { display: grid; gap: 6px; @@ -1425,6 +1472,10 @@ button, a { font: inherit; } flex-direction: column; margin-bottom: 14px; } + .preview-toolbar-actions { + width: 100%; + justify-content: space-between; + } .language-control { min-width: min(100%, 220px); } .preview-subtitle, .status, diff --git a/deploy/cloudflare-worker/test/index.test.js b/deploy/cloudflare-worker/test/index.test.js index a791b2b..fbd4ea3 100644 --- a/deploy/cloudflare-worker/test/index.test.js +++ b/deploy/cloudflare-worker/test/index.test.js @@ -237,6 +237,11 @@ test("share page serves human preview shell and agent metadata", async () => { assert.match(html, /FOR AGENTS/); assert.match(html, /Restore locally/); assert.match(html, /id="language-select"/); + assert.match( + html, + /