Reduce draft tab descriptor updates
This commit is contained in:
@@ -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,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user