mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 03:45:46 -06:00
fix: carry room event gateway actions
This commit is contained in:
@@ -138,6 +138,28 @@ describe("telegram bot message processor", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("does not send early typing cues for room events", async () => {
|
||||
const sendTyping = vi.fn().mockResolvedValue(undefined);
|
||||
buildTelegramMessageContext.mockResolvedValue(
|
||||
createMessageContext({
|
||||
sendTyping,
|
||||
ctxPayload: {
|
||||
From: "telegram:123",
|
||||
To: "telegram:123",
|
||||
ChatType: "group",
|
||||
RawBody: "ambient",
|
||||
InboundTurnKind: "room_event",
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const processMessage = createTelegramMessageProcessor(baseDeps);
|
||||
await processSampleMessage(processMessage);
|
||||
|
||||
expect(sendTyping).not.toHaveBeenCalled();
|
||||
expect(dispatchTelegramMessage).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("skips dispatch when no context is produced", async () => {
|
||||
buildTelegramMessageContext.mockResolvedValue(null);
|
||||
const processMessage = createTelegramMessageProcessor(baseDeps);
|
||||
|
||||
@@ -155,9 +155,11 @@ export const createTelegramMessageProcessor = (deps: TelegramMessageProcessorDep
|
||||
(options?.ingressBuffer ? ` buffer=${options.ingressBuffer}` : ""),
|
||||
);
|
||||
}
|
||||
void context.sendTyping().catch((err) => {
|
||||
logVerbose(`telegram early typing cue failed for chat ${context.chatId}: ${String(err)}`);
|
||||
});
|
||||
if (context.ctxPayload.InboundTurnKind !== "room_event") {
|
||||
void context.sendTyping().catch((err) => {
|
||||
logVerbose(`telegram early typing cue failed for chat ${context.chatId}: ${String(err)}`);
|
||||
});
|
||||
}
|
||||
telegramInboundLog.info(
|
||||
formatTelegramInboundLogLine({
|
||||
from: context.ctxPayload.From,
|
||||
|
||||
@@ -79,6 +79,7 @@ export const MessageActionParamsSchema = Type.Object(
|
||||
senderIsOwner: Type.Optional(Type.Boolean()),
|
||||
sessionKey: Type.Optional(Type.String()),
|
||||
sessionId: Type.Optional(Type.String()),
|
||||
inboundTurnKind: Type.Optional(Type.String({ enum: ["user_request", "room_event"] })),
|
||||
agentId: Type.Optional(Type.String()),
|
||||
toolContext: Type.Optional(MessageActionToolContextSchema),
|
||||
idempotencyKey: NonEmptyString,
|
||||
|
||||
@@ -1265,6 +1265,7 @@ describe("gateway send mirroring", () => {
|
||||
emoji: "✅",
|
||||
},
|
||||
requesterSenderId: "trusted-user",
|
||||
inboundTurnKind: "room_event",
|
||||
toolContext: {
|
||||
currentGraphChannelId: "graph:team/chan",
|
||||
currentChannelProvider: "whatsapp",
|
||||
@@ -1291,6 +1292,9 @@ describe("gateway send mirroring", () => {
|
||||
undefined,
|
||||
{ channel: "whatsapp" },
|
||||
);
|
||||
expect(mocks.dispatchChannelMessageAction).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ inboundTurnKind: "room_event" }),
|
||||
);
|
||||
});
|
||||
|
||||
it("passes agent-scoped media roots to gateway message actions", async () => {
|
||||
|
||||
@@ -287,6 +287,7 @@ export const sendHandlers: GatewayRequestHandlers = {
|
||||
senderIsOwner?: boolean;
|
||||
sessionKey?: string;
|
||||
sessionId?: string;
|
||||
inboundTurnKind?: "user_request" | "room_event";
|
||||
agentId?: string;
|
||||
toolContext?: {
|
||||
currentChannelId?: string;
|
||||
@@ -364,6 +365,7 @@ export const sendHandlers: GatewayRequestHandlers = {
|
||||
senderIsOwner,
|
||||
sessionKey: normalizeOptionalString(request.sessionKey) ?? undefined,
|
||||
sessionId: normalizeOptionalString(request.sessionId) ?? undefined,
|
||||
inboundTurnKind: request.inboundTurnKind,
|
||||
agentId: normalizeOptionalString(request.agentId) ?? undefined,
|
||||
mediaLocalRoots: getAgentScopedMediaLocalRoots(
|
||||
cfg,
|
||||
|
||||
Reference in New Issue
Block a user