Skip to content

Commit b2ec139

Browse files
perf(web): the composer draft store compiles without manual memoization
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a702563 commit b2ec139

1 file changed

Lines changed: 12 additions & 23 deletions

File tree

‎apps/web/src/composerDraftStore.ts‎

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import * as Equal from "effect/Equal";
3838
import * as Effect from "effect/Effect";
3939
import { DeepMutable } from "effect/Types";
4040
import { createModelSelection, normalizeModelSlug } from "@t3tools/shared/model";
41-
import { useMemo } from "react";
4241
import { getLocalStorageItem } from "./hooks/useLocalStorage";
4342
import { readThreadPreviewState } from "./previewStateStore";
4443
import { resolveAppModelSelection, resolveAppModelSelectionForInstance } from "./modelSelection";
@@ -81,6 +80,8 @@ import {
8180
toKindScopedComposerContextId,
8281
} from "@t3tools/shared/composerContextReferences";
8382
import { UnifiedSettings } from "@t3tools/contracts/settings";
83+
84+
const isElementContextDetails = Schema.is(ElementContextDetails);
8485
import { ReviewCommentContextSchema, type ReviewCommentContext } from "./reviewCommentContext";
8586
const isRuntimeMode = Schema.is(RuntimeMode);
8687
const isProviderDriverKind = Schema.is(ProviderDriverKind);
@@ -1781,7 +1782,7 @@ function normalizePersistedDraftsByThreadId(
17811782
: [];
17821783
for (const element of legacyElements) {
17831784
if (
1784-
!Schema.is(ElementContextDetails)(element) ||
1785+
!isElementContextDetails(element) ||
17851786
!("id" in element) ||
17861787
typeof element.id !== "string" ||
17871788
!("pickedAt" in element) ||
@@ -4267,27 +4268,15 @@ export function useEffectiveComposerModelState(input: {
42674268
}): EffectiveComposerModelState {
42684269
const draft = useComposerDraftModelState(input.threadRef ?? input.draftId ?? DraftId.make(""));
42694270

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+
});
42914280
}
42924281

42934282
export function markPromotedDraftThreadByRef(threadRef: ScopedThreadRef): void {

0 commit comments

Comments
 (0)