@zero-library/chat-copilot 3.1.23 → 3.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -6032,9 +6032,13 @@ var ModelSelect_default = ({}) => {
6032
6032
  icon: model.icon
6033
6033
  }))
6034
6034
  }));
6035
- const selectedModelValue = modelOptions.find((item) => item.value === agentState.model.providerName)?.options.find((item) => item.modelName === agentState.model.modelName)?.value;
6035
+ const hasSelectedModelConfig = Boolean(agentState.model.providerName && agentState.model.modelName);
6036
+ const selectedProvider = hasSelectedModelConfig ? modelOptions.find((item) => item.value === agentState.model.providerName) : void 0;
6037
+ const selectedModel = selectedProvider?.options.find((item) => item.modelName === agentState.model.modelName);
6038
+ const selectedModelValue = selectedModel?.value;
6036
6039
  React10.useEffect(() => {
6037
- if (!selectedModelValue && models.length > 0 && models[0].models?.length > 0) {
6040
+ const shouldUseDefaultModel = !hasSelectedModelConfig || !selectedModel;
6041
+ if (shouldUseDefaultModel && models.length > 0 && models[0].models?.length > 0) {
6038
6042
  const firstProvider = models[0];
6039
6043
  const firstModel = firstProvider.models[0];
6040
6044
  chatStore.setAgentModel({
@@ -6042,7 +6046,7 @@ var ModelSelect_default = ({}) => {
6042
6046
  providerName: firstProvider.providerName
6043
6047
  });
6044
6048
  }
6045
- }, [selectedModelValue, models, agentState.model, chatStore]);
6049
+ }, [hasSelectedModelConfig, selectedModel, models, chatStore]);
6046
6050
  const handleModelChange = (_, option) => {
6047
6051
  if (Array.isArray(option) || !option || !("providerName" in option)) return;
6048
6052
  chatStore.setAgentModel({
@@ -6109,7 +6113,25 @@ var SkillBtn_default = ({}) => {
6109
6113
  const chatStore = useChatStore();
6110
6114
  const conversationState = valtio.useSnapshot(chatStore.conversation);
6111
6115
  const [modalOpen, setModalOpen] = React10.useState(false);
6112
- const skillsCount = conversationState.active.spec?.skills?.items?.length ?? 0;
6116
+ const [skillsCount, setSkillsCount] = React10.useState(0);
6117
+ React10.useEffect(() => {
6118
+ let canceled = false;
6119
+ const syncSkillsCount = async () => {
6120
+ const initialItems = conversationState.active.spec?.skills?.items;
6121
+ if (!initialItems?.length) {
6122
+ setSkillsCount(0);
6123
+ return;
6124
+ }
6125
+ const { data } = await chatStore.config.services.request.listSkills();
6126
+ if (canceled) return;
6127
+ const validIds = new Set((data || []).map((item) => item.id));
6128
+ setSkillsCount(initialItems.map((item) => item.id).filter((id) => validIds.has(id)).length);
6129
+ };
6130
+ syncSkillsCount();
6131
+ return () => {
6132
+ canceled = true;
6133
+ };
6134
+ }, [chatStore, conversationState.active.spec?.skills?.items]);
6113
6135
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6114
6136
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: style_module_default.resourceBtn, onClick: () => setModalOpen(true), children: [
6115
6137
  /* @__PURE__ */ jsxRuntime.jsx(IconFont_default, { type: "icon-skill" }),