@townco/ui 0.1.93 → 0.1.97

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.
@@ -309,7 +309,7 @@ export function ChatView({ client, initialSessionId, error: initError, debuggerU
309
309
  .slice(0, index + 1)
310
310
  .filter((m) => m.role === "user").length - 1
311
311
  : -1;
312
- return (_jsx(Message, { message: message, className: cn(spacingClass, "group"), isLastMessage: index === messages.length - 1, children: _jsx("div", { className: "flex flex-col w-full", children: message.role === "user" ? (_jsx(EditableUserMessage, { message: message, messageIndex: userMessageIndex, isStreaming: anyMessageStreaming, onEditAndResend: editAndResend, sticky: true })) : (_jsxs(_Fragment, { children: [
312
+ return (_jsx(Message, { message: message, className: cn(spacingClass, "group"), isLastMessage: index === messages.length - 1, children: _jsx("div", { className: "flex flex-col w-full", children: message.role === "user" ? (_jsx(EditableUserMessage, { message: message, messageIndex: userMessageIndex, isStreaming: anyMessageStreaming, onEditAndResend: editAndResend })) : (_jsxs(_Fragment, { children: [
313
313
  _jsx(MessageContent, { message: message, thinkingDisplayStyle: "collapsible" }), _jsx(MessageActions, { message: message, isStreaming: message.isStreaming, onSendMessage: sendMessage, isLastAssistantMessage: index ===
314
314
  messages.findLastIndex((m) => m.role === "assistant"), onRedo: () => {
315
315
  // Find the user message that preceded this assistant message
@@ -10,9 +10,7 @@ export interface EditableUserMessageProps {
10
10
  mimeType: string;
11
11
  data: string;
12
12
  }>) => void;
13
- /** Whether to make the message content sticky */
14
- sticky?: boolean;
15
13
  }
16
- declare function PureEditableUserMessage({ message, messageIndex, isStreaming, onEditAndResend, sticky }: EditableUserMessageProps): import("react/jsx-runtime").JSX.Element;
14
+ declare function PureEditableUserMessage({ message, messageIndex, isStreaming, onEditAndResend }: EditableUserMessageProps): import("react/jsx-runtime").JSX.Element;
17
15
  export declare const EditableUserMessage: import("react").MemoExoticComponent<typeof PureEditableUserMessage>;
18
16
  export {};
@@ -1,39 +1,16 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Check, Copy, Pencil } from "lucide-react";
4
- import { memo, useCallback, useRef, useState } from "react";
4
+ import { memo, useCallback, useState } from "react";
5
5
  import { toast } from "sonner";
6
6
  import { Action, Actions } from "./Actions.js";
7
7
  import { Button } from "./Button.js";
8
8
  import { MessageContent } from "./MessageContent.js";
9
9
  import { Textarea } from "./Textarea.js";
10
- function PureEditableUserMessage({ message, messageIndex, isStreaming, onEditAndResend, sticky = false, }) {
10
+ function PureEditableUserMessage({ message, messageIndex, isStreaming, onEditAndResend, }) {
11
11
  const [isEditing, setIsEditing] = useState(false);
12
12
  const [editedContent, setEditedContent] = useState(message.content || "");
13
13
  const [isCopied, setIsCopied] = useState(false);
14
- const containerRef = useRef(null);
15
- // Handle clicking the sticky message to scroll back to its position
16
- const handleStickyClick = useCallback(() => {
17
- if (!sticky || !containerRef.current)
18
- return;
19
- // Find the scroll container (parent with overflow-y-auto)
20
- let scrollContainer = containerRef.current.parentElement;
21
- while (scrollContainer &&
22
- !scrollContainer.classList.contains("overflow-y-auto")) {
23
- scrollContainer = scrollContainer.parentElement;
24
- }
25
- if (scrollContainer) {
26
- // Get the element's position relative to the scroll container
27
- const _elementRect = containerRef.current.getBoundingClientRect();
28
- const _containerRect = scrollContainer.getBoundingClientRect();
29
- const elementTop = containerRef.current.offsetTop;
30
- // Scroll so the element is at the top of the container
31
- scrollContainer.scrollTo({
32
- top: elementTop - 16, // Small offset for padding
33
- behavior: "smooth",
34
- });
35
- }
36
- }, [sticky]);
37
14
  const handleCopy = useCallback(async () => {
38
15
  if (!message.content) {
39
16
  toast.error("There's no text to copy!");
@@ -89,14 +66,8 @@ function PureEditableUserMessage({ message, messageIndex, isStreaming, onEditAnd
89
66
  ] })
90
67
  ] }));
91
68
  }
92
- return (_jsxs("div", { ref: containerRef, className: "w-full group/user-message", children: [
93
- _jsx("div", { className: sticky ? "sticky top-0 z-10 bg-background cursor-pointer" : "", onClick: sticky ? handleStickyClick : undefined, onKeyDown: sticky
94
- ? (e) => {
95
- if (e.key === "Enter" || e.key === " ") {
96
- handleStickyClick();
97
- }
98
- }
99
- : undefined, role: sticky ? "button" : undefined, tabIndex: sticky ? 0 : undefined, children: _jsx(MessageContent, { message: message }) }), !isStreaming && message.content && (_jsxs(Actions, { className: "mt-2 opacity-0 group-hover/user-message:opacity-100 transition-opacity", children: [
69
+ return (_jsxs("div", { className: "w-full group/user-message", children: [
70
+ _jsx(MessageContent, { message: message }), !isStreaming && message.content && (_jsxs(Actions, { className: "mt-2 opacity-0 group-hover/user-message:opacity-100 transition-opacity", children: [
100
71
  _jsx(Action, { onClick: handleCopy, tooltip: isCopied ? "Copied!" : "Copy", children: isCopied ? (_jsx(Check, { className: "size-4" })) : (_jsx(Copy, { className: "size-4" })) }), _jsx(Action, { onClick: handleStartEdit, tooltip: "Edit", children: _jsx(Pencil, { className: "size-4" }) })
101
72
  ] }))] }));
102
73
  }
@@ -104,6 +75,5 @@ export const EditableUserMessage = memo(PureEditableUserMessage, (prevProps, nex
104
75
  return (prevProps.isStreaming === nextProps.isStreaming &&
105
76
  prevProps.message.id === nextProps.message.id &&
106
77
  prevProps.message.content === nextProps.message.content &&
107
- prevProps.messageIndex === nextProps.messageIndex &&
108
- prevProps.sticky === nextProps.sticky);
78
+ prevProps.messageIndex === nextProps.messageIndex);
109
79
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@townco/ui",
3
- "version": "0.1.93",
3
+ "version": "0.1.97",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -49,7 +49,7 @@
49
49
  "@radix-ui/react-slot": "^1.2.4",
50
50
  "@radix-ui/react-tabs": "^1.1.13",
51
51
  "@radix-ui/react-tooltip": "^1.2.8",
52
- "@townco/core": "0.0.71",
52
+ "@townco/core": "0.0.75",
53
53
  "@types/mdast": "^4.0.4",
54
54
  "@uiw/react-json-view": "^2.0.0-alpha.39",
55
55
  "class-variance-authority": "^0.7.1",
@@ -67,7 +67,7 @@
67
67
  "zustand": "^5.0.8"
68
68
  },
69
69
  "devDependencies": {
70
- "@townco/tsconfig": "0.1.90",
70
+ "@townco/tsconfig": "0.1.94",
71
71
  "@types/node": "^24.10.0",
72
72
  "@types/react": "^19.2.2",
73
73
  "ink": "^6.4.0",