mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 04:47:03 -06:00
fix: honor command suppression for inline skills
This commit is contained in:
@@ -801,6 +801,40 @@ describe("handleInlineActions", () => {
|
||||
expect(handleCommandsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps inline skill markers literal when command interpretation is suppressed", async () => {
|
||||
const typing = createTypingController();
|
||||
const body = "Please use /office_hours: to build me a deployment plan";
|
||||
const ctx = buildTestCtx({
|
||||
Body: body,
|
||||
CommandBody: body,
|
||||
Provider: "webchat",
|
||||
Surface: "webchat",
|
||||
CommandInterpretationSuppressed: true,
|
||||
});
|
||||
|
||||
const result = await handleInlineActions(
|
||||
createHandleInlineActionsInput({
|
||||
ctx,
|
||||
typing,
|
||||
cleanedBody: body,
|
||||
command: {
|
||||
isAuthorizedSender: true,
|
||||
rawBodyNormalized: body,
|
||||
commandBodyNormalized: body,
|
||||
},
|
||||
overrides: {
|
||||
allowTextCommands: true,
|
||||
cfg: { commands: { text: true } },
|
||||
skillCommands: officeHoursSkillCommands(),
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
expect(result).toMatchObject({ kind: "continue", cleanedBody: body });
|
||||
expect(ctx.Body).toBe(body);
|
||||
expect(handleCommandsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("preserves slash commands inside an inline skill payload", async () => {
|
||||
const typing = createTypingController();
|
||||
const body = "/office_hours: compare /help and /commands with /status";
|
||||
|
||||
@@ -338,13 +338,13 @@ export async function handleInlineActions(params: {
|
||||
const canUseInlineSkills = command.isAuthorizedSender && ctx.Surface === INTERNAL_MESSAGE_CHANNEL;
|
||||
const hasInlineSkillCandidate =
|
||||
canUseInlineSkills &&
|
||||
!ctx.CommandInterpretationSuppressed &&
|
||||
listColonMarkedInlineSkillNames(command.commandBodyNormalized).some(isPotentialInlineSkillName);
|
||||
const shouldLoadSkillCommands =
|
||||
allowTextCommands && (hasSkillReferences || hasSkillSlashCandidate || hasInlineSkillCandidate);
|
||||
const canReusePreloadedSkillCommands = execOverrides === undefined;
|
||||
const skillCommands =
|
||||
shouldLoadSkillCommands &&
|
||||
canReusePreloadedSkillCommands &&
|
||||
execOverrides === undefined &&
|
||||
params.skillCommands &&
|
||||
params.skillCommands.length > 0
|
||||
? params.skillCommands
|
||||
@@ -381,7 +381,7 @@ export async function handleInlineActions(params: {
|
||||
skillCommands,
|
||||
})
|
||||
: null;
|
||||
if (!skillInvocation && allowTextCommands && canUseInlineSkills && skillCommands.length > 0) {
|
||||
if (!skillInvocation && allowTextCommands && hasInlineSkillCandidate && skillCommands.length) {
|
||||
skillInvocation = resolveInlineSkillCommandInvocation({
|
||||
commandBodyNormalized: command.commandBodyNormalized,
|
||||
skillCommands,
|
||||
|
||||
Reference in New Issue
Block a user