@@ -20,7 +20,6 @@ import {
2020 findSidebarProposedPlan ,
2121 hasActionableProposedPlan ,
2222 hasToolActivityForTurn ,
23- isSessionActivelyRunningTurn ,
2423 isLatestTurnSettled ,
2524} from "./session-logic" ;
2625
@@ -1073,30 +1072,15 @@ describe("isLatestTurnSettled", () => {
10731072 } as const ;
10741073
10751074 it ( "returns false while the same turn is still active in a running session" , ( ) => {
1076- expect (
1077- isLatestTurnSettled (
1078- {
1079- ...latestTurn ,
1080- completedAt : null ,
1081- } ,
1082- {
1083- orchestrationStatus : "running" ,
1084- activeTurnId : TurnId . makeUnsafe ( "turn-1" ) ,
1085- } ,
1086- ) ,
1087- ) . toBe ( false ) ;
1088- } ) ;
1089-
1090- it ( "returns true when the turn completed but the session status stayed stale-running" , ( ) => {
10911075 expect (
10921076 isLatestTurnSettled ( latestTurn , {
10931077 orchestrationStatus : "running" ,
10941078 activeTurnId : TurnId . makeUnsafe ( "turn-1" ) ,
10951079 } ) ,
1096- ) . toBe ( true ) ;
1080+ ) . toBe ( false ) ;
10971081 } ) ;
10981082
1099- it ( "returns false while a different turn is still running" , ( ) => {
1083+ it ( "returns false while any turn is running to avoid stale latest-turn banners " , ( ) => {
11001084 expect (
11011085 isLatestTurnSettled ( latestTurn , {
11021086 orchestrationStatus : "running" ,
@@ -1128,56 +1112,6 @@ describe("isLatestTurnSettled", () => {
11281112 } ) ;
11291113} ) ;
11301114
1131- describe ( "isSessionActivelyRunningTurn" , ( ) => {
1132- const completedTurn = {
1133- turnId : TurnId . makeUnsafe ( "turn-1" ) ,
1134- startedAt : "2026-02-27T21:10:00.000Z" ,
1135- completedAt : "2026-02-27T21:10:06.000Z" ,
1136- } as const ;
1137-
1138- it ( "returns true when the current turn has not completed yet" , ( ) => {
1139- expect (
1140- isSessionActivelyRunningTurn (
1141- {
1142- ...completedTurn ,
1143- completedAt : null ,
1144- } ,
1145- {
1146- orchestrationStatus : "running" ,
1147- activeTurnId : TurnId . makeUnsafe ( "turn-1" ) ,
1148- } ,
1149- ) ,
1150- ) . toBe ( true ) ;
1151- } ) ;
1152-
1153- it ( "returns false when the same turn already completed and only the session is stale" , ( ) => {
1154- expect (
1155- isSessionActivelyRunningTurn ( completedTurn , {
1156- orchestrationStatus : "running" ,
1157- activeTurnId : TurnId . makeUnsafe ( "turn-1" ) ,
1158- } ) ,
1159- ) . toBe ( false ) ;
1160- } ) ;
1161-
1162- it ( "returns true when a different turn is still active" , ( ) => {
1163- expect (
1164- isSessionActivelyRunningTurn ( completedTurn , {
1165- orchestrationStatus : "running" ,
1166- activeTurnId : TurnId . makeUnsafe ( "turn-2" ) ,
1167- } ) ,
1168- ) . toBe ( true ) ;
1169- } ) ;
1170-
1171- it ( "returns false when the session is not running" , ( ) => {
1172- expect (
1173- isSessionActivelyRunningTurn ( completedTurn , {
1174- orchestrationStatus : "ready" ,
1175- activeTurnId : undefined ,
1176- } ) ,
1177- ) . toBe ( false ) ;
1178- } ) ;
1179- } ) ;
1180-
11811115describe ( "deriveActiveWorkStartedAt" , ( ) => {
11821116 const latestTurn = {
11831117 turnId : TurnId . makeUnsafe ( "turn-1" ) ,
@@ -1186,22 +1120,6 @@ describe("deriveActiveWorkStartedAt", () => {
11861120 } as const ;
11871121
11881122 it ( "prefers the in-flight turn start when the latest turn is not settled" , ( ) => {
1189- expect (
1190- deriveActiveWorkStartedAt (
1191- {
1192- ...latestTurn ,
1193- completedAt : null ,
1194- } ,
1195- {
1196- orchestrationStatus : "running" ,
1197- activeTurnId : TurnId . makeUnsafe ( "turn-1" ) ,
1198- } ,
1199- "2026-02-27T21:11:00.000Z" ,
1200- ) ,
1201- ) . toBe ( "2026-02-27T21:10:00.000Z" ) ;
1202- } ) ;
1203-
1204- it ( "falls back to sendStartedAt when only the session status is stale-running" , ( ) => {
12051123 expect (
12061124 deriveActiveWorkStartedAt (
12071125 latestTurn ,
@@ -1211,7 +1129,7 @@ describe("deriveActiveWorkStartedAt", () => {
12111129 } ,
12121130 "2026-02-27T21:11:00.000Z" ,
12131131 ) ,
1214- ) . toBe ( "2026-02-27T21:11 :00.000Z" ) ;
1132+ ) . toBe ( "2026-02-27T21:10 :00.000Z" ) ;
12151133 } ) ;
12161134
12171135 it ( "falls back to sendStartedAt once the latest turn is settled" , ( ) => {
0 commit comments