@@ -41,6 +41,7 @@ import {
4141 resolveComposerInteractionMode ,
4242 resolveComposerProviderSelection ,
4343 resolveDraftPromotionNavigationTarget ,
44+ resolveProactiveTurnDiffAction ,
4445 resolveThreadMetadataUpdateForNextTurn ,
4546 resolveSendEnvMode ,
4647 resolveDraftHeroState ,
@@ -159,6 +160,80 @@ describe("proactive panels", () => {
159160 } ) ,
160161 ) . toBe ( false ) ;
161162 } ) ;
163+
164+ it ( "opens a completed turn diff only for changed files" , ( ) => {
165+ const changedCheckpoint = {
166+ status : "ready" ,
167+ files : [ { path : "src/app.ts" , kind : "modified" , additions : 1 , deletions : 0 } ] ,
168+ } satisfies Pick < TurnDiffSummary , "status" | "files" > ;
169+ const unchangedCheckpoint = {
170+ status : "ready" ,
171+ files : [ ] ,
172+ } satisfies Pick < TurnDiffSummary , "status" | "files" > ;
173+
174+ expect (
175+ resolveProactiveTurnDiffAction ( {
176+ checkpoint : changedCheckpoint ,
177+ isGitRepo : true ,
178+ activeSurfaceKind : null ,
179+ } ) ,
180+ ) . toBe ( "open" ) ;
181+ expect (
182+ resolveProactiveTurnDiffAction ( {
183+ checkpoint : unchangedCheckpoint ,
184+ isGitRepo : true ,
185+ activeSurfaceKind : null ,
186+ } ) ,
187+ ) . toBe ( "ignore" ) ;
188+ } ) ;
189+
190+ it ( "waits for definitive checkpoint and repository state" , ( ) => {
191+ const missingCheckpoint = {
192+ status : "missing" ,
193+ files : [ ] ,
194+ } satisfies Pick < TurnDiffSummary , "status" | "files" > ;
195+ const changedCheckpoint = {
196+ status : "ready" ,
197+ files : [ { path : "src/app.ts" , kind : "modified" , additions : 1 , deletions : 0 } ] ,
198+ } satisfies Pick < TurnDiffSummary , "status" | "files" > ;
199+
200+ expect (
201+ resolveProactiveTurnDiffAction ( {
202+ checkpoint : undefined ,
203+ isGitRepo : true ,
204+ activeSurfaceKind : null ,
205+ } ) ,
206+ ) . toBe ( "defer" ) ;
207+ expect (
208+ resolveProactiveTurnDiffAction ( {
209+ checkpoint : missingCheckpoint ,
210+ isGitRepo : true ,
211+ activeSurfaceKind : null ,
212+ } ) ,
213+ ) . toBe ( "defer" ) ;
214+ expect (
215+ resolveProactiveTurnDiffAction ( {
216+ checkpoint : changedCheckpoint ,
217+ isGitRepo : undefined ,
218+ activeSurfaceKind : null ,
219+ } ) ,
220+ ) . toBe ( "defer" ) ;
221+ } ) ;
222+
223+ it ( "keeps an active pull request above a completed turn diff" , ( ) => {
224+ const changedCheckpoint = {
225+ status : "ready" ,
226+ files : [ { path : "src/app.ts" , kind : "modified" , additions : 1 , deletions : 0 } ] ,
227+ } satisfies Pick < TurnDiffSummary , "status" | "files" > ;
228+
229+ expect (
230+ resolveProactiveTurnDiffAction ( {
231+ checkpoint : changedCheckpoint ,
232+ isGitRepo : true ,
233+ activeSurfaceKind : "pull-request" ,
234+ } ) ,
235+ ) . toBe ( "ignore" ) ;
236+ } ) ;
162237} ) ;
163238
164239describe ( "toolGroupConsumesUpwardNavigation" , ( ) => {
0 commit comments