Skip to content

[Bug]: Publishing a theme moves an existing folder out of the way #39125

Closed

Description

@StiensWout

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. Add a project whose folder contains a project-local T3 home.
  2. Create a folder named nightfall.json in that home's themes directory.
  3. Save a notes file inside the folder.
  4. Use t3 theme set with a different nightfall.json theme file and point --base-dir at the project-local T3 home.
  5. Open a thread in that project and look for the notes file at its original path in the Files panel.

Expected behavior

The notes file still opens at its original path.

Actual behavior

Publishing reports success and replaces the folder with a theme file, so the notes can no longer be opened from their original path.

open original theme notes

failure

Impact

Major degradation or frequent failure. Anyone publishing from the command line loses access to the contents at their original path whenever the target theme filename matches an existing folder.

Version or commit

main at 470ca63499. The cause is at apps/server/src/cli/theme.ts:345.

Environment

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

Logs or stack traces

The file preview does not contain Notes for the original Nightfall palette.
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/cli-theme-publish-keeps-existing-directory.e2e.ts b/scripts/scenarios/cli-theme-publish-keeps-existing-directory.e2e.ts
new file mode 100644
index 0000000000..177c5d9e98
--- /dev/null
+++ b/scripts/scenarios/cli-theme-publish-keeps-existing-directory.e2e.ts
@@ -0,0 +1,50 @@
+/// <reference lib="dom" />
+import { expect } from "e2e";
+
+import { makeState, runPromise, test, WEB } from "./t3.ts";
+
+const NOTE = "userdata/themes/nightfall.json/notes.txt";
+const BODY = "Notes for the original Nightfall palette";
+
+test(
+  "Publishing a theme preserves files in an existing directory under the same name",
+  WEB,
+  async ({ t3, app, browser, screen }) => {
+    const project = await t3.project("theme-workspace", {
+      [NOTE]: BODY,
+      "nightfall.json": JSON.stringify({
+        name: "Nightfall",
+        appearance: "dark",
+        canvas: "#1a1b26",
+        accent: "#7aa2f7",
+      }),
+    });
+    const thread = await t3.thread({
+      project,
+      title: "Theme notes",
+      messages: [`See :codex-file-citation{path="${NOTE}" line_range_start="1"}`],
+    });
+    const { cli } = makeState(project);
+    await runPromise(cli(["theme", "set", `${project}/nightfall.json`], [0, 1]));
+
+    await t3.open(thread);
+    await screen.getByRole("button", /^Agent See/).tap();
+    await screen.getByRole("link", /^notes\.txt/).tap();
+
+    try {
+      await expect
+        .poll(() =>
+          browser.evaluate(() => {
+            for (const host of document.querySelectorAll("*")) {
+              const content = host.shadowRoot?.querySelector("[data-content]");
+              if (content) return content.textContent ?? "";
+            }
+            return null;
+          }),
+        )
+        .toContain(BODY);
+    } finally {
+      await app.screenshot("open-original-theme-notes");
+    }
+  },
+);
pnpm scenarios:prove scripts/scenarios/cli-theme-publish-keeps-existing-directory.e2e.ts --base main

Workaround

No response

Activity

  1. added
    vouch:trusted
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vouch:trusted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions