@@ -7,7 +7,6 @@ import { window, commands, Uri, workspace, StatusBarAlignment, ThemeColor } from
77import { Logger } from "../../Logger" ;
88import { exec } from "../../utilities/subprocess" ;
99import { Platform } from "../../utilities/platform" ;
10- import { sleep } from "../../utilities/retry" ;
1110import { IDE } from "../../project/ide" ;
1211
1312export const GIT_PATH = Platform . select ( {
@@ -99,10 +98,6 @@ const testCases: ChatTestCase[] = [
9998 prompt : "Why did the app just crash?" ,
10099 allowedToolIds : [ "view_application_logs" ] ,
101100 } ,
102- {
103- prompt : "Show me the console output for the last action." ,
104- allowedToolIds : [ "view_application_logs" ] ,
105- } ,
106101 {
107102 prompt : "Are there any errors in the logs?" ,
108103 allowedToolIds : [ "view_application_logs" ] ,
@@ -148,12 +143,10 @@ const testCases: ChatTestCase[] = [
148143
149144 {
150145 prompt : "Why is the banner not showing up?" ,
151- // Needs tree to see if it exists, logs to see if it failed, or screenshot to see if it's invisible
152146 allowedToolIds : [ "view_component_tree" , "view_application_logs" , "view_screenshot" ] ,
153147 } ,
154148 {
155149 prompt : "Inspect the padding on the user profile card." ,
156- // Needs tree for style props, screenshot for visual verification
157150 allowedToolIds : [ "view_component_tree" , "view_screenshot" ] ,
158151 } ,
159152] ;
@@ -183,14 +176,19 @@ async function setGlobalTestsRunning(areTestsRunning: boolean) {
183176 await commands . executeCommand ( "setContext" , "RNIDE.MCPToolTestsRunning" , areTestsRunning ) ;
184177}
185178
186- function throwOnTestTermination ( ideInstance : IDE ) : Promise < void > {
187- return new Promise ( ( _ , reject ) => {
188- ideInstance . onStateChanged ( ( partialState ) => {
179+ function awaitTestTerminationOrTimeout ( ideInstance : IDE , testTimeout : number ) : Promise < void > {
180+ return new Promise ( ( resolve ) => {
181+ const disposable = ideInstance . onStateChanged ( ( partialState ) => {
189182 const continueRunningTests = partialState . areMCPTestsRunning ;
190183 if ( continueRunningTests === false ) {
191- reject ( ) ;
184+ resolve ( ) ;
192185 }
193186 } ) ;
187+
188+ setTimeout ( ( ) => {
189+ disposable . dispose ( ) ;
190+ resolve ( ) ;
191+ } , testTimeout ) ;
194192 } ) ;
195193}
196194
@@ -267,17 +265,7 @@ export async function testChatToolUsage(): Promise<void> {
267265 await commands . executeCommand ( "workbench.action.chat.newChat" ) ;
268266 await commands . executeCommand ( "workbench.action.chat.openagent" , testCase . prompt ) ;
269267
270- try {
271- await Promise . race ( [
272- // FIXME: Fixed timouts like this should be avoided if possible
273- // Note: Found no way of avoiding this one for now :(
274- sleep ( 10_000 ) ,
275- throwOnTestTermination ( ideInstance ) ,
276- ] ) ;
277- } catch ( e ) {
278- console . log ( "FOOBAR: Error" , e ) ;
279- break ;
280- }
268+ await awaitTestTerminationOrTimeout ( ideInstance , 10_000 ) ;
281269
282270 const filepath = dir + randomBytes ( 8 ) . toString ( "hex" ) + ".json" ;
283271
0 commit comments