Files
openidea/src/platform/clientSettings.ts
T
l0ng-ai 0558c1127c feat(terminal): option to use the application title as the tab name always (#4477)
Settings › Tools › Terminal gets "Use application title as tab name" (When command is running, the default; Always; Never). The title a program sets via OSC 0/2 named the tab only while a command ran, so a CLI agent's own title did not show when shell integration could not tell a command was running.
2026-11-19 17:55:24 +08:00

138 lines
4.3 KiB
TypeScript

/** Settings model ownership: these UI preferences belong to the client, including their descendants.
* Mixed sections deliberately list individual keys so project/tooling settings stay on the host.
* Keep this module dependency-free: the transport also consumes this metadata.
*/
export const CLIENT_SETTINGS_KEYS = [
"keymap",
"keymapOverrides",
"customKeymaps",
"appearance",
"notifications",
"general.reopenLastProject",
"general.confirmExit",
"general.closeWithoutWelcome",
"general.closeTabsWithWindow",
"general.openProjectIn",
"general.updateSource",
"general.autoCheckUpdates",
"general.showWhatsNewAfterUpdate",
"general.lastRunVersion",
"general.dateFormat",
"editor.fontFamily",
"editor.fontSize",
"editor.lineHeight",
"editor.ligatures",
"editor.onlyMonospacedFonts",
"editor.fallbackFont",
"editor.fontWeight",
"editor.boldFontWeight",
"editor.colorScheme",
"editor.colorOverrides",
"editor.customSchemes",
"editor.semanticHighlighting",
"editor.docstringFormat",
"editor.rainbowBrackets",
"editor.rainbowBracketKinds",
"editor.rainbowBracketColors",
"editor.softWrap",
"editor.showWhitespace",
"editor.inlayHints",
"editor.stickyScroll",
"editor.appearance",
"editor.breadcrumbs",
"editor.folding",
"editor.tabs",
"editor.codeEditing",
"editor.inlay",
"editor.gutterIconsDisabled",
"editor.showGutterIcons",
"editor.general.wheelZoom",
"editor.general.wheelZoomScope",
"editor.general.dragAndDrop",
"editor.general.caretScroll",
"editor.general.softWrapFiles",
"editor.general.softWrapIndent",
"editor.general.scrollPastEnd",
"editor.general.richTextCopy",
"editor.codeStyle.visualGuides",
"terminal.tabName",
"terminal.appTitleAsTabName",
"terminal.audibleBell",
"terminal.closeOnExit",
"terminal.mouseReporting",
"terminal.copyOnSelection",
"terminal.pasteOnMiddleClick",
"terminal.overrideIdeShortcuts",
"terminal.highlightHyperlinks",
"terminal.optionAsMeta",
"terminal.escapeToEditor",
"terminal.cursorShape",
"terminal.cursorBlink",
"terminal.useEditorFont",
"terminal.fontFamily",
"terminal.fontSize",
"terminal.lineHeight",
"terminal.fallbackFontFamily",
"terminal.columnWidth",
"console.softWrap",
"console.foldPatterns",
"console.logColors",
"debugger.showOnBreakpoint",
"debugger.focusAppOnBreakpoint",
"debugger.hideOnTermination",
"debugger.variablesOnBreakpoint",
"debugger.runToCursorInlay",
"debugger.flutterHotReloadOnSave",
"debugger.inlineValues",
"debugger.sortValues",
"debugger.valueTooltip",
"debugger.valueTooltipOnSelection",
"debugger.valueTooltipDelay",
"run.confirmRerun",
"run.confirmTerminate",
"run.showOnStart",
"run.pinTabs",
"externalDiff",
"vcs.showDirtyDirectories",
"vcs.git.inlineBlame",
"vcs.git.inlineBlameClickable",
"vcs.git.showBranchInProjectView",
"vcs.git.showPushDialog",
"vcs.git.pushDialogOnlyProtected",
"vcs.git.combineStashAndShelf",
"vcs.git.stagingArea",
"vcs.commit.nonModal",
"vcs.commit.doubleClickOpensDiff",
"vcs.commit.showRightMargin",
"agents.showContextUsage",
"agents.showWorkTime",
"agents.showUsageLimits",
"agents.showCost",
"agents.foldTurns",
"agents.smoothText",
"agents.fitWindowWidth",
"agents.thinking",
"agents.toolCalls",
"agents.expandToolOutput",
"agents.sendWith",
"agents.whileRunning",
] as const;
export function isClientSetting(key: string): boolean {
return CLIENT_SETTINGS_KEYS.some((root) => key === root || key.startsWith(`${root}.`));
}
/** Overlay from local globals, never from the local window's project layer. Missing client keys
* also replace remote values, so older local settings fall back to client defaults.
*/
export function overlayClientSettings<T>(remote: T, local: unknown): T {
const object = (value: unknown): Record<string, unknown> =>
value && typeof value === "object" ? (value as Record<string, unknown>) : {};
const copy = (target: unknown, source: unknown, path: string[]): unknown => {
const [head, ...tail] = path;
const value = object(source)[head!];
return { ...object(target), [head!]: tail.length ? copy(object(target)[head!], value, tail) : value };
};
return CLIENT_SETTINGS_KEYS.reduce((settings, key) => copy(settings, local, key.split(".")) as T, remote);
}