mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-15 19:21:08 +00:00
fix(auto-reply): stop mention-only inline status turns
This commit is contained in:
@@ -391,6 +391,47 @@ describe("handleInlineActions", () => {
|
||||
expect(typing.cleanup).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("continues into the agent when mention-wrapped inline status leaves real text", async () => {
|
||||
const typing = createTypingController();
|
||||
const ctx = buildTestCtx({
|
||||
Body: "<@123> /status what's next?",
|
||||
CommandBody: "<@123> /status what's next?",
|
||||
Provider: "discord",
|
||||
Surface: "discord",
|
||||
ChatType: "channel",
|
||||
WasMentioned: true,
|
||||
});
|
||||
|
||||
const result = await handleInlineActions(
|
||||
createHandleInlineActionsInput({
|
||||
ctx,
|
||||
typing,
|
||||
cleanedBody: "<@123> what's next?",
|
||||
command: {
|
||||
surface: "discord",
|
||||
channel: "discord",
|
||||
channelId: "discord",
|
||||
isAuthorizedSender: true,
|
||||
rawBodyNormalized: "<@123> /status what's next?",
|
||||
commandBodyNormalized: "<@123> /status what's next?",
|
||||
},
|
||||
overrides: {
|
||||
allowTextCommands: true,
|
||||
inlineStatusRequested: true,
|
||||
isGroup: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
expect(result).toEqual({
|
||||
kind: "continue",
|
||||
directives: clearInlineDirectives("<@123> what's next?"),
|
||||
abortedLastRun: false,
|
||||
});
|
||||
expect(buildStatusReplyMock).toHaveBeenCalledTimes(1);
|
||||
expect(handleCommandsMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("skips stale queued messages that are at or before the /stop cutoff", async () => {
|
||||
const typing = createTypingController();
|
||||
const sessionEntry: SessionEntry = {
|
||||
|
||||
@@ -76,6 +76,17 @@ function expandBundleCommandPromptTemplate(template: string, args?: string): str
|
||||
return `${rendered.trim()}\n\nUser input:\n${normalizedArgs}`;
|
||||
}
|
||||
|
||||
function isMentionOnlyResidualText(text: string, wasMentioned: boolean | undefined): boolean {
|
||||
if (wasMentioned !== true) {
|
||||
return false;
|
||||
}
|
||||
const trimmed = text.trim();
|
||||
if (!trimmed) {
|
||||
return false;
|
||||
}
|
||||
return /^(?:<@[!&]?[A-Za-z0-9._:-]+>|<!(?:here|channel|everyone)>|[:,.!?-]|\s)+$/u.test(trimmed);
|
||||
}
|
||||
|
||||
export type InlineActionResult =
|
||||
| { kind: "reply"; reply: ReplyPayload | ReplyPayload[] | undefined }
|
||||
| {
|
||||
@@ -474,7 +485,11 @@ export async function handleInlineActions(params: {
|
||||
}
|
||||
return stripMentions(stripped, ctx, cfg, agentId).trim();
|
||||
})();
|
||||
if (didSendInlineStatus && remainingBodyAfterInlineStatus.length === 0) {
|
||||
if (
|
||||
didSendInlineStatus &&
|
||||
(remainingBodyAfterInlineStatus.length === 0 ||
|
||||
isMentionOnlyResidualText(remainingBodyAfterInlineStatus, ctx.WasMentioned))
|
||||
) {
|
||||
typing.cleanup();
|
||||
return { kind: "reply", reply: undefined };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user