Skip to content

Commit a4c1e22

Browse files
zw-xyskcursoragentsteipete
authored
fix(slack): preserve unrelated action rows after interactions (#103445)
* fix(slack): use endsWith instead of includes for _all_ action_id matching * fix(slack): codify bulk action IDs and add confirmation regressions Extract isSlackBulkActionId() with the documented _all suffix grammar, use it for bulk-row detection, and add whole-path chat.update tests for bulk-row cleanup plus deploy_all_services false-positive control. Co-authored-by: Cursor <[email protected]> * fix(slack): use OpenClaw bulk block marker instead of _all suffix Replace global endsWith("_all") bulk detection with an explicit openclaw:bulk: block_id prefix and closed action IDs, export a shared producer helper, and add live Slack chat.update proof for bulk-row removal and deploy_all_services preservation. Co-authored-by: Cursor <[email protected]> * fix(slack): keep bulk contract private and add legacy upgrade path Drop speculative bulk-action exports from the Slack plugin API, keep accepted ID collections private and immutable, and recognize legacy bare select_all/deselect_all rows while still rejecting deploy_all_services false positives. Co-authored-by: Cursor <[email protected]> * fix(slack): drop unsupported bare bulk compatibility branch Remove the legacy select_all/deselect_all classifier that overmatched single-ID and duplicate-ID rows, and add negative whole-path regressions preserving unrelated custom action rows. Co-authored-by: Cursor <[email protected]> * fix(slack): remove unsupported bulk-row cleanup heuristic Delete the undocumented bulk-row inference and namespaced replacement contract. Confirmation updates now replace only the selected actions row and preserve every other authored Block Kit row. * refactor(slack): tighten interaction confirmation fix * chore(changelog): preserve historical TTS entries * chore(slack): move release note to PR body --------- Co-authored-by: zw-xysk <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
1 parent a89e6d9 commit a4c1e22

2 files changed

Lines changed: 41 additions & 30 deletions

File tree

‎extensions/slack/src/monitor/events/interactions.block-actions.ts‎

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import { escapeSlackMrkdwn } from "../mrkdwn.js";
4040
type InteractionMessageBlock = {
4141
type?: string;
4242
block_id?: string;
43-
elements?: Array<{ action_id?: string }>;
4443
};
4544

4645
type SelectOption = {
@@ -285,15 +284,6 @@ export function summarizeAction(action: Record<string, unknown>): SlackActionSum
285284
};
286285
}
287286

288-
function isBulkActionsBlock(block: InteractionMessageBlock): boolean {
289-
return (
290-
block.type === "actions" &&
291-
Array.isArray(block.elements) &&
292-
block.elements.length > 0 &&
293-
block.elements.every((el) => typeof el.action_id === "string" && el.action_id.includes("_all_"))
294-
);
295-
}
296-
297287
function formatInteractionSelectionLabel(params: {
298288
actionId: string;
299289
summary: SlackActionSummary;
@@ -828,7 +818,7 @@ function buildSlackConfirmationBlocks(params: {
828818
summary: params.parsed.actionSummary,
829819
buttonText: params.parsed.typedActionWithText.text?.text,
830820
});
831-
let updatedBlocks = params.originalBlocks.map((block) => {
821+
return params.originalBlocks.map((block) => {
832822
const typedBlock = block as InteractionMessageBlock;
833823
if (typedBlock.type === "actions" && typedBlock.block_id === params.parsed.blockId) {
834824
return {
@@ -845,25 +835,7 @@ function buildSlackConfirmationBlocks(params: {
845835
};
846836
}
847837
return block;
848-
});
849-
const hasRemainingIndividualActionRows = updatedBlocks.some((block) => {
850-
const typedBlock = block as InteractionMessageBlock;
851-
return typedBlock.type === "actions" && !isBulkActionsBlock(typedBlock);
852-
});
853-
if (!hasRemainingIndividualActionRows) {
854-
updatedBlocks = updatedBlocks.filter((block, index) => {
855-
const typedBlock = block as InteractionMessageBlock;
856-
if (isBulkActionsBlock(typedBlock)) {
857-
return false;
858-
}
859-
if (typedBlock.type !== "divider") {
860-
return true;
861-
}
862-
const next = updatedBlocks[index + 1] as InteractionMessageBlock | undefined;
863-
return !next || !isBulkActionsBlock(next);
864-
});
865-
}
866-
return updatedBlocks as (Block | KnownBlock)[];
838+
}) as (Block | KnownBlock)[];
867839
}
868840

869841
async function updateSlackLegacyBlockAction(params: {

‎extensions/slack/src/monitor/events/interactions.test.ts‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,18 @@ describe("registerSlackInteractionEvents", () => {
601601
ts: "100.200",
602602
text: "fallback",
603603
blocks: [
604+
{ type: "divider" },
605+
{
606+
type: "actions",
607+
block_id: "deploy_row",
608+
elements: [
609+
{
610+
type: "button",
611+
action_id: "deploy_all_services",
612+
text: { type: "plain_text", text: "Deploy all services" },
613+
},
614+
],
615+
},
604616
{
605617
type: "actions",
606618
block_id: "verify_block",
@@ -643,6 +655,33 @@ describe("registerSlackInteractionEvents", () => {
643655
});
644656
expect(trackEvent).toHaveBeenCalledTimes(1);
645657
expect(app.client.chat.update).toHaveBeenCalledTimes(1);
658+
expectRecordFields(chatUpdateCall(app), {
659+
channel: "C1",
660+
ts: "100.200",
661+
blocks: [
662+
{ type: "divider" },
663+
{
664+
type: "actions",
665+
block_id: "deploy_row",
666+
elements: [
667+
{
668+
type: "button",
669+
action_id: "deploy_all_services",
670+
text: { type: "plain_text", text: "Deploy all services" },
671+
},
672+
],
673+
},
674+
{
675+
type: "context",
676+
elements: [
677+
{
678+
type: "mrkdwn",
679+
text: ":white_check_mark: *Approve* selected by <@U123>",
680+
},
681+
],
682+
},
683+
],
684+
});
646685
});
647686

648687
it("registers a matcher that accepts plugin action ids beyond the OpenClaw prefix", () => {

0 commit comments

Comments
 (0)