feat(tui): log event stream connections (#35973)

This commit is contained in:
James Long 2026-07-09 13:13:34 -04:00 committed by GitHub
commit b642f9c7bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 56 additions and 5 deletions

View file

@ -781,10 +781,19 @@ export function Session() {
)
: await (async () => {
if (options.debug) {
const events: unknown[] = []
const events: { readonly created: number }[] = []
for await (const event of sdk.api.session.log({ sessionID: sessionData.id, follow: false })) {
if (event.type !== "log.synced") events.push(event)
}
// Durable events stay in aggregate order even when their wall-clock timestamps differ.
sdk.connection.internal.history().forEach((event) => {
const index = events.findIndex((item) => item.created > event.created)
if (index === -1) {
events.push(event)
return
}
events.splice(index, 0, event)
})
return JSON.stringify({ info: sessionData, events }, null, 2) + EOL
}