@devries-cameron20 / t3code Mirror · read-only / commits / 86a028cbd4
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 09:45 UTC

fix(server): agents can switch T3 Code back to the stock theme (#36724)

Julius Marminge committed Nov 16, 2026 at 19:03 UTC 86a028cbd4c829adab5611dcf170173c35abd170
6 files changed +42 -10
apps/server/src/environmentTheme.test.ts
+14
@@ -304,6 +304,20 @@ it.layer(NodeServices.layer)("environment theme", (it) => {
304 );
305 });
306
307 + it.effect("switches back to the stock theme after selecting another", () => {
308 + const selected: Array<{ readonly theme?: string; readonly appearance?: string }> = [];
309 + return withEnvironmentThemes(
310 + {},
311 + Effect.gen(function* () {
312 + const themes = yield* EnvironmentTheme.EnvironmentThemeService;
313 + yield* themes.apply({ themeId: "agent-look", theme: NIGHTFALL_THEME });
314 + yield* themes.apply({ themeId: "t3-code" });
315 + assert.deepEqual(selected, [{ theme: "agent-look" }, { theme: "" }]);
316 + }),
317 + selected,
318 + );
319 + });
320 +
321 it.effect(
322 "reports the image beside a theme as its background, with a new revision per file",
323 () =>
apps/server/src/environmentTheme.ts
+9 -3
@@ -14,7 +14,11 @@ import {
14 } from "@t3tools/contracts";
15 import { fromJsonStringPretty } from "@t3tools/shared/schemaJson";
16 import { themeCssLoadsRemoteFiles } from "@t3tools/shared/themeCss";
17 -import { BUILT_IN_THEME_IDS, UNPUBLISHABLE_THEME_IDS } from "@t3tools/shared/themePalettes";
17 +import {
18 + MOBILE_DEFAULT_THEME_ID,
19 + MOBILE_THEME_IDS,
20 + UNPUBLISHABLE_THEME_IDS,
21 +} from "@t3tools/shared/themePalettes";
22 import * as Cause from "effect/Cause";
23 import * as Context from "effect/Context";
24 import * as DateTime from "effect/DateTime";
@@ -406,11 +410,13 @@ const make = Effect.gen(function* () {
410 }
411 // Timestamps make clients apply a set again when its value did not change. Theme and
412 // appearance have one each, so setting one does not undo a later local choice of the other.
413 + // The stock theme is an empty default with a set time, which clients adopt as stock.
414 + const defaultTheme = themeId === MOBILE_DEFAULT_THEME_ID ? "" : themeId;
415 const select = Effect.gen(function* () {
416 const setAt = DateTime.formatIso(yield* DateTime.now);
417 yield* settings
418 .updateSettings({
413 - ...(themeId === undefined ? {} : { defaultTheme: themeId, defaultThemeSetAt: setAt }),
419 + ...(defaultTheme === undefined ? {} : { defaultTheme, defaultThemeSetAt: setAt }),
420 ...(appearance === undefined
421 ? {}
422 : { defaultAppearance: appearance, defaultAppearanceSetAt: setAt }),
@@ -423,7 +429,7 @@ const make = Effect.gen(function* () {
429 Effect.gen(function* () {
430 if (themeId === undefined) return yield* select;
431 if (theme === undefined) {
426 - const known = [...BUILT_IN_THEME_IDS, ...(yield* refresh).themes.map(({ id }) => id)];
432 + const known = [...MOBILE_THEME_IDS, ...(yield* refresh).themes.map(({ id }) => id)];
433 if (!known.includes(themeId)) {
434 return yield* new EnvironmentThemeRefusedError({
435 themeId,
apps/server/src/mcp/toolkits/theme/handlers.ts
+2 -2
@@ -1,6 +1,6 @@
1 import { OrchestratorMcpFailure } from "@t3tools/contracts";
2 import { THEME_GUIDE } from "@t3tools/shared/themeCss";
3 -import { BUILT_IN_THEME_IDS } from "@t3tools/shared/themePalettes";
3 +import { MOBILE_THEME_IDS } from "@t3tools/shared/themePalettes";
4 import * as Effect from "effect/Effect";
5 import * as Struct from "effect/Struct";
6 import * as EnvironmentTheme from "../../../environmentTheme.ts";
@@ -30,7 +30,7 @@ export const layer = McpToolAccess.toLayer(ThemeToolkit, {
30 );
31 return {
32 current,
33 - builtIn: BUILT_IN_THEME_IDS,
33 + builtIn: MOBILE_THEME_IDS,
34 published: published.map(({ id, name, css, background }) => ({
35 id,
36 name,
apps/web/src/hooks/useDefaultTheme.test.ts
+5
@@ -26,6 +26,11 @@ describe("default theme adoption", () => {
26 expect(next).not.toBe(null);
27 expect(next).not.toBe(applied);
28 });
29 +
30 + it("applies the stock theme only when the environment set it", () => {
31 + expect(defaultThemeToApply({ ...BASE, defaultTheme: "", defaultThemeSetAt: "" })).toBe(null);
32 + expect(defaultThemeToApply({ ...BASE, defaultTheme: "" })).not.toBe(null);
33 + });
34 });
35
36 it("lets a theme set its own mode only when no mode was set with it or after it", () => {
apps/web/src/hooks/useDefaultTheme.ts
+11 -4
@@ -2,7 +2,7 @@ import { appAtomRegistry } from "../rpc/atomRegistry";
2 import { themeEnvironmentIdAtom } from "../state/primaryEnvironment";
3 import { themeServerSettingsAtom } from "../state/server";
4 import { getThemeDefinition, singleAppearanceOf, subscribeToCustomThemes } from "../themePalette";
5 -import { setAppearanceMode, setTheme } from "./useTheme";
5 +import { getThemeSnapshot, setAppearanceMode, setTheme } from "./useTheme";
6
7 const APPLIED_DEFAULT_THEME_STORAGE_PREFIX = "t3code:default-theme-applied:v2:";
8 const APPLIED_DEFAULT_APPEARANCE_STORAGE_PREFIX = "t3code:default-appearance-applied:v1:";
@@ -19,7 +19,9 @@ export function defaultThemeToApply(input: {
19 readonly appliedGeneration: string | null;
20 readonly resolves: boolean;
21 }): string | null {
22 - if (input.environmentId === null || input.defaultTheme.length === 0) return null;
22 + // Empty with a set time means the stock theme was set; with none, no theme was.
23 + if (input.environmentId === null) return null;
24 + if (input.defaultTheme.length === 0 && input.defaultThemeSetAt.length === 0) return null;
25 const generation = defaultThemeGeneration(input.defaultTheme, input.defaultThemeSetAt);
26 if (input.appliedGeneration === generation) return null;
27 // The setting and the palette it names arrive independently, so an id that
@@ -67,9 +69,14 @@ function adoptDefaultTheme(): void {
69 defaultTheme,
70 defaultThemeSetAt,
71 appliedGeneration: readAppliedGeneration(storageKey),
70 - resolves: definition !== null,
72 + resolves: definition !== null || defaultTheme === "",
73 });
72 - if (generation === null || definition === null) return;
74 + if (generation === null) return;
75 + if (definition === null) {
76 + // The stock theme keeps the client's own light, dark, or system mode.
77 + if (setTheme(getThemeSnapshot().appearanceMode)) writeAppliedGeneration(storageKey, generation);
78 + return;
79 + }
80
81 // A single-appearance theme needs both preference and appearance writes to take effect.
82 if (!setTheme(defaultTheme)) return;
packages/shared/src/themeCss.ts
+1 -1
@@ -89,5 +89,5 @@ export const THEME_GUIDE = [
89 ...THEME_CSS_HOOKS.map((hook) => `- ${hook.selector}: ${hook.styles}`),
90 "",
91 "You cannot see the result. Make small changes, then ask the user how it looks.",
92 - "To undo, set a built-in theme: t3-chat, grove, ocean, ember, or iris.",
92 + "To undo, set `t3-code`, the stock T3 Code theme, or another built-in theme. An empty `current` means the stock theme or no environment theme.",
93 ].join("\n");