2026-11-02 12:00:12 -08:00
|
|
|
// Plan2Code Web Console - what the User Preferences dialog is.
|
|
|
|
|
//
|
|
|
|
|
// Its tabs in order, which one opens, and what Back to default resets on
|
|
|
|
|
// each. No DOM access at module scope, and its one import is the data-only
|
|
|
|
|
// palette.js: the page and `node --test` both import this file.
|
|
|
|
|
|
2026-11-09 12:53:53 -08:00
|
|
|
import { SOUND_EVENTS, soundKey, PICKABLE_SOUNDS, soundFileKey } from "./palette.js";
|
2026-11-02 12:00:12 -08:00
|
|
|
|
|
|
|
|
const tab = (id, label, hint, sections) => Object.freeze({ id, label, hint, sections: Object.freeze(sections) });
|
|
|
|
|
|
|
|
|
|
// Each section id names one fieldset in the dialog (its data-section).
|
|
|
|
|
export const PREFS_TABS = Object.freeze([
|
2026-11-09 11:46:13 -08:00
|
|
|
tab("appearance", "Appearance", "Theme, width, color, role, intro", ["theme", "width", "accent", "role", "intro"]),
|
2026-11-02 12:00:12 -08:00
|
|
|
tab("agents", "Agents & models", "Your CLIs and models", ["agents"]),
|
|
|
|
|
tab("system", "System", "Cleanup, desktop app", ["cleanup", "desktop"]),
|
|
|
|
|
tab("sounds", "Sounds & activities", "What plays", ["sounds", "activities"]),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// The tab the dialog opens on: the one asked for when there is such a tab,
|
|
|
|
|
// else Appearance. Nothing is remembered between opens.
|
|
|
|
|
export function prefsOpenTab(asked) {
|
|
|
|
|
return PREFS_TABS.some((t) => t.id === asked) ? asked : "appearance";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The looks keys Back to default resets on a tab, or null where it has
|
|
|
|
|
// nothing to reset (and is hidden).
|
|
|
|
|
export function prefsResetScope(tab) {
|
2026-11-09 11:46:13 -08:00
|
|
|
if (tab === "appearance") return ["theme", "width", "accent", "role", "skipIntro"];
|
2026-11-09 12:53:53 -08:00
|
|
|
if (tab === "sounds") return ["sound", ...Object.keys(SOUND_EVENTS).map(soundKey), ...PICKABLE_SOUNDS.map(soundFileKey), "hideActivities", "activitySounds", "gameMusic"];
|
2026-11-02 12:00:12 -08:00
|
|
|
return null;
|
|
|
|
|
}
|