@@ -4,7 +4,12 @@ import Browser from 'webextension-polyfill'
4
4
import InputBox from '../InputBox'
5
5
import ConversationItem from '../ConversationItem'
6
6
import { createElementAtPosition , isSafari } from '../../utils'
7
- import { DownloadIcon , LinkExternalIcon , ArchiveIcon } from '@primer/octicons-react'
7
+ import {
8
+ LinkExternalIcon ,
9
+ ArchiveIcon ,
10
+ DesktopDownloadIcon ,
11
+ MoveToBottomIcon ,
12
+ } from '@primer/octicons-react'
8
13
import { WindowDesktop , XLg , Pin } from 'react-bootstrap-icons'
9
14
import FileSaver from 'file-saver'
10
15
import { render } from 'preact'
@@ -73,11 +78,23 @@ function ConversationCard(props) {
73
78
} , [ session , conversationItemData ] )
74
79
75
80
useEffect ( ( ) => {
76
- bodyRef . current . scrollTop = bodyRef . current . scrollHeight
81
+ bodyRef . current . scrollTo ( {
82
+ top : bodyRef . current . scrollHeight ,
83
+ behavior : 'instant' ,
84
+ } )
77
85
} , [ session ] )
78
86
79
87
useEffect ( ( ) => {
80
- if ( config . lockWhenAnswer ) bodyRef . current . scrollTop = bodyRef . current . scrollHeight
88
+ const { offsetHeight, scrollHeight, scrollTop } = bodyRef . current
89
+ if (
90
+ config . lockWhenAnswer &&
91
+ scrollHeight <= scrollTop + offsetHeight + config . answerScrollMargin
92
+ ) {
93
+ bodyRef . current . scrollTo ( {
94
+ top : scrollHeight ,
95
+ behavior : 'smooth' ,
96
+ } )
97
+ }
81
98
} , [ conversationItemData ] )
82
99
83
100
useEffect ( ( ) => {
@@ -361,7 +378,23 @@ function ConversationCard(props) {
361
378
FileSaver . saveAs ( blob , 'conversation.md' )
362
379
} }
363
380
>
364
- < DownloadIcon size = { 16 } />
381
+ < DesktopDownloadIcon size = { 16 } />
382
+ </ span >
383
+ < span >
384
+ { conversationItemData . length > 0 && (
385
+ < span
386
+ title = { t ( 'Jump to bottom' ) }
387
+ className = "gpt-util-icon"
388
+ onClick = { ( ) => {
389
+ bodyRef . current . scrollTo ( {
390
+ top : bodyRef . current . scrollHeight ,
391
+ behavior : 'smooth' ,
392
+ } )
393
+ } }
394
+ >
395
+ < MoveToBottomIcon size = { 16 } />
396
+ </ span >
397
+ ) }
365
398
</ span >
366
399
</ span >
367
400
</ div >
0 commit comments