mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-11 02:46:29 +00:00
* fix(app): validate persisted client state Persisted replica data could satisfy TypeScript through an assertion while missing fields required by renderers. Treat every AsyncStorage value as untrusted input, clear values that fail strict schemas, and version the replica DTO so incompatible caches cannot hydrate. * fix(app): preserve validated legacy state * fix(app): preserve validated preferences Preserve supported legacy location fields and every shipped theme while keeping unknown persisted fields rejected. Align browser test seeds with the current preference shape so strict validation exercises the intended provider. * fix(app): migrate legacy agent preferences Released clients stored host/location fields and per-provider thinkingOptionId together. Migrate those exact strict bytes into current preferences without admitting unknown fields. * fix(app): preserve drafts with legacy reviews Accept the exact strict shape released for workspace review attachments so migration can discard that obsolete attachment without clearing every persisted draft.
64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
import type { DesktopSettings } from "@/desktop/settings/desktop-settings";
|
|
import type { DesktopSettingsBridge, KeyValueStorage, ReleaseChannel } from "./storage";
|
|
|
|
export interface InMemoryKeyValueStorage extends KeyValueStorage {
|
|
readonly entries: Map<string, string>;
|
|
}
|
|
|
|
export function createInMemoryKeyValueStorage(
|
|
initial: Record<string, string> = {},
|
|
): InMemoryKeyValueStorage {
|
|
const entries = new Map<string, string>(Object.entries(initial));
|
|
return {
|
|
entries,
|
|
async getItem(key) {
|
|
return entries.get(key) ?? null;
|
|
},
|
|
async setItem(key, value) {
|
|
entries.set(key, value);
|
|
},
|
|
async removeItem(key) {
|
|
entries.delete(key);
|
|
},
|
|
};
|
|
}
|
|
|
|
export interface FakeDesktopBridge extends DesktopSettingsBridge {
|
|
readonly migrationsApplied: Array<{
|
|
manageBuiltInDaemon?: boolean;
|
|
releaseChannel?: ReleaseChannel;
|
|
}>;
|
|
}
|
|
|
|
const DEFAULT_DESKTOP: DesktopSettings = {
|
|
releaseChannel: "stable",
|
|
notifications: {
|
|
playSound: true,
|
|
},
|
|
daemon: {
|
|
manageBuiltInDaemon: true,
|
|
keepRunningAfterQuit: false,
|
|
},
|
|
};
|
|
|
|
export function createFakeDesktopBridge(
|
|
options: {
|
|
isElectron?: boolean;
|
|
settings?: DesktopSettings;
|
|
} = {},
|
|
): FakeDesktopBridge {
|
|
const isElectron = options.isElectron ?? false;
|
|
const settings = options.settings ?? DEFAULT_DESKTOP;
|
|
const migrationsApplied: FakeDesktopBridge["migrationsApplied"] = [];
|
|
return {
|
|
migrationsApplied,
|
|
isElectron: () => isElectron,
|
|
async loadDesktopSettings() {
|
|
return settings;
|
|
},
|
|
async migrateLegacyDesktopSettings(input) {
|
|
migrationsApplied.push(input);
|
|
},
|
|
};
|
|
}
|