Skip to content

Commit 9188f9d

Browse files
committed
fix(web): read current model after async draft setup
1 parent 1785c72 commit 9188f9d

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎apps/web/src/hooks/useHandleNewThread.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ export function useNewThreadHandler() {
8989
getDraftSession,
9090
getDraftThread,
9191
applyStickyState,
92-
stickyActiveProvider,
93-
stickyModelSelectionByProvider,
9492
setDraftThreadContext,
9593
setLogicalProjectDraftThreadId,
9694
setModelSelection,
@@ -136,18 +134,20 @@ export function useNewThreadHandler() {
136134
candidate.id === projectRef.projectId &&
137135
candidate.environmentId === projectRef.environmentId,
138136
);
139-
const stickyModelSelection = stickyActiveProvider
140-
? (stickyModelSelectionByProvider[stickyActiveProvider] ?? null)
141-
: null;
142-
const resolveModelSelectionOverride = (destinationDraftId: DraftId) =>
143-
resolveNewThreadModelSelectionOverride({
137+
const resolveModelSelectionOverride = (destinationDraftId: DraftId) => {
138+
const { stickyActiveProvider, stickyModelSelectionByProvider } =
139+
useComposerDraftStore.getState();
140+
return resolveNewThreadModelSelectionOverride({
144141
projectDefaultSelection: project?.defaultModelSelection ?? null,
145-
stickySelection: stickyModelSelection,
142+
stickySelection: stickyActiveProvider
143+
? (stickyModelSelectionByProvider[stickyActiveProvider] ?? null)
144+
: null,
146145
carrySelection: carryModelSelection,
147146
carrySourceDraftId:
148147
currentRouteTarget?.kind === "draft" ? currentRouteTarget.draftId : null,
149148
destinationDraftId,
150149
});
150+
};
151151
// The shared resolver owns the priority order. The t3.json read is
152152
// skipped entirely when a higher-priority source decides, and its
153153
// query atom caches per project after the first call.

0 commit comments

Comments
 (0)