@@ -41,6 +41,7 @@ import { useAutoAcceptIndicator } from './hooks/useAutoAcceptIndicator.js';
4141import { useGoalActive } from './hooks/useGoalActive.js' ;
4242import { useConsoleMessages } from './hooks/useConsoleMessages.js' ;
4343import { useBackgroundTaskNotifications , formatBackgroundTaskResult } from './hooks/useBackgroundTaskNotifications.js' ;
44+ import { formatClaudeCodeTaskResult } from 'deepv-code-core' ;
4445import { BackgroundTaskPanel } from './components/BackgroundTaskPanel.js' ;
4546import { BackgroundTaskHint } from './components/BackgroundTaskHint.js' ;
4647import { Header } from './components/Header.js' ;
@@ -1486,19 +1487,21 @@ const App = ({ config, settings, startupWarnings = [], version, promptExtensions
14861487 useBackgroundTaskNotifications ( {
14871488 onTaskCompleted : useCallback ( ( task : BackgroundTask ) => {
14881489 console . log ( '[App] Background task completed, adding to history:' , task . id ) ;
1489- const result = formatBackgroundTaskResult ( task ) ;
1490+
1491+ const isClaudeCode = task . kind === 'claude-code' ;
14901492
14911493 // 🎯 使用 tool_group 格式显示任务输出(仿 Claude Code 风格)
1492- // 🔧 截断大型输出,防止 CLI 界面压力过大
14931494 const shortId = task . id ;
14941495 const truncatedOutput = truncateBackgroundTaskOutput ( task . output ) ;
14951496 const toolGroupItem : IndividualToolCallDisplay = {
14961497 callId : `bg-${ task . id } ` ,
1497- name : t ( 'background.task.output' ) ,
1498- toolId : 'background_task_output' ,
1498+ name : isClaudeCode ? 'Claude Code' : t ( 'background.task.output' ) ,
1499+ toolId : isClaudeCode ? 'claude_code_task_output' : 'background_task_output' ,
14991500 description : `${ shortId } ${ task . command } ` ,
1500- resultDisplay : truncatedOutput || `Exit code: ${ task . exitCode ?? 'unknown' } ` ,
1501- status : task . exitCode === 0 ? ToolCallStatus . Success : ToolCallStatus . Error ,
1501+ resultDisplay : isClaudeCode
1502+ ? ( task . answer || truncatedOutput || 'Task completed' )
1503+ : ( truncatedOutput || `Exit code: ${ task . exitCode ?? 'unknown' } ` ) ,
1504+ status : isClaudeCode ? ToolCallStatus . Success : ( task . exitCode === 0 ? ToolCallStatus . Success : ToolCallStatus . Error ) ,
15021505 confirmationDetails : undefined ,
15031506 } ;
15041507 addItem (
@@ -1507,29 +1510,31 @@ const App = ({ config, settings, startupWarnings = [], version, promptExtensions
15071510 ) ;
15081511
15091512 // 🎯 构建通知消息(包含完整的任务信息,供 AI 理解)
1510- const notificationText = `[Easy Code - SYSTEM NOTIFICATION] Background task completed (Task ID: ${ task . id } ). Exit code: ${ task . exitCode ?? 'unknown' } . Output:\n${ task . output ?. substring ( 0 , 1000 ) || '(no output)' } ` ;
1513+ const resultText = isClaudeCode
1514+ ? formatClaudeCodeTaskResult ( task )
1515+ : formatBackgroundTaskResult ( task ) ;
1516+ const notificationText = isClaudeCode
1517+ ? `[Easy Code - SYSTEM NOTIFICATION] Claude Code task completed (Task ID: ${ task . id } ).\n\n${ resultText } `
1518+ : `[Easy Code - SYSTEM NOTIFICATION] Background task completed (Task ID: ${ task . id } ). Exit code: ${ task . exitCode ?? 'unknown' } . Output:\n${ task . output ?. substring ( 0 , 1000 ) || '(no output)' } ` ;
15111519
15121520 // 🎯 如果 AI 当前空闲,自动触发 AI 继续处理(静默模式,不显示用户消息)
15131521 if ( streamingState === StreamingState . Idle ) {
15141522 console . log ( '[App] AI is idle, auto-triggering continuation for background task:' , task . id ) ;
1515- // 直接发送包含完整信息的消息,让 AI 能看到结果
15161523 submitQuery ( notificationText , { silent : true } ) ;
15171524 } else {
1518- // AI 正忙,加入队列等待
15191525 console . log ( '[App] AI is busy, queuing background task notification:' , task . id ) ;
15201526 setPendingBackgroundNotifications ( prev => [ ...prev , notificationText ] ) ;
15211527 }
15221528 } , [ addItem , streamingState , submitQuery ] ) ,
15231529 onTaskFailed : useCallback ( ( task : BackgroundTask ) => {
15241530 console . log ( '[App] Background task failed:' , task . id ) ;
1525- // 🎯 使用 tool_group 格式显示任务失败
1526- // 🔧 截断大型输出,防止 CLI 界面压力过大
1531+ const isClaudeCode = task . kind === 'claude-code' ;
15271532 const shortId = task . id ;
15281533 const truncatedOutput = truncateBackgroundTaskOutput ( task . error || task . output ) ;
15291534 const toolGroupItem : IndividualToolCallDisplay = {
15301535 callId : `bg-${ task . id } ` ,
1531- name : t ( 'background.task.output' ) ,
1532- toolId : 'background_task_output' ,
1536+ name : isClaudeCode ? 'Claude Code' : t ( 'background.task.output' ) ,
1537+ toolId : isClaudeCode ? 'claude_code_task_output' : 'background_task_output' ,
15331538 description : `${ shortId } ${ task . command } ` ,
15341539 resultDisplay : truncatedOutput || 'Unknown error' ,
15351540 status : ToolCallStatus . Error ,
@@ -1541,7 +1546,9 @@ const App = ({ config, settings, startupWarnings = [], version, promptExtensions
15411546 ) ;
15421547
15431548 // 🎯 构建通知消息(包含完整的任务信息,供 AI 理解)
1544- const notificationText = `[System] Background task failed (Task ID: ${ task . id } ). Command: ${ task . command } . Error: ${ task . error || 'Unknown error' } . Output:\n${ task . output ?. substring ( 0 , 1000 ) || '(no output)' } ` ;
1549+ const notificationText = isClaudeCode
1550+ ? `[Easy Code - SYSTEM NOTIFICATION] Claude Code task failed (Task ID: ${ task . id } ).\n\n${ formatClaudeCodeTaskResult ( task ) } `
1551+ : `[System] Background task failed (Task ID: ${ task . id } ). Command: ${ task . command } . Error: ${ task . error || 'Unknown error' } . Output:\n${ task . output ?. substring ( 0 , 1000 ) || '(no output)' } ` ;
15451552
15461553 // 🎯 如果 AI 当前空闲,自动触发 AI 继续处理(静默模式,不显示用户消息)
15471554 if ( streamingState === StreamingState . Idle ) {
0 commit comments