From 0056710dcbb2426b56612f71689bfa72591113ed Mon Sep 17 00:00:00 2001 From: Grant Reaber Date: Sun, 15 Nov 2026 04:56:09 +0100 Subject: [PATCH] fix(web): the desktop app no longer fails to start with "twMerge is not a function" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #7 made composerDraftStore import the toast module, which imports lib/utils, which imported DraftId from composerDraftStore. In the desktop build that cycle ran cn() before lib/utils had defined twMerge, so the window showed "T3 Code failed to start. TypeError: … is not a function"; the browser tests failed to load with "Cannot access 'twMerge' before initialization". DraftId moves to its own module; composerDraftStore re-exports it. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/composerDraftStore.ts | 4 ++-- apps/web/src/draftId.ts | 6 ++++++ apps/web/src/lib/utils.ts | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 apps/web/src/draftId.ts diff --git a/apps/web/src/composerDraftStore.ts b/apps/web/src/composerDraftStore.ts index b9761b2caf3f..2924308ea5d3 100644 --- a/apps/web/src/composerDraftStore.ts +++ b/apps/web/src/composerDraftStore.ts @@ -36,6 +36,7 @@ import { scopeThreadRef, } from "@t3tools/client-runtime/environment"; import * as Schema from "effect/Schema"; +import { DraftId } from "./draftId"; import * as Equal from "effect/Equal"; import * as Effect from "effect/Effect"; import { DeepMutable } from "effect/Types"; @@ -121,8 +122,7 @@ const COMPOSER_DRAFT_STORAGE_VERSION = 9; const DraftThreadEnvModeSchema = Schema.Literals(["local", "worktree"]); export type DraftThreadEnvMode = typeof DraftThreadEnvModeSchema.Type; -export const DraftId = Schema.String.pipe(Schema.brand("DraftId")); -export type DraftId = typeof DraftId.Type; +export { DraftId } from "./draftId"; const COMPOSER_PERSIST_DEBOUNCE_MS = 300; diff --git a/apps/web/src/draftId.ts b/apps/web/src/draftId.ts new file mode 100644 index 000000000000..b3c566c616dc --- /dev/null +++ b/apps/web/src/draftId.ts @@ -0,0 +1,6 @@ +import * as Schema from "effect/Schema"; + +// Kept out of composerDraftStore so lib/utils can mint ids without importing the store, +// whose toast import would close a cycle back to lib/utils. +export const DraftId = Schema.String.pipe(Schema.brand("DraftId")); +export type DraftId = typeof DraftId.Type; diff --git a/apps/web/src/lib/utils.ts b/apps/web/src/lib/utils.ts index 747af2d52dd3..162bb90846c5 100644 --- a/apps/web/src/lib/utils.ts +++ b/apps/web/src/lib/utils.ts @@ -3,7 +3,7 @@ import { isMacPlatform } from "@t3tools/shared/keybindings"; import { type CxOptions, cx } from "class-variance-authority"; import * as Hex from "effect/encoding/Hex"; import { extendTailwindMerge } from "tailwind-merge"; -import { DraftId } from "../composerDraftStore"; +import { DraftId } from "../draftId"; // Register extra font sizes and background images so tailwind-merge does not // treat text-2xs or bg-composer-seam-below as colors.