Skip to content

Commit 92dd0ba

Browse files
feat: remove storageKeyPrefix and getDefaultHistoryStorage, simplifying history storage initialization to default to localStorage
1 parent af8ee45 commit 92dd0ba

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

packages/sds/src/message_channel/persistent_history.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export interface HistoryStorage {
1212
export interface PersistentHistoryOptions {
1313
channelId: ChannelId;
1414
storage?: HistoryStorage;
15-
storageKeyPrefix?: string;
1615
}
1716

1817
type StoredHistoryEntry = {
@@ -45,8 +44,8 @@ export class PersistentHistory implements ILocalHistory {
4544

4645
public constructor(options: PersistentHistoryOptions) {
4746
this.memory = new MemLocalHistory();
48-
this.storage = options.storage ?? getDefaultHistoryStorage();
49-
this.storageKey = `${HISTORY_STORAGE_PREFIX}${options.storageKeyPrefix}:${options.channelId}`;
47+
this.storage = options.storage || localStorage;
48+
this.storageKey = `${HISTORY_STORAGE_PREFIX}${options.channelId}`;
5049
this.load();
5150
}
5251

@@ -132,21 +131,6 @@ export class PersistentHistory implements ILocalHistory {
132131
}
133132
}
134133

135-
export const getDefaultHistoryStorage = (): HistoryStorage | undefined => {
136-
try {
137-
if (typeof localStorage === "undefined") {
138-
return undefined;
139-
}
140-
141-
const probeKey = `${HISTORY_STORAGE_PREFIX}__probe__`;
142-
localStorage.setItem(probeKey, probeKey);
143-
localStorage.removeItem(probeKey);
144-
return localStorage;
145-
} catch {
146-
return undefined;
147-
}
148-
};
149-
150134
const serializeHistoryEntry = (entry: HistoryEntry): StoredHistoryEntry => ({
151135
messageId: entry.messageId,
152136
retrievalHint: entry.retrievalHint

0 commit comments

Comments
 (0)