Skip to content

Commit f186246

Browse files
committed
refactor: extract backend settings schema
1 parent 54455c0 commit f186246

1 file changed

Lines changed: 7 additions & 47 deletions

File tree

lib/codex-manager/settings-hub.ts

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import type { PluginConfig } from "../types.js";
2424
import { ANSI } from "../ui/ansi.js";
2525
import { UI_COPY } from "../ui/copy.js";
2626
import { getUiRuntimeOptions, setUiRuntimeOptions } from "../ui/runtime.js";
27-
import { type MenuItem, type SelectOptions, select } from "../ui/select.js";
27+
import { type MenuItem, select } from "../ui/select.js";
2828
import { getUnifiedSettingsPath } from "../unified-settings.js";
2929
import { sleep } from "../utils.js";
3030
import {
@@ -46,6 +46,12 @@ import {
4646
} from "./backend-settings-schema.js";
4747
import { promptBehaviorSettingsPanel } from "./behavior-settings-panel.js";
4848
import { promptDashboardDisplayPanel } from "./dashboard-display-panel.js";
49+
import {
50+
type ExperimentalSettingsAction,
51+
getExperimentalSelectOptions,
52+
mapExperimentalMenuHotkey,
53+
mapExperimentalStatusHotkey,
54+
} from "./experimental-settings-schema.js";
4955
import { promptStatuslineSettingsPanel } from "./statusline-settings-panel.js";
5056
import { promptThemeSettingsPanel } from "./theme-settings-panel.js";
5157

@@ -177,52 +183,6 @@ type SettingsHubAction =
177183
| { type: "backend" }
178184
| { type: "back" };
179185

180-
type ExperimentalSettingsAction =
181-
| { type: "sync" }
182-
| { type: "backup" }
183-
| { type: "toggle-refresh-guardian" }
184-
| { type: "decrease-refresh-interval" }
185-
| { type: "increase-refresh-interval" }
186-
| { type: "apply" }
187-
| { type: "save" }
188-
| { type: "back" };
189-
190-
function getExperimentalSelectOptions(
191-
ui: ReturnType<typeof getUiRuntimeOptions>,
192-
help: string,
193-
onInput?: SelectOptions<ExperimentalSettingsAction>["onInput"],
194-
): SelectOptions<ExperimentalSettingsAction> {
195-
return {
196-
message: UI_COPY.settings.experimentalTitle,
197-
subtitle: UI_COPY.settings.experimentalSubtitle,
198-
help,
199-
clearScreen: true,
200-
theme: ui.theme,
201-
selectedEmphasis: "minimal",
202-
onInput,
203-
};
204-
}
205-
206-
function mapExperimentalMenuHotkey(
207-
raw: string,
208-
): ExperimentalSettingsAction | undefined {
209-
if (raw === "1") return { type: "sync" };
210-
if (raw === "2") return { type: "backup" };
211-
if (raw === "3") return { type: "toggle-refresh-guardian" };
212-
if (raw === "[" || raw === "-") return { type: "decrease-refresh-interval" };
213-
if (raw === "]" || raw === "+") return { type: "increase-refresh-interval" };
214-
const lower = raw.toLowerCase();
215-
if (lower === "q") return { type: "back" };
216-
if (lower === "s") return { type: "save" };
217-
return undefined;
218-
}
219-
220-
function mapExperimentalStatusHotkey(
221-
raw: string,
222-
): ExperimentalSettingsAction | undefined {
223-
return raw.toLowerCase() === "q" ? { type: "back" } : undefined;
224-
}
225-
226186
type DashboardSettingKey = keyof DashboardDisplaySettings;
227187

228188
const RETRYABLE_SETTINGS_WRITE_CODES = new Set([

0 commit comments

Comments
 (0)