Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 161 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/patches/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { DEFAULT_SETTINGS } from '../defaultSettings';

import { writeShowMoreItemsInSelectMenus } from './showMoreItemsInSelectMenus';
import { writeThemes } from './themes';
import { writeSettingsTheme } from './settingsTheme';
import { writeContextLimit } from './contextLimit';
import { writeInputBoxBorder } from './inputBorderBox';
import { writeThinkerFormat } from './thinkerFormat';
Expand Down Expand Up @@ -212,6 +213,12 @@ const PATCH_DEFINITIONS = [
group: PatchGroup.MISC_CONFIGURABLE,
description: 'Your custom themes will be available via /theme',
},
{
id: 'settings-theme-schema',
name: 'Settings theme schema',
group: PatchGroup.MISC_CONFIGURABLE,
description: 'Allows custom theme IDs to persist in settings.json',
},
{
id: 'thinking-verbs',
name: 'Thinking verbs',
Expand Down Expand Up @@ -695,6 +702,15 @@ export const applyCustomization = async (
JSON.stringify(DEFAULT_SETTINGS.themes)
),
},
'settings-theme-schema': {
fn: c => writeSettingsTheme(c),
condition: !!(
config.settings.themes &&
config.settings.themes.length > 0 &&
JSON.stringify(config.settings.themes) !==
JSON.stringify(DEFAULT_SETTINGS.themes)
),
},
'thinking-verbs': {
fn: c => writeThinkingVerbs(c, config.settings.thinkingVerbs!.verbs),
condition: !!config.settings.thinkingVerbs,
Expand Down
19 changes: 19 additions & 0 deletions src/patches/settingsTheme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { globalReplace } from './index';

export const writeSettingsTheme = (file: string): string | null => {
const pattern =
/,theme:([$\w]+)\.union\(\[\1\.enum\([$\w$]+\),\1\.string\(\)\.startsWith\("[^"]*"\)\.transform\(\([^)]+\)=>[^)]+\)\]\)\.optional\(\)\.catch\(void 0\)/;

let patched = 0;
const newFile = globalReplace(file, pattern, (match, zodVar) => {
patched++;
return `,theme:${zodVar as string}.string().optional().catch(void 0)`;
});

if (patched < 2) {
console.error(`patch: settingsTheme: expected 2 replacements, got ${patched}`);
return null;
}

return newFile;
};