From f59c7b25253e6203f6f30f3cd1036808516d25f0 Mon Sep 17 00:00:00 2001 From: Bohdan Triapitsyn Date: Mon, 19 Jan 2026 14:04:23 +0200 Subject: [PATCH] fix: skip trimming for active sessions to preserve anchor --- packages/ui/src/stores/useSessionStore.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/ui/src/stores/useSessionStore.ts b/packages/ui/src/stores/useSessionStore.ts index 7726a719..f6ffa46c 100644 --- a/packages/ui/src/stores/useSessionStore.ts +++ b/packages/ui/src/stores/useSessionStore.ts @@ -506,6 +506,11 @@ export const useSessionStore = create()( 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: () => {