Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Appearance stops reflecting theme edits after the themes folder is restored #39597

ClosedStiensWout(GitHub profile, opens in a new tab) opened this issue 0 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Put a custom theme file in the environment's themes folder.
  2. Open Settings → Appearance.
  3. While T3 Code is running, move the themes folder aside and put a replacement folder at the same path.
  4. Once the restored theme appears, change its name in the replacement folder and save the file.
  5. Look at the theme's name in Appearance.

Expected behavior

Appearance shows the newly saved theme name.

Actual behavior

Appearance keeps the previous name until a fresh connection reloads the theme list.

appearance after editing restored theme

failure

Impact

Minor bug or occasional failure. People restoring or syncing their themes by swapping the folder see stale themes after subsequent file edits.

Version or commit

main at 272cd38379. The cause is at apps/server/src/environmentTheme.ts:319.

Environment

Linux x64 boat.dev default machine, a fresh checkout.

Logs or stack traces

Use Edited Restored Palette theme
Automated repro

Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.

diff --git a/scripts/scenarios/restored-theme-directory-stays-live.e2e.ts b/scripts/scenarios/restored-theme-directory-stays-live.e2e.ts
new file mode 100644
index 0000000000..f941795c42
--- /dev/null
+++ b/scripts/scenarios/restored-theme-directory-stays-live.e2e.ts
@@ -0,0 +1,75 @@
+import { expect } from "e2e";
+import * as Effect from "effect/Effect";
+import * as FileSystem from "effect/FileSystem";
+
+import { T3_HOME } from "../e2e.config.ts";
+import { runPromise, test, WEB } from "./t3.ts";
+
+test(
+  "Appearance reflects new edits after the environment theme directory is restored",
+  WEB,
+  async ({ t3, app, screen }) => {
+    await t3.project("theme-directory");
+    const themes = `${T3_HOME}/userdata/themes`;
+    const previous = `${T3_HOME}/themes-before-restore`;
+    const restored = `${T3_HOME}/themes-to-restore`;
+    const file = "restore-fixture.json";
+    const contents = (name: string) =>
+      JSON.stringify({
+        version: 1,
+        name,
+        appearance: "dark",
+        colors: { canvas: "#171820", accent: "#7aa2f7" },
+      });
+    await runPromise(
+      Effect.gen(function* () {
+        const fs = yield* FileSystem.FileSystem;
+        yield* fs.writeFileString(`${themes}/${file}`, contents("Original Palette"));
+        yield* fs.makeDirectory(restored);
+        yield* fs.writeFileString(`${restored}/${file}`, contents("Restored Palette"));
+      }),
+    );
+    try {
+      await t3.open("/settings/appearance");
+      await screen.getByRole("button", "Use Original Palette theme", { exact: true }).waitFor();
+      await runPromise(
+        Effect.gen(function* () {
+          const fs = yield* FileSystem.FileSystem;
+          yield* fs.rename(themes, previous);
+          yield* fs.rename(restored, themes);
+        }),
+      );
+      // Wait for the rename event to be reflected before editing the replacement directory.
+      const restoredTheme = screen.getByRole("button", "Use Restored Palette theme", {
+        exact: true,
+      });
+      await restoredTheme.waitFor();
+      await restoredTheme.scrollIntoView();
+
+      await runPromise(
+        Effect.flatMap(FileSystem.FileSystem, (fs) =>
+          fs.writeFileString(`${themes}/${file}`, contents("Edited Restored Palette")),
+        ),
+      );
+      try {
+        await expect(
+          screen.getByRole("button", "Use Edited Restored Palette theme", { exact: true }),
+        ).toBeVisible();
+      } finally {
+        await app.screenshot("appearance-after-editing-restored-theme");
+      }
+    } finally {
+      await runPromise(
+        Effect.gen(function* () {
+          const fs = yield* FileSystem.FileSystem;
+          if (yield* fs.exists(previous)) {
+            yield* fs.remove(themes, { recursive: true, force: true });
+            yield* fs.rename(previous, themes);
+          }
+          yield* fs.remove(`${themes}/${file}`, { force: true });
+          yield* fs.remove(restored, { recursive: true, force: true });
+        }),
+      );
+    }
+  },
+);
pnpm scenarios:prove scripts/scenarios/restored-theme-directory-stays-live.e2e.ts --base main

Workaround

No response

  1. tanstack-source added labelsbug

  2. juliusmarminge closed this

Sign in to join this conversation.