@@ -7,6 +7,7 @@ import { Chat } from '../chat';
77import { DefaultChatTransport } from 'ai' ;
88import { useCoreStore } from '@/stores/core' ;
99import { useAgentTransitions } from './useAgentTransitions' ;
10+ import { useWindowSize } from '@vueuse/core' ;
1011
1112type AgentMode = {
1213 name : string ;
@@ -48,6 +49,7 @@ export const useAgentStore = defineStore('agent', () => {
4849 const availableModes = ref < AgentMode [ ] > ( [ ] ) ;
4950 const activeModeName = ref < string | null > ( null ) ;
5051 const hasTypedMessageInPageSession = ref ( false ) ;
52+ const { width : windowWidth } = useWindowSize ( ) ;
5153 let placeholderAnimationTimer : ReturnType < typeof setTimeout > | null = null ;
5254
5355 function setLocalStorageItem ( key : string , value : string ) {
@@ -56,6 +58,11 @@ export const useAgentStore = defineStore('agent', () => {
5658 function getLocalStorageItem ( key : string ) {
5759 return window . localStorage . getItem ( `${ coreStore . config . brandName || 'adminforth' } -${ key } ` ) ;
5860 }
61+ watch ( windowWidth , ( newWidth : number ) => {
62+ if ( isFullScreen . value ) {
63+ setChatWidth ( newWidth , false ) ;
64+ }
65+ } )
5966 watch ( isTeleportedToBody , ( newVal : boolean ) => {
6067 setLocalStorageItem ( 'isTeleportedToBody' , newVal ? 'true' : 'false' ) ;
6168 } )
@@ -85,7 +92,14 @@ export const useAgentStore = defineStore('agent', () => {
8592 if ( chatWidthBeforeFullScreen ) {
8693 chatWidth . value = chatWidthBeforeFullScreen ;
8794 } else {
88- chatWidth . value = parseInt ( getLocalStorageItem ( 'chatWidth' ) || DEFAULT_CHAT_WIDTH . toString ( ) , 10 ) ;
95+ const savedChatWidth = parseInt ( getLocalStorageItem ( 'chatWidth' ) || '0' , 10 ) ;
96+ if ( savedChatWidth ) {
97+ if ( savedChatWidth > MAX_WIDTH || savedChatWidth < MIN_WIDTH ) {
98+ chatWidth . value = DEFAULT_CHAT_WIDTH ;
99+ } else {
100+ chatWidth . value = savedChatWidth ;
101+ }
102+ }
89103 }
90104 isTeleportedToBody . value = getLocalStorageItem ( 'isTeleportedToBody' ) === 'true' ;
91105 lastSessionId . value = getLocalStorageItem ( 'lastSessionId' ) ;
0 commit comments