From 47fdb30ddd506dc87be0fcba0ed107ecdc9131ac Mon Sep 17 00:00:00 2001 From: dog Date: Sun, 1 Nov 2026 09:53:53 +0800 Subject: [PATCH 1/5] feat(web): blog detail page gets a 'Comment on GitHub' button linking to the post's issue thread (#5393 convention: blog: in title) --- src/web/client.ts | 7 ++++++- src/web/i18n.ts | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/web/client.ts b/src/web/client.ts index a26bc182f0..bd385768fb 100644 --- a/src/web/client.ts +++ b/src/web/client.ts @@ -956,6 +956,11 @@ function changelogCatOf(rawLine) { // keep the stale paint; the cache keeps its old timestamp, so the next visit retries }).then(function () { blogRefreshBusy = false; }); } + // Per-post GitHub comment thread (issue #5393 convention): one issue per blog + // post whose title carries the machine-locatable 'blog:ID' token. + function blogIssueUrl(id) { + return "https://github.com/ranxianglei/billion-context/issues?q=" + encodeURIComponent('is:issue in:title "' + id + '"'); + } async function loadBlog(sub) { const host = $("bl-list"); if (!host) return; @@ -985,7 +990,7 @@ function changelogCatOf(rawLine) { const kindLabel = item.kind === "post" ? t("bl.kind_post") : t("bl.kind_article"); const title = zhOn && item.titleZh ? item.titleZh : (item.title || ""); const html = zhOn ? (item.htmlZh || item.html || "") : (item.html || ""); - host.innerHTML = offlineNote + '
' + escapeHtml(item.date || "\u2014") + '' + escapeHtml(kindLabel) + '' + escapeHtml(t("bl.back")) + "
" + host.innerHTML = offlineNote + '
' + escapeHtml(item.date || "\u2014") + '' + escapeHtml(kindLabel) + '' + escapeHtml(t("bl.back")) + "" + '' + escapeHtml(t("bl.comment")) + "
" + '

' + escapeHtml(title) + "

" + '
' + html + "
"; return; diff --git a/src/web/i18n.ts b/src/web/i18n.ts index ff7f1e5a8a..7fcaa2b120 100644 --- a/src/web/i18n.ts +++ b/src/web/i18n.ts @@ -38,6 +38,7 @@ export const MESSAGES: Record> = { "bl.kind_article": "长文", "bl.empty": "这个版本还没内置文章。", "bl.back": "← 全部文章", + "bl.comment": "去 GitHub 评论", "bl.nf": "文章不存在或已被移除。", "bl.offline": "上次拉取未完成,显示的是缓存内容(上次成功拉取或包内文章)。", "nav.connect": "接入", @@ -762,6 +763,7 @@ export const MESSAGES: Record> = { "bl.kind_article": "Article", "bl.empty": "No bundled articles in this build.", "bl.back": "\u2190 All articles", + "bl.comment": "Comment on GitHub", "bl.nf": "Article not found or removed from this build.", "bl.offline": "Last refresh did not finish — showing cached content (the last good pull or bundled articles).", "nav.connect": "Connect", From 986eed496136a97f2b987299a46e1028cf5cf8d9 Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 1 Nov 2026 10:16:28 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix(web):=20review=20nits=20for=20the=20blo?= =?UTF-8?q?g=20comment-thread=20link=20=E2=80=94=20space=20between=20the?= =?UTF-8?q?=20two=20detail-header=20links=20(they=20rendered=20glued);=20p?= =?UTF-8?q?in=20the=20new=20anchor=20in=20web-blog-route?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web/client.ts | 2 +- tests/web-blog-route.test.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/web/client.ts b/src/web/client.ts index bd385768fb..a495ae482b 100644 --- a/src/web/client.ts +++ b/src/web/client.ts @@ -990,7 +990,7 @@ function changelogCatOf(rawLine) { const kindLabel = item.kind === "post" ? t("bl.kind_post") : t("bl.kind_article"); const title = zhOn && item.titleZh ? item.titleZh : (item.title || ""); const html = zhOn ? (item.htmlZh || item.html || "") : (item.html || ""); - host.innerHTML = offlineNote + '
' + escapeHtml(item.date || "\u2014") + '' + escapeHtml(kindLabel) + '' + escapeHtml(t("bl.back")) + "" + '' + escapeHtml(t("bl.comment")) + "
" + host.innerHTML = offlineNote + '
' + escapeHtml(item.date || "\u2014") + '' + escapeHtml(kindLabel) + '' + escapeHtml(t("bl.back")) + " " + '' + escapeHtml(t("bl.comment")) + "
" + '

