fix(skills): scope inline markers to webchat

This commit is contained in:
Jesse Merhi
2026-08-13 11:23:52 +10:00
parent 287fdf4296
commit d3c6d32cd0
2 changed files with 42 additions and 3 deletions
@@ -762,7 +762,12 @@ describe("handleInlineActions", () => {
it("rewrites a skill marker embedded in normal prose", async () => {
const typing = createTypingController();
const body = "Please use /office_hours: to build me a deployment plan";
const ctx = buildTestCtx({ Body: body, CommandBody: body });
const ctx = buildTestCtx({
Body: body,
CommandBody: body,
Provider: "webchat",
Surface: "webchat",
});
const result = await handleInlineActions(
createHandleInlineActionsInput({
@@ -796,7 +801,12 @@ describe("handleInlineActions", () => {
it("keeps unauthorized inline skill markers as plain text", async () => {
const typing = createTypingController();
const body = "Please use /office_hours: to build me a deployment plan";
const ctx = buildTestCtx({ Body: body, CommandBody: body });
const ctx = buildTestCtx({
Body: body,
CommandBody: body,
Provider: "webchat",
Surface: "webchat",
});
const result = await handleInlineActions(
createHandleInlineActionsInput({
@@ -821,6 +831,34 @@ describe("handleInlineActions", () => {
expect(handleCommandsMock).not.toHaveBeenCalled();
});
it("keeps authorized messaging-channel inline skill markers as plain text", async () => {
const typing = createTypingController();
const body = "Please use /office_hours: to build me a deployment plan";
const ctx = buildTestCtx({ Body: body, CommandBody: body });
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.each(["Review /tmp/foo before continuing", "/tmp/foo should stay a path"])(
"does not load workspace skills for a bare path in %j",
async (body) => {
@@ -385,7 +385,8 @@ export async function handleInlineActions(params: {
!skillInvocation &&
allowTextCommands &&
skillCommands.length > 0 &&
command.isAuthorizedSender
command.isAuthorizedSender &&
ctx.Surface === INTERNAL_MESSAGE_CHANNEL
) {
skillInvocation = resolveInlineSkillCommandInvocation({
commandBodyNormalized: command.commandBodyNormalized,