@devries-cameron20 / t3code-1 / commits / 6927cfe2ad
Fork 0

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

fix(web): dropped folders open on this computer's server when the desktop app's own environment is off (#38722)

Julius Marminge committed Nov 18, 2026 at 14:27 UTC 6927cfe2adb0867eb098009a5eb35e42da2b13a1
12 files changed +151 -89
apps/desktop/src/app/DesktopApp.test.ts
+57 -46
@@ -84,6 +84,7 @@ interface StubbedDesktop {
84 readonly backends?: ReadonlyArray<{ readonly stop: () => Effect.Effect<void> }>;
85 readonly flushRendererHistory?: Effect.Effect<void>;
86 readonly tokenRequested?: Deferred.Deferred<void>;
87 + readonly activationStarted?: Deferred.Deferred<void>;
88 }
89
90 const runStubbedDesktop = (stub: StubbedDesktop) =>
@@ -189,7 +190,9 @@ const runStubbedDesktop = (stub: StubbedDesktop) =>
190 reconcile: Effect.void,
191 } as DesktopWslBackend.DesktopWslBackend["Service"]),
192 Effect.provideService(DesktopAppActivation.DesktopAppActivation, {
192 - start: Effect.void,
193 + start: stub.activationStarted
194 + ? Deferred.succeed(stub.activationStarted, undefined)
195 + : Effect.void,
196 } as unknown as DesktopAppActivation.DesktopAppActivation["Service"]),
197 Effect.provideService(DesktopRendererHistory.DesktopRendererHistory, {
198 shutdown: stub.flushRendererHistory ?? Effect.void,
@@ -323,52 +326,60 @@ it.effect.each([false, true])(
326 }).pipe(Effect.provide(DesktopShutdown.layer)),
327 );
328
326 -it.effect("points a stale t3 launcher at the updated AppImage with Local environment off", () =>
327 - Effect.gen(function* () {
328 - const fs = yield* FileSystem.FileSystem;
329 - const path = yield* Path.Path;
330 - const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-desktop-app-" });
331 - const launcher = DesktopCliShim.launcherPath({
332 - path,
333 - baseDir,
334 - platform: "linux",
335 - } as DesktopEnvironment.DesktopEnvironment["Service"]);
336 - const removedAppImage = path.join(baseDir, "T3-Code-0.1.6-x86_64.AppImage");
337 - const updatedAppImage = path.join(baseDir, "T3-Code-0.1.7-x86_64.AppImage");
338 - yield* fs.makeDirectory(path.dirname(launcher), { recursive: true });
339 - yield* fs.writeFileString(
340 - launcher,
341 - DesktopCliShim.renderCliShim({
342 - target: { kind: "appimage", appImage: removedAppImage, executableName: "t3code" },
343 - shimPath: launcher,
344 - t3Home: baseDir,
345 - }),
346 - );
347 - yield* fs.writeFileString(updatedAppImage, "", { mode: 0o755 });
348 - const windowStarted = yield* Deferred.make<void>();
349 -
350 - const app = yield* runStubbedDesktop({
351 - localEnvironmentEnabled: false,
352 - environment: {
329 +it.effect(
330 + "points a stale t3 launcher at the updated AppImage and accepts t3 <dir> with Local environment off",
331 + () =>
332 + Effect.gen(function* () {
333 + const fs = yield* FileSystem.FileSystem;
334 + const path = yield* Path.Path;
335 + const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-desktop-app-" });
336 + const launcher = DesktopCliShim.launcherPath({
337 path,
338 baseDir,
355 - serverRoot: path.join(baseDir, "resources", "app.asar"),
356 - appImagePath: Option.some(updatedAppImage),
357 - },
358 - fileSystem: Layer.succeed(FileSystem.FileSystem, fs),
359 - record: () => Effect.void,
360 - windowStarted,
361 - registerLinuxUrlHandler: Effect.void,
362 - });
363 - yield* Deferred.await(windowStarted);
364 - yield* (yield* DesktopShutdown.DesktopShutdown).request;
365 - yield* Fiber.join(app);
339 + platform: "linux",
340 + } as DesktopEnvironment.DesktopEnvironment["Service"]);
341 + const removedAppImage = path.join(baseDir, "T3-Code-0.1.6-x86_64.AppImage");
342 + const updatedAppImage = path.join(baseDir, "T3-Code-0.1.7-x86_64.AppImage");
343 + yield* fs.makeDirectory(path.dirname(launcher), { recursive: true });
344 + yield* fs.writeFileString(
345 + launcher,
346 + DesktopCliShim.renderCliShim({
347 + target: { kind: "appimage", appImage: removedAppImage, executableName: "t3code" },
348 + shimPath: launcher,
349 + t3Home: baseDir,
350 + }),
351 + );
352 + yield* fs.writeFileString(updatedAppImage, "", { mode: 0o755 });
353 + const windowStarted = yield* Deferred.make<void>();
354 + const activationStarted = yield* Deferred.make<void>();
355
367 - const content = yield* fs.readFileString(launcher);
368 - assert.include(
369 - content,
370 - `app='${updatedAppImage}'`,
371 - "startup left the t3 launcher pointing at the removed AppImage",
372 - );
373 - }).pipe(Effect.provide(Layer.mergeAll(DesktopShutdown.layer, NodeServices.layer))),
356 + const app = yield* runStubbedDesktop({
357 + localEnvironmentEnabled: false,
358 + activationStarted,
359 + environment: {
360 + path,
361 + baseDir,
362 + serverRoot: path.join(baseDir, "resources", "app.asar"),
363 + appImagePath: Option.some(updatedAppImage),
364 + },
365 + fileSystem: Layer.succeed(FileSystem.FileSystem, fs),
366 + record: () => Effect.void,
367 + windowStarted,
368 + registerLinuxUrlHandler: Effect.void,
369 + });
370 + yield* Deferred.await(windowStarted);
371 + yield* (yield* DesktopShutdown.DesktopShutdown).request;
372 + yield* Fiber.join(app);
373 +
374 + const content = yield* fs.readFileString(launcher);
375 + assert.include(
376 + content,
377 + `app='${updatedAppImage}'`,
378 + "startup left the t3 launcher pointing at the removed AppImage",
379 + );
380 + assert.isTrue(
381 + yield* Deferred.isDone(activationStarted),
382 + "startup left the t3 <dir> control socket closed",
383 + );
384 + }).pipe(Effect.provide(Layer.mergeAll(DesktopShutdown.layer, NodeServices.layer))),
385 );
apps/desktop/src/app/DesktopApp.ts
+7 -4
@@ -285,6 +285,10 @@ const bootstrap = Effect.fn("desktop.bootstrap")(function* (backendStarted: bool
285 const snapShot = yield* DesktopSnapShot.DesktopSnapShot;
286 const appActivation = yield* DesktopAppActivation.DesktopAppActivation;
287 const settings = yield* desktopSettings.get;
288 + const startAppActivation = appActivation.start.pipe(
289 + Effect.tap(() => logBootstrapInfo("desktop app control socket ready")),
290 + Effect.catch((error) => logStartupError("desktop app control socket unavailable", { error })),
291 + );
292 if (settings.localEnvironmentEnabled && (!backendStarted || (yield* Ref.get(state.quitting)))) {
293 return;
294 }
@@ -309,6 +313,8 @@ const bootstrap = Effect.fn("desktop.bootstrap")(function* (backendStarted: bool
313 if (!(yield* Ref.get(state.quitting))) {
314 yield* desktopWindow.createMainIfBackendReady;
315 }
316 + // `t3 <dir>` still reaches the renderer, which opens it on this machine's connected service.
317 + yield* startAppActivation;
318 return;
319 }
320
@@ -321,10 +327,7 @@ const bootstrap = Effect.fn("desktop.bootstrap")(function* (backendStarted: bool
327 ) {
328 yield* desktopWindow.ensureMain;
329 }
324 - yield* appActivation.start.pipe(
325 - Effect.tap(() => logBootstrapInfo("desktop app control socket ready")),
326 - Effect.catch((error) => logStartupError("desktop app control socket unavailable", { error })),
327 - );
330 + yield* startAppActivation;
331 yield* Effect.forkScoped((yield* DesktopWslBackend.DesktopWslBackend).reconcile);
332 });
333
apps/web/src/hooks/useDefaultTheme.ts
+4 -4
@@ -1,5 +1,5 @@
1 import { appAtomRegistry } from "../rpc/atomRegistry";
2 -import { themeEnvironmentIdAtom } from "../state/primaryEnvironment";
2 +import { localEnvironmentIdAtom } from "../state/primaryEnvironment";
3 import { themeServerSettingsAtom } from "../state/server";
4 import { getThemeDefinition, singleAppearanceOf, subscribeToCustomThemes } from "../themePalette";
5 import { getThemeSnapshot, setAppearanceMode, setTheme } from "./useTheme";
@@ -58,7 +58,7 @@ function writeAppliedGeneration(storageKey: string, generation: string): void {
58
59 function adoptDefaultTheme(): void {
60 if (typeof window === "undefined") return;
61 - const environmentId = appAtomRegistry.get(themeEnvironmentIdAtom);
61 + const environmentId = appAtomRegistry.get(localEnvironmentIdAtom);
62 if (environmentId === null) return;
63 const settings = appAtomRegistry.get(themeServerSettingsAtom);
64 const { defaultTheme, defaultThemeSetAt } = settings;
@@ -89,7 +89,7 @@ function adoptDefaultTheme(): void {
89 /** Like the theme, the environment's mode applies once per set, then local choices win. */
90 function adoptDefaultAppearance(): void {
91 if (typeof window === "undefined") return;
92 - const environmentId = appAtomRegistry.get(themeEnvironmentIdAtom);
92 + const environmentId = appAtomRegistry.get(localEnvironmentIdAtom);
93 const { defaultAppearance, defaultAppearanceSetAt } =
94 appAtomRegistry.get(themeServerSettingsAtom);
95 const storageKey = `${APPLIED_DEFAULT_APPEARANCE_STORAGE_PREFIX}${environmentId}`;
@@ -117,7 +117,7 @@ function adoptDefaults(): void {
117 */
118 export function startDefaultThemeAdoption(): () => void {
119 const unsubscribes = [
120 - appAtomRegistry.subscribe(themeEnvironmentIdAtom, adoptDefaults),
120 + appAtomRegistry.subscribe(localEnvironmentIdAtom, adoptDefaults),
121 appAtomRegistry.subscribe(themeServerSettingsAtom, adoptDefaults),
122 subscribeToCustomThemes(adoptDefaults),
123 ];
apps/web/src/hooks/useHandleNewThread.test.ts
+31
@@ -28,6 +28,9 @@ const testState = vi.hoisted(() => {
28 navigate: vi.fn(async (request: { readonly params: { readonly draftId: string } }) => {
29 router.state.location.href = `/draft/${request.params.draftId}`;
30 }),
31 + buildLocation: (request: { readonly params: { readonly draftId: string } }) => ({
32 + href: `/draft/${request.params.draftId}`,
33 + }),
34 };
35 const draftStore = {
36 getComposerDraft: vi.fn((draftId: string) => ({ draftId })),
@@ -78,6 +81,9 @@ const testState = vi.hoisted(() => {
81 get openDraftRoute() {
82 return openDraftRoute;
83 },
84 + registerDraft(draft: NonNullable<typeof storedDraft>) {
85 + storedDraft = draft;
86 + },
87 openEmptyDraft(draftId: string) {
88 openDraftRoute = { kind: "draft", draftId };
89 },
@@ -282,6 +288,31 @@ describe.each([
288 expect(testState.draftStore.setLogicalProjectDraftThreadId).not.toHaveBeenCalled();
289 });
290
291 + it("resolves to the draft another opener showed for the same project meanwhile", async () => {
292 + testState.reset(draft);
293 + const pendingOpen = useNewThreadHandler()(
294 + { environmentId: "environment-ssh", projectId: "project-remote" } as never,
295 + { replace: true },
296 + );
297 +
298 + // The location moves before the route matches do.
299 + testState.registerDraft({
300 + draftId: "draft-home",
301 + environmentId: "environment-ssh",
302 + promotedTo: null,
303 + threadId: "thread-home",
304 + });
305 + testState.router.state.location.href = "/draft/draft-home";
306 + testState.completeProjectFileRead(null);
307 +
308 + await expect(pendingOpen).resolves.toEqual({
309 + draftId: "draft-home",
310 + threadId: "thread-home",
311 + });
312 + expect(testState.router.navigate).not.toHaveBeenCalled();
313 + expect(testState.draftStore.setLogicalProjectDraftThreadId).not.toHaveBeenCalled();
314 + });
315 +
316 it("sets the prompt before the draft shows", async () => {
317 testState.reset(draft);
318 const pendingOpen = useNewThreadHandler()(
apps/web/src/hooks/useHandleNewThread.ts
+17 -2
@@ -233,6 +233,21 @@ export function createNewThreadHandler(router: AnyRouter) {
233 const logicalProjectKey = project
234 ? deriveLogicalProjectKeyFromSettings(project, projectGroupingSettings)
235 : scopedProjectKey(projectRef);
236 + // Another opener (home's own first-project draft) may have reached this project's draft first.
237 + // Matches lag the location during a navigation, so compare against the location.
238 + const resultIfAbandoned = () => {
239 + const draft = getDraftSessionByLogicalProjectKey(logicalProjectKey);
240 + if (draft === null || draft.promotedTo != null || readProject(projectRef) === null) {
241 + return null;
242 + }
243 + const draftHref = router.buildLocation({
244 + to: "/draft/$draftId",
245 + params: { draftId: draft.draftId },
246 + }).href;
247 + return router.state.location.href === draftHref
248 + ? { draftId: draft.draftId, threadId: draft.threadId }
249 + : null;
250 + };
251 const hasBranchOption = options?.branch !== undefined;
252 const hasWorktreePathOption = options?.worktreePath !== undefined;
253 const hasEnvModeOption = options?.envMode !== undefined;
@@ -274,7 +289,7 @@ export function createNewThreadHandler(router: AnyRouter) {
289 } else if (!isDraftAlreadyOpen) {
290 const defaultEnvMode = await resolveDefaultEnvMode();
291 if (abandonedSinceRequest()) {
277 - return null;
292 + return resultIfAbandoned();
293 }
294 // Concurrent calls may change the draft; stale resets, remaps, or navigation could clobber it.
295 const routeTargetNow = getCurrentRouteTarget();
@@ -390,7 +405,7 @@ export function createNewThreadHandler(router: AnyRouter) {
405 return (async () => {
406 const initialEnvMode = options?.envMode ?? (await resolveDefaultEnvMode());
407 if (abandonedSinceRequest()) {
393 - return null;
408 + return resultIfAbandoned();
409 }
410 // Reuse drafts registered while awaiting so their pending navigation cannot lose them.
411 const racedDraft = getDraftSessionByLogicalProjectKey(logicalProjectKey);
apps/web/src/hooks/useOpenLocalWorkspace.ts
+14 -14
@@ -3,6 +3,7 @@ import {
3 findProjectByPath,
4 inferProjectTitleFromPath,
5 } from "@t3tools/client-runtime/state/projects";
6 +import { useAtomValue } from "@effect/atom-react";
7 import type { DesktopAppActivationRequest } from "@t3tools/contracts";
8 import { msg } from "gt-react";
9
@@ -10,7 +11,8 @@ import { handleDesktopAppActivationRequest } from "../desktopAppActivation";
11 import { m } from "../i18n/messages";
12 import { newProjectId } from "../lib/utils";
13 import { readProjects, waitForProject } from "../state/entities";
13 -import { usePrimaryEnvironment } from "../state/environments";
14 +import { useEnvironment } from "../state/environments";
15 +import { localEnvironmentIdAtom } from "../state/primaryEnvironment";
16 import { projectEnvironment } from "../state/projects";
17 import { useEnvironmentShellHasSnapshot } from "../state/shell";
18 import { useAtomCommand } from "../state/use-atom-command";
@@ -19,38 +21,36 @@ import { reportProjectFailure } from "./useProjectGroupUpdate";
21 import { useNewThreadHandler } from "./useHandleNewThread";
22
23 /**
22 - * Opens a folder on this computer as a project in the primary environment: an
24 + * Opens a folder on this computer as a project in this computer's environment: an
25 * existing project opens (and unarchives), a new one is added. Used by `t3 <dir>`
24 - * activations and folders dropped on the sidebar. `ready` is false until the
25 - * primary environment's projects have loaded, so a known folder is not added twice.
26 + * activations and folders dropped on the sidebar. `ready` is false until that
27 + * environment's projects have loaded, so a known folder is not added twice.
28 */
29 export function useOpenLocalWorkspace() {
28 - const primaryEnvironment = usePrimaryEnvironment();
30 + const localEnvironment = useEnvironment(useAtomValue(localEnvironmentIdAtom));
31 const createProject = useAtomCommand(projectEnvironment.create, { reportFailure: false });
32 const updateProject = useOrchestrationCommand(projectEnvironment.update, {
33 label: "project unarchive",
34 });
35 const openThread = useNewThreadHandler();
34 - const shellHasSnapshot = useEnvironmentShellHasSnapshot(
35 - primaryEnvironment?.environmentId ?? null,
36 - );
36 + const shellHasSnapshot = useEnvironmentShellHasSnapshot(localEnvironment?.environmentId ?? null);
37 const ready =
38 - primaryEnvironment?.connection.phase === "connected" &&
39 - primaryEnvironment.serverConfig !== null &&
38 + localEnvironment?.connection.phase === "connected" &&
39 + localEnvironment.serverConfig !== null &&
40 shellHasSnapshot;
41
42 const open = (request: DesktopAppActivationRequest) =>
43 handleDesktopAppActivationRequest(request, {
44 getTarget: () => {
45 if (
46 - primaryEnvironment?.connection.phase !== "connected" ||
47 - primaryEnvironment.serverConfig === null
46 + localEnvironment?.connection.phase !== "connected" ||
47 + localEnvironment.serverConfig === null
48 ) {
49 return null;
50 }
51 return {
52 - environmentId: primaryEnvironment.environmentId,
53 - platform: primaryEnvironment.serverConfig.environment.platform.os,
52 + environmentId: localEnvironment.environmentId,
53 + platform: localEnvironment.serverConfig.environment.platform.os,
54 };
55 },
56 findProject: (environmentId, workspaceRoot) =>
apps/web/src/routes/__root.tsx
+4 -2
@@ -186,9 +186,11 @@ function RootRouteBranch() {
186 // first-run gate and the event router, whose first navigation would leave the page.
187 const appHosts = (
188 <>
189 - {primaryEnvironmentAuthenticated ? <DesktopAppActivationCoordinator /> : null}
189 {primaryEnvironmentAuthenticated || localEnvironmentDisabled ? (
191 - <DesktopWebLinkCoordinator />
190 + <>
191 + <DesktopAppActivationCoordinator />
192 + <DesktopWebLinkCoordinator />
193 + </>
194 ) : null}
195 {isElectron ? <RunningThreadKeepAlive /> : null}
196 <RelayClientInstallDialog />
apps/web/src/state/primaryEnvironment.test.ts
+8 -8
@@ -8,18 +8,18 @@ import { EnvironmentId } from "@t3tools/contracts";
8 import { Atom, AtomRegistry } from "effect/reactivity";
9 import { describe, expect, it } from "vite-plus/test";
10
11 -import { createThemeEnvironmentIdAtom } from "./primaryEnvironment";
11 +import { createLocalEnvironmentIdAtom } from "./primaryEnvironment";
12
13 const PRIMARY = EnvironmentId.make("primary");
14 const SERVICE = EnvironmentId.make("service");
15 const REMOTE = EnvironmentId.make("remote");
16
17 -function themeEnvironmentId(input: {
17 +function localEnvironmentId(input: {
18 primary: EnvironmentId | null;
19 host: string | null;
20 catalog: ReadonlyArray<EnvironmentId>;
21 }) {
22 - const atom = createThemeEnvironmentIdAtom({
22 + const atom = createLocalEnvironmentIdAtom({
23 primaryEnvironmentIdAtom: Atom.make(input.primary),
24 hostEnvironmentIdAtom: Atom.make(input.host),
25 catalogValueAtom: Atom.make({ entries: new Map(input.catalog.map((id) => [id, null])) }),
@@ -27,22 +27,22 @@ function themeEnvironmentId(input: {
27 return AtomRegistry.make().get(atom);
28 }
29
30 -describe("themeEnvironmentIdAtom", () => {
30 +describe("localEnvironmentIdAtom", () => {
31 it("prefers the primary environment over this machine's background service", () => {
32 expect(
33 - themeEnvironmentId({ primary: PRIMARY, host: "service", catalog: [PRIMARY, SERVICE] }),
33 + localEnvironmentId({ primary: PRIMARY, host: "service", catalog: [PRIMARY, SERVICE] }),
34 ).toBe(PRIMARY);
35 });
36
37 it("uses the connected background service sharing the app's T3 home when there is no primary", () => {
38 - expect(themeEnvironmentId({ primary: null, host: "service", catalog: [REMOTE, SERVICE] })).toBe(
38 + expect(localEnvironmentId({ primary: null, host: "service", catalog: [REMOTE, SERVICE] })).toBe(
39 SERVICE,
40 );
41 });
42
43 it("uses no environment when that service is not among the connections", () => {
44 - expect(themeEnvironmentId({ primary: null, host: "service", catalog: [REMOTE] })).toBeNull();
45 - expect(themeEnvironmentId({ primary: null, host: null, catalog: [REMOTE] })).toBeNull();
44 + expect(localEnvironmentId({ primary: null, host: "service", catalog: [REMOTE] })).toBeNull();
45 + expect(localEnvironmentId({ primary: null, host: null, catalog: [REMOTE] })).toBeNull();
46 });
47 });
48
apps/web/src/state/primaryEnvironment.ts
+4 -4
@@ -18,8 +18,8 @@ export const hostEnvironmentIdAtom = Atom.make<string | null>(null).pipe(
18 Atom.withLabel("web-host-environment-id"),
19 );
20
21 -// Without a primary, only the service sharing the desktop app's T3 home supplies themes.
22 -export function createThemeEnvironmentIdAtom(input: {
21 +// This computer's environment: the primary, else a connection to the service sharing the app's T3 home.
22 +export function createLocalEnvironmentIdAtom(input: {
23 readonly primaryEnvironmentIdAtom: Atom.Atom<EnvironmentId | null>;
24 readonly hostEnvironmentIdAtom: Atom.Atom<string | null>;
25 readonly catalogValueAtom: Atom.Atom<{ readonly entries: ReadonlyMap<EnvironmentId, unknown> }>;
@@ -32,10 +32,10 @@ export function createThemeEnvironmentIdAtom(input: {
32 if (environmentId === hostEnvironmentId) return environmentId;
33 }
34 return null;
35 - }).pipe(Atom.withLabel("web-theme-environment-id"));
35 + }).pipe(Atom.withLabel("web-local-environment-id"));
36 }
37
38 -export const themeEnvironmentIdAtom = createThemeEnvironmentIdAtom({
38 +export const localEnvironmentIdAtom = createLocalEnvironmentIdAtom({
39 primaryEnvironmentIdAtom,
40 hostEnvironmentIdAtom,
41 catalogValueAtom: environmentCatalog.catalogValueAtom,
apps/web/src/state/server.ts
+2 -2
@@ -25,7 +25,7 @@ import { isConnectedWithConfig } from "../components/settings/scopedSettings";
25 import { environmentCatalog } from "../connection/catalog";
26 import { connectionAtomRuntime } from "../connection/runtime";
27 import { environmentAtomList } from "./environmentAtomList";
28 -import { primaryEnvironmentIdAtom, themeEnvironmentIdAtom } from "./primaryEnvironment";
28 +import { primaryEnvironmentIdAtom, localEnvironmentIdAtom } from "./primaryEnvironment";
29 import { environmentSession } from "./session";
30 import { reuseProvidersIgnoringCheckedAt } from "./serverProviders.logic";
31
@@ -167,7 +167,7 @@ export const primaryServerKeybindingsAtom = createShortcutKeybindingsAtom({
167 const EMPTY_ENVIRONMENT_THEMES: ReadonlyArray<EnvironmentTheme> = [];
168
169 const themeServerConfigAtom = Atom.make((get): ServerConfig | null => {
170 - const environmentId = get(themeEnvironmentIdAtom);
170 + const environmentId = get(localEnvironmentIdAtom);
171 return environmentId === null ? null : get(serverEnvironment.configValueAtom(environmentId));
172 }).pipe(Atom.withLabel("web-theme-server-config"));
173
apps/web/src/themeBackground.test.ts
+1 -1
@@ -11,7 +11,7 @@ vi.mock(
11 );
12 vi.mock(import("./state/primaryEnvironment"), async () => {
13 const { Atom } = await import("effect/reactivity");
14 - return { themeEnvironmentIdAtom: Atom.make(EnvironmentId.make("host")) } as never;
14 + return { localEnvironmentIdAtom: Atom.make(EnvironmentId.make("host")) } as never;
15 });
16 vi.mock(import("./state/server"), async () => {
17 const { Atom } = await import("effect/reactivity");
apps/web/src/themeBackground.ts
+2 -2
@@ -4,7 +4,7 @@ import type { EnvironmentId } from "@t3tools/contracts";
4
5 import { appAtomRegistry, subscribeAtomChanges } from "./rpc/atomRegistry";
6 import { assetEnvironment } from "./state/assets";
7 -import { themeEnvironmentIdAtom } from "./state/primaryEnvironment";
7 +import { localEnvironmentIdAtom } from "./state/primaryEnvironment";
8 import { themeServerEnvironmentThemesAtom } from "./state/server";
9 import { environmentSession } from "./state/session";
10 import { getCustomThemes } from "./themePalette";
@@ -58,7 +58,7 @@ async function loadBackground(
58 export function applyThemeBackground(themeId: string | undefined): void {
59 if (typeof document === "undefined") return;
60 appliedThemeId = themeId;
61 - const environmentId = appAtomRegistry.get(themeEnvironmentIdAtom);
61 + const environmentId = appAtomRegistry.get(localEnvironmentIdAtom);
62 // A saved theme wins its id over a published one, so the published image is not its.
63 const revision =
64 themeId === undefined || getCustomThemes().some((theme) => theme.id === themeId)