Open History to see the last commit
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 useLegacyPlanModeEnabled(): boolean {
13 return useLegacyPlanModeState().enabled;
14}
15
16export function useLegacyPlanModeState(): { readonly enabled: boolean; readonly loaded: boolean } {
17 const preferences = useAtomValue(mobilePreferencesAtom);
18 const loaded = AsyncResult.isSuccess(preferences);
19 return {
20 enabled: resolveLegacyPlanModeEnabled({
21 loaded,
22 preference: loaded ? preferences.value.planModeEnabled : undefined,
23 }),
24 loaded,
25 };
26}