@devries-cameron20 / t3code-1 / commits / f43206d35f
Fork 0

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

perf(web): the composer draft store compiles without manual memoization (#20713)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 16, 2026 at 21:47 UTC f43206d35f056ce0955382d761f1fdc4d2b8bcb1
1 file changed +12 -23
apps/web/src/composerDraftStore.ts
+12 -23
@@ -38,7 +38,6 @@ import * as Equal from "effect/Equal";
38 import * as Effect from "effect/Effect";
39 import { DeepMutable } from "effect/Types";
40 import { createModelSelection, normalizeModelSlug } from "@t3tools/shared/model";
41 -import { useMemo } from "react";
41 import { getLocalStorageItem } from "./hooks/useLocalStorage";
42 import { readThreadPreviewState } from "./previewStateStore";
43 import { resolveAppModelSelection, resolveAppModelSelectionForInstance } from "./modelSelection";
@@ -81,6 +80,8 @@ import {
80 toKindScopedComposerContextId,
81 } from "@t3tools/shared/composerContextReferences";
82 import { UnifiedSettings } from "@t3tools/contracts/settings";
83 +
84 +const isElementContextDetails = Schema.is(ElementContextDetails);
85 import { ReviewCommentContextSchema, type ReviewCommentContext } from "./reviewCommentContext";
86 const isRuntimeMode = Schema.is(RuntimeMode);
87 const isProviderDriverKind = Schema.is(ProviderDriverKind);
@@ -1781,7 +1782,7 @@ function normalizePersistedDraftsByThreadId(
1782 : [];
1783 for (const element of legacyElements) {
1784 if (
1784 - !Schema.is(ElementContextDetails)(element) ||
1785 + !isElementContextDetails(element) ||
1786 !("id" in element) ||
1787 typeof element.id !== "string" ||
1788 !("pickedAt" in element) ||
@@ -4267,27 +4268,15 @@ export function useEffectiveComposerModelState(input: {
4268 }): EffectiveComposerModelState {
4269 const draft = useComposerDraftModelState(input.threadRef ?? input.draftId ?? DraftId.make(""));
4270
4270 - return useMemo(
4271 - () =>
4272 - deriveEffectiveComposerModelState({
4273 - draft,
4274 - providers: input.providers,
4275 - selectedProvider: input.selectedProvider,
4276 - selectedInstanceId: input.selectedInstanceId,
4277 - threadModelSelection: input.threadModelSelection,
4278 - projectModelSelection: input.projectModelSelection,
4279 - settings: input.settings,
4280 - }),
4281 - [
4282 - draft,
4283 - input.providers,
4284 - input.settings,
4285 - input.projectModelSelection,
4286 - input.selectedInstanceId,
4287 - input.selectedProvider,
4288 - input.threadModelSelection,
4289 - ],
4290 - );
4271 + return deriveEffectiveComposerModelState({
4272 + draft,
4273 + providers: input.providers,
4274 + selectedProvider: input.selectedProvider,
4275 + selectedInstanceId: input.selectedInstanceId,
4276 + threadModelSelection: input.threadModelSelection,
4277 + projectModelSelection: input.projectModelSelection,
4278 + settings: input.settings,
4279 + });
4280 }
4281
4282 export function markPromotedDraftThreadByRef(threadRef: ScopedThreadRef): void {