| 273 | return deferred.promise |
| 274 | }, |
| 275 | async waitForVisibleText(predicate, timeoutMs, label) { |
| 276 | const deadline = Date.now() + timeoutMs |
| 277 | while (Date.now() < deadline) { |
| 278 | if (predicate(visibleText)) { |
| 279 | return visibleText |
| 280 | } |
| 281 | await Bun.sleep(20) |
| 282 | } |
| 283 | |
| 284 | throw new Error( |
| 285 | `Timed out waiting for ${label} after ${timeoutMs}ms. Current visible PTY output:\n${visibleText}`, |
| 286 | ) |
| 287 | }, |
| 288 | async waitForVisibleRows(predicate, timeoutMs, label) { |
| 289 | const visibleTextSnapshot = await this.waitForVisibleText( |
| 290 | text => predicate(readVisibleRows(text)), |