Reduce draft tab descriptor updates

This commit is contained in:
Mohamed Boudra
2026-05-25 21:37:04 +07:00
parent 30a8bffc24
commit 48d4e3e408
+16 -8
View File
@@ -367,16 +367,24 @@ export function useDraftPanelDescriptor(
target: { kind: "draft"; draftId: string }, target: { kind: "draft"; draftId: string },
context: { serverId: string }, context: { serverId: string },
) { ) {
const pendingCreate = useCreateFlowStore((state) => { const createDescriptorState = useCreateFlowStore(
const pending = state.pendingByDraftId[target.draftId]; useShallow((state) => {
return pending?.serverId === context.serverId && pending.lifecycle === "active" const pending = state.pendingByDraftId[target.draftId];
? pending if (pending?.serverId !== context.serverId || pending.lifecycle !== "active") {
: null; return {
}); isCreating: false,
pendingPrompt: null,
};
}
return {
isCreating: true,
pendingPrompt: pending.text,
};
}),
);
return buildDraftPanelDescriptor({ return buildDraftPanelDescriptor({
isCreating: Boolean(pendingCreate), ...createDescriptorState,
pendingPrompt: pendingCreate?.text,
icon: SquarePen, icon: SquarePen,
}); });
} }