@blade-hq/agent-react 2610.0.0-beta.13 → 2610.0.0-beta.15

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.js CHANGED
@@ -1103,7 +1103,7 @@ function ConnectionBanner({ connection, className }) {
1103
1103
 
1104
1104
  // src/components/MessageList.tsx
1105
1105
  import { isHiddenInternalMessage } from "@blade-hq/agent-client";
1106
- import { useCallback as useCallback6, useEffect as useEffect8, useMemo as useMemo7, useRef as useRef8, useState as useState12 } from "react";
1106
+ import { useCallback as useCallback6, useEffect as useEffect8, useMemo as useMemo7, useRef as useRef9, useState as useState12 } from "react";
1107
1107
 
1108
1108
  // ../../node_modules/.pnpm/use-stick-to-bottom@1.1.3_react@19.2.4/node_modules/use-stick-to-bottom/dist/useStickToBottom.js
1109
1109
  import { useCallback as useCallback3, useMemo as useMemo3, useRef as useRef4, useState as useState5 } from "react";
@@ -1816,8 +1816,37 @@ function Shimmer({ children = "\u6B63\u5728\u601D\u8003...", className }) {
1816
1816
  import { useState as useState9 } from "react";
1817
1817
 
1818
1818
  // src/components/AskUserQuestionBlock.tsx
1819
- import { useEffect as useEffect6, useMemo as useMemo6, useState as useState8 } from "react";
1819
+ import { useEffect as useEffect6, useMemo as useMemo6, useRef as useRef7, useState as useState8 } from "react";
1820
1820
  import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
1821
+ var CUSTOM_TEXTAREA_MAX_HEIGHT = 160;
1822
+ function resizeCustomTextarea(textarea) {
1823
+ textarea.style.height = "auto";
1824
+ textarea.style.height = `${Math.min(textarea.scrollHeight, CUSTOM_TEXTAREA_MAX_HEIGHT)}px`;
1825
+ textarea.style.overflowY = textarea.scrollHeight > CUSTOM_TEXTAREA_MAX_HEIGHT ? "auto" : "hidden";
1826
+ }
1827
+ function useAutoResizeTextarea(value) {
1828
+ const textareaRef = useRef7(null);
1829
+ useEffect6(() => {
1830
+ const textarea = textareaRef.current;
1831
+ if (textarea?.value === value) resizeCustomTextarea(textarea);
1832
+ }, [value]);
1833
+ useEffect6(() => {
1834
+ const textarea = textareaRef.current;
1835
+ if (!textarea || typeof ResizeObserver === "undefined") return;
1836
+ let previousWidth = textarea.clientWidth;
1837
+ const observer = new ResizeObserver(([entry]) => {
1838
+ if (!entry || entry.contentRect.width === previousWidth) return;
1839
+ previousWidth = entry.contentRect.width;
1840
+ resizeCustomTextarea(textarea);
1841
+ });
1842
+ observer.observe(textarea);
1843
+ return () => observer.disconnect();
1844
+ }, []);
1845
+ return textareaRef;
1846
+ }
1847
+ function indentAnswerContinuationLines(answer) {
1848
+ return answer.replaceAll("\n", "\n ");
1849
+ }
1821
1850
  function AskUserQuestionBlock({
1822
1851
  data,
1823
1852
  answered,
@@ -1914,7 +1943,9 @@ function AskUserQuestionBlock({
1914
1943
  Array.from(usingCustom).map((qIdx) => [qIdx, (customTexts.get(qIdx) ?? "").trim()]).filter(([, text2]) => text2.length > 0)
1915
1944
  )
1916
1945
  };
1917
- const parts = data.questions.map((q, i) => `- ${q.question} -> ${getAnswer(i)}`);
1946
+ const parts = data.questions.map(
1947
+ (q, i) => `- ${q.question} -> ${indentAnswerContinuationLines(getAnswer(i) ?? "")}`
1948
+ );
1918
1949
  const text = `\u5173\u4E8E\u9700\u8981\u786E\u8BA4\u7684\u95EE\u9898\uFF0C\u7528\u6237\u7684\u56DE\u7B54\u5982\u4E0B\uFF1A
1919
1950
  ${parts.join("\n")}`;
1920
1951
  setSubmitted(true);
@@ -1986,6 +2017,7 @@ function QuestionCard({
1986
2017
  onCustomChange
1987
2018
  }) {
1988
2019
  const multi = question.multiSelect ?? false;
2020
+ const customTextareaRef = useAutoResizeTextarea(customText);
1989
2021
  return /* @__PURE__ */ jsxs7("div", { children: [
1990
2022
  /* @__PURE__ */ jsxs7("div", { className: cn("flex items-start gap-2", answered ? "mb-2" : "mb-3"), children: [
1991
2023
  /* @__PURE__ */ jsx9(
@@ -2062,25 +2094,26 @@ function QuestionCard({
2062
2094
  "div",
2063
2095
  {
2064
2096
  className: cn(
2065
- "flex items-center gap-2 rounded-lg border transition-all",
2097
+ "flex items-start gap-2 rounded-lg border transition-all focus-within:ring-2 focus-within:ring-[hsl(var(--ring)/0.35)]",
2066
2098
  answered ? "px-2.5 py-1.5" : "px-3 py-2.5",
2067
2099
  isCustom ? "border-[hsl(var(--ring)/0.6)] bg-[hsl(var(--accent))]" : "border-[hsl(var(--border))] hover:border-[hsl(var(--ring)/0.3)] hover:bg-[hsl(var(--accent))]",
2068
2100
  answered && "cursor-default opacity-70"
2069
2101
  ),
2070
2102
  children: [
2071
- /* @__PURE__ */ jsx9("span", { className: "shrink-0 text-xs text-[hsl(var(--muted-foreground))]", children: "\u5176\u4ED6\uFF1A" }),
2103
+ /* @__PURE__ */ jsx9("span", { className: "shrink-0 pt-1 text-xs text-[hsl(var(--muted-foreground))]", children: "\u5176\u4ED6\uFF1A" }),
2072
2104
  /* @__PURE__ */ jsx9(
2073
- "input",
2105
+ "textarea",
2074
2106
  {
2075
- type: "text",
2107
+ ref: customTextareaRef,
2108
+ rows: 2,
2076
2109
  value: customText,
2077
- disabled: answered,
2110
+ readOnly: answered,
2078
2111
  onChange: (e) => onCustomChange(qIdx, e.target.value),
2079
2112
  onFocus: () => onCustomFocus(qIdx),
2080
2113
  "aria-label": "\u81EA\u5B9A\u4E49\u56DE\u7B54",
2081
2114
  placeholder: "\u8F93\u5165\u4F60\u7684\u7B54\u6848...",
2082
2115
  className: cn(
2083
- "min-w-0 flex-1 bg-transparent text-[hsl(var(--foreground))] outline-none placeholder:text-[hsl(var(--muted-foreground)/0.5)]",
2116
+ "min-h-10 min-w-0 flex-1 resize-none bg-transparent leading-5 text-[hsl(var(--foreground))] outline-none placeholder:text-[hsl(var(--muted-foreground)/0.5)]",
2084
2117
  answered ? "text-xs" : "text-sm"
2085
2118
  )
2086
2119
  }
@@ -2411,7 +2444,7 @@ var RenderErrorBoundary = class extends Component {
2411
2444
  };
2412
2445
 
2413
2446
  // src/components/PostChatFollowupBlock.tsx
2414
- import { useCallback as useCallback5, useEffect as useEffect7, useRef as useRef7, useState as useState11 } from "react";
2447
+ import { useCallback as useCallback5, useEffect as useEffect7, useRef as useRef8, useState as useState11 } from "react";
2415
2448
  import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
2416
2449
  function emitInteraction(callback, event) {
2417
2450
  try {
@@ -2542,8 +2575,8 @@ function ResultFeedback({
2542
2575
  const [reason, setReason] = useState11(savedFeedback?.reason ?? null);
2543
2576
  const [saving, setSaving] = useState11(false);
2544
2577
  const [saveError, setSaveError] = useState11(false);
2545
- const reportedShown = useRef7(false);
2546
- const latestChoice = useRef7(null);
2578
+ const reportedShown = useRef8(false);
2579
+ const latestChoice = useRef8(null);
2547
2580
  const eligible = followup.feedback_eligible === true && Boolean(sessionId) && !isViewer;
2548
2581
  useEffect7(() => {
2549
2582
  if (!eligible || reportedShown.current) return;
@@ -2667,10 +2700,10 @@ function PostChatFollowupBlock({
2667
2700
  onFeedbackSaved
2668
2701
  }) {
2669
2702
  const [expanded, setExpanded] = useState11(false);
2670
- const adopted = useRef7(/* @__PURE__ */ new Set());
2671
- const reportedSuggestions = useRef7(false);
2672
- const reportedArtifacts = useRef7(/* @__PURE__ */ new Set());
2673
- const openedArtifacts = useRef7(/* @__PURE__ */ new Set());
2703
+ const adopted = useRef8(/* @__PURE__ */ new Set());
2704
+ const reportedSuggestions = useRef8(false);
2705
+ const reportedArtifacts = useRef8(/* @__PURE__ */ new Set());
2706
+ const openedArtifacts = useRef8(/* @__PURE__ */ new Set());
2674
2707
  const artifacts = followup.final_artifacts ?? [];
2675
2708
  const visibleArtifacts = expanded ? artifacts : artifacts.slice(0, 3);
2676
2709
  useEffect7(() => {
@@ -3047,7 +3080,7 @@ function MessageList({
3047
3080
  }
3048
3081
  function AutoScrollOnUserSend({ userMessageCount }) {
3049
3082
  const { scrollToBottom } = useStickToBottomContext();
3050
- const previousCountRef = useRef8(userMessageCount);
3083
+ const previousCountRef = useRef9(userMessageCount);
3051
3084
  useEffect8(() => {
3052
3085
  if (userMessageCount > previousCountRef.current) {
3053
3086
  scrollToBottom("instant");
@@ -3059,7 +3092,7 @@ function AutoScrollOnUserSend({ userMessageCount }) {
3059
3092
  function ScrollToBottomButton() {
3060
3093
  const { isAtBottom, scrollToBottom } = useStickToBottomContext();
3061
3094
  const [visible, setVisible] = useState12(false);
3062
- const hideTimerRef = useRef8(null);
3095
+ const hideTimerRef = useRef9(null);
3063
3096
  useEffect8(() => {
3064
3097
  if (isAtBottom) {
3065
3098
  if (!hideTimerRef.current) {