From 2606da3fea4668e9d6d6c10cfab4875c6a251e15 Mon Sep 17 00:00:00 2001 From: pouyarezvani Date: Sat, 14 Nov 2026 02:26:21 -0800 Subject: [PATCH] feat(themes): theme CSS can hold 50,000 characters A theme's custom CSS was capped at 20,000 characters. A theme that restyles most of the app already needs about 15,500 characters with comments and whitespace stripped, so the cap left little room. THEME_CSS_MAX_LENGTH goes to 50,000. The server's per-theme-file cap goes from 32 KB to 80 KB and the total from 192 KB to 480 KB, so a theme with 50,000 characters of CSS still fits once JSON-encoded. The agent styling guide states the new limit. The CSS guard is unchanged. Closes #36650 Co-Authored-By: Claude Opus 5.5 --- apps/server/src/environmentTheme.ts | 4 ++-- packages/contracts/src/server.ts | 2 +- packages/shared/src/themeCss.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/server/src/environmentTheme.ts b/apps/server/src/environmentTheme.ts index b658870f2e960..97f74f47cc198 100644 --- a/apps/server/src/environmentTheme.ts +++ b/apps/server/src/environmentTheme.ts @@ -45,8 +45,8 @@ const THEME_FILE_SUFFIX = ".json"; const MAX_THEME_FILES = 32; /** Shared with publishing so it cannot accept files the watcher skips. */ -export const MAX_THEME_FILE_BYTES = 32 * 1024; -const MAX_THEME_TOTAL_BYTES = 192 * 1024; +export const MAX_THEME_FILE_BYTES = 80 * 1024; +const MAX_THEME_TOTAL_BYTES = 480 * 1024; interface PublishedThemes { readonly seq: number; diff --git a/packages/contracts/src/server.ts b/packages/contracts/src/server.ts index 88fa0220fe920..e224471c19607 100644 --- a/packages/contracts/src/server.ts +++ b/packages/contracts/src/server.ts @@ -622,7 +622,7 @@ const EnvironmentThemeColors = Schema.Record( TrimmedNonEmptyString.check(Schema.isMaxLength(64)), ); -export const THEME_CSS_MAX_LENGTH = 20_000; +export const THEME_CSS_MAX_LENGTH = 50_000; const environmentThemeFields = { version: Schema.optional(Schema.Literal(1)), diff --git a/packages/shared/src/themeCss.ts b/packages/shared/src/themeCss.ts index 48b1259d0377b..ee933f48a171e 100644 --- a/packages/shared/src/themeCss.ts +++ b/packages/shared/src/themeCss.ts @@ -67,7 +67,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.", - "A background image must be embedded as a data: address. `css` holds 20,000 characters, so keep the image near 10 KB.", + "A background image must be embedded as a data: address. `css` holds 50,000 characters, so keep the image near 30 KB.", "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`.",