Slack: attribute interaction confirmations and structured selects

This commit is contained in:
Colin
2026-02-16 13:45:48 -05:00
committed by Peter Steinberger
parent 9fcb93dd13
commit a7c1b8aea7
2 changed files with 26 additions and 6 deletions

View File

@@ -213,7 +213,7 @@ describe("registerSlackInteractionEvents", () => {
blocks: [
{
type: "context",
elements: [{ type: "mrkdwn", text: ":white_check_mark: *Canary* selected" }],
elements: [{ type: "mrkdwn", text: ":white_check_mark: *Canary* selected by <@U555>" }],
},
],
}),
@@ -314,7 +314,10 @@ describe("registerSlackInteractionEvents", () => {
{
type: "context",
elements: [
{ type: "mrkdwn", text: ":white_check_mark: *Alpha, Beta, Gamma +1* selected" },
{
type: "mrkdwn",
text: ":white_check_mark: *Alpha, Beta, Gamma +1* selected by <@U222>",
},
],
},
],
@@ -423,7 +426,9 @@ describe("registerSlackInteractionEvents", () => {
blocks: [
{
type: "context",
elements: [{ type: "mrkdwn", text: ":white_check_mark: *2026-02-16* selected" }],
elements: [
{ type: "mrkdwn", text: ":white_check_mark: *2026-02-16* selected by <@U333>" },
],
},
expect.anything(),
expect.anything(),
@@ -438,7 +443,7 @@ describe("registerSlackInteractionEvents", () => {
blocks: [
{
type: "context",
elements: [{ type: "mrkdwn", text: ":white_check_mark: *14:30* selected" }],
elements: [{ type: "mrkdwn", text: ":white_check_mark: *14:30* selected by <@U333>" }],
},
],
}),
@@ -454,7 +459,9 @@ describe("registerSlackInteractionEvents", () => {
elements: [
{
type: "mrkdwn",
text: `:white_check_mark: *${new Date(selectedDateTimeEpoch * 1000).toISOString()}* selected`,
text: `:white_check_mark: *${new Date(
selectedDateTimeEpoch * 1000,
).toISOString()}* selected by <@U333>`,
},
],
},

View File

@@ -284,6 +284,14 @@ function formatInteractionSelectionLabel(params: {
return params.actionId;
}
function formatInteractionConfirmationText(params: {
selectedLabel: string;
userId?: string;
}): string {
const actor = params.userId?.trim() ? ` by <@${params.userId.trim()}>` : "";
return `:white_check_mark: *${params.selectedLabel}* selected${actor}`;
}
function summarizeViewState(values: unknown): ModalInputSummary[] {
if (!values || typeof values !== "object") {
return [];
@@ -425,7 +433,12 @@ export function registerSlackInteractionEvents(params: { ctx: SlackMonitorContex
if (typedBlock.type === "actions" && typedBlock.block_id === blockId) {
return {
type: "context",
elements: [{ type: "mrkdwn", text: `:white_check_mark: *${selectedLabel}* selected` }],
elements: [
{
type: "mrkdwn",
text: formatInteractionConfirmationText({ selectedLabel, userId }),
},
],
};
}
return block;