feat(home): add privacy-safe home page mode

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-10-04 02:12:03 +08:00
1 parent 1edbb7b935
commit 951f0a21a0
22 files changed
+436 -8

No files matched your search

@@ -71,6 +71,11 @@ describe("EDITOR_SETTINGS_DRAFT_KEYS", () => {
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("savedSqlOpenTargetMode");
});
it("includes the privacy-safe welcome page mode", () => {
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("welcomePageMode");
expect(editorSettingsDraftFromSettings(makeSettings({ welcomePageMode: "workspace" })).welcomePageMode).toBe("workspace");
});
it("includes the regular expression match limit", () => {
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("regexMaxMatchCount");
});
@@ -23,6 +23,16 @@ describe("settingsTransfer", () => {
expect(parseSettingsTransferFile(fileWith({ resultTabPreferComments: "false" })).ok).toBe(false);
});
it("round-trips the welcome page mode and rejects invalid values", () => {
const result = parseSettingsTransferFile(fileWith({ welcomePageMode: "workspace" }));
expect(result.ok).toBe(true);
if (result.ok) expect(result.value.editorSettings.welcomePageMode).toBe("workspace");
const invalid = parseSettingsTransferFile(fileWith({ welcomePageMode: "connections" }));
expect(invalid.ok).toBe(false);
if (!invalid.ok) expect(invalid.error.detail).toContain("welcomePageMode");
});
it("builds a dated transfer filename", () => {
expect(buildSettingsTransferFilename(new Date(2026, 8, 6))).toBe("dbx-settings-2026-09-06.json");
});
@@ -44,6 +44,7 @@ export const EDITOR_SETTINGS_DRAFT_KEYS = [
"confirmUnsavedSqlClose",
"appCloseUnsavedTabsMode",
"savedSqlOpenTargetMode",
"welcomePageMode",
"appLayout",
"tabLayout",
"tabPlacement",
@@ -187,6 +187,7 @@ export const SETTINGS_SEARCH_DEFINITIONS: readonly SettingsSearchDefinition[] =
{ id: "appearance-ui-font", category: "appearance", titleKey: "settings.uiFontFamily", descriptionKey: "settings.uiFontFamilyDescription", targetId: "appearance" },
{ id: "appearance-grid-font", category: "appearance", titleKey: "settings.dataGridFontFamily", descriptionKey: "settings.dataGridFontFamilyDescription", targetId: "appearance" },
{ id: "appearance-corners", category: "appearance", titleKey: "settings.cornerStyle", targetId: "appearance" },
{ id: "appearance-welcome-page", category: "appearance", titleKey: "settings.welcomePage", descriptionKey: "settings.welcomePageDescription", targetId: "welcome-page-settings" },
{ id: "appearance-layout", category: "appearance", titleKey: "settings.appLayout", targetId: "appearance" },
{ id: "appearance-tab-layout", category: "appearance", titleKey: "settings.tabLayout", targetId: "appearance" },
{ id: "appearance-connection-tab-colors", category: "appearance", titleKey: "settings.colorizeConnectionTabs", descriptionKey: "settings.colorizeConnectionTabsDescription", targetId: "appearance" },
@@ -71,7 +71,7 @@ export function serializeSettingsTransfer(settings: EditorSettings, meta: Settin
const SETTINGS_TRANSFER_CATEGORY_ORDER: readonly SettingsTransferCategoryId[] = ["appearance", "editor", "formatter", "navigation", "data", "shortcuts", "snippets", "other"];
const SETTINGS_TRANSFER_CATEGORY_KEYS: Record<SettingsTransferCategoryId, readonly EditorSettingsDraftKey[]> = {
appearance: ["fontFamily", "fontSize", "tableFontFamily", "uiFontFamily", "uiScale", "theme", "customThemes", "activeCustomThemeId", "backgroundImage", "toolbarItems"],
appearance: ["fontFamily", "fontSize", "tableFontFamily", "uiFontFamily", "uiScale", "theme", "customThemes", "activeCustomThemeId", "backgroundImage", "toolbarItems", "welcomePageMode"],
editor: [
"executeMode",
"defaultTransactionMode",
@@ -308,6 +308,7 @@ const PASS_THROUGH_BOOLEAN_KEYS = [
const PASS_THROUGH_FIELD_VALIDATORS: Partial<Record<EditorSettingsDraftKey, (value: unknown) => boolean>> = {
// The editor font slider and the Ctrl+wheel zoom both clamp to this range.
fontSize: (value) => typeof value === "number" && Number.isFinite(value) && value >= EDITOR_MIN_FONT_SIZE && value <= EDITOR_MAX_FONT_SIZE,
welcomePageMode: (value) => value === "intro" || value === "workspace",
appLayout: (value) => value === "separated" || value === "classic",
resultTabNamingMode: (value) => value === "source" || value === "ordinal" || value === "comment",
activeCustomThemeId: (value) => typeof value === "string" && value.trim().length > 0,