Skip to content

Commit 958a2bf

Browse files
author
Joshua Chittick
committed
fix: reuse /setting launcher for settings issues
1 parent 3c8c169 commit 958a2bf

File tree

2 files changed

+44
-47
lines changed

2 files changed

+44
-47
lines changed

packages/ims/slack/client.ts

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,36 @@ function isGitHubCommand(text: string): boolean {
245245
return /^\/gh\b/i.test(text.trim());
246246
}
247247

248+
type SettingsLauncherButton = {
249+
actionId: string;
250+
label: string;
251+
};
252+
253+
function buildSettingsLauncherBlocks(
254+
channelId: string,
255+
description: string,
256+
buttons: SettingsLauncherButton[]
257+
): any[] {
258+
return [
259+
{
260+
type: "section",
261+
text: {
262+
type: "mrkdwn",
263+
text: description,
264+
},
265+
},
266+
{
267+
type: "actions",
268+
elements: buttons.map((button) => ({
269+
type: "button",
270+
action_id: button.actionId,
271+
text: { type: "plain_text", text: button.label },
272+
value: channelId,
273+
})),
274+
},
275+
];
276+
}
277+
248278
async function postChannelSettingsLauncher(
249279
channelId: string,
250280
userId: string,
@@ -254,26 +284,11 @@ async function postChannelSettingsLauncher(
254284
channel: channelId,
255285
user: userId,
256286
text: "Open channel settings",
257-
blocks: [
258-
{
259-
type: "section",
260-
text: {
261-
type: "mrkdwn",
262-
text: "Open channel settings for agent, working directory, base branch, and optional channel system message (model appears for OpenCode and Codex).",
263-
},
264-
},
265-
{
266-
type: "actions",
267-
elements: [
268-
{
269-
type: "button",
270-
action_id: "open_settings_modal",
271-
text: { type: "plain_text", text: "Open settings" },
272-
value: channelId,
273-
},
274-
],
275-
},
276-
],
287+
blocks: buildSettingsLauncherBlocks(
288+
channelId,
289+
"Open channel settings for agent, working directory, base branch, and optional channel system message (model appears for OpenCode and Codex).",
290+
[{ actionId: "open_settings_modal", label: "Open settings" }]
291+
),
277292
});
278293
}
279294

@@ -286,32 +301,14 @@ async function postGeneralSettingsLauncher(
286301
channel: channelId,
287302
user: userId,
288303
text: "Open settings",
289-
blocks: [
290-
{
291-
type: "section",
292-
text: {
293-
type: "mrkdwn",
294-
text: "Choose which settings page to open.",
295-
},
296-
},
297-
{
298-
type: "actions",
299-
elements: [
300-
{
301-
type: "button",
302-
action_id: "open_general_settings_modal",
303-
text: { type: "plain_text", text: "general setting" },
304-
value: channelId,
305-
},
306-
{
307-
type: "button",
308-
action_id: "open_settings_modal",
309-
text: { type: "plain_text", text: "channel setting" },
310-
value: channelId,
311-
},
312-
],
313-
},
314-
],
304+
blocks: buildSettingsLauncherBlocks(
305+
channelId,
306+
"Choose which settings page to open.",
307+
[
308+
{ actionId: "open_general_settings_modal", label: "general setting" },
309+
{ actionId: "open_settings_modal", label: "channel setting" },
310+
]
311+
),
315312
});
316313
}
317314

packages/ims/slack/message-router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ async function maybeNotifySettingsIssues(
131131
text: `Channel settings need attention:\n- ${settingsIssues.join("\n- ")}`,
132132
thread_ts: threadId,
133133
});
134-
await deps.postChannelSettingsLauncher(channelId, userId, client);
134+
await deps.postGeneralSettingsLauncher(channelId, userId, client);
135135
return true;
136136
}
137137

0 commit comments

Comments
 (0)