()
| 80 | } |
| 81 | |
| 82 | async connect(): Promise<void> { |
| 83 | if (!this.currentIde || !this.currentIdeDisplayName) { |
| 84 | this.setState( |
| 85 | IDEConnectionStatus.Disconnected, |
| 86 | `IDE integration is not supported in your current environment. To use this feature, run ANUS in one of these supported IDEs: ${Object.values( |
| 87 | DetectedIde, |
| 88 | ) |
| 89 | .map((ide) => getIdeInfo(ide).displayName) |
| 90 | .join(', ')}`, |
| 91 | false, |
| 92 | ); |
| 93 | return; |
| 94 | } |
| 95 | |
| 96 | this.setState(IDEConnectionStatus.Connecting); |
| 97 | |
| 98 | const { isValid, error } = IdeClient.validateWorkspacePath( |
| 99 | process.env['ANUS_CLI_IDE_WORKSPACE_PATH'], |
| 100 | this.currentIdeDisplayName, |
| 101 | process.cwd(), |
| 102 | ); |
| 103 | |
| 104 | if (!isValid) { |
| 105 | this.setState(IDEConnectionStatus.Disconnected, error, true); |
| 106 | return; |
| 107 | } |
| 108 | |
| 109 | const portFromFile = await this.getPortFromFile(); |
| 110 | if (portFromFile) { |
| 111 | const connected = await this.establishConnection(portFromFile); |
| 112 | if (connected) { |
| 113 | return; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | const portFromEnv = this.getPortFromEnv(); |
| 118 | if (portFromEnv) { |
| 119 | const connected = await this.establishConnection(portFromEnv); |
| 120 | if (connected) { |
| 121 | return; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | this.setState( |
| 126 | IDEConnectionStatus.Disconnected, |
| 127 | `Failed to connect to IDE companion extension for ${this.currentIdeDisplayName}. Please ensure the extension is running. To install the extension, run /ide install.`, |
| 128 | true, |
| 129 | ); |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * A diff is accepted with any modifications if the user performs one of the |
no test coverage detected