LibreChat/client/src/utils/focus.ts
Danny Avila eeb4ea226c
🧭 perf: Warm Conversation Switches with Single-Navigation Focus Intent (#14334)
* 🧭 perf: Warm Conversation Switches with Single-Navigation Focus Intent

* 🧭 fix: Drop Warm Message Cache When Conversation Revalidation Fails

* 🧭 fix: Defer Departing-Convo Refetch and Gate Resume on Revalidation

* 🧭 fix: Gate Stale-Cache Sends During Revalidation and Honor disableFocus
2026-07-20 22:31:44 -04:00

18 lines
579 B
TypeScript

let pendingChatFocus = false;
/**
* Transient cross-navigation focus intent for the chat composer. Carried
* outside `location.state` so consuming it needs no second state-clearing
* navigation, which doubled every router-context sweep per conversation
* switch; being transient, it also never re-fires from history entries on
* back/forward navigation.
*/
export const requestChatFocus = (): void => {
pendingChatFocus = true;
};
export const consumeChatFocus = (): boolean => {
const requested = pendingChatFocus;
pendingChatFocus = false;
return requested;
};