@usecrow/ui 0.1.37 → 0.1.39

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 CHANGED
@@ -164,11 +164,13 @@ function useChat({
164
164
  const reader = response.body?.getReader();
165
165
  const decoder = new TextDecoder();
166
166
  if (reader) {
167
+ let buffer = "";
167
168
  while (true) {
168
169
  const { done, value } = await reader.read();
169
170
  if (done) break;
170
- const chunk = decoder.decode(value);
171
- const lines = chunk.split("\n");
171
+ buffer += decoder.decode(value, { stream: true });
172
+ const lines = buffer.split("\n");
173
+ buffer = lines.pop() || "";
172
174
  for (const line of lines) {
173
175
  if (line.startsWith("data: ")) {
174
176
  const data = line.slice(6).trim();
@@ -275,6 +277,7 @@ function useChat({
275
277
  const newToolCall = {
276
278
  id: `tool-${Date.now()}`,
277
279
  name: parsed.tool_name,
280
+ displayName: parsed.display_name || void 0,
278
281
  arguments: parsed.arguments || {},
279
282
  status: "executing",
280
283
  timestamp: /* @__PURE__ */ new Date()
@@ -349,6 +352,7 @@ function useChat({
349
352
  const clientToolCall = {
350
353
  id: `tool-${Date.now()}`,
351
354
  name: parsed.tool_name,
355
+ displayName: parsed.display_name || void 0,
352
356
  arguments: parsed.arguments || {},
353
357
  status: "executing",
354
358
  timestamp: /* @__PURE__ */ new Date()
@@ -517,11 +521,13 @@ function useChat({
517
521
  const decoder = new TextDecoder();
518
522
  let accumulatedText = "";
519
523
  if (reader) {
524
+ let buffer = "";
520
525
  while (true) {
521
526
  const { done, value } = await reader.read();
522
527
  if (done) break;
523
- const chunk = decoder.decode(value);
524
- const lines = chunk.split("\n");
528
+ buffer += decoder.decode(value, { stream: true });
529
+ const lines = buffer.split("\n");
530
+ buffer = lines.pop() || "";
525
531
  for (const line of lines) {
526
532
  if (line.startsWith("data: ")) {
527
533
  const data = line.slice(6).trim();
@@ -662,6 +668,7 @@ function useConversations({ productId, apiUrl = "" }) {
662
668
  toolCalls: msg.tool_calls?.map((tc, i) => ({
663
669
  id: `history-tool-${idx}-${i}`,
664
670
  name: tc.name,
671
+ displayName: tc.display_name || void 0,
665
672
  arguments: tc.arguments || {},
666
673
  status: tc.status,
667
674
  timestamp: /* @__PURE__ */ new Date()
@@ -699,6 +706,7 @@ function useConversations({ productId, apiUrl = "" }) {
699
706
  toolCalls: msg.tool_calls?.map((tc, i) => ({
700
707
  id: `history-tool-${idx}-${i}`,
701
708
  name: tc.name,
709
+ displayName: tc.display_name || void 0,
702
710
  arguments: tc.arguments || {},
703
711
  status: tc.status,
704
712
  timestamp: /* @__PURE__ */ new Date()
@@ -1950,7 +1958,7 @@ function ToolCallBlock({
1950
1958
  isExecuting && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "crow-w-3 crow-h-3 crow-animate-spin crow-text-blue-500" }),
1951
1959
  isComplete && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "crow-w-3 crow-h-3 crow-text-green-500" }),
1952
1960
  isError && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "crow-w-3 crow-h-3 crow-text-red-500", children: "\u2715" }),
1953
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "crow-font-medium", children: toolCall.name }),
1961
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "crow-font-medium", children: toolCall.displayName || toolCall.name }),
1954
1962
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "crow-text-gray-400", children: [
1955
1963
  isExecuting && "running...",
1956
1964
  isComplete && "done",