From 52ce7b23d233de4705bdb09ba7fe2bc365f9636a Mon Sep 17 00:00:00 2001 From: Victor Nogueira Date: Thu, 27 Aug 2026 16:52:37 +0800 Subject: [PATCH] fix(desktop): scope saved scroll by gateway --- apps/desktop/src/store/thread-scroll.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/store/thread-scroll.ts b/apps/desktop/src/store/thread-scroll.ts index 696bfbbd74..0eb02e2073 100644 --- a/apps/desktop/src/store/thread-scroll.ts +++ b/apps/desktop/src/store/thread-scroll.ts @@ -1,5 +1,6 @@ import { atom, type WritableAtom } from 'nanostores' +import { activeConnectionScopeSuffix } from '@/lib/connection-scoped' import { readKey, writeKey } from '@/lib/storage' import { $activeProfile, normalizeProfileKey } from '@/store/profile' @@ -153,7 +154,7 @@ export function threadScrollTargetTop( const SCROLL_POS_KEY_BASE = 'hermes.desktop.threadScroll.v1' export function threadScrollStorageKey(profile: string): string { - return `${SCROLL_POS_KEY_BASE}.profile.${encodeURIComponent(normalizeProfileKey(profile))}` + return `${SCROLL_POS_KEY_BASE}.profile.${encodeURIComponent(normalizeProfileKey(profile))}${activeConnectionScopeSuffix()}` } // Bounded so a marathon runtime that touches hundreds of sessions doesn't grow @@ -172,7 +173,12 @@ function isValidState(value: unknown): value is ThreadScrollState { return true } - return record.kind === 'offset' && typeof record.fromBottom === 'number' && Number.isFinite(record.fromBottom) + return ( + record.kind === 'offset' && + typeof record.fromBottom === 'number' && + Number.isFinite(record.fromBottom) && + record.fromBottom >= 0 + ) } function loadPositions(profile: string): Record {