Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

use-legacy-plan-mode-enabled.ts

22 lines812 Bytes

1import { useAtomValue } from "@effect/atom-react";
2import { AsyncResult } from "effect/unstable/reactivity";
3​
4import { mobilePreferencesAtom } from "../../state/preferences";
5import { resolveLegacyPlanModeEnabled } from "./legacy-plan-mode";
6​
7/**
8 * Mobile preferences are device-local, matching the desktop client setting.
9 * Keep the legacy composer mode hidden until the preference has loaded and is
10 * explicitly enabled.
11 */
12export function useLegacyPlanModeState(): { readonly enabled: boolean; readonly loaded: boolean } {
13 const preferences = useAtomValue(mobilePreferencesAtom);
14 const loaded = AsyncResult.isSuccess(preferences);
15 return {
16 enabled: resolveLegacyPlanModeEnabled({
17 loaded,
18 preference: loaded ? preferences.value.planModeEnabled : undefined,
19 }),
20 loaded,
21 };