Repository navigation
[PR] feat: panel blog live-refreshes posts from GitHub master (#4906) - #4915
ranxianglei wants to merge 5 commits into
Conversation
…e overlay (#4906) Extracts frontmatter+H1+markdown rendering into renderPostText, bilingual item assembly into shapePost, and feed ordering into sortBlogItems (+ postIdFromBase) — exported so web/blog-live.ts reuses the exact same definitions instead of drifting copies. collectPosts/collect now go through them with zero behavior change (web-blogfeed suite unchanged and green). In passing: drops renderBody(), dead since #4587 shipped (definition only, zero callers repo-wide).
The panel blog (/__bili/blog) served posts frozen at package-release time; newly written posts waited for a release + self-update. /__bili/blog now overlays the bundled feed with the latest website/blog/posts/*.md from GitHub master, access-driven like web/changelog.ts (#3719): one network round per hour of panel use (contents listing + raw bodies, concurrency 4, 15s wall-clock budget), in-memory cache only — no config keys, no env vars, no disk cache, no resident timer. A successful listing is authoritative for posts: changed posts replace their bundled twin, new slugs append, posts deleted on master leave the panel, and a listed post whose body fails to fetch keeps its bundled twin. Every failure mode (offline, HTTP error, non-array or empty listing, budget overrun) fails soft to the bundled feed with error:"offline" — the handler still answers 200 and the panel never errors. Articles stay bundled. Relative image refs in live posts rewrite onto raw.githubusercontent.com (markdown.ts passes absolute http(s) image targets through); traversal refs drop. Closes #4906
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6381-pr.4915.d241337This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4915.tgz
npm install -g packageInstall instructions are refreshed on each push. |
admin.ts now serves /__bili/blog through handleBlogLiveGet, so the bundled-only handler had zero production callers repo-wide. Removing it (the always-200 handler behavior stays covered by tests/web-blog-live.test.ts); the disk-feed test keeps its broken-manifest degradation half.
…nto phantom deletions MAX_FILES used to slice the parsed listing: posts beyond the cap were excluded from listedIds, which mergeLive reads as deleted-on-master — silently stripping real master posts from the panel, the opposite of fail-soft. Over-cap now throws so the refresh degrades onto the bundled feed, pinned by a 51-row regression.
🔶 需要决策 This conflict is not textual drift — it is a design clash between two incompatible implementations of the same feature (#4906), and no mechanical rebase can resolve it without picking one of the two designs. The merge-guard run of 2026-10-29 already identified this and filed decision request #5170 (p1); that issue was closed by @ranxianglei on 2026-10-31T17:45Z as Live state verified this run (2026-11-12):
Options (unchanged from #5170):
Default if undecided: hold — no push, branch unchanged at Option-A residual verification (the one open item from #5170): does master have the over-cap "phantom deletion" protection this PR's last commit 请拍板:确认 A(并请你自行关闭本 PR),或选 B/C。标签已打 八问
判定:待 owner 拍板(推荐 A:确认后请你关闭本 PR);本轮未修改分支,已打 |
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
[bot] 🏷 Status after forced restart (no output for 34 min, floor 27) — re-verified everything live this run; nothing has changed, still blocked on the same owner decision from floor 22. Live state this run (2026-11-12):
Why I still won't rebase: the conflict is the two incompatible #4906 implementations (master's 八问(本轮)
判定:继续 hold,待 owner 拍板(A = 确认后请你关闭本 PR;B/C = 指明方向我再来对齐)。 |
[ework] CI fix verified green ✓ |
[bot] 🏷 Re-trigger status ping (no change since floor 28 — full decision request remains at floor 22, not re-pasted here). Live-verified this run (2026-11-13):
Position unchanged: the conflict is the two incompatible #4906 implementations (master's 八问(本轮)
判定:继续 hold,待 owner 拍板(A = 确认后请你关闭本 PR;B/C = 指明方向我再来对齐)。 |
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
What
The panel's Blog view served posts frozen at npm-release time — master's new posts waited for the next release + self-update. This makes
/__bili/blogpull the latestwebsite/blog/posts/*.mdfrom GitHub master behind a 1-hour access-driven throttle, failing soft onto the bundled copy otherwise. Style mirrors the changelog module (#3719): in-memory cache only, no config keys, no env vars, no disk cache files, no resident timer.Behavior change (old → new):
/__bili/blogcontent source: release-frozen bundled posts → bundled base overlaid with live master posts (~1 h throttle while online). This old→new switch is the point of Web Panel Blog: Automatically pulls new posts from GitHub master — no need to wait for a release. | Web 面板博客:自动从 GitHub master 拉取新文章,不用等发版 #4906.{items}→{items, error?}— additive;error:"offline"is present when the latest check failed (the panel ignores it today; same contract as/__bili/changelog).Config surface: none — deliberate. No new key/env/flag; the refresh window and caps are module constants (changelog precedent, #3719).
Mechanics: ONE api.github.com contents call per window (unauthenticated, inside the 60 req/h anonymous budget) plus raw.githubusercontent.com fetches for the markdown bodies (no API quota), concurrency 4, 15 s whole-refresh budget via a shared AbortController — an overrun aborts the whole refresh so a partial set can never become authoritative. An empty listing is treated as content anomaly (fail soft), not truth. Relative image refs in live posts rewrite onto raw.githubusercontent.com absolute URLs (web/markdown.ts passes absolute http(s) image targets through untouched, so the guarded
/__bili/blog-assets/route stays bundled-only); traversal refs drop.Tests: new
tests/web-blog-live.test.ts(10 cases, both gate directions: merge replace/append/delete-on-master/articles-stay-bundled, throttle + force bypass, network/HTTP-500/non-array/empty-listing fail-soft, per-file fallback, remote image rewrite incl. traversal drop, malformed listing rows, budget abort, always-200 handler).blogfeed.tsgains exported shared helpers (renderPostText/shapePost/sortBlogItems/postIdFromBase) used by both disk and live paths so the two views cannot drift. In passing: droppedrenderBody()from blogfeed.ts — dead since #4587 shipped (definition only, zero callers repo-wide).Verified locally: typecheck + build clean (dist external-dep check OK — no new dependencies); targeted suites 30/30 (
web-blog-live,web-blogfeed,web-changelog,web-blog-route); real-bundle smoke test (boot dist, GET/__bili/blogtwice) — 200 JSON with the live refresh succeeding against real GitHub, second call instant (throttled). Full-suite verdict: CI on this head.Closes #4906