' + escapeHtml(title) + "

" + '
' + html + "
"; return; diff --git a/tests/web-blog-route.test.ts b/tests/web-blog-route.test.ts index 373ae4232c..2042e6a8e4 100644 --- a/tests/web-blog-route.test.ts +++ b/tests/web-blog-route.test.ts @@ -113,6 +113,10 @@ test("#/blog/ renders that single article with a back link", async () => { const list = r.els.get("bl-list")!; assert.ok(list.innerHTML.includes("post-body") && (list.innerHTML.includes("

hi

") || list.innerHTML.includes("\u4f60\u597d

")), "article body rendered (locale-twin aware)"); assert.ok(list.innerHTML.includes(''), "back link to the index present"); + // #5396: the detail header also carries the GitHub comment-thread link — + // repo-scoped issue search on the post id (#5393 convention), new tab, noopener. + const issueHref = "https://github.com/ranxianglei/billion-context/issues?q=" + encodeURIComponent('is:issue in:title "demo"'); + assert.ok(list.innerHTML.includes('href="' + issueHref + '" target="_blank" rel="noopener"'), "GitHub comment-thread link present for the post id"); }); test("unknown slug degrades to a back link without a crash", async () => { From ff472bc14c3db97d0e0899c425fb6fc0cdbf0018 Mon Sep 17 00:00:00 2001 From: dog Date: Sun, 1 Nov 2026 15:10:55 +0800 Subject: [PATCH 3/5] feat(web): comment button links to repo Discussions threads (#5411 convention) instead of issues --- src/web/client.ts | 8 ++++---- tests/web-blog-route.test.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/web/client.ts b/src/web/client.ts index a495ae482b..52ec2ae5e3 100644 --- a/src/web/client.ts +++ b/src/web/client.ts @@ -956,10 +956,10 @@ function changelogCatOf(rawLine) { // keep the stale paint; the cache keeps its old timestamp, so the next visit retries }).then(function () { blogRefreshBusy = false; }); } - // Per-post GitHub comment thread (issue #5393 convention): one issue per blog + // Per-post discussion thread (Discussion #5411 convention): one repo Discussion per blog // post whose title carries the machine-locatable 'blog:ID' token. - function blogIssueUrl(id) { - return "https://github.com/ranxianglei/billion-context/issues?q=" + encodeURIComponent('is:issue in:title "' + id + '"'); + function blogDiscussionUrl(id) { + return "https://github.com/ranxianglei/billion-context/discussions?discussions_q=" + encodeURIComponent('is:open in:title "' + id + '"'); } async function loadBlog(sub) { const host = $("bl-list"); @@ -990,7 +990,7 @@ function changelogCatOf(rawLine) { const kindLabel = item.kind === "post" ? t("bl.kind_post") : t("bl.kind_article"); const title = zhOn && item.titleZh ? item.titleZh : (item.title || ""); const html = zhOn ? (item.htmlZh || item.html || "") : (item.html || ""); - host.innerHTML = offlineNote + '
" + host.innerHTML = offlineNote + '
' + escapeHtml(item.date || "\u2014") + '' + escapeHtml(kindLabel) + '' + escapeHtml(t("bl.back")) + " " + '' + escapeHtml(t("bl.comment")) + "
" + '

' + escapeHtml(title) + "

" + '
' + html + "
"; return; diff --git a/tests/web-blog-route.test.ts b/tests/web-blog-route.test.ts index 2042e6a8e4..64be76e1e2 100644 --- a/tests/web-blog-route.test.ts +++ b/tests/web-blog-route.test.ts @@ -113,10 +113,10 @@ test("#/blog/ renders that single article with a back link", async () => { const list = r.els.get("bl-list")!; assert.ok(list.innerHTML.includes("post-body") && (list.innerHTML.includes("

hi

") || list.innerHTML.includes("\u4f60\u597d

