From 3a0a4fc526bebf9966c62c0b41d8222f7b8d96d2 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Mon, 16 Nov 2026 13:37:02 -0800 Subject: [PATCH 1/2] feat(themes): theme CSS can hold 100,000 characters The total size of published themes stays near 1.8 MB, because clients cache them in localStorage. Co-Authored-By: Claude Fable 5.2 --- apps/server/src/environmentTheme.test.ts | 2 +- apps/server/src/environmentTheme.ts | 3 ++- apps/server/src/provider/agentContextBudget.json | 2 +- packages/contracts/src/server.ts | 2 +- packages/shared/src/themeCss.ts | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/server/src/environmentTheme.test.ts b/apps/server/src/environmentTheme.test.ts index cb3f812cad4bc..70c46c1c3873b 100644 --- a/apps/server/src/environmentTheme.test.ts +++ b/apps/server/src/environmentTheme.test.ts @@ -356,7 +356,7 @@ it.layer(NodeServices.layer)("environment theme", (it) => { return withEnvironmentThemes( { ...Object.fromEntries( - Array.from({ length: 6 }, (_, index) => [ + Array.from({ length: 3 }, (_, index) => [ `aa-${index}.json`, encodeThemeFileEscaped(large(`Large ${index}`)), ]), diff --git a/apps/server/src/environmentTheme.ts b/apps/server/src/environmentTheme.ts index 947e6969225c7..039b766b779df 100644 --- a/apps/server/src/environmentTheme.ts +++ b/apps/server/src/environmentTheme.ts @@ -55,7 +55,8 @@ const MAX_THEME_FILES = 32; * JSON encoding, at up to 6 bytes per character for a `\uXXXX` escape, plus the colors. */ export const MAX_THEME_FILE_BYTES = 6 * THEME_CSS_MAX_LENGTH + 16 * 1024; -const MAX_THEME_TOTAL_BYTES = 6 * MAX_THEME_FILE_BYTES; +// Clients cache every published theme in localStorage, which holds about 5 MB per origin. +const MAX_THEME_TOTAL_BYTES = 3 * MAX_THEME_FILE_BYTES; /** A theme's background is `.` beside `.json`; earlier extensions win. */ const THEME_BACKGROUND_EXTENSIONS = ["webp", "png", "jpg", "jpeg"] as const; diff --git a/apps/server/src/provider/agentContextBudget.json b/apps/server/src/provider/agentContextBudget.json index 0051813371e5b..9d44bc792a452 100644 --- a/apps/server/src/provider/agentContextBudget.json +++ b/apps/server/src/provider/agentContextBudget.json @@ -1,5 +1,5 @@ { "claudeSystemAppendBytes": 5930, "codexAdditionalContextBytes": 7324, - "mcpToolListJsonBytes": 49736 + "mcpToolListJsonBytes": 49737 } diff --git a/packages/contracts/src/server.ts b/packages/contracts/src/server.ts index f2e02c6b0a95e..6ba3a09f8053b 100644 --- a/packages/contracts/src/server.ts +++ b/packages/contracts/src/server.ts @@ -627,7 +627,7 @@ const EnvironmentThemeColors = Schema.Record( TrimmedNonEmptyString.check(Schema.isMaxLength(64)), ); -export const THEME_CSS_MAX_LENGTH = 50_000; +export const THEME_CSS_MAX_LENGTH = 100_000; const environmentThemeFields = { version: Schema.optional(Schema.Literal(1)), diff --git a/packages/shared/src/themeCss.ts b/packages/shared/src/themeCss.ts index 2aa9a29b1e053..0665f8cb56237 100644 --- a/packages/shared/src/themeCss.ts +++ b/packages/shared/src/themeCss.ts @@ -79,7 +79,7 @@ export const THEME_GUIDE = [ "", "CSS: `css` applies after the app's styles. Use `.dark` or `:root:not(.dark)` for one appearance.", "It cannot load files: no @import, no image-set(), and url() only with data: or #id.", - 'For a background image, copy a JPEG, PNG, or WebP file of up to 16 MB to `/.jpg` (or .png, .webp), beside the theme file. CSS shows it with `var(--theme-background-image)`, such as `[data-workspace-area="conversation"] { background: var(--theme-background-image) center / cover no-repeat; }`. Delete the file to remove it. Do not embed images in `css`: it holds 50,000 characters.', + 'For a background image, copy a JPEG, PNG, or WebP file of up to 16 MB to `/.jpg` (or .png, .webp), beside the theme file. CSS shows it with `var(--theme-background-image)`, such as `[data-workspace-area="conversation"] { background: var(--theme-background-image) center / cover no-repeat; }`. Delete the file to remove it. Do not embed images in `css`: it holds 100,000 characters.', "The app's own rules can be more specific. If a rule has no effect, add !important.", "It cannot reach the terminal text, the file tree, or diff internals. Use color roles for those.", "Native scrollbars take `::-webkit-scrollbar` and `::-webkit-scrollbar-thumb`.", From 9c1361aa11f5fef9e773170ad1b1188c309504cd Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Mon, 16 Nov 2026 19:04:14 -0800 Subject: [PATCH 2/2] fix(server): the published theme total is a flat 2 MiB, not lower than before Co-Authored-By: Claude Fable 5.2 --- apps/server/src/environmentTheme.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/server/src/environmentTheme.ts b/apps/server/src/environmentTheme.ts index 039b766b779df..73df72f6b01e7 100644 --- a/apps/server/src/environmentTheme.ts +++ b/apps/server/src/environmentTheme.ts @@ -56,7 +56,7 @@ const MAX_THEME_FILES = 32; */ export const MAX_THEME_FILE_BYTES = 6 * THEME_CSS_MAX_LENGTH + 16 * 1024; // Clients cache every published theme in localStorage, which holds about 5 MB per origin. -const MAX_THEME_TOTAL_BYTES = 3 * MAX_THEME_FILE_BYTES; +const MAX_THEME_TOTAL_BYTES = 2 * 1024 * 1024; /** A theme's background is `.` beside `.json`; earlier extensions win. */ const THEME_BACKGROUND_EXTENSIONS = ["webp", "png", "jpg", "jpeg"] as const;