From 15f1a22f2e2bd7e01ac72908a5db860cd8cacbbc Mon Sep 17 00:00:00 2001 From: Danish Arora Date: Thu, 20 Nov 2025 16:26:27 -0500 Subject: [PATCH] feat: remove `storageKeyPrefix` and `getDefaultHistoryStorage`, simplifying history storage initialization to default to `localStorage` --- .../src/message_channel/persistent_history.ts | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/packages/sds/src/message_channel/persistent_history.ts b/packages/sds/src/message_channel/persistent_history.ts index d9de3e592b..d68cae183e 100644 --- a/packages/sds/src/message_channel/persistent_history.ts +++ b/packages/sds/src/message_channel/persistent_history.ts @@ -12,7 +12,6 @@ export interface HistoryStorage { export interface PersistentHistoryOptions { channelId: ChannelId; storage?: HistoryStorage; - storageKeyPrefix?: string; } type StoredHistoryEntry = { @@ -45,8 +44,8 @@ export class PersistentHistory implements ILocalHistory { public constructor(options: PersistentHistoryOptions) { this.memory = new MemLocalHistory(); - this.storage = options.storage ?? getDefaultHistoryStorage(); - this.storageKey = `${HISTORY_STORAGE_PREFIX}${options.storageKeyPrefix}:${options.channelId}`; + this.storage = options.storage || localStorage; + this.storageKey = `${HISTORY_STORAGE_PREFIX}${options.channelId}`; this.load(); } @@ -132,21 +131,6 @@ export class PersistentHistory implements ILocalHistory { } } -export const getDefaultHistoryStorage = (): HistoryStorage | undefined => { - try { - if (typeof localStorage === "undefined") { - return undefined; - } - - const probeKey = `${HISTORY_STORAGE_PREFIX}__probe__`; - localStorage.setItem(probeKey, probeKey); - localStorage.removeItem(probeKey); - return localStorage; - } catch { - return undefined; - } -}; - const serializeHistoryEntry = (entry: HistoryEntry): StoredHistoryEntry => ({ messageId: entry.messageId, retrievalHint: entry.retrievalHint