fix: ensure onCompleted callback finishes before using persistedResult

- Update RooTerminalCallbacks.onCompleted type to allow async callbacks (void | Promise<void>)
- Track onCompleted completion with a promise and await it before using persistedResult
- This fixes a race condition where exitDetails could be set before the async finalize() completes
- Fix test callback to not return assignment value
This commit is contained in:
Hannes Rudolph 2026-01-27 14:14:14 -07:00
parent 6bc2a14d61
commit 5711f1f32b

View file

@ -210,6 +210,7 @@ export async function executeCommandInTerminal(
// Bound accumulated output buffer size to prevent unbounded memory growth for long-running commands.
// The interceptor preserves full output; this buffer is only for UI display (100KB limit).
const maxAccumulatedOutputSize = 100_000
// Track when onCompleted callback finishes to avoid race condition.
// The callback is async but Terminal/ExecaTerminal don't await it, so we track completion
// explicitly to ensure persistedResult is set before we use it.