* Lazy default-project resolution. Three layers: * 1. await the in-flight init kicked off from `handleInitialize` (if any); * 2. if still uninitialized and we never asked the client for its roots, * do so now (one-shot); fall back to cwd if the client lacks roots; * 3. last-re
()
| 303 | * that were `codegraph init`'d *after* the server started. |
| 304 | */ |
| 305 | private async retryInitIfNeeded(): Promise<void> { |
| 306 | if (this.resolvePromise) { |
| 307 | try { await this.resolvePromise; } catch { /* fall through to retry */ } |
| 308 | this.resolvePromise = null; |
| 309 | } |
| 310 | |
| 311 | if (this.engine.hasDefaultCodeGraph()) return; |
| 312 | |
| 313 | const hint = this.explicitProjectPath ?? this.engine.getProjectPath(); |
| 314 | if (!hint && !this.rootsAttempted) { |
| 315 | this.rootsAttempted = true; |
| 316 | this.resolvePromise = this.clientSupportsRoots |
| 317 | ? this.initFromRoots() |
| 318 | : this.engine.ensureInitialized(process.cwd()); |
| 319 | try { await this.resolvePromise; } catch { /* fall through */ } |
| 320 | this.resolvePromise = null; |
| 321 | if (this.engine.hasDefaultCodeGraph()) return; |
| 322 | } |
| 323 | |
| 324 | // Last resort: walk from the best candidate (sync open). Picks up |
| 325 | // projects that appeared after the server started. |
| 326 | const candidate = hint ?? process.cwd(); |
| 327 | this.engine.retryInitializeSync(candidate); |
| 328 | } |
| 329 | |
| 330 | /** |
| 331 | * Ask the client for its workspace root via `roots/list` and open the |
no test coverage detected