Fix: avoid double inline replies
This commit is contained in:
parent
da71eaebd2
commit
597931e0fb
@ -160,6 +160,35 @@ describe("trigger handling", () => {
|
|||||||
expect(text).toBe("ok");
|
expect(text).toBe("ok");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it("returns a single reply for envelope-prefixed /help", async () => {
|
||||||
|
await withTempHome(async (home) => {
|
||||||
|
const blockReplies: Array<{ text?: string }> = [];
|
||||||
|
const res = await getReplyFromConfig(
|
||||||
|
{
|
||||||
|
Body: "[Signal] T: /help",
|
||||||
|
RawBody: "/help",
|
||||||
|
CommandBody: "/help",
|
||||||
|
From: "+1002",
|
||||||
|
To: "+2000",
|
||||||
|
Provider: "signal",
|
||||||
|
Surface: "signal",
|
||||||
|
SenderName: "T",
|
||||||
|
SenderId: "signal:+1002",
|
||||||
|
CommandAuthorized: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onBlockReply: async (payload) => {
|
||||||
|
blockReplies.push(payload);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
makeCfg(home),
|
||||||
|
);
|
||||||
|
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
||||||
|
expect(blockReplies.length).toBe(0);
|
||||||
|
expect(text).toContain("Help");
|
||||||
|
expect(runEmbeddedPiAgent).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
it("drops /status for unauthorized senders", async () => {
|
it("drops /status for unauthorized senders", async () => {
|
||||||
await withTempHome(async (home) => {
|
await withTempHome(async (home) => {
|
||||||
const cfg = {
|
const cfg = {
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import type { InlineDirectives } from "./directive-handling.js";
|
|||||||
import { isDirectiveOnly } from "./directive-handling.js";
|
import { isDirectiveOnly } from "./directive-handling.js";
|
||||||
import type { createModelSelectionState } from "./model-selection.js";
|
import type { createModelSelectionState } from "./model-selection.js";
|
||||||
import { extractInlineSimpleCommand } from "./reply-inline.js";
|
import { extractInlineSimpleCommand } from "./reply-inline.js";
|
||||||
|
import { stripStructuralPrefixes } from "./mentions.js";
|
||||||
import type { TypingController } from "./typing.js";
|
import type { TypingController } from "./typing.js";
|
||||||
import { listSkillCommandsForWorkspace, resolveSkillCommandInvocation } from "../skill-commands.js";
|
import { listSkillCommandsForWorkspace, resolveSkillCommandInvocation } from "../skill-commands.js";
|
||||||
import { logVerbose } from "../../globals.js";
|
import { logVerbose } from "../../globals.js";
|
||||||
@ -297,7 +298,8 @@ export async function handleInlineActions(params: {
|
|||||||
skillCommands,
|
skillCommands,
|
||||||
});
|
});
|
||||||
if (inlineResult.reply) {
|
if (inlineResult.reply) {
|
||||||
if (!inlineCommand.cleaned) {
|
const cleanedAfterStrip = stripStructuralPrefixes(inlineCommand.cleaned);
|
||||||
|
if (!cleanedAfterStrip) {
|
||||||
typing.cleanup();
|
typing.cleanup();
|
||||||
return { kind: "reply", reply: inlineResult.reply };
|
return { kind: "reply", reply: inlineResult.reply };
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user