refactor(settings): split 73-line god file into 5 sections + auto-save preferences + guard Restore
The previous SettingsPane.tsx hid 8 unrelated concerns behind 73 "lines"
of JSX where each line ran 400-2000 chars. Reading the file was
infeasible; editing it meant scrolling horizontally through a single
statement spanning every button, modal, and table row.
Split by concern into `settings-sections/`:
SettingsPane.tsx 62 LOC orchestrator
GeneralSection.tsx 94 LOC theme / language / auto-update
ExecutionModeSection.tsx 105 LOC AI CEO ↔ AI Co-Founder toggle
ShortcutsSection.tsx 40 LOC keyboard reference (read-only)
DataSection.tsx 123 LOC update check / backup / restore /
secret backend
SecretsSection.tsx 102 LOC per-company secret bindings
Every file now reads top-to-bottom with normal indentation.
Behavioral changes bundled (they belong with the restructure, not a
separate pass):
- Preferences save model unified: theme already auto-saved on change;
language and auto-update checkbox now do the same. The global
"Save settings" button is gone — there is no longer a state where
a toggled language sits unpersisted waiting for a second click.
- Execution mode card gained a subheader line that names the current
company ("Applies to current company: X"). Multi-company users can
no longer confuse which company they just flipped.
- Auto-updater checkbox gained an inline hint: "Check for application
updates at launch" — the previous naked checkbox never explained
what happens when it is off.
- Restore profile moved into DataSection's backup/restore group,
given `tone="danger"`, and gated behind a `window.confirm` with
copy warning about running work being lost. Backup stays neutral.
The previous layout put Restore in the same 2-col grid as Save +
Check Updates + Backup, making a profile-replacing operation look
as routine as saving a theme preference.
- Secret backend display promoted from a naked text line to a
bordered card so it matches the surrounding section rhythm.
Added i18n keys (zh + en):
settings.updaterHint / settings.modeScope / settings.backupRestore /
settings.restoreConfirm / settings.restoreHint.
Covers J-S1 / J-S6 / S-S1 / S-S2 / S-S3 / S-S4 from the settings audit.
Remaining work (tab sidebar, Providers IA reordering, copy sweep)
lands in follow-up commits.
This commit is contained in:
1 parent
fd6471988a
commit
16e45b6a8d
8 files changed
+530
-67
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { Eyebrow } from "../../ui";
|
||||
import { useT } from "../../../i18n";
|
||||
import { isMac } from "../../../lib/platform";
|
||||
|
||||
/**
|
||||
* Read-only keyboard shortcut reference. Listed in the settings page
|
||||
* because this is where users look when they want to remember how to
|
||||
* invoke a hotkey; it is NOT a configurable surface — so the visuals
|
||||
* are lighter than the other settings sections (no active state, no
|
||||
* action buttons).
|
||||
*/
|
||||
export function ShortcutsSection() {
|
||||
const t = useT();
|
||||
const mac = isMac();
|
||||
|
||||
const rows: Array<[string, string]> = [
|
||||
[mac ? "⌘K" : "Ctrl+K", t("settings.shortcut.commandPalette")],
|
||||
[mac ? "⌘Enter" : "Ctrl+Enter", t("settings.shortcut.sendMessage")],
|
||||
["Escape", t("settings.shortcut.closeModal")],
|
||||
["↑ / ↓", t("settings.shortcut.navigatePalette")],
|
||||
["Enter", t("settings.shortcut.selectPaletteResult")],
|
||||
["Tab", t("settings.shortcut.moveFocus")],
|
||||
];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Eyebrow className="mb-3">{t("settings.keyboardShortcuts")}</Eyebrow>
|
||||
<div className="divide-y divide-border rounded-lg border border-border">
|
||||
{rows.map(([key, description]) => (
|
||||
<div key={key} className="flex items-center justify-between px-3 py-2 text-[12px]">
|
||||
<span className="text-muted-foreground">{description}</span>
|
||||
<kbd className="rounded border border-border bg-muted px-2 py-0.5 font-mono text-[11px] text-foreground">
|
||||
{key}
|
||||
</kbd>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user