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

legacy-plan-mode.ts

29 lines1.1 KB

1import {
2 DEFAULT_PROVIDER_INTERACTION_MODE,
3 type ProviderInteractionMode,
4} from "@t3tools/contracts";
5​
6export function resolveLegacyPlanModeEnabled(input: {
7 readonly loaded: boolean;
8 readonly preference: boolean | undefined;
9}): boolean {
10 return input.loaded && input.preference === true;
12​
13export function resolvePendingTaskInteractionMode(input: {
14 readonly preferenceLoaded: boolean;
15 readonly planModeEnabled: boolean;
16 readonly draftInteractionMode: ProviderInteractionMode | undefined;
17 readonly queuedInteractionMode: ProviderInteractionMode | undefined;
18}): ProviderInteractionMode {
19 if (input.planModeEnabled) {
20 return input.draftInteractionMode ?? DEFAULT_PROVIDER_INTERACTION_MODE;
21 }
22 if (!input.preferenceLoaded) {
23 // Only an existing queued task may retain its previous mode while the
24 // preference is unknown. A fresh draft still defaults to Build so a stale
25 // persisted Plan selection cannot bypass a disabled preference at launch.
26 return input.queuedInteractionMode ?? DEFAULT_PROVIDER_INTERACTION_MODE;
27 }
28 return DEFAULT_PROVIDER_INTERACTION_MODE;