test(server): use the live clock for theme watch notifications #39598
main fromrefs/pull/39598/head·merged by juliusmarminge View on GitHubReplacing the themes directory left the server watching the old directory, so Appearance missed later edits. The server now follows the configured path through replacement of the directory, its symlink target, or the target's containing directory, and rescans after reattaching. The shared replacement watcher uses native path resolution for existing theme links and filters unrelated filenames before queueing parent events.
Fixes pingdotgg/t3code#39597
Reproduction on main#
Commit 272cd38379 (main). Appearance keeps the previous name until a fresh connection reloads the theme list. The cause is at apps/server/src/environmentTheme.ts:319. Ran pnpm scenarios:prove scripts/scenarios/restored-theme-directory-stays-live.e2e.ts --base main with the repro test added: it failed in 2 of 2 runs on a clean checkout, with Use Edited Restored Palette theme in the output.
Evidence#
Environment: boat.dev default machine, Linux x64, a fresh checkout of each commit
Steps: Appearance reflects new edits after the environment theme directory is restored: app.open ; expect.not.toHaveURL //pair(?:[?#]|$)/; app.open /settings/appearance; locator.waitFor getByRole("button", name: "Use Original Palette theme") → visible; locator.waitFor getByRole("button", name: "Use Restored Palette theme") → visible; locator.scrollIntoView getByRole("button", name: "Use Restored Palette theme"); expect.toBeVisible getByRole("button", name: "Use Edited Restored Palette theme"); app.screenshot appearance-after-editing-restored-theme.
Proven: the scenario fails on base 019e55bad5 and passes on head 0a2edfcda1.
| Before | After | |
|---|---|---|
| Commit | 019e55bad5 | 0a2edfcda1 |
| Result | Fails: ASSERTION_FAILED: expect.toBeVisible failed | Passes |
| appearance after editing restored theme | ![]() | ![]() |
| failure | ![]() | |
| Recording | Before: Recording | After: Recording |
Scenario source: scripts/scenarios/restored-theme-directory-stays-live.e2e.ts
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 });
}),
);
}
},
);
Tests#
- 932d1271f1 adds the failing test, alone, before the fix.
pnpm exec vp test run apps/server/src/environmentTheme.test.ts -t 'publishes restored themes to subscribers that saw the directory disappear'passed on head.pnpm exec vp run check:changedpassed on head.
Not in this change#
- Replacing the entire server state directory or higher ancestors of an external themes target is a separate recovery case.
- Changes to intermediate symlinks outside the watched directories are outside this recovery path.
- Alternate path spellings on case-insensitive volumes are outside restoration at the configured path.
- Exhausted native watches and inaccessible directories are infrastructure failures, and explicit theme reads still rescan.
- Unrelated sibling events cannot identify a replacement at the configured themes path.
- Concurrent reads and identical snapshots still use the serialized refresh and snapshot comparison.
- Theme parsing and duplicate names still use the existing file scan and ID rules.
- iOS and Android use a separate theme catalog, while web and desktop share this server subscription.
Who did the work#
- Written by GPT 6.2 Sol, in Codex
- Review findings fixed by GPT 6.2 Sol, in Codex
- Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex, each on its own
- Also reviewed by cubic, run locally by a program, with no score
- Reproduction, checks and proof run by a program on base and head, not by an agent
Made in T3 Code by Claude Opus 5.5 and GPT 6.2 Sol
- 1
- 2
Pushedf70fd3c
Evidence#
Create a custom theme, open Settings → Appearance, replace the themes directory while connected, wait for the replacement theme, then save its name as Edited replacement theme. Same Linux Chromium viewport (1280×800), light appearance and synthetic data on both sides.
Before After 019e55bad5 f70fd3c910 Retains Replacement theme after saving and waiting 15 seconds. Automatically displays Edited replacement theme without reconnecting. 

Before recording After recording Reproduction scenario.
scenarios:proveexited 0: failed on base and passed on head.Not shown:
- Restoring the original directory after replacement was not separately exercised; the captured reproduction covers replacement followed by a saved JSON edit.
juliusmarminge added labelstakeover:ready
juliusmarminge removed labelstakeover:in-progress
juliusmarminge merged thise963572
juliusmarminge closed this
juliusmarminge removed labelstakeover:ready
Sign in to join this conversation.



coderabbitai[bot](GitHub profile, opens in a new tab) reviewed
a786d82e-7ad4-409f-b1f1-dba39964567aReviewing files that changed from the base of the PR and between 0a2edfcda19b8cc045ddee6e47da3918d87e5e75 and f70fd3c910e041caeb7ccab7d1595078c5579045.
apps/server/src/environmentTheme.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.