From a5dc2c0506aaed6bed6caa38ade2aca8115b4d29 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 12 May 2026 19:54:55 +0000 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=E6=B8=85=E7=90=86=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E4=B8=AD=E5=86=97=E4=BD=99/=E8=BF=87=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 thread.tsx 中重复说明属性名/函数名的"是什么"注释(标识符已自解释) - 移除 DocsAssistant.tsx 的占位注释("其他需要的属性...")和重复 state 说明, 保留并精炼真正解释"为什么"需要 loader/pending 缓存的注释 - 删除 HotDocsTab.tsx、LinkCard.tsx 中纯标签 JSX 区段("加载状态/列表/标题"等) - 删除 ZoteroFeed.tsx 中误导性的 "Debug helpers (removed in production)" 残留标记 - 删除 assistant-modal.tsx 中 issue #285 任务引用,保留受控 state 的 WHY 说明 - 删除 generate-leaderboard.mjs 中已不适用的"历史:早期直连 Postgres"段落 保留所有解释 WHY 的踩坑记录、不变式、降级策略等有价值注释。 --- app/[locale]/feed/components/LinkCard.tsx | 9 --------- app/components/DocsAssistant.tsx | 8 ++------ app/components/ZoteroFeed.tsx | 3 --- .../assistant-ui/assistant-modal.tsx | 9 ++------- app/components/assistant-ui/thread.tsx | 18 ------------------ app/components/rank/HotDocsTab.tsx | 5 ----- scripts/generate-leaderboard.mjs | 3 --- 7 files changed, 4 insertions(+), 51 deletions(-) diff --git a/app/[locale]/feed/components/LinkCard.tsx b/app/[locale]/feed/components/LinkCard.tsx index 5851d24a..44f8a65a 100644 --- a/app/[locale]/feed/components/LinkCard.tsx +++ b/app/[locale]/feed/components/LinkCard.tsx @@ -33,7 +33,6 @@ export function LinkCard({ link, categoryLabel, isLoggedIn }: LinkCardProps) { return (
  • - {/* 整卡可点击区域,跳到原文 */} - {/* OG 封面 / 占位块 */} {safeOgCover && !link.ogFetchFailed ? ( // next/image 全站 unoptimized:true,用 img 即可(与 events 页一致)。 // referrerPolicy="no-referrer":微信 mmbiz.qpic.cn 防盗链会检查 Referer, @@ -55,7 +53,6 @@ export function LinkCard({ link, categoryLabel, isLoggedIn }: LinkCardProps) { className="w-full aspect-[16/9] object-cover border-b border-[var(--foreground)]" /> ) : ( - // 无封面:显示 host 首字母占位
    {getHostInitial(link.host)} @@ -72,22 +69,17 @@ export function LinkCard({ link, categoryLabel, isLoggedIn }: LinkCardProps) {
    )} - {/* 卡片内容区 */}
    - {/* 标题 */}

    {link.ogTitle ?? link.url}

    - {/* OG 描述 / 用户推荐语 */} {(link.recommendation || link.ogDescription) && (

    - {/* 用户推荐语优先展示,没有则展示 OG description */} {link.recommendation ?? link.ogDescription}

    )} - {/* 分类 badge + 失效标记 */}
    {link.category && ( - {/* 提交人 + host 来源 */}
    {link.host}
    diff --git a/app/components/DocsAssistant.tsx b/app/components/DocsAssistant.tsx index d6f4e4ab..1ab06cf4 100644 --- a/app/components/DocsAssistant.tsx +++ b/app/components/DocsAssistant.tsx @@ -106,14 +106,12 @@ function DocsAssistantInner({ pageContext }: DocsAssistantProps) { ); const [suggestions, setSuggestions] = useState([]); - // 仅标志后台是否正在获取建议(用于逻辑判断) const [isFetchingSuggestions, setIsFetchingSuggestions] = useState(false); - // 控制 UI 上是否显示“正在思考...”加载状态(只有主回答结束后,由于建议还在获取,才显示骨架屏) + // 仅在主回答结束后、建议仍未返回时展示骨架屏;这与 isFetchingSuggestions 解耦,避免在流式过程中提前出现 loader const [showSuggestionsLoader, setShowSuggestionsLoader] = useState(false); - // 缓存获取好的建议,等待主回答结束后才推给 Thread 渲染 + // 先缓存预取建议,等主回答 onFinish 后再推给 Thread,避免与流式回复抢渲染 const [pendingSuggestions, setPendingSuggestions] = useState([]); - // 欢迎页建议相关的 state const [welcomeSuggestions, setWelcomeSuggestions] = useState< WelcomeSuggestion[] >([]); @@ -179,7 +177,6 @@ function DocsAssistantInner({ pageContext }: DocsAssistantProps) { status: chatStatus, messages, clearError: clearChatError, - // 其他需要的属性... } = chat; // 初次加载欢迎建议的 Effect @@ -269,7 +266,6 @@ function DocsAssistantInner({ pageContext }: DocsAssistantProps) { })(); } - // 监控 AI 主流程是否结束:当从 'streaming' 变为 'submitted' / 结束状态时 const isChatFinished = prevStatus === "streaming" && chatStatus !== "streaming" && diff --git a/app/components/ZoteroFeed.tsx b/app/components/ZoteroFeed.tsx index a6bb8412..562cacbb 100644 --- a/app/components/ZoteroFeed.tsx +++ b/app/components/ZoteroFeed.tsx @@ -1,8 +1,6 @@ "use client"; import * as React from "react"; -// Debug helpers (removed in production) - type ZoteroItem = { key: string; data?: { @@ -36,7 +34,6 @@ export function ZoteroFeed({ .then(async (r) => { if (!r.ok) throw new Error(`${r.status} ${r.statusText}`); const data: ZoteroItem[] = await r.json(); - // No debug exposure in production setItems(data); }) .catch((e: unknown) => { diff --git a/app/components/assistant-ui/assistant-modal.tsx b/app/components/assistant-ui/assistant-modal.tsx index 6f37aa72..3cc74da3 100644 --- a/app/components/assistant-ui/assistant-modal.tsx +++ b/app/components/assistant-ui/assistant-modal.tsx @@ -30,8 +30,7 @@ export const AssistantModal: FC = ({ isLoadingWelcome, }) => { const [showBubble, setShowBubble] = useState(false); - // 受控状态:允许模态框内部的 X 按钮主动关闭窗口 - // issue #285: 原先只能靠 Trigger/点击外部/Esc 关闭,用户反馈不知道怎么关窗 + // 受控 open:让模态框右上角的 X 按钮能主动关闭;非受控时只能靠 Trigger/点外部/Esc const [open, setOpen] = useState(false); const handleCloseModal = useCallback(() => { @@ -70,7 +69,6 @@ export const AssistantModal: FC = ({ return ( - {/* 自定义气泡组件 */} {showBubble && (
    = ({ sideOffset={16} className="aui-root aui-modal-content relative z-50 h-[500px] w-[400px] overflow-clip rounded-xl border bg-popover p-0 text-popover-foreground shadow-md outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-bottom-1/2 data-[state=closed]:slide-out-to-right-1/2 data-[state=closed]:zoom-out data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:slide-in-from-bottom-1/2 data-[state=open]:slide-in-from-right-1/2 data-[state=open]:zoom-in [&>.aui-thread-root]:bg-inherit" > - {/* 右上角关闭按钮,issue #285:用户找不到关闭模态框的显式入口 */}