")), "article body rendered (locale-twin aware)"); assert.ok(list.innerHTML.includes(''), "back link to the index present"); - // #5396: the detail header also carries the GitHub comment-thread link — - // repo-scoped issue search on the post id (#5393 convention), new tab, noopener. - const issueHref = "https://github.com/ranxianglei/billion-context/issues?q=" + encodeURIComponent('is:issue in:title "demo"'); - assert.ok(list.innerHTML.includes('href="' + issueHref + '" target="_blank" rel="noopener"'), "GitHub comment-thread link present for the post id"); + // #5396: the detail header also carries the GitHub discussion-thread link — + // repo-scoped Discussions search on the post id (#5411 convention), new tab, noopener. + const discHref = "https://github.com/ranxianglei/billion-context/discussions?discussions_q=" + encodeURIComponent('is:open in:title "demo"'); + assert.ok(list.innerHTML.includes('href="' + discHref + '" target="_blank" rel="noopener"'), "GitHub discussion-thread link present for the post id"); }); test("unknown slug degrades to a back link without a crash", async () => { From 3a88c0a431cefcffe03f72355acb0ffdc9512b8e Mon Sep 17 00:00:00 2001 From: ranxianglei-devbox Date: Sun, 1 Nov 2026 15:45:42 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feat(web):=20exact=20discussion=20link=20fr?= =?UTF-8?q?om=20recorded=20number=20+=20in-page=20EN|=E4=B8=AD=E6=96=87=20?= =?UTF-8?q?pins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The comment button no longer guesses a repo-wide Discussions search URL: it renders only when the feed carries a recorded thread number (item.discussion, written back by the blog pipeline workflow into articles.json) and links straight to /discussions/. A post without a recorded thread shows no button at all. Detail header also gains plain ?lang= links that double as a per-article EN|中文 switch (the pin outranks the stored UI language, #2321). --- src/web/client.ts | 20 +++++++++++++++----- tests/web-blog-route.test.ts | 19 ++++++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/web/client.ts b/src/web/client.ts index 52ec2ae5e3..60f81eb180 100644 --- a/src/web/client.ts +++ b/src/web/client.ts @@ -956,10 +956,14 @@ function changelogCatOf(rawLine) { // keep the stale paint; the cache keeps its old timestamp, so the next visit retries }).then(function () { blogRefreshBusy = false; }); } - // Per-post discussion thread (Discussion #5411 convention): one repo Discussion per blog - // post whose title carries the machine-locatable 'blog:ID' token. - function blogDiscussionUrl(id) { - return "https://github.com/ranxianglei/billion-context/discussions?discussions_q=" + encodeURIComponent('is:open in:title "' + id + '"'); + // Per-post discussion thread: the thread number is data, not inference — the blog + // pipeline workflow creates one Discussion per post and records its number in + // articles.json, which the feed passes through as item.discussion. Exact direct link + // only; a post without a recorded number simply shows no button (no guessed search URL). + function blogDiscussionUrl(item) { + return (typeof item.discussion === "number" && item.discussion > 0) + ? "https://github.com/ranxianglei/billion-context/discussions/" + item.discussion + : null; } async function loadBlog(sub) { const host = $("bl-list"); @@ -990,7 +994,13 @@ function changelogCatOf(rawLine) { const kindLabel = item.kind === "post" ? t("bl.kind_post") : t("bl.kind_article"); const title = zhOn && item.titleZh ? item.titleZh : (item.title || ""); const html = zhOn ? (item.htmlZh || item.html || "") : (item.html || ""); - host.innerHTML = offlineNote + '
" + const dUrl = blogDiscussionUrl(item); + const commentLink = dUrl ? '' + escapeHtml(t("bl.comment")) + "" : ""; + // Per-article language pin: ?lang= outranks the saved UI language (#2321), so plain + // links double as an in-page EN|中文 toggle. Labels stay self-describing on purpose. + const subHref = "#/blog/" + encodeURIComponent(String(item.id)); + const langToggle = 'EN \u4e2d\u6587'; + host.innerHTML = offlineNote + '
' + escapeHtml(item.date || "\u2014") + '' + escapeHtml(kindLabel) + '' + escapeHtml(t("bl.back")) + " " + langToggle + " " + commentLink + "
" + '

' + escapeHtml(title) + "

" + '
' + html + "
"; return; diff --git a/tests/web-blog-route.test.ts b/tests/web-blog-route.test.ts index 64be76e1e2..242a9d392c 100644 --- a/tests/web-blog-route.test.ts +++ b/tests/web-blog-route.test.ts @@ -34,7 +34,7 @@ const mkHarnessEl = (): HarnessEl => ({ querySelectorAll: () => [], querySelector: () => null, }); -const FEED = { items: [{ id: "demo", kind: "post", date: "2026-10-08", title: "Demo post", titleZh: "演示", excerpt: "ex", html: "

