@fv-ui/ai-chat 0.12.0 → 0.12.2

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/es/index.mjs CHANGED
@@ -4913,7 +4913,10 @@ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
4913
4913
  }
4914
4914
  let lastFlushAt = 0;
4915
4915
  let lastFlushChars = 0;
4916
+ let orchestrated = false;
4916
4917
  watch(() => props.items, (items) => {
4918
+ const firstRun = !orchestrated;
4919
+ orchestrated = true;
4917
4920
  const now = Date.now();
4918
4921
  let flushedChars = 0;
4919
4922
  const flushCounting = (it) => {
@@ -4937,7 +4940,7 @@ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
4937
4940
  }
4938
4941
  }
4939
4942
  for (const it of items) {
4940
- if (it.typing && it.closed && preRegistered.has(it.key)) flushCounting(it);
4943
+ if (it.closed && (preRegistered.has(it.key) || !firstRun)) flushCounting(it);
4941
4944
  }
4942
4945
  if (flushedChars > 0) {
4943
4946
  lastFlushAt = now;
@@ -6751,6 +6754,14 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6751
6754
  { immediate: true }
6752
6755
  );
6753
6756
  const useTypewriter = computed(() => !isUser.value && !!props.typing && wasStreaming.value);
6757
+ const reasoningFlushed = ref(false);
6758
+ watch(
6759
+ () => [props.message.content, props.message.status],
6760
+ ([content, status]) => {
6761
+ if (content || status === "done" || status === "error") reasoningFlushed.value = true;
6762
+ },
6763
+ { immediate: true }
6764
+ );
6754
6765
  const textStepIcon = markRaw(ChatLineRound);
6755
6766
  const toolStepIcon = markRaw(Search);
6756
6767
  const toolChainItems = computed(() => {
@@ -6899,13 +6910,21 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6899
6910
  items: toolChainItems.value,
6900
6911
  collapsible: __props.collapsible,
6901
6912
  onTyping: _cache[0] || (_cache[0] = ($event) => emit("typing"))
6902
- }, null, 8, ["items", "collapsible"])) : hasReasoning.value && useTypewriter.value ? (openBlock(), createBlock(_sfc_main$h, {
6903
- key: 1,
6904
- content: __props.message.reasoning ?? "",
6905
- "is-markdown": "",
6906
- typing: __props.typing,
6907
- onWriting: _cache[1] || (_cache[1] = ($event) => emit("typing"))
6908
- }, null, 8, ["content", "typing"])) : hasReasoning.value ? (openBlock(), createBlock(_sfc_main$i, {
6913
+ }, null, 8, ["items", "collapsible"])) : hasReasoning.value && useTypewriter.value && !reasoningFlushed.value ? (openBlock(), createElementBlock(
6914
+ Fragment,
6915
+ { key: 1 },
6916
+ [
6917
+ createCommentVNode(" \u7EAF\u601D\u8003\u6D88\u606F(reasoning \u65E0 toolSteps)\u56DE\u843D\u94FE\u4E0B\u6E32\u67D3:\u6D41\u5F0F\u671F\u95F4 Typewriter \u9010\u5B57,\r\n \u6B63\u6587\u51FA\u73B0/\u601D\u8003\u6536\u53E3\u5373\u51B2\u5237\u56DE\u843D\u9759\u6001 Markdown(\u540C ThoughtChain \u5C01\u53E3\u51B2\u5237\u8BED\u4E49) "),
6918
+ createVNode(_sfc_main$h, {
6919
+ content: __props.message.reasoning ?? "",
6920
+ "is-markdown": "",
6921
+ typing: __props.typing,
6922
+ onWriting: _cache[1] || (_cache[1] = ($event) => emit("typing"))
6923
+ }, null, 8, ["content", "typing"])
6924
+ ],
6925
+ 2112
6926
+ /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
6927
+ )) : hasReasoning.value ? (openBlock(), createBlock(_sfc_main$i, {
6909
6928
  key: 2,
6910
6929
  content: __props.message.reasoning ?? ""
6911
6930
  }, null, 8, ["content"])) : createCommentVNode("v-if", true)
@@ -7932,7 +7951,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7932
7951
  const msgEl = btn.closest(".fv-msg");
7933
7952
  const msgId = msgEl?.getAttribute("data-message-id") ?? "";
7934
7953
  if (!lang || !msgId || !msgEl) return;
7935
- const pres = Array.from(msgEl.querySelectorAll("pre"));
7954
+ const pres = Array.from(msgEl.querySelectorAll("pre[data-fv-code-lang]"));
7936
7955
  const pre = btn.closest("pre");
7937
7956
  const idx = pre ? pres.indexOf(pre) : -1;
7938
7957
  if (idx < 0) return;
package/lib/index.js CHANGED
@@ -4929,7 +4929,10 @@
4929
4929
  }
