@@ -113,6 +113,9 @@ const patchedAddMessage = async (message: Message) => {
113113} ;
114114
115115const patchedSendMessage = async ( content : string | any [ ] , providerId : string , modelName : string , options : any = { } ) => {
116+ // 🏆 v0.5.0: 物理级激活调试哨兵
117+ initDebugEventListeners ( ) ;
118+
116119 const store = getStoreAdapter ( ) ;
117120 const settings = useSettingsStore . getState ( ) ;
118121 const threadStore = useThreadStore . getState ( ) ;
@@ -444,11 +447,17 @@ coreUseChatStore.subscribe((state, prevState) => {
444447
445448// 🏆 v0.5.0: DebuggerAgent 实时同步引擎 (强同步初始化)
446449let isDebugInitialized = false ;
447- function initDebugEventListeners ( ) {
450+ export async function initDebugEventListeners ( ) {
448451 if ( isDebugInitialized ) return ;
449- isDebugInitialized = true ;
450452
451- console . log ( '[ChatStore] 📡 Initializing DebuggerAgent Event Listeners (Sync)...' ) ;
453+ // 检查 Tauri 物理环境
454+ if ( typeof window === 'undefined' || ! ( window as any ) . __TAURI_INTERNALS__ ) {
455+ console . warn ( '[ChatStore] 📡 Tauri internals not found, deferring DebuggerAgent initialization.' ) ;
456+ return ;
457+ }
458+
459+ isDebugInitialized = true ;
460+ console . log ( '[ChatStore] 📡 Activating DebuggerAgent Physical Sentry...' ) ;
452461
453462 // 1. 监听步骤开始
454463 listen < { messageId : string ; stepLabel : string ; status ?: string } > ( 'debug:step:start' , ( event ) => {
@@ -479,10 +488,19 @@ function initDebugEventListeners() {
479488 listen < { file : string ; original : string ; modified : string } > ( 'debug:diff:preview' , ( event ) => {
480489 const { file, original, modified } = event . payload ;
481490 const inlineStore = ( window as any ) . __inlineEditStore ;
491+ const fileStore = useFileStore . getState ( ) ;
492+ const rootPath = fileStore . rootPath ;
493+
494+ // 🏆 v0.5.0: 物理级路径纠偏 (Normalize Path)
495+ let normalizedPath = file ;
496+ if ( rootPath && normalizedPath . startsWith ( rootPath ) ) {
497+ normalizedPath = normalizedPath . replace ( rootPath , '' ) . replace ( / ^ \/ + / , '' ) ;
498+ }
499+
482500 if ( inlineStore ) {
483501 inlineStore . setState ( {
484502 isInlineEditVisible : true ,
485- currentFilePath : file ,
503+ currentFilePath : normalizedPath ,
486504 originalCode : original ,
487505 modifiedCode : modified ,
488506 pivoStage : 'implement'
0 commit comments