Open History to see the last commit
1import * as Context from "effect/Context";
2import * as Effect from "effect/Effect";
3import * as Layer from "effect/Layer";
4import * as Option from "effect/Option";
5import * as Ref from "effect/Ref";
6import * as Schema from "effect/Schema";
7import * as Semaphore from "effect/Semaphore";
8import {
9 EnvironmentId,
10 PullRequestInvolvement,
11 PullRequestListFilters,
12 PullRequestListState,
13 type ProviderInstanceId,
14 type PullRequestMergeMethod,
15 type SidebarProjectGroupingMode,
16} from "@t3tools/contracts";
17import { ToolCallVisibility } from "@t3tools/contracts/settings";
18import type { AndroidNavigationStyle } from "../lib/androidNavigationStyle";
19import type { ComposerEnterBehavior } from "../lib/composerEnterBehavior";
20import type { FollowUpBehavior } from "../lib/followUpBehavior";
21import { isMicrophoneKind, type MicrophoneEntry } from "../lib/microphonePriority";
22import { MOBILE_THEME_IDS, type MobileThemeId, type MobileThemeMode } from "../lib/mobileTheme";
23import * as MobileDatabase from "./mobile-database";
24import * as MobileSecureStorage from "./mobile-secure-storage";
25import { MobileStorageDecodeError, MobileStorageEncodeError } from "./mobile-storage";
26
27const PREFERENCES_KEY = "t3code.preferences";
28const PREFERENCES_FALLBACK_KEY = "t3code.preferences.fallback";
29const encodeJson = Schema.encodeUnknownEffect(Schema.fromJsonString(Schema.Unknown));
30
31export const PullRequestListControls = Schema.Struct({
32 state: PullRequestListState,
33 involvement: PullRequestInvolvement,
34 filters: PullRequestListFilters,
35 projectId: Schema.optional(Schema.String),
36 projectEnvironmentId: Schema.optional(Schema.String),
37 sort: Schema.Literals(["updated", "created", "oldest"]),
38});
39export type PullRequestListControls = typeof PullRequestListControls.Type;
40
41const ThreadListFilters = Schema.Struct({
42 environmentId: Schema.NullOr(EnvironmentId),
43 projectKey: Schema.NullOr(Schema.String),
44});
45export type ThreadListFilters = typeof ThreadListFilters.Type;
46
47const PullRequestListPreferences = Schema.Struct({
48 environmentId: Schema.NullOr(Schema.String),
49 controls: Schema.Record(Schema.String, PullRequestListControls),
50});
51export type PullRequestListPreferences = typeof PullRequestListPreferences.Type;
52
53/**
54 * The page each workspace tab last showed, reopened when the tab returns with columns. `key` is
55 * that page's route key: reopening under the same key reuses the screen a tab kept mounted.
56 */
57const WorkspaceSelections = Schema.Struct({
58 threads: Schema.optional(
59 Schema.Struct({
60 environmentId: Schema.String,
61 threadId: Schema.String,
62 key: Schema.optional(Schema.String),
63 }),
64 ),
65 pullRequests: Schema.optional(
66 Schema.Struct({
67 environmentId: Schema.String,
68 projectId: Schema.String,
69 repository: Schema.String,
70 number: Schema.Number,
71 host: Schema.optional(Schema.String),
72 key: Schema.optional(Schema.String),
73 }),
74 ),
75 settings: Schema.optional(Schema.String),
76 settingsKey: Schema.optional(Schema.String),
77 /** A draft the threads tab showed after its last chat; only meaningful in its session. */
78 threadsDraft: Schema.optional(Schema.Struct({ key: Schema.String, params: Schema.Unknown })),
79});
80export type WorkspaceSelections = typeof WorkspaceSelections.Type;
81
82const isThreadListFilters = Schema.is(ThreadListFilters);
83const isWorkspaceSelections = Schema.is(WorkspaceSelections);
84const isPullRequestListPreferences = Schema.is(PullRequestListPreferences);
85const ThreadProject = Schema.Struct({
86 environmentId: Schema.NonEmptyString,
87 projectId: Schema.NonEmptyString,
88});
89const isThreadProject = Schema.is(ThreadProject);
90
91export interface Preferences {
92 readonly navigationTabOrder?: readonly string[];
93 readonly hiddenNavigationTabs?: readonly string[];
94 readonly pullRequestHideTestFiles?: boolean;
95 readonly pullRequestMergeMethod?: PullRequestMergeMethod;
96 readonly liveActivitiesEnabled?: boolean;
97 readonly themeId?: MobileThemeId;
98 readonly lightThemeId?: MobileThemeId;
99 readonly darkThemeId?: MobileThemeId;
100 readonly themeMode?: MobileThemeMode;
101 readonly androidNavigationStyle?: AndroidNavigationStyle;
102 readonly baseFontSize?: number;
103 readonly terminalFontSize?: number | null;
104 readonly markdownFontSize?: number;
105 readonly codeFontSize?: number | null;
106 readonly codeWordBreak?: boolean;
107 readonly mathRenderingEnabled?: boolean;
108 /** Unset means on: crash reports are sent unless the user turns them off. */
109 readonly crashReportsEnabled?: boolean;
110 readonly connectOnboardingOptOutAccounts?: ReadonlyArray<string>;
111 readonly collapsedProjectGroups?: readonly string[];
112 readonly dismissedDatabaseStorageNotices?: readonly string[];
113 /** Hardware-keyboard Return behavior in the composer. */
114 readonly composerEnterBehavior?: ComposerEnterBehavior;
115 readonly followUpBehavior?: FollowUpBehavior;
116 /** The client `language` setting: a locale code or "system". Unset means English. */
117 readonly language?: string;
118 readonly microphones?: ReadonlyArray<MicrophoneEntry>;
119 readonly projectGroupingEnabled?: boolean;
120 readonly projectGroupingMode?: SidebarProjectGroupingMode;
121 readonly toolCallVisibility?: ToolCallVisibility;
122 readonly workingShelfEnabled?: boolean;
123 readonly useLastProjectForNewThreads?: boolean;
124 readonly lastThreadProject?: typeof ThreadProject.Type;
125 readonly modelFavorites?: ReadonlyArray<{
126 readonly provider: ProviderInstanceId;
127 readonly model: string;
128 }>;
129 readonly threadListSettledShelfExpanded?: boolean;
130 readonly threadListSnoozedShelfExpanded?: boolean;
131 readonly threadListWorkingShelfExpanded?: boolean;
132 readonly threadListFilters?: ThreadListFilters;
133 readonly pullRequestListFilters?: PullRequestListPreferences;
134 readonly workspaceSelections?: WorkspaceSelections;
135}
136
137export class MobilePreferencesLoadError extends Schema.TaggedError<MobilePreferencesLoadError>()(
138 "MobilePreferencesLoadError",
139 { cause: Schema.Defect() },
140) {
141 override get message(): string {
142 return "Failed to load mobile preferences.";
143 }
144}
145
146export class MobilePreferencesSaveError extends Schema.TaggedError<MobilePreferencesSaveError>()(
147 "MobilePreferencesSaveError",
148 { cause: Schema.Defect() },
149) {
150 override get message(): string {
151 return "Failed to save mobile preferences.";
152 }
153}
154
155const isMobilePreferencesSaveError = Schema.is(MobilePreferencesSaveError);
156
157interface PreferencesFallback {
158 readonly payload: string;
159 readonly updatedAt: number;
160 readonly preferences: Preferences;
161}
162
163export class MobilePreferencesStore extends Context.Service<
164 MobilePreferencesStore,
165 {
166 readonly load: Effect.Effect<Preferences, MobilePreferencesLoadError>;
167 readonly savePatch: (
168 patch: Partial<Preferences>,
169 ) => Effect.Effect<Preferences, MobilePreferencesSaveError>;
170 readonly update: (
171 transform: (current: Preferences) => Partial<Preferences>,
172 ) => Effect.Effect<Preferences, MobilePreferencesSaveError>;
173 }
174>()("@t3tools/mobile/persistence/mobile-preferences/MobilePreferencesStore") {}
175
176const isToolCallVisibility = Schema.is(ToolCallVisibility);
177
178function sanitizePreferences(parsed: Preferences): Preferences {
179 const preferences: {
180 navigationTabOrder?: readonly string[];
181 hiddenNavigationTabs?: readonly string[];
182 pullRequestHideTestFiles?: boolean;
183 pullRequestMergeMethod?: PullRequestMergeMethod;
184 liveActivitiesEnabled?: boolean;
185 themeId?: MobileThemeId;
186 lightThemeId?: MobileThemeId;
187 darkThemeId?: MobileThemeId;
188 themeMode?: MobileThemeMode;
189 androidNavigationStyle?: AndroidNavigationStyle;
190 baseFontSize?: number;
191 terminalFontSize?: number | null;
192 markdownFontSize?: number;
193 codeFontSize?: number | null;
194 codeWordBreak?: boolean;
195 mathRenderingEnabled?: boolean;
196 crashReportsEnabled?: boolean;
197 connectOnboardingOptOutAccounts?: ReadonlyArray<string>;
198 collapsedProjectGroups?: readonly string[];
199 dismissedDatabaseStorageNotices?: readonly string[];
200 composerEnterBehavior?: ComposerEnterBehavior;
201 followUpBehavior?: FollowUpBehavior;
202 language?: string;
203 microphones?: ReadonlyArray<MicrophoneEntry>;
204 projectGroupingEnabled?: boolean;
205 projectGroupingMode?: SidebarProjectGroupingMode;
206 toolCallVisibility?: ToolCallVisibility;
207 workingShelfEnabled?: boolean;
208 useLastProjectForNewThreads?: boolean;
209 lastThreadProject?: typeof ThreadProject.Type;
210 modelFavorites?: Preferences["modelFavorites"];
211 threadListSettledShelfExpanded?: boolean;
212 threadListSnoozedShelfExpanded?: boolean;
213 threadListWorkingShelfExpanded?: boolean;
214 threadListFilters?: ThreadListFilters;
215 pullRequestListFilters?: PullRequestListPreferences;
216 workspaceSelections?: WorkspaceSelections;
217 } = {};
218
219 if (Array.isArray(parsed.hiddenNavigationTabs)) {
220 preferences.hiddenNavigationTabs = parsed.hiddenNavigationTabs.filter(
221 (tab): tab is string => typeof tab === "string",
222 );
223 }
224
225 if (Array.isArray(parsed.navigationTabOrder)) {
226 preferences.navigationTabOrder = parsed.navigationTabOrder.filter(
227 (tab): tab is string => typeof tab === "string",
228 );
229 }
230
231 if (typeof parsed.pullRequestHideTestFiles === "boolean") {
232 preferences.pullRequestHideTestFiles = parsed.pullRequestHideTestFiles;
233 }
234
235 if (
236 parsed.pullRequestMergeMethod === "squash" ||
237 parsed.pullRequestMergeMethod === "merge" ||
238 parsed.pullRequestMergeMethod === "rebase"
239 ) {
240 preferences.pullRequestMergeMethod = parsed.pullRequestMergeMethod;
241 }
242
243 if (typeof parsed.liveActivitiesEnabled === "boolean") {
244 preferences.liveActivitiesEnabled = parsed.liveActivitiesEnabled;
245 }
246 if (
247 typeof parsed.themeId === "string" &&
248 (MOBILE_THEME_IDS as readonly string[]).includes(parsed.themeId)
249 ) {
250 preferences.themeId = parsed.themeId as MobileThemeId;
251 }
252 if (
253 typeof parsed.lightThemeId === "string" &&
254 (MOBILE_THEME_IDS as readonly string[]).includes(parsed.lightThemeId)
255 ) {
256 preferences.lightThemeId = parsed.lightThemeId as MobileThemeId;
257 }
258 if (
259 typeof parsed.darkThemeId === "string" &&
260 (MOBILE_THEME_IDS as readonly string[]).includes(parsed.darkThemeId)
261 ) {
262 preferences.darkThemeId = parsed.darkThemeId as MobileThemeId;
263 }
264 if (
265 parsed.themeMode === "system" ||
266 parsed.themeMode === "light" ||
267 parsed.themeMode === "dark"
268 ) {
269 preferences.themeMode = parsed.themeMode;
270 }
271 if (parsed.androidNavigationStyle === "one-ui" || parsed.androidNavigationStyle === "material") {
272 preferences.androidNavigationStyle = parsed.androidNavigationStyle;
273 }
274 if (typeof parsed.baseFontSize === "number") preferences.baseFontSize = parsed.baseFontSize;
275 if (typeof parsed.terminalFontSize === "number" || parsed.terminalFontSize === null) {
276 preferences.terminalFontSize = parsed.terminalFontSize;
277 }
278 if (typeof parsed.markdownFontSize === "number") {
279 preferences.markdownFontSize = parsed.markdownFontSize;
280 }
281 if (typeof parsed.codeFontSize === "number" || parsed.codeFontSize === null) {
282 preferences.codeFontSize = parsed.codeFontSize;
283 }
284 if (typeof parsed.codeWordBreak === "boolean") preferences.codeWordBreak = parsed.codeWordBreak;
285 if (typeof parsed.mathRenderingEnabled === "boolean")
286 preferences.mathRenderingEnabled = parsed.mathRenderingEnabled;
287 if (typeof parsed.crashReportsEnabled === "boolean") {
288 preferences.crashReportsEnabled = parsed.crashReportsEnabled;
289 }
290 if (Array.isArray(parsed.connectOnboardingOptOutAccounts)) {
291 preferences.connectOnboardingOptOutAccounts = parsed.connectOnboardingOptOutAccounts.filter(
292 (account): account is string => typeof account === "string",
293 );
294 }
295 if (Array.isArray(parsed.collapsedProjectGroups)) {
296 preferences.collapsedProjectGroups = parsed.collapsedProjectGroups.filter(
297 (key): key is string => typeof key === "string",
298 );
299 }
300 if (Array.isArray(parsed.dismissedDatabaseStorageNotices)) {
301 preferences.dismissedDatabaseStorageNotices = parsed.dismissedDatabaseStorageNotices.filter(
302 (value): value is string => typeof value === "string",
303 );
304 }
305 if (parsed.composerEnterBehavior === "send" || parsed.composerEnterBehavior === "newline") {
306 preferences.composerEnterBehavior = parsed.composerEnterBehavior;
307 }
308 if (parsed.followUpBehavior === "queue" || parsed.followUpBehavior === "steer") {
309 preferences.followUpBehavior = parsed.followUpBehavior;
310 }
311 if (typeof parsed.language === "string") preferences.language = parsed.language;
312 if (Array.isArray(parsed.microphones)) {
313 preferences.microphones = parsed.microphones.flatMap((entry): MicrophoneEntry[] => {
314 if (typeof entry !== "object" || entry === null || !isMicrophoneKind(entry.kind)) return [];
315 if (!("uid" in entry)) return [{ kind: entry.kind }];
316 return typeof entry.uid === "string" && typeof entry.name === "string"
317 ? [{ kind: entry.kind, uid: entry.uid, name: entry.name }]
318 : [];
319 });
320 }
321 if (typeof parsed.projectGroupingEnabled === "boolean") {
322 preferences.projectGroupingEnabled = parsed.projectGroupingEnabled;
323 }
324 if (
325 parsed.projectGroupingMode === "repository" ||
326 parsed.projectGroupingMode === "repository_path" ||
327 parsed.projectGroupingMode === "separate"
328 ) {
329 preferences.projectGroupingMode = parsed.projectGroupingMode;
330 }
331 if (isToolCallVisibility(parsed.toolCallVisibility)) {
332 preferences.toolCallVisibility = parsed.toolCallVisibility;
333 }
334 if (typeof parsed.workingShelfEnabled === "boolean") {
335 preferences.workingShelfEnabled = parsed.workingShelfEnabled;
336 }
337 if (typeof parsed.useLastProjectForNewThreads === "boolean") {
338 preferences.useLastProjectForNewThreads = parsed.useLastProjectForNewThreads;
339 }
340 if (isThreadProject(parsed.lastThreadProject)) {
341 preferences.lastThreadProject = parsed.lastThreadProject;
342 }
343 if (Array.isArray(parsed.modelFavorites)) {
344 preferences.modelFavorites = parsed.modelFavorites.filter(
345 (favorite) =>
346 typeof favorite === "object" &&
347 favorite !== null &&
348 typeof favorite.provider === "string" &&
349 favorite.provider.length > 0 &&
350 typeof favorite.model === "string" &&
351 favorite.model.trim().length > 0,
352 );
353 }
354 if (typeof parsed.threadListSettledShelfExpanded === "boolean") {
355 preferences.threadListSettledShelfExpanded = parsed.threadListSettledShelfExpanded;
356 }
357 if (typeof parsed.threadListSnoozedShelfExpanded === "boolean") {
358 preferences.threadListSnoozedShelfExpanded = parsed.threadListSnoozedShelfExpanded;
359 }
360 if (typeof parsed.threadListWorkingShelfExpanded === "boolean") {
361 preferences.threadListWorkingShelfExpanded = parsed.threadListWorkingShelfExpanded;
362 }
363 if (isThreadListFilters(parsed.threadListFilters)) {
364 preferences.threadListFilters = parsed.threadListFilters;
365 }
366 if (isPullRequestListPreferences(parsed.pullRequestListFilters)) {
367 preferences.pullRequestListFilters = parsed.pullRequestListFilters;
368 }
369 if (isWorkspaceSelections(parsed.workspaceSelections)) {
370 preferences.workspaceSelections = parsed.workspaceSelections;
371 }
372 return preferences;
373}
374
375const make = Effect.fn("MobilePreferencesStore.make")(function* () {
376 const database = yield* MobileDatabase.MobileDatabase;
377 const secureStorage = yield* MobileSecureStorage.MobileSecureStorage;
378 const lock = yield* Semaphore.make(1);
379 const lastUpdatedAt = yield* Ref.make(0);
380
381 const parsePayload = (raw: string | null): Preferences | null => {
382 if (raw === null || !raw.trim()) return null;
383 let parsed: unknown;
384 try {
385 parsed = JSON.parse(raw);
386 } catch (cause) {
387 console.warn(
388 "[mobile-storage] ignored invalid JSON",
389 new MobileStorageDecodeError({ key: PREFERENCES_KEY, cause }),
390 );
391 return null;
392 }
393 return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)
394 ? (parsed as Preferences)
395 : null;
396 };
397
398 const parseFallback = (raw: string | null): PreferencesFallback | null => {
399 if (raw === null || !raw.trim()) return null;
400 let parsed: unknown;
401 try {
402 parsed = JSON.parse(raw);
403 } catch (cause) {
404 console.warn(
405 "[mobile-storage] ignored invalid JSON",
406 new MobileStorageDecodeError({ key: PREFERENCES_FALLBACK_KEY, cause }),
407 );
408 return null;
409 }
410 if (
411 typeof parsed !== "object" ||
412 parsed === null ||
413 !("payload" in parsed) ||
414 typeof parsed.payload !== "string" ||
415 !("updatedAt" in parsed) ||
416 typeof parsed.updatedAt !== "number"
417 ) {
418 return null;
419 }
420 const preferences = parsePayload(parsed.payload);
421 return preferences === null
422 ? null
423 : { payload: parsed.payload, updatedAt: parsed.updatedAt, preferences };
424 };
425
426 const encode = Effect.fn("MobilePreferencesStore.encode")(function* (
427 key: string,
428 value: unknown,
429 ) {
430 return yield* encodeJson(value).pipe(
431 Effect.mapError((cause) => new MobileStorageEncodeError({ key, cause })),
432 );
433 });
434
435 const nextUpdatedAt = Ref.modify(lastUpdatedAt, (last) => {
436 const next = Math.max(Date.now(), last + 1);
437 return [next, next] as const;
438 });
439
440 const saveJson = Effect.fn("MobilePreferencesStore.saveJson")(function* (
441 payload: string,
442 updatedAt?: number,
443 ) {
444 const timestamp = updatedAt ?? (yield* nextUpdatedAt);
445 yield* Ref.update(lastUpdatedAt, (last) => Math.max(last, timestamp));
446 const databaseResult = yield* Effect.result(database.savePreferencesJson(payload, timestamp));
447 if (databaseResult._tag === "Failure") {
448 yield* Effect.logWarning("Database unavailable; saving preferences to secure storage.").pipe(
449 Effect.annotateLogs({ cause: databaseResult.failure }),
450 );
451 const fallback = yield* encode(PREFERENCES_FALLBACK_KEY, { payload, updatedAt: timestamp });
452 yield* secureStorage.setItem(PREFERENCES_FALLBACK_KEY, fallback);
453 return;
454 }
455 yield* secureStorage
456 .removeItem(PREFERENCES_FALLBACK_KEY)
457 .pipe(
458 Effect.catch((error) =>
459 Effect.logWarning("Could not remove the mobile preferences fallback.").pipe(
460 Effect.annotateLogs({ error }),
461 ),
462 ),
463 );
464 });
465
466 const loadUnlocked = Effect.gen(function* () {
467 const databaseResult = yield* Effect.result(database.loadPreferencesJson);
468 const databaseAvailable = databaseResult._tag === "Success";
469 const storedJson = databaseAvailable
470 ? databaseResult.success
471 : Option.none<MobileDatabase.StoredPreferencesJson>();
472 if (databaseResult._tag === "Failure") {
473 yield* Effect.logWarning("Database unavailable; loading fallback preferences.").pipe(
474 Effect.annotateLogs({ cause: databaseResult.failure }),
475 );
476 }
477
478 const fallbackResult = yield* Effect.result(secureStorage.getItem(PREFERENCES_FALLBACK_KEY));
479 let fallbackJson: string | null = null;
480 if (fallbackResult._tag === "Success") {
481 fallbackJson = fallbackResult.success;
482 } else if (Option.isNone(storedJson)) {
483 return yield* fallbackResult.failure;
484 } else {
485 yield* Effect.logWarning("Could not inspect the mobile preferences fallback.").pipe(
486 Effect.annotateLogs({ error: fallbackResult.failure }),
487 );
488 }
489
490 const fallback = parseFallback(fallbackJson);
491 const storedPreferences = Option.isSome(storedJson)
492 ? parsePayload(storedJson.value.payload)
493 : null;
494 const fallbackIsNewer =
495 fallback !== null &&
496 (storedPreferences === null ||
497 (Option.isSome(storedJson) && fallback.updatedAt > storedJson.value.updatedAt));
498
499 let parsed: Preferences | null = null;
500 if (fallbackIsNewer) {
501 parsed = fallback.preferences;
502 yield* Ref.update(lastUpdatedAt, (last) => Math.max(last, fallback.updatedAt));
503 if (databaseAvailable) yield* saveJson(fallback.payload, fallback.updatedAt);
504 } else if (storedPreferences !== null && Option.isSome(storedJson)) {
505 parsed = storedPreferences;
506 yield* Ref.update(lastUpdatedAt, (last) => Math.max(last, storedJson.value.updatedAt));
507 if (fallbackJson !== null) {
508 yield* secureStorage
509 .removeItem(PREFERENCES_FALLBACK_KEY)
510 .pipe(
511 Effect.catch((error) =>
512 Effect.logWarning("Could not remove a stale mobile preferences fallback.").pipe(
513 Effect.annotateLogs({ error }),
514 ),
515 ),
516 );
517 }
518 }
519
520 if (parsed === null) {
521 const legacyJson = yield* secureStorage.getItem(PREFERENCES_KEY);
522 const legacyPreferences = parsePayload(legacyJson);
523 parsed = legacyPreferences;
524 if (legacyJson !== null && legacyPreferences !== null && databaseAvailable) {
525 yield* saveJson(legacyJson);
526 yield* secureStorage
527 .removeItem(PREFERENCES_KEY)
528 .pipe(
529 Effect.catch((error) =>
530 Effect.logWarning("Could not remove migrated mobile preferences.").pipe(
531 Effect.annotateLogs({ error }),
532 ),
533 ),
534 );
535 }
536 }
537
538 return parsed === null ? {} : sanitizePreferences(parsed);
539 });
540
541 const load = lock
542 .withPermits(1)(loadUnlocked)
543 .pipe(Effect.mapError((cause) => new MobilePreferencesLoadError({ cause })));
544
545 const update = Effect.fn("MobilePreferencesStore.update")(
546 (transform: (current: Preferences) => Partial<Preferences>) =>
547 lock
548 .withPermits(1)(
549 Effect.gen(function* () {
550 const current = yield* loadUnlocked;
551 const patch = yield* Effect.try({
552 try: () => transform(current),
553 catch: (cause) => new MobilePreferencesSaveError({ cause }),
554 });
555 const next: Preferences = { ...current, ...patch };
556 const payload = yield* encode(PREFERENCES_KEY, next);
557 yield* saveJson(payload);
558 return next;
559 }),
560 )
561 .pipe(
562 Effect.mapError((cause) =>
563 isMobilePreferencesSaveError(cause) ? cause : new MobilePreferencesSaveError({ cause }),
564 ),
565 ),
566 );
567
568 return MobilePreferencesStore.of({
569 load,
570 update,
571 savePatch: Effect.fn("MobilePreferencesStore.savePatch")((patch) => update(() => patch)),
572 });
573});
574
575export const layer = Layer.effect(MobilePreferencesStore, make());