1+ const escapeRegex = ( value ) => value . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) ;
2+
3+ const CHAT_TRANSPORT_MODE_STORAGE_KEY = 'chat.transportMode' ;
4+ const CHAT_TRANSPORT_MODE_WEBSOCKET = 'websocket' ;
5+
6+ const CHAT_TRANSPORT_STORAGE_KEY_PATTERN = escapeRegex ( CHAT_TRANSPORT_MODE_STORAGE_KEY ) ;
7+ const CHAT_TRANSPORT_WEBSOCKET_PATTERN = escapeRegex ( CHAT_TRANSPORT_MODE_WEBSOCKET ) ;
8+
19const DESKTOP_BRIDGE_PATTERNS = {
210 trayRestartGuard : / i f \s * \( \s * ! d e s k t o p B r i d g e \s * \? \. \s * o n T r a y R e s t a r t B a c k e n d \s * \) \s * \{ / ,
311 trayRestartPromptInvoke :
@@ -10,6 +18,12 @@ const DESKTOP_BRIDGE_PATTERNS = {
1018 / c o n s t \s + r u n t i m e I n f o \s * = \s * a w a i t \s + g e t D e s k t o p R u n t i m e I n f o \s * \( \s * \) \s * ; ? [ \s \S ] * ?i s D e s k t o p R e l e a s e M o d e \. v a l u e \s * = \s * r u n t i m e I n f o \. i s D e s k t o p R u n t i m e / ,
1119 desktopReleaseModeFlag : / \b i s D e s k t o p R e l e a s e M o d e \b / ,
1220 desktopRuntimeProbeWarn : / c o n s o l e \. w a r n \( [ \s \S ] * d e s k t o p r u n t i m e / i,
21+ chatTransportPreferenceRead : new RegExp (
22+ `localStorage\\.getItem\\(["']${ CHAT_TRANSPORT_STORAGE_KEY_PATTERN } ["']\\)[\\s\\S]*?["']${ CHAT_TRANSPORT_WEBSOCKET_PATTERN } ["']` ,
23+ ) ,
24+ chatTransportPreferenceWrite : new RegExp (
25+ `localStorage\\.setItem\\(["']${ CHAT_TRANSPORT_STORAGE_KEY_PATTERN } ["']\\s*,` ,
26+ ) ,
1327} ;
1428
1529const DESKTOP_BRIDGE_EXPECTATIONS = [
@@ -62,6 +76,29 @@ const DESKTOP_BRIDGE_EXPECTATIONS = [
6276 hint : 'Expected warning log when desktop runtime detection fails.' ,
6377 required : false ,
6478 } ,
79+ {
80+ filePath : [ 'src' , 'components' , 'chat' , 'Chat.vue' ] ,
81+ pattern : DESKTOP_BRIDGE_PATTERNS . chatTransportPreferenceRead ,
82+ label : 'chat transport preference read' ,
83+ hint :
84+ 'Expected chat UI to read localStorage["chat.transportMode"] and recognize "websocket".' ,
85+ required : true ,
86+ } ,
87+ {
88+ filePath : [ 'src' , 'components' , 'chat' , 'Chat.vue' ] ,
89+ pattern : DESKTOP_BRIDGE_PATTERNS . chatTransportPreferenceWrite ,
90+ label : 'chat transport preference write' ,
91+ hint : 'Expected chat UI to persist transport mode via localStorage.setItem("chat.transportMode", ...).' ,
92+ required : true ,
93+ } ,
94+ {
95+ filePath : [ 'src' , 'components' , 'chat' , 'StandaloneChat.vue' ] ,
96+ pattern : DESKTOP_BRIDGE_PATTERNS . chatTransportPreferenceRead ,
97+ label : 'standalone chat transport preference read' ,
98+ hint :
99+ 'Expected standalone chat UI to read localStorage["chat.transportMode"] and recognize "websocket".' ,
100+ required : true ,
101+ } ,
65102] ;
66103
67104export const getDesktopBridgeExpectations = ( ) => [ ...DESKTOP_BRIDGE_EXPECTATIONS ] ;
0 commit comments