@fv-ui/ai-chat 0.9.1 → 0.9.3

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/README.md CHANGED
@@ -439,6 +439,7 @@ Markdown 渲染(Sanitized by DOMPurify),内置 Prism 代码高亮与 KaTeX。
439
439
  | centerWelcome | boolean | true | 空态居中:未开始对话时欢迎内容与输入区整体垂直居中,首条消息后输入区恢复固定底部 |
440
440
  | showScrollButton | boolean | true | 显示滚到底部悬浮按钮(透传 AiMessages;距底超过 scrollButtonThreshold 时出现) |
441
441
  | scrollButtonThreshold | number | 100 | 滚到底部悬浮按钮显示阈值(px,透传 AiMessages) |
442
+ | scrollThreshold | number | 100 | 用户上滚免打扰阈值(px,透传 AiMessages):距底不超过该值视为「钉在底部」,流式期间自动跟随滚动;调小可恢复更灵敏的跟随 |
442
443
  | showUserAvatar | boolean | true | 显示用户头像(false 时用户消息不渲染头像;助手头像不受影响) |
443
444
  | showUserName | boolean | true | 显示用户名称(false 时用户消息不渲染头部名称行;助手名称不受影响) |
444
445
  | showAssistantAvatar | boolean | true | 显示助手头像(false 时助手消息不渲染头像;用户头像不受影响) |
@@ -500,7 +501,7 @@ Markdown 渲染(Sanitized by DOMPurify),内置 Prism 代码高亮与 KaTeX。
500
501
  | description | string | '' | 空态欢迎页描述 |
501
502
  | suggestions | AiMessagesSuggestion[] | [] | 空态建议列表 |
502
503
  | suggestionsTitle | string | '' | 空态建议区标题 |
503
- | scrollThreshold | number | 40 | 吸底阈值(px):距底不超过该值才自动跟随 |
504
+ | scrollThreshold | number | 100 | 用户上滚免打扰阈值(px):距底不超过该值视为「钉在底部」,流式期间自动跟随滚动 |
504
505
  | showScrollButton | boolean | true | 显示滚到底部悬浮按钮(空态不渲染) |
505
506
  | scrollButtonThreshold | number | 100 | 距底超过该值(px)才显示滚到底部悬浮按钮 |
506
507
  | showActions | boolean | true | 显示消息操作按钮(复制/重生成) |
package/dist/index.d.ts CHANGED
@@ -134,7 +134,7 @@ declare var __VLS_1$9: {};
134
134
  declare var __VLS_10$1: {};
135
135
  declare var __VLS_12$1: {};
136
136
  declare var __VLS_14: {};
