@devries-cameron20 / t3code-1 / commits / e82050b8b9
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

feat(themes): theme CSS can hold 50,000 characters (#36656)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Pouya Rezvani committed Nov 14, 2026 at 16:07 UTC e82050b8b97c44ea8509712f699efcc79e526f38
4 files changed +27 -10
apps/server/src/environmentTheme.test.ts
+18 -5
@@ -2,6 +2,7 @@ import {
2 DEFAULT_SERVER_SETTINGS,
3 EnvironmentThemeFile,
4 ServerSettingsError,
5 + THEME_CSS_MAX_LENGTH,
6 } from "@t3tools/contracts";
7 import * as NodeServices from "@effect/platform-node/NodeServices";
8 import { assert, it } from "@effect/vitest";
@@ -20,6 +21,12 @@ import { ServerSettingsService } from "./serverSettings.ts";
21 import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
22
23 const encodeThemeFile = Schema.encodeSync(Schema.fromJsonString(EnvironmentThemeFile));
24 +/** Writes non-ASCII characters as `\uXXXX` escapes, as encoders such as Python's json.dumps do. */
25 +const encodeThemeFileEscaped = (theme: EnvironmentThemeFile) =>
26 + encodeThemeFile(theme).replace(
27 + /[\u0080-\uffff]/g,
28 + (char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`,
29 + );
30
31 const NIGHTFALL_THEME: EnvironmentThemeFile = {
32 name: "Nightfall",
@@ -190,7 +197,10 @@ it.layer(NodeServices.layer)("environment theme", (it) => {
197 );
198
199 it.effect("does not replace a theme file it could not put back", () => {
193 - const oversized = JSON.stringify({ ...NIGHTFALL_THEME, padding: "x".repeat(40_000) });
200 + const oversized = JSON.stringify({
201 + ...NIGHTFALL_THEME,
202 + padding: "x".repeat(EnvironmentTheme.MAX_THEME_FILE_BYTES),
203 + });
204 return withEnvironmentThemes(
205 { [`${REFUSED_THEME_ID}.json`]: oversized },
206 Effect.gen(function* () {
@@ -298,14 +308,14 @@ it.layer(NodeServices.layer)("environment theme", (it) => {
308 const large = (name: string): EnvironmentThemeFile => ({
309 ...NIGHTFALL_THEME,
310 name,
301 - css: `/* ${"x".repeat(19_900)} */`,
311 + css: `/* ${"界".repeat(THEME_CSS_MAX_LENGTH - 6)} */`,
312 });
313 return withEnvironmentThemes(
314 {
315 ...Object.fromEntries(
306 - Array.from({ length: 9 }, (_, index) => [
316 + Array.from({ length: 6 }, (_, index) => [
317 `aa-${index}.json`,
308 - encodeThemeFile(large(`Large ${index}`)),
318 + encodeThemeFileEscaped(large(`Large ${index}`)),
319 ]),
320 ),
321 "zz-look.json": encodeThemeFile(NIGHTFALL_THEME),
@@ -341,7 +351,10 @@ it.layer(NodeServices.layer)("environment theme", (it) => {
351 withEnvironmentThemes(
352 {
353 ...Object.fromEntries(
344 - Array.from({ length: 7 }, (_, index) => [`junk-${index}.json`, "{".repeat(30_000)]),
354 + Array.from({ length: 7 }, (_, index) => [
355 + `junk-${index}.json`,
356 + "{".repeat(EnvironmentTheme.MAX_THEME_FILE_BYTES),
357 + ]),
358 ),
359 "zz-valid.json": encodeThemeFile(NIGHTFALL_THEME),
360 },
apps/server/src/environmentTheme.ts
+7 -3
@@ -9,6 +9,7 @@ import {
9 EnvironmentThemeFile,
10 EnvironmentThemeId,
11 environmentThemeFileHasColors,
12 + THEME_CSS_MAX_LENGTH,
13 } from "@t3tools/contracts";
14 import { fromJsonStringPretty } from "@t3tools/shared/schemaJson";
15 import { themeCssLoadsRemoteFiles } from "@t3tools/shared/themeCss";
@@ -44,9 +45,12 @@ const isEnvironmentThemeId = Schema.is(EnvironmentThemeId);
45 const THEME_FILE_SUFFIX = ".json";
46
47 const MAX_THEME_FILES = 32;
47 -/** Shared with publishing so it cannot accept files the watcher skips. */
48 -export const MAX_THEME_FILE_BYTES = 32 * 1024;
49 -const MAX_THEME_TOTAL_BYTES = 192 * 1024;
48 +/**
49 + * Shared with publishing so it cannot accept files the watcher skips. Fits the longest CSS in any
50 + * JSON encoding, at up to 6 bytes per character for a `\uXXXX` escape, plus the colors.
51 + */
52 +export const MAX_THEME_FILE_BYTES = 6 * THEME_CSS_MAX_LENGTH + 16 * 1024;
53 +const MAX_THEME_TOTAL_BYTES = 6 * MAX_THEME_FILE_BYTES;
54
55 interface PublishedThemes {
56 readonly seq: number;
packages/contracts/src/server.ts
+1 -1
@@ -622,7 +622,7 @@ const EnvironmentThemeColors = Schema.Record(
622 TrimmedNonEmptyString.check(Schema.isMaxLength(64)),
623 );
624
625 -export const THEME_CSS_MAX_LENGTH = 20_000;
625 +export const THEME_CSS_MAX_LENGTH = 50_000;
626
627 const environmentThemeFields = {
628 version: Schema.optional(Schema.Literal(1)),
packages/shared/src/themeCss.ts
+1 -1
@@ -79,7 +79,7 @@ export const THEME_GUIDE = [
79 "",
80 "CSS: `css` applies after the app's styles. Use `.dark` or `:root:not(.dark)` for one appearance.",
81 "It cannot load files: no @import, no image-set(), and url() only with data: or #id.",
82 - "A background image must be embedded as a data: address. `css` holds 20,000 characters, so keep the image near 10 KB.",
82 + "A background image must be embedded as a data: address. `css` holds 50,000 characters, so keep the image near 30 KB.",
83 "The app's own rules can be more specific. If a rule has no effect, add !important.",
84 "It cannot reach the terminal text, the file tree, or diff internals. Use color roles for those.",
85 "Native scrollbars take `::-webkit-scrollbar` and `::-webkit-scrollbar-thumb`.",