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:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user