代码质量:
- 新增 .prettierrc + eslint-plugin-prettier,全量格式化所有 TSX/TS/CSS 文件
- npm scripts 新增 format / format:check / lint:fix
Logo 重设计:
- SVG logo 从简单星月改为望远镜+轨道+三角架+星光,favicon 同步更新
Library 服务端分页与多维筛选:
- LibraryQueryParams 支持 q(全局搜索)/status(下载状态)/doctype/author/year/journal/sort_by
- API 返回 {items, total},默认每页 12 条
- 前端新增筛选面板:搜索栏、状态下拉、文献类型、排序、分页控件
Agent 工具输出可视化:
- 新增 SpecialToolRenderers.tsx:query_target 天体参数卡片(含 SIMBAD/VizieR 链接)、search_papers
文献列表(内嵌下载/阅读/星系跳转按钮)
- 系统内部工具(compress_context 等)无错误时自动隐藏,减少时间线噪音
- ToolCallCard 与 Reader/Citation 打通:可在工具输出中直接打开文献或跳转引用星系
.agent 目录统一:
- memory/tool-results/trajectories/images 全部归入 library/.agent/ 子目录
PDF 加载修复:
- BilingualViewer 改用 fetch → blob:// URL 加载 PDF,绕过 iframe SameSite Cookie 限制
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
// dashboard/src/components/agent/useAutoScroll.ts
|
||
// 共享自动滚动 hook:检测是否贴底,仅在贴底时自动滚动
|
||
import { useState, useRef, useEffect, useCallback } from 'react';
|
||
|
||
interface UseAutoScrollReturn {
|
||
chatEndRef: React.RefObject<HTMLDivElement | null>;
|
||
scrollContainerRef: React.RefObject<HTMLDivElement | null>;
|
||
shouldAutoScroll: boolean;
|
||
setShouldAutoScroll: (v: boolean) => void;
|
||
scrollToBottom: (behavior?: ScrollBehavior) => void;
|
||
handleScroll: () => void;
|
||
}
|
||
|
||
export function useAutoScroll(deps: React.DependencyList): UseAutoScrollReturn {
|
||
const chatEndRef = useRef<HTMLDivElement>(null);
|
||
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
||
const [shouldAutoScroll, setShouldAutoScroll] = useState(true);
|
||
|
||
const scrollToBottom = useCallback((behavior: ScrollBehavior = 'smooth') => {
|
||
const el = scrollContainerRef.current;
|
||
if (el) {
|
||
el.scrollTo({
|
||
top: el.scrollHeight,
|
||
behavior,
|
||
});
|
||
}
|
||
}, []);
|
||
|
||
useEffect(() => {
|
||
if (shouldAutoScroll) {
|
||
scrollToBottom();
|
||
}
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||
}, deps);
|
||
|
||
const handleScroll = useCallback(() => {
|
||
const el = scrollContainerRef.current;
|
||
if (!el) return;
|
||
const { scrollTop, scrollHeight, clientHeight } = el;
|
||
setShouldAutoScroll(scrollHeight - scrollTop - clientHeight < 50);
|
||
}, []);
|
||
|
||
return {
|
||
chatEndRef,
|
||
scrollContainerRef,
|
||
shouldAutoScroll,
|
||
setShouldAutoScroll,
|
||
scrollToBottom,
|
||
handleScroll,
|
||
};
|
||
}
|