Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions app/channel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,52 @@ describe("createOpenTagChannel", () => {
expect((agent as CapturingAgent).calls).toHaveLength(2);
});

it("handles an unmentioned turn already admitted by managed ingress", async () => {
it.each(["bot", "app"] as const)(
"ignores %s-authored messages in a subscribed thread",
async (actorKind) => {
const { adapter, agent, channel } = makeChannel();

await channel.ɵruntime.start();
await adapter.getSink().onTurn({
conversationKey: "bot-loop-thread",
replyTarget: {},
userText: "@Kite join us",
platform: "slack",
actor: { id: "U1", kind: "human" },
operation: {
kind: "created",
logicalMessageId: "m1",
revisionId: "m1",
mentioned: true,
},
});

await adapter.getSink().onTurn({
conversationKey: "bot-loop-thread",
replyTarget: {},
userText: "Canonical status confirmed: vibing cat it is.",
platform: "slack",
actor: { id: "B1", kind: actorKind },
operation: {
kind: "created",
logicalMessageId: "m2",
revisionId: "m2",
mentioned: false,
},
});

expect((agent as CapturingAgent).calls).toHaveLength(1);
},
);

it("ignores an unmentioned turn in an unsubscribed thread", async () => {
const { adapter, agent, channel } = makeChannel();

await channel.ɵruntime.start();
await adapter.getSink().onTurn({
conversationKey: "managed-thread",
replyTarget: {},
userText: "This turn passed the managed subscription gate",
userText: "This thread is not subscribed",
platform: "slack",
actor: { id: "U2", kind: "human" },
operation: {
Expand All @@ -196,7 +234,7 @@ describe("createOpenTagChannel", () => {
},
});

expect((agent as CapturingAgent).calls).toHaveLength(1);
expect((agent as CapturingAgent).calls).toHaveLength(0);
});

it("declares one managed Channel and retains app commands", () => {
Expand Down
5 changes: 4 additions & 1 deletion app/channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ export function createOpenTagChannel(
});

channel.onMessage(async ({ thread, message }) => {
if(await thread.isSubscribed())
if (message.actor.kind === "bot" || message.actor.kind === "app") return;

if (await thread.isSubscribed()) {
await runAgentSafely({ thread, message });
}
});

channel.onModalSubmit(FILE_ISSUE_CALLBACK, fileIssueSubmit);
Expand Down