()
| 315 | } |
| 316 | |
| 317 | private registerClientHandlers() { |
| 318 | if (!this.client) { |
| 319 | return; |
| 320 | } |
| 321 | |
| 322 | this.client.setNotificationHandler( |
| 323 | IdeContextNotificationSchema, |
| 324 | (notification) => { |
| 325 | ideContext.setIdeContext(notification.params); |
| 326 | }, |
| 327 | ); |
| 328 | this.client.onerror = (_error) => { |
| 329 | this.setState( |
| 330 | IDEConnectionStatus.Disconnected, |
| 331 | `IDE connection error. The connection was lost unexpectedly. Please try reconnecting by running /ide enable`, |
| 332 | true, |
| 333 | ); |
| 334 | }; |
| 335 | this.client.onclose = () => { |
| 336 | this.setState( |
| 337 | IDEConnectionStatus.Disconnected, |
| 338 | `IDE connection error. The connection was lost unexpectedly. Please try reconnecting by running /ide enable`, |
| 339 | true, |
| 340 | ); |
| 341 | }; |
| 342 | this.client.setNotificationHandler( |
| 343 | IdeDiffAcceptedNotificationSchema, |
| 344 | (notification) => { |
| 345 | const { filePath, content } = notification.params; |
| 346 | const resolver = this.diffResponses.get(filePath); |
| 347 | if (resolver) { |
| 348 | resolver({ status: 'accepted', content }); |
| 349 | this.diffResponses.delete(filePath); |
| 350 | } else { |
| 351 | logger.debug(`No resolver found for ${filePath}`); |
| 352 | } |
| 353 | }, |
| 354 | ); |
| 355 | |
| 356 | this.client.setNotificationHandler( |
| 357 | IdeDiffClosedNotificationSchema, |
| 358 | (notification) => { |
| 359 | const { filePath } = notification.params; |
| 360 | const resolver = this.diffResponses.get(filePath); |
| 361 | if (resolver) { |
| 362 | resolver({ status: 'rejected', content: undefined }); |
| 363 | this.diffResponses.delete(filePath); |
| 364 | } else { |
| 365 | logger.debug(`No resolver found for ${filePath}`); |
| 366 | } |
| 367 | }, |
| 368 | ); |
| 369 | } |
| 370 | |
| 371 | private async establishConnection(port: string): Promise<boolean> { |
| 372 | let transport: StreamableHTTPClientTransport | undefined; |
no test coverage detected