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

use-legacy-plan-mode-enabled.ts

26 lines912 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 useLegacyPlanModeEnabled(): boolean {
13 return useLegacyPlanModeState().enabled;
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 };