@@ -6,7 +6,7 @@ import { WebSocket, WebSocketServer } from 'ws';
66import { appendAttachmentsToMessageContent , isEmptyContent , MessageRole , MessageKind , type AttachmentInput , type ChatMessage , type MessageContent , writeAttachmentInput } from "scorpio.ai" ;
77import { IChannelService , ChannelSessionHandler , SessionService } from "channel.base" ;
88import { WsCommandType , WebChatEventType , WEB_CHANNEL_ID , WEB_CHANNEL_TYPE } from 'sbot.commons' ;
9- import { database , type ChannelSessionRow , type SessionProfileRow } from "../../Core/Database" ;
9+ import { database , type ChannelSessionRow } from "../../Core/Database" ;
1010import { sessionManager } from "../../Session/SessionManager" ;
1111import { SaverPool } from "../../Agent/SaverPool" ;
1212import { LoggerService } from "../../Core/LoggerService" ;
@@ -80,15 +80,8 @@ export class WebService implements IChannelService {
8080 case WsCommandType . Query : {
8181 const contentCount = Array . isArray ( msg . content ) ? msg . content . length : typeof msg . content === 'string' ? 1 : 0 ;
8282 const attCount = msg . attachments ?. length ?? 0 ;
83- // 客户端(如 vscode 插件)可在每次 Query 携带 workPath,按消息粒度
84- // 覆盖 profile.workPath;vscode 借此免去按 cwd 过滤会话和建会话时绑路径
85- if ( typeof msg . workPath === 'string' && msg . workPath . trim ( ) ) {
86- const profile = await database . findByPk < SessionProfileRow > ( database . sessionProfile , session . profileId ) ;
87- if ( profile && profile . workPath !== msg . workPath ) {
88- await database . update ( database . sessionProfile , { workPath : msg . workPath } , { where : { id : session . profileId } } ) ;
89- logger . debug ( `ws workPath override: profileId=${ session . profileId } "${ profile . workPath ?? '' } " -> "${ msg . workPath } "` ) ;
90- }
91- }
83+ // 客户端(如 vscode 插件)可在每次 Query 携带仅对本轮生效的 workPath。
84+ const workPath = typeof msg . workPath === 'string' && msg . workPath . trim ( ) ? msg . workPath : undefined ;
9285 const enriched = await processMessage ( msg . content ?? '' , msg . attachments , uploadDir ) ;
9386 if ( isEmptyContent ( enriched ) ) {
9487 logger . debug ( `ws query empty: profileId=${ profileId } content=${ contentCount } attachments=${ attCount } ` ) ;
@@ -99,6 +92,7 @@ export class WebService implements IChannelService {
9992 channelId : WEB_CHANNEL_ID ,
10093 dbSessionId : session . id ,
10194 sessionId : channelSessionId ,
95+ workPath,
10296 } ) ;
10397 break ;
10498 }
0 commit comments