Skip to content

Commit a5dc2c0

Browse files
committed
chore: 清理项目中冗余/过时的代码注释
- 删除 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 的踩坑记录、不变式、降级策略等有价值注释。
1 parent f42bdba commit a5dc2c0

7 files changed

Lines changed: 4 additions & 51 deletions

File tree

app/[locale]/feed/components/LinkCard.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,13 @@ export function LinkCard({ link, categoryLabel, isLoggedIn }: LinkCardProps) {
3333

3434
return (
3535
<li className="group border border-[var(--foreground)] hover:border-[#CC0000] transition-colors duration-150 flex flex-col">
36-
{/* 整卡可点击区域,跳到原文 */}
3736
<a
3837
href={link.url}
3938
target="_blank"
4039
rel="noopener noreferrer"
4140
className="flex flex-col flex-1"
4241
aria-label={link.ogTitle ?? link.url}
4342
>
44-
{/* OG 封面 / 占位块 */}
4543
{safeOgCover && !link.ogFetchFailed ? (
4644
// next/image 全站 unoptimized:true,用 img 即可(与 events 页一致)。
4745
// referrerPolicy="no-referrer":微信 mmbiz.qpic.cn 防盗链会检查 Referer,
@@ -55,7 +53,6 @@ export function LinkCard({ link, categoryLabel, isLoggedIn }: LinkCardProps) {
5553
className="w-full aspect-[16/9] object-cover border-b border-[var(--foreground)]"
5654
/>
5755
) : (
58-
// 无封面:显示 host 首字母占位
5956
<div className="w-full aspect-[16/9] bg-neutral-100 dark:bg-neutral-900 border-b border-[var(--foreground)] flex flex-col items-center justify-center gap-1">
6057
<span className="font-serif text-4xl font-black text-neutral-400 select-none">
6158
{getHostInitial(link.host)}
@@ -72,22 +69,17 @@ export function LinkCard({ link, categoryLabel, isLoggedIn }: LinkCardProps) {
7269
</div>
7370
)}
7471

75-
{/* 卡片内容区 */}
7672
<div className="p-4 flex flex-col gap-2 flex-1">
77-
{/* 标题 */}
7873
<h3 className="font-serif text-base font-black leading-snug group-hover:text-[#CC0000] transition-colors line-clamp-2 text-[var(--foreground)]">
7974
{link.ogTitle ?? link.url}
8075
</h3>
8176

82-
{/* OG 描述 / 用户推荐语 */}
8377
{(link.recommendation || link.ogDescription) && (
8478
<p className="text-sm text-neutral-600 dark:text-neutral-400 line-clamp-3 leading-relaxed">
85-
{/* 用户推荐语优先展示,没有则展示 OG description */}
8679
{link.recommendation ?? link.ogDescription}
8780
</p>
8881
)}
8982

90-
{/* 分类 badge + 失效标记 */}
9183
<div className="flex items-center gap-2 flex-wrap mt-auto pt-2">
9284
{link.category && (
9385
<Badge
@@ -107,7 +99,6 @@ export function LinkCard({ link, categoryLabel, isLoggedIn }: LinkCardProps) {
10799
)}
108100
</div>
109101

110-
{/* 提交人 + host 来源 */}
111102
<div className="flex items-center justify-between text-[10px] font-mono text-neutral-400 pt-1">
112103
<span className="truncate max-w-[60%]">{link.host}</span>
113104
</div>

app/components/DocsAssistant.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,12 @@ function DocsAssistantInner({ pageContext }: DocsAssistantProps) {
106106
);
107107

108108
const [suggestions, setSuggestions] = useState<string[]>([]);
109-
// 仅标志后台是否正在获取建议(用于逻辑判断)
110109
const [isFetchingSuggestions, setIsFetchingSuggestions] = useState(false);
111-
// 控制 UI 上是否显示“正在思考...”加载状态(只有主回答结束后,由于建议还在获取,才显示骨架屏)
110+
// 仅在主回答结束后、建议仍未返回时展示骨架屏;这与 isFetchingSuggestions 解耦,避免在流式过程中提前出现 loader
112111
const [showSuggestionsLoader, setShowSuggestionsLoader] = useState(false);
113-
// 缓存获取好的建议,等待主回答结束后才推给 Thread 渲染
112+
// 先缓存预取建议,等主回答 onFinish 后再推给 Thread,避免与流式回复抢渲染
114113
const [pendingSuggestions, setPendingSuggestions] = useState<string[]>([]);
115114

116-
// 欢迎页建议相关的 state
117115
const [welcomeSuggestions, setWelcomeSuggestions] = useState<
118116
WelcomeSuggestion[]
119117
>([]);
@@ -179,7 +177,6 @@ function DocsAssistantInner({ pageContext }: DocsAssistantProps) {
179177
status: chatStatus,
180178
messages,
181179
clearError: clearChatError,
182-
// 其他需要的属性...
183180
} = chat;
184181

185182
// 初次加载欢迎建议的 Effect
@@ -269,7 +266,6 @@ function DocsAssistantInner({ pageContext }: DocsAssistantProps) {
269266
})();
270267
}
271268

272-
// 监控 AI 主流程是否结束:当从 'streaming' 变为 'submitted' / 结束状态时
273269
const isChatFinished =
274270
prevStatus === "streaming" &&
275271
chatStatus !== "streaming" &&

app/components/ZoteroFeed.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"use client";
22
import * as React from "react";
33

4-
// Debug helpers (removed in production)
5-
64
type ZoteroItem = {
75
key: string;
86
data?: {
@@ -36,7 +34,6 @@ export function ZoteroFeed({
3634
.then(async (r) => {
3735
if (!r.ok) throw new Error(`${r.status} ${r.statusText}`);
3836
const data: ZoteroItem[] = await r.json();
39-
// No debug exposure in production
4037
setItems(data);
4138
})
4239
.catch((e: unknown) => {

app/components/assistant-ui/assistant-modal.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ export const AssistantModal: FC<AssistantModalProps> = ({
3030
isLoadingWelcome,
3131
}) => {
3232
const [showBubble, setShowBubble] = useState(false);
33-
// 受控状态:允许模态框内部的 X 按钮主动关闭窗口
34-
// issue #285: 原先只能靠 Trigger/点击外部/Esc 关闭,用户反馈不知道怎么关窗
33+
// 受控 open:让模态框右上角的 X 按钮能主动关闭;非受控时只能靠 Trigger/点外部/Esc
3534
const [open, setOpen] = useState(false);
3635

3736
const handleCloseModal = useCallback(() => {
@@ -70,7 +69,6 @@ export const AssistantModal: FC<AssistantModalProps> = ({
7069
return (
7170
<AssistantModalPrimitive.Root open={open} onOpenChange={setOpen}>
7271
<AssistantModalPrimitive.Anchor className="aui-root aui-modal-anchor fixed right-4 bottom-4 size-14">
73-
{/* 自定义气泡组件 */}
7472
{showBubble && (
7573
<div
7674
className="absolute bottom-17 right-0 z-40 animate-in fade-in-0 slide-in-from-bottom-2 duration-500"
@@ -97,7 +95,6 @@ export const AssistantModal: FC<AssistantModalProps> = ({
9795
sideOffset={16}
9896
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"
9997
>
100-
{/* 右上角关闭按钮,issue #285:用户找不到关闭模态框的显式入口 */}
10198
<button
10299
type="button"
103100
onClick={handleCloseModal}
@@ -134,17 +131,15 @@ const AssistantModalButton = forwardRef<
134131
const tooltip = state === "open" ? "Close Assistant" : "Open Assistant";
135132

136133
const handleClick = (e: React.MouseEvent) => {
137-
// 当点击open按钮时,关闭气泡对话
138134
if (onCloseBubble) {
139135
onCloseBubble();
140136
}
141137

142-
// 如果当前是关闭状态,说明即将打开,记录埋点
138+
// 仅在 closed → open 时埋点,避免关闭动作也计一次 open
143139
if (state === "closed" && window.umami) {
144140
window.umami.track("ai_assistant_open");
145141
}
146142

147-
// 继续执行原有的点击事件
148143
if (rest.onClick) {
149144
rest.onClick(e);
150145
}

app/components/assistant-ui/thread.tsx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,12 @@ export interface WelcomeSuggestion {
4545
}
4646

4747
interface ThreadProps {
48-
// 错误信息
4948
errorMessage?: string;
50-
// 是否显示设置操作按钮
5149
showSettingsAction?: boolean;
52-
// 清除错误的回调函数
5350
onClearError?: () => void;
54-
// AI 生成的后续问题建议
5551
suggestions?: string[];
56-
// 是否正在加载建议
5752
isLoadingSuggestions?: boolean;
58-
// AI 生成的欢迎问题建议
5953
welcomeSuggestions?: WelcomeSuggestion[];
60-
// 是否正在加载欢迎建议
6154
isLoadingWelcome?: boolean;
6255
}
6356

@@ -70,7 +63,6 @@ export const Thread: FC<ThreadProps> = ({
7063
welcomeSuggestions,
7164
isLoadingWelcome,
7265
}) => {
73-
// 控制设置对话框是否打开的状态
7466
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
7567

7668
const handleSettingsChange = useCallback(
@@ -83,7 +75,6 @@ export const Thread: FC<ThreadProps> = ({
8375
[onClearError],
8476
);
8577

86-
// 打开设置对话框的处理函数
8778
const handleOpenSettings = useCallback(() => {
8879
handleSettingsChange(true);
8980
}, [handleSettingsChange]);
@@ -206,7 +197,6 @@ const ThreadScrollToBottom: FC = () => {
206197
);
207198
};
208199

209-
// 欢迎界面组件
210200
const ThreadWelcome: FC = () => {
211201
return (
212202
<ThreadPrimitive.Empty>
@@ -237,7 +227,6 @@ const ThreadWelcome: FC = () => {
237227
);
238228
};
239229

240-
// 欢迎页面的初始建议组件
241230
interface ThreadWelcomeSuggestionsProps {
242231
suggestions?: WelcomeSuggestion[];
243232
isLoading?: boolean;
@@ -330,14 +319,12 @@ const ThreadWelcomeSuggestions: FC<ThreadWelcomeSuggestionsProps> = ({
330319
);
331320
};
332321

333-
// 输入框组件 Props
334322
interface ComposerProps {
335323
isSettingsOpen: boolean;
336324
onOpenChange: (open: boolean) => void;
337325
onClearError?: () => void;
338326
}
339327

340-
// 输入框组件,负责处理用户输入和发送消息
341328
const Composer: FC<ComposerProps> = ({
342329
isSettingsOpen,
343330
onOpenChange,
@@ -366,7 +353,6 @@ const Composer: FC<ComposerProps> = ({
366353
return (
367354
<div className="aui-composer-wrapper sticky bottom-0 mx-auto flex w-full max-w-[var(--thread-max-width)] flex-col gap-4 overflow-visible bg-[var(--background)] pb-4 md:pb-6 pt-2 border-t border-[var(--foreground)]">
368355
<ThreadScrollToBottom />
369-
{/* 当没有消息时,显示空状态内容(现已经移到上面的Viewport内以统一滑动,这里可以置空或保留其它用途)*/}
370356
<ComposerPrimitive.Root
371357
className="aui-composer-root relative flex w-full flex-col rounded-none border border-[var(--foreground)] bg-[var(--background)] px-1 pt-2 shadow-none"
372358
aria-disabled={!hasActiveKey}
@@ -418,7 +404,6 @@ interface ComposerActionProps {
418404
onClearError?: () => void;
419405
}
420406

421-
// 输入框操作按钮组件(发送、设置、取消)
422407
const ComposerAction: FC<ComposerActionProps> = ({
423408
canSend,
424409
isSettingsOpen,
@@ -660,7 +645,6 @@ const EditComposer: FC = () => {
660645
);
661646
};
662647

663-
// 分支切换组件(用于在多次生成的回复之间切换)
664648
const BranchPicker: FC<BranchPickerPrimitive.Root.Props> = ({
665649
className,
666650
...rest
@@ -691,13 +675,11 @@ const BranchPicker: FC<BranchPickerPrimitive.Root.Props> = ({
691675
);
692676
};
693677

694-
// 后续问题建议组件 Props
695678
interface ThreadFollowupSuggestionsProps {
696679
suggestions?: string[];
697680
isLoading?: boolean;
698681
}
699682

700-
// 后续问题建议组件,显示 AI 生成的建议问题
701683
const ThreadFollowupSuggestions: FC<ThreadFollowupSuggestionsProps> = ({
702684
suggestions,
703685
isLoading,

app/components/rank/HotDocsTab.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ export function HotDocsTab({ initialWindow }: { initialWindow: WindowParam }) {
112112

113113
return (
114114
<div>
115-
{/* 窗口切换 */}
116115
<div className="flex gap-0 mb-8 border border-[var(--foreground)]">
117116
{windowOptions.map((opt) => (
118117
<button
@@ -129,7 +128,6 @@ export function HotDocsTab({ initialWindow }: { initialWindow: WindowParam }) {
129128
))}
130129
</div>
131130

132-
{/* 加载状态 */}
133131
{state.status === "loading" && (
134132
<div className="flex flex-col gap-3">
135133
{Array.from({ length: 5 }).map((_, i) => (
@@ -141,7 +139,6 @@ export function HotDocsTab({ initialWindow }: { initialWindow: WindowParam }) {
141139
</div>
142140
)}
143141

144-
{/* 错误状态 */}
145142
{state.status === "error" && (
146143
<div className="border border-[var(--foreground)] p-8 text-center">
147144
<p className="font-mono text-sm uppercase tracking-widest text-neutral-500">
@@ -150,7 +147,6 @@ export function HotDocsTab({ initialWindow }: { initialWindow: WindowParam }) {
150147
</div>
151148
)}
152149

153-
{/* 空状态 */}
154150
{state.status === "ok" && state.docs.length === 0 && (
155151
<div className="border border-[var(--foreground)] p-8 text-center">
156152
<p className="font-mono text-sm uppercase tracking-widest text-neutral-500">
@@ -159,7 +155,6 @@ export function HotDocsTab({ initialWindow }: { initialWindow: WindowParam }) {
159155
</div>
160156
)}
161157

162-
{/* 列表 */}
163158
{state.status === "ok" && state.docs.length > 0 && (
164159
<div className="flex flex-col gap-3">
165160
{state.docs.map((doc, idx) => (

scripts/generate-leaderboard.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
* 结合本地 .source/index.ts 的 docId→title/url 映射 + git log noreply 反推 login,
55
* 生成静态 leaderboard 供排行榜页和首页使用。
66
*
7-
* 历史:早期版本直接 prisma 连 Postgres 5432,逼着 DB 端口公网开放。
8-
* 现已改走后端 endpoint,DB 收回内网。详见 backend PR #22。
9-
*
107
* 用法:
118
* node scripts/generate-leaderboard.mjs
129
*/

0 commit comments

Comments
 (0)