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
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export function pendingTranscriptMessage(
// Keep pending rows after history without colliding with real event seqs.
sourceSeq: Number.MAX_SAFE_INTEGER - 1_000_000 + index,
timestamp: Date.parse(message.createdAt),
...(message.actorIdentity ? { actorIdentity: message.actorIdentity } : undefined),
...(message.actorIdentity
? { actorIdentity: message.actorIdentity }
: undefined),
};
}

Expand Down Expand Up @@ -197,7 +199,9 @@ export function transcriptMessagesFromEvents(
: { type: "text", text: data.text! },
]),
messageId: data.messageId,
...(data.actorIdentity ? { actorIdentity: data.actorIdentity } : undefined),
...(data.actorIdentity
? { actorIdentity: data.actorIdentity }
: undefined),
...(data.eventType ? { eventType: data.eventType } : undefined),
...(data.trustedSummary
? { trustedSummary: data.trustedSummary }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describeEval("Event automation management", slackEvals, (it) => {
],
fail: [
"Do not create separate tasks for closed and reopened.",
"Do not claim a polling schedule, recurring timer, or watch was created.",
"Do not claim that `watchEvents`, a polling schedule, or a recurring timer was created instead of the event automation.",
],
}),
});
Expand Down Expand Up @@ -208,7 +208,7 @@ describeEval("Event automation management", slackEvals, (it) => {
fail: [
"Do not narrow the task to one issue number.",
"Do not create separate tasks for closed and reopened issues.",
"Do not claim a polling schedule or watch was created.",
"Do not claim that `watchEvents` or a polling schedule was created instead of the event automation.",
],
}),
});
Expand Down
3 changes: 1 addition & 2 deletions packages/junior-evals/src/behavior-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1143,8 +1143,7 @@ function toEvalAssistantPost(value: unknown): EvalAssistantPost {
* Build a Chat SDK Message for Slack ingress from a harness event.
*
* Synthetic Slack ingress keeps an empty formatted AST so plain text remains
* the source of truth, matching mailbox restore and edited-message
* construction elsewhere in Junior.
* the source of truth, matching mailbox restore elsewhere in Junior.
*/
function toSlackMessage(
event: MentionEvent | SubscribedMessageEvent,
Expand Down
190 changes: 0 additions & 190 deletions packages/junior/src/chat/ingress/message-changed.ts

This file was deleted.

64 changes: 2 additions & 62 deletions packages/junior/src/chat/ingress/slack-webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ import {
import { coerceThreadConversationState } from "@/chat/state/conversation";
import { parseContent } from "@/chat/slack/message/content";
import { stopSlackThread } from "@/chat/slack/thread-stop";
import {
extractMessageChangedMention,
isMessageChangedEnvelope,
} from "@/chat/ingress/message-changed";
import {
normalizeIncomingSlackThreadId,
withNormalizedThreadId,
Expand Down Expand Up @@ -102,6 +98,8 @@ function slackEventLogContext(
}

const IGNORED_MESSAGE_SUBTYPES = new Set([
// Conversation Messages are immutable once accepted. An edit must not
// rewrite input or start another Turn. Send a new Slack Message instead.
"message_changed",
"message_deleted",
"message_replied",
Expand Down Expand Up @@ -454,50 +452,6 @@ async function routeParsedMessage(args: {
});
}

async function handleMessageChanged(args: {
adapter: SlackAdapter;
body: unknown;
installation: SlackInstallationContext;
queue: ConversationWorkQueue;
conversationStore?: ConversationStore;
receivedAtMs: number;
state: StateAdapter;
}): Promise<boolean> {
if (!isMessageChangedEnvelope(args.body)) {
return false;
}
const botUserId = args.adapter.botUserId;
if (!botUserId) {
// Entry classification requires resolved bot identity; degrading into
// silently dropped edited-mention events would hide the outage. Throwing
// makes the webhook return a retryable non-2xx so Slack redelivers.
throw new Error(
"Slack bot identity is unresolved; cannot classify message_changed event",
);
}

const result = extractMessageChangedMention(
args.body,
botUserId,
args.adapter,
);
if (!result || shouldIgnoreMessage(result.message)) {
return true;
}

await persistSlackMessage({
adapter: args.adapter,
installation: args.installation,
message: result.message,
conversationStore: args.conversationStore,
queue: args.queue,
receivedAtMs: args.receivedAtMs,
route: "mention",
state: args.state,
});
return true;
}

async function handleSlackEvent(args: {
body: SlackEventEnvelope;
services: SlackWebhookServices;
Expand Down Expand Up @@ -533,20 +487,6 @@ async function handleSlackEvent(args: {
installation,
state,
task: async () => {
if (
await handleMessageChanged({
adapter,
body: args.body,
installation,
conversationStore: args.services.conversationStore,
queue: args.services.queue,
receivedAtMs,
state,
})
) {
return;
}

if (event.type === "assistant_thread_started") {
const assistantThread = (event as Record<string, unknown>)
.assistant_thread as
Expand Down
Loading
Loading