fix(discord): clarify startup readiness log (#51425)

Merged via squash.

Prepared head SHA: 390986dc4729975aadb25018b857063e79649f6c
Co-authored-by: scoootscooob <167050519+scoootscooob@users.noreply.github.com>
Co-authored-by: scoootscooob <167050519+scoootscooob@users.noreply.github.com>
Reviewed-by: @scoootscooob
This commit is contained in:
scoootscooob 2026-03-20 22:00:09 -07:00 committed by GitHub
parent d78e13f545
commit 9fb78453e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 48 additions and 1 deletions

View File

@ -193,6 +193,7 @@ Docs: https://docs.openclaw.ai
- Agents/replay: sanitize malformed assistant tool-call replay blocks before provider replay so follow-up Anthropic requests do not inherit the downstream `replace` crash. (#50005) Thanks @jalehman.
- Plugins/context engines: retry strict legacy `assemble()` calls without the new `prompt` field when older engines reject it, preserving prompt-aware retrieval compatibility for pre-prompt plugins. (#50848) thanks @danhdoan.
- Agents/embedded transport errors: distinguish common network failures like connection refused, DNS lookup failure, and interrupted sockets from true timeouts in embedded-run user messaging and lifecycle diagnostics. (#51419) Thanks @scoootscooob.
- Discord/startup logging: report client initialization while the gateway is still connecting instead of claiming Discord is logged in before readiness is reached. (#51425) Thanks @scoootscooob.
### Breaking

View File

@ -92,6 +92,7 @@ import { resolveDiscordPresenceUpdate } from "./presence.js";
import { resolveDiscordAllowlistConfig } from "./provider.allowlist.js";
import { runDiscordGatewayLifecycle } from "./provider.lifecycle.js";
import { resolveDiscordRestFetch } from "./rest-fetch.js";
import { formatDiscordStartupStatusMessage } from "./startup-status.js";
import type { DiscordMonitorStatusSink } from "./status.js";
import {
createNoopThreadBindingManager,
@ -972,7 +973,12 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
const botIdentity =
botUserId && botUserName ? `${botUserId} (${botUserName})` : (botUserId ?? botUserName ?? "");
runtime.log?.(`logged in to discord${botIdentity ? ` as ${botIdentity}` : ""}`);
runtime.log?.(
formatDiscordStartupStatusMessage({
gatewayReady: lifecycleGateway?.isConnected === true,
botIdentity: botIdentity || undefined,
}),
);
if (lifecycleGateway?.isConnected) {
opts.setStatus?.(createConnectedChannelStatusPatch());
}

View File

@ -0,0 +1,30 @@
import { describe, expect, it } from "vitest";
import { formatDiscordStartupStatusMessage } from "./startup-status.js";
describe("formatDiscordStartupStatusMessage", () => {
it("reports logged-in status only after the gateway is ready", () => {
expect(
formatDiscordStartupStatusMessage({
gatewayReady: true,
botIdentity: "bot-1 (Molty)",
}),
).toBe("logged in to discord as bot-1 (Molty)");
});
it("reports client initialization while gateway readiness is still pending", () => {
expect(
formatDiscordStartupStatusMessage({
gatewayReady: false,
botIdentity: "bot-1 (Molty)",
}),
).toBe("discord client initialized as bot-1 (Molty); awaiting gateway readiness");
});
it("handles missing identity without awkward punctuation", () => {
expect(
formatDiscordStartupStatusMessage({
gatewayReady: false,
}),
).toBe("discord client initialized; awaiting gateway readiness");
});
});

View File

@ -0,0 +1,10 @@
export function formatDiscordStartupStatusMessage(params: {
gatewayReady: boolean;
botIdentity?: string;
}): string {
const identitySuffix = params.botIdentity ? ` as ${params.botIdentity}` : "";
if (params.gatewayReady) {
return `logged in to discord${identitySuffix}`;
}
return `discord client initialized${identitySuffix}; awaiting gateway readiness`;
}