@@ -1341,6 +1341,46 @@ test('submitTaskOrchestrationChatMessage treats /plan as chat preview command',
13411341 assert . deepStrictEqual ( previewCalls , [ { silent : false } , { silent : false } ] ) ;
13421342} ) ;
13431343
1344+ test ( 'submitTaskOrchestrationChatMessage clears stale failed run detail before /plan preview' , async ( ) => {
1345+ const methods = createTaskOrchestrationMethods ( { api : async ( ) => ( { } ) } ) ;
1346+ const context = {
1347+ ensureTaskOrchestrationState : methods . ensureTaskOrchestrationState ,
1348+ appendTaskChatMessage : methods . appendTaskChatMessage ,
1349+ previewTaskPlan ( options ) {
1350+ const state = this . ensureTaskOrchestrationState ( ) ;
1351+ assert . strictEqual ( state . selectedRunId , '' ) ;
1352+ assert . strictEqual ( state . selectedRunDetail , null ) ;
1353+ assert . strictEqual ( state . selectedRunError , '' ) ;
1354+ assert . strictEqual ( state . workspaceTab , 'queue' ) ;
1355+ return Promise . resolve ( { ok : true , options } ) ;
1356+ } ,
1357+ showMessage ( message , tone ) {
1358+ throw new Error ( `unexpected message: ${ tone } :${ message } ` ) ;
1359+ } ,
1360+ taskOrchestration : {
1361+ chatDraft : '/plan Fix the orchestration preview' ,
1362+ target : '' ,
1363+ followUpsText : '' ,
1364+ selectedEngine : 'openai-chat' ,
1365+ runMode : 'write' ,
1366+ plan : null ,
1367+ planFingerprint : '' ,
1368+ planIssues : [ ] ,
1369+ planWarnings : [ ] ,
1370+ selectedRunId : 'run-failed' ,
1371+ selectedRunDetail : { run : { status : 'failed' , summary : '前置节点失败,已阻塞' } } ,
1372+ selectedRunError : '前置节点失败,已阻塞' ,
1373+ workspaceTab : 'detail' ,
1374+ lastError : ''
1375+ }
1376+ } ;
1377+
1378+ const result = await methods . submitTaskOrchestrationChatMessage . call ( context ) ;
1379+
1380+ assert . deepStrictEqual ( result , { ok : true , options : { silent : false } } ) ;
1381+ assert . strictEqual ( context . taskOrchestration . target , 'Fix the orchestration preview' ) ;
1382+ } ) ;
1383+
13441384test ( 'previewTaskPlan sends previewOnly without mutating normal run semantics' , async ( ) => {
13451385 const apiCalls = [ ] ;
13461386 const methods = createTaskOrchestrationMethods ( {
@@ -1564,6 +1604,55 @@ test('taskOrchestrationActiveQueue hides completed and failed queue history from
15641604 assert . deepStrictEqual ( activeQueue , [ queued , running , runStatusOnly ] ) ;
15651605} ) ;
15661606
1607+ test ( 'taskOrchestrationWorkbenchVisible ignores passive failed run history' , ( ) => {
1608+ const computed = createMainTabsComputed ( ) ;
1609+ const context = {
1610+ taskOrchestrationActiveQueue : [ ] ,
1611+ taskOrchestration : {
1612+ runs : [
1613+ { runId : 'run-failed' , status : 'failed' , summary : '前置节点失败,已阻塞' }
1614+ ] ,
1615+ selectedRunId : '' ,
1616+ selectedRunError : ''
1617+ }
1618+ } ;
1619+
1620+ assert . strictEqual ( computed . taskOrchestrationWorkbenchVisible . call ( context ) , false ) ;
1621+
1622+ context . taskOrchestration . selectedRunId = 'run-failed' ;
1623+ assert . strictEqual ( computed . taskOrchestrationWorkbenchVisible . call ( context ) , true ) ;
1624+ } ) ;
1625+
1626+ test ( 'loadTaskOrchestrationOverview does not auto-select latest failed run history' , async ( ) => {
1627+ const methods = createTaskOrchestrationMethods ( {
1628+ api : async ( name ) => {
1629+ assert . strictEqual ( name , 'task-overview' ) ;
1630+ return {
1631+ runs : [ { runId : 'run-failed' , status : 'failed' , summary : '前置节点失败,已阻塞' } ] ,
1632+ queue : [ ] ,
1633+ workflows : [ ] ,
1634+ warnings : [ ]
1635+ } ;
1636+ }
1637+ } ) ;
1638+ const context = {
1639+ ensureTaskOrchestrationState : methods . ensureTaskOrchestrationState ,
1640+ loadTaskRunDetail ( ) {
1641+ throw new Error ( 'should not load detail for passive history' ) ;
1642+ } ,
1643+ isTaskRunActive : ( ) => false ,
1644+ showMessage ( ) { } ,
1645+ syncTaskOrchestrationPolling ( ) { }
1646+ } ;
1647+ context . taskOrchestration = methods . ensureTaskOrchestrationState . call ( context ) ;
1648+
1649+ await methods . loadTaskOrchestrationOverview . call ( context , { silent : true , includeDetail : false } ) ;
1650+
1651+ assert . strictEqual ( context . taskOrchestration . runs . length , 1 ) ;
1652+ assert . strictEqual ( context . taskOrchestration . selectedRunId , '' ) ;
1653+ assert . strictEqual ( context . taskOrchestration . selectedRunDetail , null ) ;
1654+ } ) ;
1655+
15671656test ( 'startTaskQueueRunner surfaces already-running queue state distinctly' , async ( ) => {
15681657 const api = async ( name ) => {
15691658 if ( name === 'task-queue-start' ) {
0 commit comments