@@ -80,6 +80,7 @@ import {
80
80
MAX_RENDER_MSG_COUNT ,
81
81
Path ,
82
82
REQUEST_TIMEOUT_MS ,
83
+ UNFINISHED_INPUT ,
83
84
} from "../constant" ;
84
85
import { Avatar } from "./emoji" ;
85
86
import { ContextPrompts , MaskAvatar , MaskConfig } from "./mask" ;
@@ -935,7 +936,8 @@ function _Chat() {
935
936
936
937
const isTouchTopEdge = e . scrollTop <= edgeThreshold ;
937
938
const isTouchBottomEdge = bottomHeight >= e . scrollHeight - edgeThreshold ;
938
- const isHitBottom = bottomHeight >= e . scrollHeight - ( isMobileScreen ? 0 : 10 ) ;
939
+ const isHitBottom =
940
+ bottomHeight >= e . scrollHeight - ( isMobileScreen ? 0 : 10 ) ;
939
941
940
942
const prevPageMsgIndex = msgRenderIndex - CHAT_PAGE_SIZE ;
941
943
const nextPageMsgIndex = msgRenderIndex + CHAT_PAGE_SIZE ;
@@ -1013,6 +1015,23 @@ function _Chat() {
1013
1015
// edit / insert message modal
1014
1016
const [ isEditingMessage , setIsEditingMessage ] = useState ( false ) ;
1015
1017
1018
+ // remember unfinished input
1019
+ useEffect ( ( ) => {
1020
+ // try to load from local storage
1021
+ const key = UNFINISHED_INPUT ( session . id ) ;
1022
+ const mayBeUnfinishedInput = localStorage . getItem ( key ) ;
1023
+ if ( mayBeUnfinishedInput && userInput . length === 0 ) {
1024
+ setUserInput ( mayBeUnfinishedInput ) ;
1025
+ localStorage . removeItem ( key ) ;
1026
+ }
1027
+
1028
+ const dom = inputRef . current ;
1029
+ return ( ) => {
1030
+ localStorage . setItem ( key , dom ?. value ?? "" ) ;
1031
+ } ;
1032
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1033
+ } , [ ] ) ;
1034
+
1016
1035
return (
1017
1036
< div className = { styles . chat } key = { session . id } >
1018
1037
< div className = "window-header" data-tauri-drag-region >
0 commit comments