@extrachill/chat 0.2.1 → 0.2.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ChatMessages.d.ts","sourceRoot":"","sources":["../../src/components/ChatMessages.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIvF,MAAM,WAAW,iBAAiB;IACjC,wCAAwC;IACxC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,6DAA6D;IAC7D,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,6DAA6D;IAC7D,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC;IAC9E,oEAAoE;IACpE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,0EAA0E;IAC1E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAC5B,QAAQ,EACR,aAAa,EACb,aAAa,EACb,SAAiB,EACjB,SAAS,EACT,UAAiB,EACjB,UAAU,EACV,SAAS,GACT,EAAE,iBAAiB,2CAqDnB"}
1
+ {"version":3,"file":"ChatMessages.d.ts","sourceRoot":"","sources":["../../src/components/ChatMessages.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIvF,MAAM,WAAW,iBAAiB;IACjC,wCAAwC;IACxC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,6DAA6D;IAC7D,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,6DAA6D;IAC7D,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC;IAC9E,oEAAoE;IACpE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,0EAA0E;IAC1E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAC5B,QAAQ,EACR,aAAa,EACb,aAAa,EACb,SAAiB,EACjB,SAAS,EACT,UAAiB,EACjB,UAAU,EACV,SAAS,GACT,EAAE,iBAAiB,2CA0DnB"}
@@ -12,9 +12,14 @@ export function ChatMessages({ messages, contentFormat, renderContent, showTools
12
12
  const bottomRef = useRef(null);
13
13
  const containerRef = useRef(null);
14
14
  useEffect(() => {
15
- if (autoScroll && bottomRef.current) {
16
- bottomRef.current.scrollIntoView({ behavior: 'smooth' });
17
- }
15
+ if (!autoScroll || !containerRef.current)
16
+ return;
17
+ // Scroll within the container, not the whole page.
18
+ const container = containerRef.current;
19
+ container.scrollTo({
20
+ top: container.scrollHeight,
21
+ behavior: 'smooth',
22
+ });
18
23
  }, [messages, autoScroll]);
19
24
  const displayItems = buildDisplayItems(messages, showTools);
20
25
  const baseClass = 'ec-chat-messages';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrachill/chat",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Chat UI components with built-in REST API client. Speaks the standard chat message format natively.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -42,9 +42,14 @@ export function ChatMessages({
42
42
  const containerRef = useRef<HTMLDivElement>(null);
43
43
 
44
44
  useEffect(() => {
45
- if (autoScroll && bottomRef.current) {
46
- bottomRef.current.scrollIntoView({ behavior: 'smooth' });
47
- }
45
+ if (!autoScroll || !containerRef.current) return;
46
+
47
+ // Scroll within the container, not the whole page.
48
+ const container = containerRef.current;
49
+ container.scrollTo({
50
+ top: container.scrollHeight,
51
+ behavior: 'smooth',
52
+ });
48
53
  }, [messages, autoScroll]);
49
54
 
50
55
  const displayItems = buildDisplayItems(messages, showTools);