@@ -60,6 +60,10 @@ export const useAgentStore = defineStore('agent', () => {
6060 const activeModeName = ref < string | null > ( null ) ;
6161 const hasTypedMessageInPageSession = ref ( false ) ;
6262 const { width : windowWidth } = useWindowSize ( ) ;
63+
64+ const chats = new Map < string , Chat < any > > ( ) ;
65+ const currentChat = shallowRef < Chat < any > > ( ) ;
66+
6367 let placeholderAnimationTimer : ReturnType < typeof setTimeout > | null = null ;
6468
6569 function setLocalStorageItem ( key : string , value : string ) {
@@ -189,8 +193,6 @@ export const useAgentStore = defineStore('agent', () => {
189193 }
190194 }
191195 } )
192- const chats = new Map < string , Chat < any > > ( ) ;
193- const currentChat = shallowRef < Chat < any > > ( ) ;
194196
195197 function setAvailableModes ( modes : AgentMode [ ] , defaultModeName ?: string | null ) {
196198 availableModes . value = modes ;
@@ -549,14 +551,16 @@ export const useAgentStore = defineStore('agent', () => {
549551 }
550552 currentSession . value = sessions . value [ sessionId ] ;
551553 setCurrentChat ( sessionId ) ;
552- currentChat . value . messages = currentSession . value ?. messages . map ( ( m : any ) => ( {
553- role : m . role ,
554- parts :[ {
555- type : 'text' ,
556- text : m . text ,
557- state : 'done' ,
558- } ]
559- } ) ) ;
554+ if ( currentChat . value . messages . length === 0 ) {
555+ currentChat . value . messages = currentSession . value ?. messages . map ( ( m : any ) => ( {
556+ role : m . role ,
557+ parts :[ {
558+ type : 'text' ,
559+ text : m . text ,
560+ state : 'done' ,
561+ } ]
562+ } ) ) ;
563+ }
560564 }
561565
562566 async function fetchSessionsList ( ) {
0 commit comments