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
20 changes: 20 additions & 0 deletions apps/api/src/handlers/discord/callback-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import {
handleDiscordRoutingCallback,
parseDiscordRouteCallbackData,
} from './routing-confirmation.js';
import {
hasPendingDiscordRequestUserInputCallback,
tryHandleDiscordRequestUserInputCallback,
} from './request-user-input.js';
import type { DiscordChannelContext } from './task-launch.js';
import {
discordMetadataForChannel,
Expand Down Expand Up @@ -370,6 +374,22 @@ export async function handleDiscordComponentInteraction(input: {
channel: DiscordChannelContext;
}): Promise<'handled' | 'unsupported'> {
const customId = input.interaction.data?.custom_id;
if (hasPendingDiscordRequestUserInputCallback(customId)) {
const sender = input.interaction.member?.user ?? input.interaction.user;
const mappedUserId = sender?.id
? await findDiscordMappedUserId(sender.id)
: null;
await tryHandleDiscordRequestUserInputCallback({
provider: input.provider,
applicationId: input.applicationId,
channel: input.channel,
interaction: input.interaction,
interactionDeferred: input.interactionDeferred,
customId,
userId: mappedUserId,
});
return 'handled';
}
const cancelRunId = parseCancelCallbackData(customId);
if (cancelRunId) {
await handleCancelCallback({ ...input, runId: cancelRunId });
Expand Down
23 changes: 23 additions & 0 deletions apps/api/src/handlers/discord/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
findCommunicationTaskRunBySourceEvent,
} from '../tasks/communication-task-run-lookup.js';
import { resumeCommunicationTaskFromSnapshot } from '../tasks/communication-snapshot-resume.js';
import { tryHandleDiscordRequestUserInputMessage } from './request-user-input.js';
import {
attachOutOfBandContextToCommunicationMessage,
releaseCommunicationOutOfBandClaim,
Expand Down Expand Up @@ -519,6 +520,28 @@ async function processDiscordGatewayEvent(event: DiscordGatewayEvent) {
runId: activeRun.id,
senderUserId,
});

if (message && queuedMessage) {
const handledRequestUserInput =
await tryHandleDiscordRequestUserInputMessage({
provider: resolved.provider,
applicationId: resolved.applicationId,
channel,
activeRun: { id: activeRun.id },
userId: senderUserId,
text: queuedMessage.text,
replyToMessageId: message.id,
});
if (handledRequestUserInput) {
return {
ok: true,
queued: true,
runId: activeRun.id,
requestUserInput: true,
};
}
}

// Mirror Slack: rebuild undelivered thread context + latest bot reply into
// the follow-up prompt so agents keep full Discord conversation context.
let continuationClaim: {
Expand Down
Loading
Loading