4930
4930
  let lastFlushAt = 0;
4931
4931
  let lastFlushChars = 0;
4932
+ let orchestrated = false;
4932
4933
  vue.watch(() => props.items, (items) => {
4934
+ const firstRun = !orchestrated;
4935
+ orchestrated = true;
4933
4936
  const now = Date.now();
4934
4937
  let flushedChars = 0;
4935
4938
  const flushCounting = (it) => {
@@ -4953,7 +4956,7 @@
4953
4956
  }
4954
4957
  }
4955
4958
  for (const it of items) {
4956
- if (it.typing && it.closed && preRegistered.has(it.key)) flushCounting(it);
4959
+ if (it.closed && (preRegistered.has(it.key) || !firstRun)) flushCounting(it);
4957
4960
  }
4958
4961
  if (flushedChars > 0) {
4959
4962
  lastFlushAt = now;
@@ -6767,6 +6770,14 @@
6767
6770
  { immediate: true }
6768
6771
  );
6769
6772
  const useTypewriter = vue.computed(() => !isUser.value && !!props.typing && wasStreaming.value);
6773
+ const reasoningFlushed = vue.ref(false);
6774
+ vue.watch(
6775
+ () => [props.message.content, props.message.status],
6776
+ ([content, status]) => {
6777
+ if (content || status === "done" || status === "error") reasoningFlushed.value = true;
6778
+ },
6779
+ { immediate: true }
6780
+ );
6770
6781
  const textStepIcon = vue.markRaw(ElementPlusIconsVue.ChatLineRound);
6771
6782
  const toolStepIcon = vue.markRaw(ElementPlusIconsVue.Search);
6772
6783
  const toolChainItems = vue.computed(() => {
@@ -6915,13 +6926,21 @@
6915
6926
  items: toolChainItems.value,
6916
6927
  collapsible: __props.collapsible,
6917
6928
  onTyping: _cache[0] || (_cache[0] = ($event) => emit("typing"))
6918
- }, null, 8, ["items", "collapsible"])) : hasReasoning.value && useTypewriter.value ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
6919
- key: 1,
6920
- content: __props.message.reasoning ?? "",
6921
- "is-markdown": "",
6922
- typing: __props.typing,
6923
- onWriting: _cache[1] || (_cache[1] = ($event) => emit("typing"))
6924
- }, null, 8, ["content", "typing"])) : hasReasoning.value ? (vue.openBlock(), vue.createBlock(_sfc_main$i, {
6929
+ }, null, 8, ["items", "collapsible"])) : hasReasoning.value && useTypewriter.value && !reasoningFlushed.value ? (vue.openBlock(), vue.createElementBlock(
6930
+ vue.Fragment,
6931
+ { key: 1 },
6932
+ [
6933
+ vue.createCommentVNode(" \u7EAF\u601D\u8003\u6D88\u606F(reasoning \u65E0 toolSteps)\u56DE\u843D\u94FE\u4E0B\u6E32\u67D3:\u6D41\u5F0F\u671F\u95F4 Typewriter \u9010\u5B57,\r\n \u6B63\u6587\u51FA\u73B0/\u601D\u8003\u6536\u53E3\u5373\u51B2\u5237\u56DE\u843D\u9759\u6001 Markdown(\u540C ThoughtChain \u5C01\u53E3\u51B2\u5237\u8BED\u4E49) "),
6934
+ vue.createVNode(_sfc_main$h, {
6935
+ content: __props.message.reasoning ?? "",
6936
+ "is-markdown": "",
6937
+ typing: __props.typing,
6938
+ onWriting: _cache[1] || (_cache[1] = ($event) => emit("typing"))
6939
+ }, null, 8, ["content", "typing"])
6940
+ ],
6941
+ 2112
6942
+ /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
6943
+ )) : hasReasoning.value ? (vue.openBlock(), vue.createBlock(_sfc_main$i, {
6925
6944
  key: 2,
6926
6945
  content: __props.message.reasoning ?? ""
6927
6946
  }, null, 8, ["content"])) : vue.createCommentVNode("v-if", true)
@@ -7948,7 +7967,7 @@
7948
7967
  const msgEl = btn.closest(".fv-msg");
7949
7968
  const msgId = msgEl?.getAttribute("data-message-id") ?? "";
7950
7969
  if (!lang || !msgId || !msgEl) return;
7951
- const pres = Array.from(msgEl.querySelectorAll("pre"));
7970
+ const pres = Array.from(msgEl.querySelectorAll("pre[data-fv-code-lang]"));
7952
7971
  const pre = btn.closest("pre");
7953
7972
  const idx = pre ? pres.indexOf(pre) : -1;
7954
7973
  if (idx < 0) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fv-ui/ai-chat",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "基于 Vue3 + Element Plus 的 AI 对话组件库",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",