* 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.
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import type {
|
|
FormPreferences,
|
|
ProviderPreferences,
|
|
} from "../../../src/create-agent-preferences/preferences";
|
|
|
|
export const TEST_HOST_LABEL = "localhost";
|
|
|
|
export const TEST_PROVIDER_PREFERENCES = {
|
|
claude: { model: "haiku" },
|
|
codex: { model: "gpt-5.4-mini", thinkingByModel: { "gpt-5.4-mini": "low" } },
|
|
} satisfies Record<string, ProviderPreferences>;
|
|
|
|
export function buildDirectTcpConnection(endpoint: string): {
|
|
id: string;
|
|
type: "directTcp";
|
|
endpoint: string;
|
|
} {
|
|
return {
|
|
id: `direct:${endpoint}`,
|
|
type: "directTcp",
|
|
endpoint,
|
|
};
|
|
}
|
|
|
|
export function buildSeededHost(input: {
|
|
serverId: string;
|
|
endpoint: string;
|
|
label?: string;
|
|
nowIso: string;
|
|
}) {
|
|
const connection = buildDirectTcpConnection(input.endpoint);
|
|
return {
|
|
serverId: input.serverId,
|
|
label: input.label ?? TEST_HOST_LABEL,
|
|
connections: [connection],
|
|
preferredConnectionId: connection.id,
|
|
createdAt: input.nowIso,
|
|
updatedAt: input.nowIso,
|
|
};
|
|
}
|
|
|
|
export const TEST_MOCK_PROVIDER_PREFERENCES = {
|
|
...TEST_PROVIDER_PREFERENCES,
|
|
mock: { model: "ten-second-stream" },
|
|
} satisfies Record<string, ProviderPreferences>;
|
|
|
|
export function buildCreateAgentPreferences() {
|
|
return {
|
|
provider: "mock",
|
|
providerPreferences: TEST_MOCK_PROVIDER_PREFERENCES,
|
|
} satisfies FormPreferences;
|
|
}
|