@helpai/elements 0.51.5 → 0.51.7

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/index.mjs CHANGED
@@ -29,7 +29,7 @@ var BRAND = {
29
29
  };
30
30
 
31
31
  // src/core/version.ts
32
- var ELEMENTS_VERSION = true ? "0.51.5" : "0.0.0-dev";
32
+ var ELEMENTS_VERSION = true ? "0.51.7" : "0.0.0-dev";
33
33
  var ELEMENTS_VERSION_PARAM = "_ev";
34
34
 
35
35
  // src/i18n/strings.ts
@@ -2840,6 +2840,9 @@ function wireHasNoVisibleAnswer(w) {
2840
2840
  function isResumeOwnedWireTurn(w) {
2841
2841
  return w.role === "assistant" && w.status != null && !TERMINAL_WIRE_STATUS.has(w.status) && wireHasNoVisibleAnswer(w);
2842
2842
  }
2843
+ function hydrateWireMessages(messages) {
2844
+ return messages.filter((w) => !isResumeOwnedWireTurn(w)).map(fromWireMessage);
2845
+ }
2843
2846
  function fromReactive(m) {
2844
2847
  return {
2845
2848
  id: m.id,
@@ -6015,12 +6018,17 @@ function MessageList({
6015
6018
  return () => obs.disconnect();
6016
6019
  }, [messages.value]);
6017
6020
  const activeFormId = form?.form.id;
6021
+ const inlineForm = !!form && (formMarkers ?? []).some((m) => m.formId === form.form.id);
6018
6022
  useLayoutEffect2(() => {
6019
6023
  const el = ref.current;
6020
6024
  if (!el || !activeFormId || detachedRef.current) return;
6021
6025
  if (!messages.value.some((m) => m.role === "user")) return;
6022
- pinBottom(el);
6023
- }, [activeFormId]);
6026
+ if (inlineForm) {
6027
+ el.querySelector(`[data-testid="${TID.formGate}"]`)?.scrollIntoView({ block: "nearest" });
6028
+ } else {
6029
+ pinBottom(el);
6030
+ }
6031
+ }, [activeFormId, inlineForm]);
6024
6032
  useEffect7(() => {
6025
6033
  const el = ref.current;
6026
6034
  if (!el) return;
@@ -6093,15 +6101,29 @@ function MessageList({
6093
6101
  const pendingMarkers = [...formMarkers ?? []].toSorted(
6094
6102
  (a, b) => (a.createdAt ?? Infinity) - (b.createdAt ?? Infinity)
6095
6103
  );
6096
- const markerRow = (marker) => /* @__PURE__ */ jsx19(
6097
- FormDoneMarker,
6098
- {
6099
- marker,
6100
- strings,
6101
- onFill: !form && onFillForm ? () => onFillForm(marker.formId) : void 0
6102
- },
6103
- marker.key
6104
- );
6104
+ const markerRow = (marker) => {
6105
+ if (form && marker.formId === form.form.id) {
6106
+ return /* @__PURE__ */ jsx19(
6107
+ FormGate,
6108
+ {
6109
+ form: form.form,
6110
+ strings,
6111
+ onSubmit: form.onSubmit,
6112
+ onSkip: form.onSkip
6113
+ },
6114
+ `gate:${marker.formId}`
6115
+ );
6116
+ }
6117
+ return /* @__PURE__ */ jsx19(
6118
+ FormDoneMarker,
6119
+ {
6120
+ marker,
6121
+ strings,
6122
+ onFill: !form && onFillForm ? () => onFillForm(marker.formId) : void 0
6123
+ },
6124
+ marker.key
6125
+ );
6126
+ };
6105
6127
  const flushMarkersBefore = (createdAt) => {
6106
6128
  for (let next = pendingMarkers[0]; next?.createdAt !== void 0; next = pendingMarkers[0]) {
6107
6129
  if (createdAt !== void 0 && next.createdAt > createdAt) break;
@@ -6154,7 +6176,7 @@ function MessageList({
6154
6176
  children: [
6155
6177
  loading && messages.value.length === 0 ? /* @__PURE__ */ jsx19("div", { class: `${p18}-list-loading`, role: "status", children: strings.conversationLoading }) : null,
6156
6178
  rows,
6157
- form ? /* @__PURE__ */ jsx19(FormGate, { form: form.form, strings, onSubmit: form.onSubmit, onSkip: form.onSkip }) : null
6179
+ form && !inlineForm ? /* @__PURE__ */ jsx19(FormGate, { form: form.form, strings, onSubmit: form.onSubmit, onSkip: form.onSkip }) : null
6158
6180
  ]
6159
6181
  }
6160
6182
  ),
@@ -7776,7 +7798,7 @@ function App({ options, hostElement, bus }) {
7776
7798
  try {
7777
7799
  const [chat, markers] = await Promise.all([transport.loadConversation(conversationId), fetchFormMarkers()]);
7778
7800
  if (isStale()) return;
7779
- const loaded = (chat.messages ?? []).filter((w) => !isResumeOwnedWireTurn(w)).map(fromWireMessage);
7801
+ const loaded = hydrateWireMessages(chat.messages ?? []);
7780
7802
  setFormMarkers(markers);
7781
7803
  const tail = resumeBubbleRef.current ? [resumeBubbleRef.current] : [];
7782
7804
  if (loaded.length || tail.length) {
@@ -8490,7 +8512,7 @@ function App({ options, hostElement, bus }) {
8490
8512
  transport.loadConversation(targetConversationId),
8491
8513
  fetchFormMarkers(targetConversationId)
8492
8514
  ]);
8493
- const hydrated = res.messages.filter((w) => !isResumeOwnedWireTurn(w)).map(fromWireMessage);
8515
+ const hydrated = hydrateWireMessages(res.messages);
8494
8516
  batch(() => {
8495
8517
  messagesSig.value = withWelcomeRows(hydrated, markers);
8496
8518
  conversationIdSig.value = res.conversationId;
package/package.json CHANGED
@@ -80,5 +80,5 @@
80
80
  ],
81
81
  "type": "module",
82
82
  "types": "./index.d.ts",
83
- "version": "0.51.5"
83
+ "version": "0.51.7"
84
84
  }
package/web-component.mjs CHANGED
@@ -1794,7 +1794,7 @@ function createAuth(opts) {
1794
1794
  }
1795
1795
 
1796
1796
  // src/core/version.ts
1797
- var ELEMENTS_VERSION = true ? "0.51.5" : "0.0.0-dev";
1797
+ var ELEMENTS_VERSION = true ? "0.51.7" : "0.0.0-dev";
1798
1798
  var ELEMENTS_VERSION_PARAM = "_ev";
1799
1799
 
1800
1800
  // src/stream/types.ts
@@ -2799,6 +2799,9 @@ function wireHasNoVisibleAnswer(w) {
2799
2799
  function isResumeOwnedWireTurn(w) {
2800
2800
  return w.role === "assistant" && w.status != null && !TERMINAL_WIRE_STATUS.has(w.status) && wireHasNoVisibleAnswer(w);
2801
2801
  }
2802
+ function hydrateWireMessages(messages) {
2803
+ return messages.filter((w) => !isResumeOwnedWireTurn(w)).map(fromWireMessage);
2804
+ }
2802
2805
  function fromReactive(m) {
2803
2806
  return {
2804
2807
  id: m.id,
@@ -5974,12 +5977,17 @@ function MessageList({
5974
5977
  return () => obs.disconnect();
5975
5978
  }, [messages.value]);
5976
5979
  const activeFormId = form?.form.id;
5980
+ const inlineForm = !!form && (formMarkers ?? []).some((m) => m.formId === form.form.id);
5977
5981
  useLayoutEffect2(() => {
5978
5982
  const el = ref.current;
5979
5983
  if (!el || !activeFormId || detachedRef.current) return;
5980
5984
  if (!messages.value.some((m) => m.role === "user")) return;
5981
- pinBottom(el);
5982
- }, [activeFormId]);
5985
+ if (inlineForm) {
5986
+ el.querySelector(`[data-testid="${TID.formGate}"]`)?.scrollIntoView({ block: "nearest" });
5987
+ } else {
5988
+ pinBottom(el);
5989
+ }
5990
+ }, [activeFormId, inlineForm]);
5983
5991
  useEffect7(() => {
5984
5992
  const el = ref.current;
5985
5993
  if (!el) return;
@@ -6052,15 +6060,29 @@ function MessageList({
6052
6060
  const pendingMarkers = [...formMarkers ?? []].toSorted(
6053
6061
  (a, b) => (a.createdAt ?? Infinity) - (b.createdAt ?? Infinity)
6054
6062
  );
6055
- const markerRow = (marker) => /* @__PURE__ */ jsx19(
6056
- FormDoneMarker,
6057
- {
6058
- marker,
6059
- strings,
6060
- onFill: !form && onFillForm ? () => onFillForm(marker.formId) : void 0
6061
- },
6062
- marker.key
6063
- );
6063
+ const markerRow = (marker) => {
6064
+ if (form && marker.formId === form.form.id) {
6065
+ return /* @__PURE__ */ jsx19(
6066
+ FormGate,
6067
+ {
6068
+ form: form.form,
6069
+ strings,
6070
+ onSubmit: form.onSubmit,
6071
+ onSkip: form.onSkip
6072
+ },
6073
+ `gate:${marker.formId}`
6074
+ );
6075
+ }
6076
+ return /* @__PURE__ */ jsx19(
6077
+ FormDoneMarker,
6078
+ {
6079
+ marker,
6080
+ strings,
6081
+ onFill: !form && onFillForm ? () => onFillForm(marker.formId) : void 0
6082
+ },
6083
+ marker.key
6084
+ );
6085
+ };
6064
6086
  const flushMarkersBefore = (createdAt) => {
6065
6087
  for (let next = pendingMarkers[0]; next?.createdAt !== void 0; next = pendingMarkers[0]) {
6066
6088
  if (createdAt !== void 0 && next.createdAt > createdAt) break;
@@ -6113,7 +6135,7 @@ function MessageList({
6113
6135
  children: [
6114
6136
  loading && messages.value.length === 0 ? /* @__PURE__ */ jsx19("div", { class: `${p18}-list-loading`, role: "status", children: strings.conversationLoading }) : null,
6115
6137
  rows,
6116
- form ? /* @__PURE__ */ jsx19(FormGate, { form: form.form, strings, onSubmit: form.onSubmit, onSkip: form.onSkip }) : null
6138
+ form && !inlineForm ? /* @__PURE__ */ jsx19(FormGate, { form: form.form, strings, onSubmit: form.onSubmit, onSkip: form.onSkip }) : null
6117
6139
  ]
6118
6140
  }
6119
6141
  ),
@@ -7735,7 +7757,7 @@ function App({ options, hostElement, bus }) {
7735
7757
  try {
7736
7758
  const [chat, markers] = await Promise.all([transport.loadConversation(conversationId), fetchFormMarkers()]);
7737
7759
  if (isStale()) return;
7738
- const loaded = (chat.messages ?? []).filter((w) => !isResumeOwnedWireTurn(w)).map(fromWireMessage);
7760
+ const loaded = hydrateWireMessages(chat.messages ?? []);
7739
7761
  setFormMarkers(markers);
7740
7762
  const tail = resumeBubbleRef.current ? [resumeBubbleRef.current] : [];
7741
7763
  if (loaded.length || tail.length) {
@@ -8449,7 +8471,7 @@ function App({ options, hostElement, bus }) {
8449
8471
  transport.loadConversation(targetConversationId),
8450
8472
  fetchFormMarkers(targetConversationId)
8451
8473
  ]);
8452
- const hydrated = res.messages.filter((w) => !isResumeOwnedWireTurn(w)).map(fromWireMessage);
8474
+ const hydrated = hydrateWireMessages(res.messages);
8453
8475
  batch(() => {
8454
8476
  messagesSig.value = withWelcomeRows(hydrated, markers);
8455
8477
  conversationIdSig.value = res.conversationId;