hi

", htmlZh: "

你好

" }] }; +const FEED = { items: [{ id: "demo", kind: "post", date: "2026-10-08", title: "Demo post", titleZh: "演示", excerpt: "ex", html: "

hi

", htmlZh: "

你好

", discussion: 123 }] }; // #4957: blog slugs keep whatever the filename carried after the date prefix // (blogfeed.ts strips only `YYYY-MM-DD_`), so ids can contain dots, spaces and @@ -113,10 +113,19 @@ test("#/blog/ renders that single article with a back link", async () => { const list = r.els.get("bl-list")!; assert.ok(list.innerHTML.includes("post-body") && (list.innerHTML.includes("

hi

") || list.innerHTML.includes("\u4f60\u597d

")), "article body rendered (locale-twin aware)"); assert.ok(list.innerHTML.includes(''), "back link to the index present"); - // #5396: the detail header also carries the GitHub discussion-thread link — - // repo-scoped Discussions search on the post id (#5411 convention), new tab, noopener. - const discHref = "https://github.com/ranxianglei/billion-context/discussions?discussions_q=" + encodeURIComponent('is:open in:title "demo"'); - assert.ok(list.innerHTML.includes('href="' + discHref + '" target="_blank" rel="noopener"'), "GitHub discussion-thread link present for the post id"); + // #5396 final form: exact discussion link built from the manifest-recorded number + // (item.discussion) — no search guesswork; plus the in-page EN|中文 language pins. + assert.ok(list.innerHTML.includes('href="https://github.com/ranxianglei/billion-context/discussions/123" target="_blank" rel="noopener"'), "exact discussion-thread link from the recorded number"); + assert.ok(list.innerHTML.includes("?lang=en#/blog/demo") && list.innerHTML.includes("?lang=zh#/blog/" + encodeURIComponent("demo")), "in-page language pins present"); + assert.ok(list.innerHTML.includes("\u4e2d\u6587"), "Chinese toggle label rendered"); +}); + +test("#/blog/ without a recorded discussion number shows no thread button", async () => { + const feed = { items: [{ id: "plain", kind: "post", date: "2026-10-08", title: "Plain", excerpt: "ex", html: "

p

" }] }; + const r = await runClient("#/blog/plain", feed); + const list = r.els.get("bl-list")!; + assert.ok(list.innerHTML.includes("post-body"), "article still renders without a recorded thread"); + assert.ok(!list.innerHTML.includes("billion-context/discussions"), "no discussion link when the manifest recorded none"); }); test("unknown slug degrades to a back link without a crash", async () => { From b78195be180175a79673d86f99a3cf570285ad91 Mon Sep 17 00:00:00 2001 From: ci-check Date: Sun, 1 Nov 2026 16:21:12 +0800 Subject: [PATCH 5/5] =?UTF-8?q?docs(web):=20helper=20comment=20must=20not?= =?UTF-8?q?=20state=20a=20not-yet-existing=20pipeline=20as=20fact=20?= =?UTF-8?q?=E2=80=94=20say=20what=20the=20client=20contract=20is=20and=20w?= =?UTF-8?q?here=20the=20data=20dependency=20lives=20(review=20nit,=20comme?= =?UTF-8?q?nt-only)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web/client.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/web/client.ts b/src/web/client.ts index 60f81eb180..bb4e50bb00 100644 --- a/src/web/client.ts +++ b/src/web/client.ts @@ -956,10 +956,10 @@ function changelogCatOf(rawLine) { // keep the stale paint; the cache keeps its old timestamp, so the next visit retries }).then(function () { blogRefreshBusy = false; }); } - // Per-post discussion thread: the thread number is data, not inference — the blog - // pipeline workflow creates one Discussion per post and records its number in - // articles.json, which the feed passes through as item.discussion. Exact direct link - // only; a post without a recorded number simply shows no button (no guessed search URL). + // Per-post discussion thread: the thread number is data, not inference — it reaches + // the client as item.discussion once the server-side passthrough lands (separate PR, + // see PR body) and the pipeline records a number for the post. Exact direct link only; + // a post without a recorded number simply shows no button (no guessed search URL). function blogDiscussionUrl(item) { return (typeof item.discussion === "number" && item.discussion > 0) ? "https://github.com/ranxianglei/billion-context/discussions/" + item.discussion