From efdd75cbdc935f7aead6fed34d54c0bcd36fd035 Mon Sep 17 00:00:00 2001 From: richblack Date: Sun, 17 May 2026 09:53:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(mira/feed):=20WikiStatusBadge=20=E2=80=94?= =?UTF-8?q?=20=E9=A1=AF=E7=A4=BA=E8=B2=BC=E6=96=87=20wiki=20=E5=90=88?= =?UTF-8?q?=E6=88=90=E7=8B=80=E6=85=8B=20(leo=202026-05-17=20=E5=8F=8D?= =?UTF-8?q?=E9=A5=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit leo 反饋:「沒有符號顯示是否已建立 wiki,不知道是出錯了還是要等下一批」 新 component WikiStatusBadge 顯示在 PostCard header 來源/時間旁邊: - ✅ wiki — tags 含 wiki-processed - ⏳ 處理中 — 貼 < 6 分鐘前(cron 5 分鐘一輪,可能還沒撈到) - ○ 排隊 — 6-30 分鐘(等下一個 tick) - ⚠️ 漏了? — > 30 分鐘還沒處理(可能 wiki_synthesis 失敗) Mira 自己貼文(type=wiki-page from showMira)不顯示 — 它本身就是 wiki。 資料來源純 client-side:mainBlocksList[0].tags_json + doc.created_at。 未來可加 click → 跳對應 wiki page,或 hover 顯示 entity 預覽。 Co-Authored-By: Claude Opus 4.7 --- landing/app/mira/feed/page.tsx | 87 ++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/landing/app/mira/feed/page.tsx b/landing/app/mira/feed/page.tsx index 0028dfe..9e0a7b2 100644 --- a/landing/app/mira/feed/page.tsx +++ b/landing/app/mira/feed/page.tsx @@ -1139,6 +1139,18 @@ function DocCard({ · + {(() => { + const badge = ( + + ); + return !showMira && mainBlocksList[0] + ? (<>·{badge}) + : null; + })()} @@ -2046,6 +2058,81 @@ function SourceBadge({ source }: { source: string }) { ); } +// WikiStatusBadge:顯示這篇 raw 是否已合成 wiki +// - ✅ 已合成(tags 含 wiki-processed) +// - ⏳ 處理中(< 6 分鐘前貼,可能還沒被 cron 撈到 / wiki_synthesis 正在跑) +// - ○ 排隊中(> 6 分鐘但 < 30 分鐘,等下一個 cron tick) +// - ⚠️ 可能漏了(> 30 分鐘還沒處理) +// 對應 leo 2026-05-17 反饋:「沒有符號顯示是否已建立 wiki」 +function WikiStatusBadge({ + mainBlock, + createdAt, + showMira, +}: { + mainBlock: KBDBBlock | undefined; + createdAt: number | string; + showMira: boolean; +}) { + // Mira 自己貼的(type=wiki-page)就是 wiki,不需要狀態 + if (showMira) return null; + if (!mainBlock) return null; + + let processed = false; + try { + const tags = JSON.parse(mainBlock.tags_json || '[]') as string[]; + processed = Array.isArray(tags) && tags.includes('wiki-processed'); + } catch { + // ignore + } + + if (processed) { + return ( + + ✅ wiki + + ); + } + + const ageMs = Date.now() - toDate(createdAt).getTime(); + const minutes = ageMs / 60_000; + + if (minutes < 6) { + return ( + + ⏳ 處理中 + + ); + } + if (minutes < 30) { + return ( + + ○ 排隊 + + ); + } + return ( + + ⚠️ 漏了? + + ); +} + function RelTime({ when }: { when: number | string }) { const d = toDate(when); const now = Date.now();