fix(frontend): skip hash anchor navigation until session is validated

Avoid chat day fetches with empty session_id on the login page when a stale URL hash is present.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
weichen
2026-09-13 02:50:23 +00:00
committed by weichen
co-authored by Cursor
parent 38e44a2606
commit 574dd16546
2 changed files with 7 additions and 0 deletions
+6
View File
@@ -1704,8 +1704,14 @@ export default function App() {
loadDayForAnchorRef.current = chatWindow.loadDayForAnchor;
}, [chatWindow.loadDayForAnchor]);
const sessionValidatedRef = useRef(sessionValidated);
useEffect(() => {
sessionValidatedRef.current = sessionValidated;
}, [sessionValidated]);
useEffect(() => {
const handleHashChange = () => {
if (sessionValidatedRef.current !== true) return;
const parsed = parseAnchorHash(window.location.hash);
if (!parsed) return;
const currentActive = activeSessionIdRef.current;
+1
View File
@@ -301,6 +301,7 @@ export function useChatWindow({
// 跨日锚点拉取: 根据 messageId 拉取所属日分片并合并进窗口
const loadDayForAnchor = useCallback(
async (messageId: number): Promise<boolean> => {
if (!sessionId) return false;
for (const b of dayStack) {
if (b.messages.some((m) => m.serverId === messageId)) {
return true;