Surface Codex usage-limit reset details in chat replies (#77557)

* fix(codex): surface usage limit reset details

* fix(codex): satisfy extension lint

* fix: surface codex runtime failures in tool-only replies
This commit is contained in:
pashpashpash
2026-05-04 17:00:39 -07:00
committed by GitHub
parent 306a582294
commit b2c3202a15
26 changed files with 1187 additions and 103 deletions

View File

@@ -2762,6 +2762,37 @@ describe("createTelegramBot", () => {
expect(sendMessageSpy).toHaveBeenCalledTimes(1);
expect(sendMessageSpy.mock.calls[0][1]).toBe("PFX final reply");
});
it("sends Codex usage-limit reset details as the Telegram reply body", async () => {
const codexRateLimitText =
"⚠️ You've reached your Codex subscription usage limit. Next reset in 42 minutes (2026-05-04T21:34:00.000Z). Run /codex account for current usage details.";
replySpy.mockResolvedValue({ text: codexRateLimitText });
loadConfig.mockReturnValue({
channels: {
telegram: { dmPolicy: "open", allowFrom: ["*"] },
},
});
createTelegramBot({ token: "tok" });
const handler = getOnHandler("message") as (ctx: Record<string, unknown>) => Promise<void>;
await handler({
message: {
chat: { id: 5, type: "private" },
text: "hi",
date: 1736380800,
},
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
expect(sendMessageSpy).toHaveBeenCalledTimes(1);
expect(sendMessageSpy.mock.calls[0][0]).toBe("5");
expect(sendMessageSpy.mock.calls[0][1]).toBe(codexRateLimitText);
expect(String(sendMessageSpy.mock.calls[0][1])).not.toContain(
"All models are temporarily rate-limited",
);
});
it("honors threaded replies for replyToMode=first/all", async () => {
for (const [mode, messageId] of [
["first", 101],