MCPcopy
hub / github.com/CodebuffAI/codebuff / waitForReady

Method waitForReady

freebuff/e2e/utils/freebuff-session.ts:119–134  ·  view source on GitHub ↗

* Wait for the CLI to be fully initialized and ready for input. * Polls terminal output until enough non-empty lines are visible, * indicating the TUI has rendered its initial layout.

(timeoutMs = 30_000, minLines = 5)

Source from the content-addressed store, hash-verified

117 * indicating the TUI has rendered its initial layout.
118 */
119 async waitForReady(timeoutMs = 30_000, minLines = 5): Promise<void> {
120 const start = Date.now()
121 while (Date.now() - start < timeoutMs) {
122 const output = await this.capture()
123 const nonEmptyLines = output
124 .split('\n')
125 .filter((line) => line.trim().length > 0)
126 if (nonEmptyLines.length >= minLines) return
127 await new Promise((resolve) => setTimeout(resolve, 250))
128 }
129 const finalOutput = await this.capture()
130 throw new Error(
131 `Timed out after ${timeoutMs}ms waiting for CLI to be ready.\n` +
132 `Last output:\n${finalOutput}`,
133 )
134 }
135
136 /** Send text input to the freebuff CLI (presses Enter by default). */
137 async send(

Calls 2

captureMethod · 0.95
setTimeoutFunction · 0.85

Tested by

no test coverage detected