feat(cli/logs): announce --follow gateway reconnect and add JSON notice parity (#75372)

This commit is contained in:
Dallin Romney
2026-05-03 17:55:58 +08:00
committed by GitHub
parent 3ee5df618a
commit 4bb4127a33
4 changed files with 60 additions and 10 deletions

View File

@@ -341,15 +341,12 @@ export function registerLogsCli(program: Command) {
if (opts.follow && followRetryAttempt < MAX_FOLLOW_RETRIES && isTransientFollowError(err)) {
followRetryAttempt += 1;
const backoffMs = computeBackoff(FOLLOW_BACKOFF_POLICY, followRetryAttempt);
if (
!errorLine(
colorize(
rich,
theme.warn,
`[logs] gateway disconnected, reconnecting in ${Math.round(backoffMs / 1_000)}s...`,
),
)
) {
const message = `[logs] gateway disconnected, reconnecting in ${Math.round(backoffMs / 1_000)}s...`;
if (jsonMode) {
if (!emitJsonLine({ type: "notice", message }, true)) {
return;
}
} else if (!errorLine(colorize(rich, theme.warn, message))) {
return;
}
await delay(backoffMs);
@@ -366,6 +363,16 @@ export function registerLogsCli(program: Command) {
process.exit(1);
return;
}
if (followRetryAttempt > 0) {
const message = "[logs] gateway reconnected";
if (jsonMode) {
if (!emitJsonLine({ type: "notice", message }, true)) {
return;
}
} else if (!errorLine(colorize(rich, theme.muted, message))) {
return;
}
}
followRetryAttempt = 0;
const lines = Array.isArray(payload.lines) ? payload.lines : [];
if (jsonMode) {