@@ -11,6 +11,7 @@ import { TelemetryService } from "@roo-code/telemetry"
1111
1212import { Task } from "../Task"
1313import { createRateLimitClock } from "../RateLimitClock"
14+ import { summarizeConversation } from "../../condense"
1415import { ClineProvider } from "../../webview/ClineProvider"
1516import { ApiStreamChunk } from "../../../api/transform/stream"
1617import { ContextProxy } from "../../config/ContextProxy"
@@ -1796,6 +1797,24 @@ describe("Cline", () => {
17961797 expect ( cancelSpy ) . toHaveBeenCalled ( )
17971798 } )
17981799 describe ( "abortSignal" , ( ) => {
1800+ it ( "should pass AbortController signal to condenseContext metadata when a current request exists" , async ( ) => {
1801+ const task = new Task ( {
1802+ provider : mockProvider ,
1803+ apiConfiguration : mockApiConfig ,
1804+ task : "test task" ,
1805+ startTask : false ,
1806+ } )
1807+
1808+ task . currentRequestAbortController = new AbortController ( )
1809+ vi . spyOn ( task as any , "getSystemPrompt" ) . mockResolvedValue ( "mock system prompt" )
1810+
1811+ await task . condenseContext ( )
1812+
1813+ expect ( summarizeConversation ) . toHaveBeenCalled ( )
1814+ const [ options ] = vi . mocked ( summarizeConversation ) . mock . calls . at ( - 1 ) !
1815+ expect ( options . metadata ?. abortSignal ) . toBeInstanceOf ( AbortSignal )
1816+ } )
1817+
17991818 it ( "should pass AbortController signal to createMessage metadata" , async ( ) => {
18001819 const task = new Task ( {
18011820 provider : mockProvider ,
@@ -1934,6 +1953,53 @@ describe("Cline", () => {
19341953 expect ( metadataSignal ) . toBe ( task . currentRequestAbortController ! . signal )
19351954 } )
19361955 } )
1956+
1957+ it ( "should pass AbortController signal to forced context-management metadata when a current request exists" , async ( ) => {
1958+ const task = new Task ( {
1959+ provider : mockProvider ,
1960+ apiConfiguration : mockApiConfig ,
1961+ task : "test task" ,
1962+ startTask : false ,
1963+ } )
1964+
1965+ task . currentRequestAbortController = new AbortController ( )
1966+ vi . spyOn ( task as any , "getSystemPrompt" ) . mockResolvedValue ( "mock system prompt" )
1967+ vi . spyOn ( task as any , "handleContextWindowExceededError" ) . mockRestore ?.( )
1968+ vi . spyOn ( task , "getTokenUsage" ) . mockReturnValue ( {
1969+ totalCost : 0 ,
1970+ totalTokensIn : 0 ,
1971+ totalTokensOut : 0 ,
1972+ contextTokens : 120000 ,
1973+ } )
1974+ vi . spyOn ( mockProvider , "getState" ) . mockResolvedValue ( {
1975+ apiConfiguration : mockApiConfig ,
1976+ mode : "code" ,
1977+ autoCondenseContext : true ,
1978+ autoCondenseContextPercent : 80 ,
1979+ requestDelaySeconds : 0 ,
1980+ customModes : [ ] ,
1981+ experiments : { } ,
1982+ disabledTools : [ ] ,
1983+ customSupportPrompts : { } ,
1984+ autoApprovalEnabled : true ,
1985+ profileThresholds : { } ,
1986+ currentApiConfigName : "default" ,
1987+ } )
1988+
1989+ task . apiConversationHistory = [
1990+ {
1991+ role : "user" as const ,
1992+ content : [ { type : "text" as const , text : "test message" } ] ,
1993+ ts : Date . now ( ) ,
1994+ } ,
1995+ ] as any
1996+
1997+ await ( task as any ) . handleContextWindowExceededError ( )
1998+
1999+ expect ( summarizeConversation ) . toHaveBeenCalled ( )
2000+ const [ options ] = vi . mocked ( summarizeConversation ) . mock . calls . at ( - 1 ) !
2001+ expect ( options . metadata ?. abortSignal ) . toBeInstanceOf ( AbortSignal )
2002+ } )
19372003 } )
19382004 } )
19392005
0 commit comments