fix: skip trimming for active sessions to preserve anchor

This commit is contained in:
Bohdan Triapitsyn
2026-01-19 14:04:23 +02:00
parent 0f7eefe574
commit f59c7b2525
@@ -506,6 +506,11 @@ export const useSessionStore = create<SessionStore>()(
getActiveTurnAnchor: (sessionId: string) => useMessageStore.getState().getActiveTurnAnchor(sessionId),
trimToViewportWindow: (sessionId: string, targetSize?: number) => {
const currentSessionId = useSessionManagementStore.getState().currentSessionId;
// Skip trimming for sessions in active phase (busy/cooldown) to preserve anchor/spacer
const phase = get().sessionActivityPhase?.get(sessionId);
if (phase === 'busy' || phase === 'cooldown') {
return;
}
return useMessageStore.getState().trimToViewportWindow(sessionId, targetSize, currentSessionId || undefined);
},
evictLeastRecentlyUsed: () => {