137
- declare var __VLS_32$1: {};
137
+ declare var __VLS_32: {};
138
138
  type __VLS_Slots$e = {} & {
139
139
  avatar?: (props: typeof __VLS_1$9) => any;
140
140
  } & {
@@ -144,7 +144,7 @@ type __VLS_Slots$e = {} & {
144
144
  } & {
145
145
  content?: (props: typeof __VLS_14) => any;
146
146
  } & {
147
- footer?: (props: typeof __VLS_32$1) => any;
147
+ footer?: (props: typeof __VLS_32) => any;
148
148
  };
149
149
  declare const __VLS_base$e: vue.DefineComponent<__VLS_Props$f, {
150
150
  interrupt: typeof interrupt;
@@ -822,16 +822,16 @@ type __VLS_Props$a = {
822
822
  /** 切换门控:start 起始态不可切换;thinking 中可展开查看思考流,end/error 后可自由收起展开 */
823
823
  declare function toggle(): void;
824
824
  declare var __VLS_1$6: {};
825
- declare var __VLS_36$1: {};
826
- declare var __VLS_38$1: {};
825
+ declare var __VLS_36$2: {};
826
+ declare var __VLS_38: {};
827
827
  declare var __VLS_51: {};
828
828
  declare var __VLS_53: {};
829
829
  type __VLS_Slots$9 = {} & {
830
830
  'status-icon'?: (props: typeof __VLS_1$6) => any;
831
831
  } & {
832
- label?: (props: typeof __VLS_36$1) => any;
832
+ label?: (props: typeof __VLS_36$2) => any;
833
833
  } & {
834
- arrow?: (props: typeof __VLS_38$1) => any;
834
+ arrow?: (props: typeof __VLS_38) => any;
835
835
  } & {
836
836
  error?: (props: typeof __VLS_51) => any;
837
837
  } & {
@@ -908,13 +908,13 @@ type __VLS_Props$8 = {
908
908
  };
909
909
  declare var __VLS_1$5: {};
910
910
  declare var __VLS_24$1: {};
911
- declare var __VLS_26$1: {};
911
+ declare var __VLS_26: {};
912
912
  type __VLS_Slots$7 = {} & {
913
913
  icon?: (props: typeof __VLS_1$5) => any;
914
914
  } & {
915
915
  name?: (props: typeof __VLS_24$1) => any;
916
916
  } & {
917
- description?: (props: typeof __VLS_26$1) => any;
917
+ description?: (props: typeof __VLS_26) => any;
918
918
  };
919
919
  declare const __VLS_base$7: vue.DefineComponent<__VLS_Props$8, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<__VLS_Props$8> & Readonly<{}>, {
920
920
  name: string;
@@ -1522,43 +1522,43 @@ declare function scrollToBottom(smooth?: boolean): void;
1522
1522
  /** 回到顶部:与 scrollToBottom 同款 try/catch 回落(happy-dom 旧版 scrollTo(options) 可能缺实现) */
1523
1523
  declare function scrollToTop(): void;
1524
1524
  declare var __VLS_1$1: {};
1525
- declare var __VLS_26: {
1525
+ declare var __VLS_27$1: {
1526
1526
  message: MessageNode;
1527
1527
  };
1528
- declare var __VLS_29$1: {
1528
+ declare var __VLS_30$1: {
1529
1529
  message: MessageNode;
1530
1530
  };
1531
- declare var __VLS_32: {};
1532
- declare var __VLS_35: {};
1533
- declare var __VLS_38: {
1531
+ declare var __VLS_33$2: {};
1532
+ declare var __VLS_36$1: {};
1533
+ declare var __VLS_39$1: {
1534
1534
  message: MessageNode;
1535
1535
  };
1536
- declare var __VLS_41: {
1536
+ declare var __VLS_42$1: {
1537
1537
  message: MessageNode;
1538
1538
  };
1539
- declare var __VLS_49: {
1539
+ declare var __VLS_50: {
1540
1540
  scrollToBottom: typeof scrollToBottom;
1541
1541
  awayFromBottom: boolean;
1542
1542
  };
1543
- declare var __VLS_65: {};
1543
+ declare var __VLS_66: {};
1544
1544
  type __VLS_Slots$2 = {} & {
1545
1545
  empty?: (props: typeof __VLS_1$1) => any;
1546
1546
  } & {
1547
- 'message-avatar'?: (props: typeof __VLS_26) => any;
1547
+ 'message-avatar'?: (props: typeof __VLS_27$1) => any;
1548
1548
  } & {
1549
- 'message-actions'?: (props: typeof __VLS_29$1) => any;
1549
+ 'message-actions'?: (props: typeof __VLS_30$1) => any;
1550
1550
  } & {
1551
- 'user-avatar'?: (props: typeof __VLS_32) => any;
1551
+ 'user-avatar'?: (props: typeof __VLS_33$2) => any;
1552
1552
  } & {
1553
- 'assistant-avatar'?: (props: typeof __VLS_35) => any;
1553
+ 'assistant-avatar'?: (props: typeof __VLS_36$1) => any;
1554
1554
  } & {
1555
- 'user-name'?: (props: typeof __VLS_38) => any;
1555
+ 'user-name'?: (props: typeof __VLS_39$1) => any;
1556
1556
  } & {
1557
- 'assistant-name'?: (props: typeof __VLS_41) => any;
1557
+ 'assistant-name'?: (props: typeof __VLS_42$1) => any;
1558
1558
  } & {
1559
- 'scroll-button'?: (props: typeof __VLS_49) => any;
1559
+ 'scroll-button'?: (props: typeof __VLS_50) => any;
1560
1560
  } & {
1561
- 'scroll-button-icon'?: (props: typeof __VLS_65) => any;
1561
+ 'scroll-button-icon'?: (props: typeof __VLS_66) => any;
1562
1562
  };
1563
1563
  declare const __VLS_base$2: vue.DefineComponent<__VLS_Props$3, {
1564
1564
  scrollToBottom: typeof scrollToBottom;
@@ -1641,6 +1641,8 @@ type __VLS_Props$2 = {
1641
1641
  showScrollButton?: boolean;
1642
1642
  /** 滚到底部悬浮按钮显示阈值(px,透传 AiMessages) */
1643
1643
  scrollButtonThreshold?: number;
1644
+ /** 用户上滚免打扰阈值(px,透传 AiMessages):距底不超过该值视为「钉在底部」,流式自动跟随 */
1645
+ scrollThreshold?: number;
1644
1646
  /** 显示用户头像(false 时用户消息不渲染头像;助手头像不受影响) */
1645
1647
  showUserAvatar?: boolean;
1646
1648
  /** 显示用户名称(false 时用户消息不渲染头部名称行;助手名称不受影响) */
@@ -1788,6 +1790,7 @@ declare const __VLS_base$1: vue.DefineComponent<__VLS_Props$2, {
1788
1790
  userName: string;
1789
1791
  assistantName: string;
1790
1792
  suggestions: AiChatSuggestion[];
1793
+ scrollThreshold: number;
1791
1794
  showScrollButton: boolean;
1792
1795
  scrollButtonThreshold: number;
1793
1796
  models: string[];
@@ -1865,7 +1868,7 @@ declare var __VLS_33: {
1865
1868
  message: MessageNode;
1866
1869
  files: ChatFile[];
1867
1870
  };
1868
- declare var __VLS_67: {
1871
+ declare var __VLS_71: {
1869
1872
  message: MessageNode;
1870
1873
  };
1871
1874
  type __VLS_Slots = {} & {
@@ -1881,15 +1884,17 @@ type __VLS_Slots = {} & {
1881
1884
  } & {
1882
1885
  'message-files'?: (props: typeof __VLS_33) => any;
1883
1886
  } & {
1884
- 'message-actions'?: (props: typeof __VLS_67) => any;
1887
+ 'message-actions'?: (props: typeof __VLS_71) => any;
1885
1888
  };
1886
1889
  declare const __VLS_base: vue.DefineComponent<__VLS_Props$1, {
1887
1890
  message: vue.ComputedRef<MessageNode>;
1888
1891
  }, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {} & {
1892
+ typing: () => any;
1889
1893
  copy: (message: MessageNode) => any;
1890
1894
  regenerate: (message: MessageNode) => any;
1891
1895
  "branch-change": (dir: BranchDirection, message: MessageNode) => any;
1892
1896
  }, string, vue.PublicProps, Readonly<__VLS_Props$1> & Readonly<{
1897
+ onTyping?: (() => any) | undefined;
1893
1898
  onCopy?: ((message: MessageNode) => any) | undefined;
1894
1899
  onRegenerate?: ((message: MessageNode) => any) | undefined;
1895
1900
  "onBranch-change"?: ((dir: BranchDirection, message: MessageNode) => any) | undefined;
package/es/index.mjs CHANGED
@@ -5898,15 +5898,19 @@ ${fileParts.join("\n")}` });
5898
5898
  msgs.edit(assistantId, { backendId: id });
5899
5899
  },
5900
5900
  onTool: (ev) => {
5901
+ const label = (name) => options.toolStepLabel ? options.toolStepLabel(name) : name;
5901
5902
  const steps = [...msgs.messages.value[assistantId]?.toolSteps ?? []];
5902
5903
  if (ev.status === "start") {
5903
5904
  steps.push({
5904
5905
  key: `${ev.toolName}-${steps.length}`,
5905
- title: options.toolStepLabel ? options.toolStepLabel(ev.toolName) : ev.toolName,
5906
+ title: label(ev.toolName),
5906
5907
  status: "loading"
5907
5908
  });
5908
5909
  } else if (steps.length) {
5909
- steps[steps.length - 1] = { ...steps[steps.length - 1], status: "success" };
5910
+ let i = steps.length - 1;
5911
+ while (i >= 0 && !(steps[i].status === "loading" && steps[i].title === label(ev.toolName))) i--;
5912
+ if (i < 0) i = steps.length - 1;
5913
+ steps[i] = { ...steps[i], status: "success" };
5910
5914
  }
5911
5915
  msgs.edit(assistantId, { toolSteps: steps });
5912
5916
  options.onToolEvent?.(ev);
@@ -6086,7 +6090,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6086
6090
  autoCollapse: { type: Boolean, required: false, default: true },
6087
6091
  typing: { type: [Boolean, Object], required: false, default: false }
6088
6092
  },
6089
- emits: ["copy", "regenerate", "branch-change"],
6093
+ emits: ["copy", "regenerate", "branch-change", "typing"],
6090
6094
  setup(__props, { expose: __expose, emit: __emit }) {
6091
6095
  const props = __props;
6092
6096
  const emit = __emit;
@@ -6112,12 +6116,12 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6112
6116
  const steps = props.message.toolSteps ?? [];
6113
6117
  const running = props.message.status === "pending" || props.message.status === "streaming";
6114
6118
  return steps.map((s) => {
6115
- const loading = running && s.status !== "error" && s.status !== "success";
6116
- return {
6117
- ...s,
6118
- status: loading ? "loading" : s.status ?? "success",
6119
- title: `${loading ? "\u6B63\u5728\u67E5\u8BE2" : "\u5DF2\u67E5\u8BE2"}${s.title ?? ""}`
6120
- };
6119
+ if (running) {
6120
+ const loading = s.status !== "error" && s.status !== "success";
6121
+ return loading ? { ...s, status: "loading", title: `\u6B63\u5728\u67E5\u8BE2${s.title ?? ""}` } : { ...s, title: `\u5DF2\u67E5\u8BE2${s.title ?? ""}` };
6122
+ }
6123
+ const settled = s.status === "success" || s.status === "error" ? s.status : props.message.status === "error" ? "error" : "success";
6124
+ return { ...s, status: settled, title: `\u5DF2\u67E5\u8BE2${s.title ?? ""}` };
6121
6125
  });
6122
6126
  });
6123
6127
  const modelLabel = computed(() => props.message.model ?? "");
@@ -6255,7 +6259,8 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6255
6259
  key: 0,
6256
6260
  content: __props.message.reasoning ?? "",
6257
6261
  "is-markdown": "",
6258
- typing: __props.typing
6262
+ typing: __props.typing,
6263
+ onWriting: _cache[0] || (_cache[0] = ($event) => emit("typing"))
6259
6264
  }, null, 8, ["content", "typing"])) : (openBlock(), createBlock(_sfc_main$i, {
6260
6265
  key: 1,
6261
6266
  content: __props.message.reasoning ?? ""
@@ -6276,7 +6281,8 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6276
6281
  key: 1,
6277
6282
  content: __props.message.content,
6278
6283
  "is-markdown": "",
6279
- typing: __props.typing
6284
+ typing: __props.typing,
6285
+ onWriting: _cache[1] || (_cache[1] = ($event) => emit("typing"))
6280
6286
  }, null, 8, ["content", "typing"])) : __props.message.content ? (openBlock(), createBlock(_sfc_main$i, {
6281
6287
  key: 2,
6282
6288
  content: __props.message.content
@@ -6407,7 +6413,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6407
6413
  class: "fv-msg-action",
6408
6414
  disabled: __props.branch.index <= 1,
6409
6415
  "aria-label": "\u4E0A\u4E00\u5206\u652F",
6410
- onClick: _cache[0] || (_cache[0] = ($event) => onBranch("prev"))
6416
+ onClick: _cache[2] || (_cache[2] = ($event) => onBranch("prev"))
6411
6417
  }, {
6412
6418
  default: withCtx(() => [
6413
6419
  createVNode(unref(ElIcon), null, {
@@ -6434,7 +6440,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6434
6440
  class: "fv-msg-action",
6435
6441
  disabled: __props.branch.index >= __props.branch.count,
6436
6442
  "aria-label": "\u4E0B\u4E00\u5206\u652F",
6437
- onClick: _cache[1] || (_cache[1] = ($event) => onBranch("next"))
6443
+ onClick: _cache[3] || (_cache[3] = ($event) => onBranch("next"))
6438
6444
  }, {
6439
6445
  default: withCtx(() => [
6440
6446
  createVNode(unref(ElIcon), null, {
@@ -6492,6 +6498,9 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
6492
6498
  setup(__props, { expose: __expose, emit: __emit }) {
6493
6499
  const props = __props;
6494
6500
  const emit = __emit;
6501
+ function onChildTyping() {
6502
+ followIfPinned();
6503
+ }
6495
6504
  const isEmpty = computed(() => props.messages.length === 0);
6496
6505
  const scrollRef = ref(null);
6497
6506
  function distanceFromBottom() {
@@ -6640,6 +6649,7 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
6640
6649
  "user-name": __props.userName,
6641
6650
  "assistant-name": __props.assistantName,
6642
6651
  typing: __props.typing,
6652
+ onTyping: onChildTyping,
6643
6653
  onCopy,
6644
6654
  onRegenerate,
6645
6655
  onBranchChange: onBranch
@@ -7017,6 +7027,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7017
7027
  centerWelcome: { type: Boolean, required: false, default: true },
7018
7028
  showScrollButton: { type: Boolean, required: false, default: true },
7019
7029
  scrollButtonThreshold: { type: Number, required: false, default: 100 },
7030
+ scrollThreshold: { type: Number, required: false, default: 100 },
7020
7031
  showUserAvatar: { type: Boolean, required: false, default: true },
7021
7032
  showUserName: { type: Boolean, required: false, default: true },
7022
7033
  showAssistantAvatar: { type: Boolean, required: false, default: true },
@@ -7071,7 +7082,9 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7071
7082
  adapter: resolveAdapter,
7072
7083
  models: () => isMultiple.value && selectedModels.value.length ? selectedModels.value : [""],
7073
7084
  initial: { messages: initialTable, currentId: initialId },
7074
- toolStepLabel: props.toolStepLabel,
7085
+ // 与 adapter/models 同语义按工厂惰性取用:options 在 setup 构造一次,
7086
+ // 按值快照会把父组件运行期更换的函数 prop 冻在旧引用上(换了映射不生效)
7087
+ toolStepLabel: (name) => props.toolStepLabel ? props.toolStepLabel(name) : name,
7075
7088
  onToolEvent: (ev) => emit("tool-event", ev)
7076
7089
  });
7077
7090
  const { send, stop: stopChat, regenerate: regenerateChat, msgs, isLoading } = chat;
@@ -7293,6 +7306,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7293
7306
  suggestions: __props.suggestions,
7294
7307
  "show-scroll-button": __props.showScrollButton,
7295
7308
  "scroll-button-threshold": __props.scrollButtonThreshold,
7309
+ "scroll-threshold": __props.scrollThreshold,
7296
7310
  "show-user-avatar": __props.showUserAvatar,
7297
7311
  "show-user-name": __props.showUserName,
7298
7312
  "show-assistant-avatar": __props.showAssistantAvatar,
@@ -7373,7 +7387,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7373
7387
  ]),
7374
7388
  key: "8"
7375
7389
  } : void 0
7376
- ]), 1032, ["messages", "nodes", "name", "suggestions", "show-scroll-button", "scroll-button-threshold", "show-user-avatar", "show-user-name", "show-assistant-avatar", "show-assistant-name", "user-avatar", "assistant-avatar", "user-name", "assistant-name", "typing"]),
7390
+ ]), 1032, ["messages", "nodes", "name", "suggestions", "show-scroll-button", "scroll-button-threshold", "scroll-threshold", "show-user-avatar", "show-user-name", "show-assistant-avatar", "show-assistant-name", "user-avatar", "assistant-avatar", "user-name", "assistant-name", "typing"]),
7377
7391
  __props.features?.artifacts && artifacts.value.length ? (openBlock(), createBlock(_sfc_main$1, {
7378
7392
  key: 0,
7379
7393
  artifacts: artifacts.value,
package/lib/index.js CHANGED
@@ -5914,15 +5914,19 @@ ${fileParts.join("\n")}` });
5914
5914
  msgs.edit(assistantId, { backendId: id });
5915
5915
  },
5916
5916
  onTool: (ev) => {
5917
+ const label = (name) => options.toolStepLabel ? options.toolStepLabel(name) : name;
5917
5918
  const steps = [...msgs.messages.value[assistantId]?.toolSteps ?? []];
5918
5919
  if (ev.status === "start") {
5919
5920
  steps.push({
5920
5921
  key: `${ev.toolName}-${steps.length}`,
5921
- title: options.toolStepLabel ? options.toolStepLabel(ev.toolName) : ev.toolName,
5922
+ title: label(ev.toolName),
5922
5923
  status: "loading"
5923
5924
  });
5924
5925
  } else if (steps.length) {
5925
- steps[steps.length - 1] = { ...steps[steps.length - 1], status: "success" };
5926
+ let i = steps.length - 1;
5927
+ while (i >= 0 && !(steps[i].status === "loading" && steps[i].title === label(ev.toolName))) i--;
5928
+ if (i < 0) i = steps.length - 1;
5929
+ steps[i] = { ...steps[i], status: "success" };
5926
5930
  }
5927
5931
  msgs.edit(assistantId, { toolSteps: steps });
5928
5932
  options.onToolEvent?.(ev);
@@ -6102,7 +6106,7 @@ ${fileParts.join("\n")}` });
6102
6106
  autoCollapse: { type: Boolean, required: false, default: true },
6103
6107
  typing: { type: [Boolean, Object], required: false, default: false }
6104
6108
  },
6105
- emits: ["copy", "regenerate", "branch-change"],
6109
+ emits: ["copy", "regenerate", "branch-change", "typing"],
6106
6110
  setup(__props, { expose: __expose, emit: __emit }) {
6107
6111
  const props = __props;
6108
6112
  const emit = __emit;
@@ -6128,12 +6132,12 @@ ${fileParts.join("\n")}` });
6128
6132
  const steps = props.message.toolSteps ?? [];
6129
6133
  const running = props.message.status === "pending" || props.message.status === "streaming";
6130
6134
  return steps.map((s) => {
6131
- const loading = running && s.status !== "error" && s.status !== "success";
6132
- return {
6133
- ...s,
6134
- status: loading ? "loading" : s.status ?? "success",
6135
- title: `${loading ? "\u6B63\u5728\u67E5\u8BE2" : "\u5DF2\u67E5\u8BE2"}${s.title ?? ""}`
6136
- };
6135
+ if (running) {
6136
+ const loading = s.status !== "error" && s.status !== "success";
6137
+ return loading ? { ...s, status: "loading", title: `\u6B63\u5728\u67E5\u8BE2${s.title ?? ""}` } : { ...s, title: `\u5DF2\u67E5\u8BE2${s.title ?? ""}` };
6138
+ }
6139
+ const settled = s.status === "success" || s.status === "error" ? s.status : props.message.status === "error" ? "error" : "success";
6140
+ return { ...s, status: settled, title: `\u5DF2\u67E5\u8BE2${s.title ?? ""}` };
6137
6141
  });
6138
6142
  });
6139
6143
  const modelLabel = vue.computed(() => props.message.model ?? "");
@@ -6271,7 +6275,8 @@ ${fileParts.join("\n")}` });
6271
6275
  key: 0,
6272
6276
  content: __props.message.reasoning ?? "",
6273
6277
  "is-markdown": "",
6274
- typing: __props.typing
6278
+ typing: __props.typing,
6279
+ onWriting: _cache[0] || (_cache[0] = ($event) => emit("typing"))
6275
6280
  }, null, 8, ["content", "typing"])) : (vue.openBlock(), vue.createBlock(_sfc_main$i, {
6276
6281
  key: 1,
6277
6282
  content: __props.message.reasoning ?? ""
@@ -6292,7 +6297,8 @@ ${fileParts.join("\n")}` });
6292
6297
  key: 1,
6293
6298
  content: __props.message.content,
6294
6299
  "is-markdown": "",
6295
- typing: __props.typing
6300
+ typing: __props.typing,
6301
+ onWriting: _cache[1] || (_cache[1] = ($event) => emit("typing"))
6296
6302
  }, null, 8, ["content", "typing"])) : __props.message.content ? (vue.openBlock(), vue.createBlock(_sfc_main$i, {
6297
6303
  key: 2,
6298
6304
  content: __props.message.content
@@ -6423,7 +6429,7 @@ ${fileParts.join("\n")}` });
6423
6429
  class: "fv-msg-action",
6424
6430
  disabled: __props.branch.index <= 1,
6425
6431
  "aria-label": "\u4E0A\u4E00\u5206\u652F",
6426
- onClick: _cache[0] || (_cache[0] = ($event) => onBranch("prev"))
6432
+ onClick: _cache[2] || (_cache[2] = ($event) => onBranch("prev"))
6427
6433
  }, {
6428
6434
  default: vue.withCtx(() => [
6429
6435
  vue.createVNode(vue.unref(elementPlus.ElIcon), null, {
@@ -6450,7 +6456,7 @@ ${fileParts.join("\n")}` });
6450
6456
  class: "fv-msg-action",
6451
6457
  disabled: __props.branch.index >= __props.branch.count,
6452
6458
  "aria-label": "\u4E0B\u4E00\u5206\u652F",
6453
- onClick: _cache[1] || (_cache[1] = ($event) => onBranch("next"))
6459
+ onClick: _cache[3] || (_cache[3] = ($event) => onBranch("next"))
6454
6460
  }, {
6455
6461
  default: vue.withCtx(() => [
6456
6462
  vue.createVNode(vue.unref(elementPlus.ElIcon), null, {
@@ -6508,6 +6514,9 @@ ${fileParts.join("\n")}` });
6508
6514
  setup(__props, { expose: __expose, emit: __emit }) {
6509
6515
  const props = __props;
6510
6516
  const emit = __emit;
6517
+ function onChildTyping() {
6518
+ followIfPinned();
6519
+ }
6511
6520
  const isEmpty = vue.computed(() => props.messages.length === 0);
6512
6521
  const scrollRef = vue.ref(null);
6513
6522
  function distanceFromBottom() {
@@ -6656,6 +6665,7 @@ ${fileParts.join("\n")}` });
6656
6665
  "user-name": __props.userName,
6657
6666
  "assistant-name": __props.assistantName,
6658
6667
  typing: __props.typing,
6668
+ onTyping: onChildTyping,
6659
6669
  onCopy,
6660
6670
  onRegenerate,
6661
6671
  onBranchChange: onBranch
@@ -7033,6 +7043,7 @@ ${fileParts.join("\n")}` });
7033
7043
  centerWelcome: { type: Boolean, required: false, default: true },
7034
7044
  showScrollButton: { type: Boolean, required: false, default: true },
7035
7045
  scrollButtonThreshold: { type: Number, required: false, default: 100 },
7046
+ scrollThreshold: { type: Number, required: false, default: 100 },
7036
7047
  showUserAvatar: { type: Boolean, required: false, default: true },
7037
7048
  showUserName: { type: Boolean, required: false, default: true },
7038
7049
  showAssistantAvatar: { type: Boolean, required: false, default: true },
@@ -7087,7 +7098,9 @@ ${fileParts.join("\n")}` });
7087
7098
  adapter: resolveAdapter,
7088
7099
  models: () => isMultiple.value && selectedModels.value.length ? selectedModels.value : [""],
7089
7100
  initial: { messages: initialTable, currentId: initialId },
7090
- toolStepLabel: props.toolStepLabel,
7101
+ // 与 adapter/models 同语义按工厂惰性取用:options 在 setup 构造一次,
7102
+ // 按值快照会把父组件运行期更换的函数 prop 冻在旧引用上(换了映射不生效)
7103
+ toolStepLabel: (name) => props.toolStepLabel ? props.toolStepLabel(name) : name,
7091
7104
  onToolEvent: (ev) => emit("tool-event", ev)
7092
7105
  });
7093
7106
  const { send, stop: stopChat, regenerate: regenerateChat, msgs, isLoading } = chat;
@@ -7309,6 +7322,7 @@ ${fileParts.join("\n")}` });
7309
7322
  suggestions: __props.suggestions,
7310
7323
  "show-scroll-button": __props.showScrollButton,
7311
7324
  "scroll-button-threshold": __props.scrollButtonThreshold,
7325
+ "scroll-threshold": __props.scrollThreshold,
7312
7326
  "show-user-avatar": __props.showUserAvatar,
7313
7327
  "show-user-name": __props.showUserName,
7314
7328
  "show-assistant-avatar": __props.showAssistantAvatar,
@@ -7389,7 +7403,7 @@ ${fileParts.join("\n")}` });
7389
7403
  ]),
7390
7404
  key: "8"
7391
7405
  } : void 0
7392
- ]), 1032, ["messages", "nodes", "name", "suggestions", "show-scroll-button", "scroll-button-threshold", "show-user-avatar", "show-user-name", "show-assistant-avatar", "show-assistant-name", "user-avatar", "assistant-avatar", "user-name", "assistant-name", "typing"]),
7406
+ ]), 1032, ["messages", "nodes", "name", "suggestions", "show-scroll-button", "scroll-button-threshold", "scroll-threshold", "show-user-avatar", "show-user-name", "show-assistant-avatar", "show-assistant-name", "user-avatar", "assistant-avatar", "user-name", "assistant-name", "typing"]),
7393
7407
  __props.features?.artifacts && artifacts.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$1, {
7394
7408
  key: 0,
7395
7409
  artifacts: artifacts.value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fv-ui/ai-chat",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "基于 Vue3 + Element Plus 的 AI 对话组件库",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",