Skip to content
Draft
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ function mapSettingsToFormState(
platformIssueSlackChannelId: string | null;
platformIssueSlackChannelName?: string | null;
platformIssueDiscordChannelId: string | null;
platformIssueTeamsChannelId: string | null;
securityAuditorSlackChannelId: string | null;
securityAuditorSlackChannelName?: string | null;
securityAuditorDiscordChannelId: string | null;
Expand Down Expand Up @@ -850,6 +851,7 @@ function mapSettingsToFormState(
settings.platformIssueSlackChannelId ??
'',
platformIssueDiscordChannel: settings.platformIssueDiscordChannelId ?? '',
platformIssueTeamsChannel: settings.platformIssueTeamsChannelId ?? '',
securityAuditorSlackChannel:
settings.securityAuditorSlackChannelName ??
settings.securityAuditorSlackChannelId ??
Expand Down Expand Up @@ -897,16 +899,21 @@ export function buildSlackWorkflowLaunchUrl(

export function isPlatformIssueAlertsEnabled(
formState:
| Pick<
FormState,
'platformIssueSlackChannel' | 'platformIssueDiscordChannel'
| Partial<
Pick<
FormState,
| 'platformIssueSlackChannel'
| 'platformIssueDiscordChannel'
| 'platformIssueTeamsChannel'
>
>
| null
| undefined,
): boolean {
return Boolean(
formState?.platformIssueSlackChannel.trim() ||
formState?.platformIssueDiscordChannel.trim(),
formState?.platformIssueSlackChannel?.trim() ||
formState?.platformIssueDiscordChannel?.trim() ||
formState?.platformIssueTeamsChannel?.trim(),
);
}

Expand Down Expand Up @@ -2544,6 +2551,9 @@ export function AutomationsSettings() {
DISCORD_DESTINATION_OPTION_PREFIX.length,
),
...clearSuggesterAltDestinations,
...(field === 'platformIssueSlackChannel'
? { platformIssueTeamsChannel: '' }
: {}),
};
}

Expand All @@ -2552,6 +2562,9 @@ export function AutomationsSettings() {
[field]: nextValue ?? '',
[discordField]: '',
...clearSuggesterAltDestinations,
...(field === 'platformIssueSlackChannel'
? { platformIssueTeamsChannel: '' }
: {}),
};
})
}
Expand Down Expand Up @@ -4509,6 +4522,48 @@ If unclear, send to manager channel.`}
warningChannelId:
slackChannelAccessWarnings.platformIssueSlackChannel,
})}
{(settingsQuery.data?.teamsConversations.length ?? 0) > 0 ? (
<div className="space-y-2">
<Label htmlFor="platform-issue-teams-channel">
Or post alerts to this Teams conversation
</Label>
<Select
value={formState?.platformIssueTeamsChannel || '__none__'}
onValueChange={(value) =>
setFormState((prev) =>
prev
? {
...prev,
platformIssueTeamsChannel:
value === '__none__' ? '' : value,
platformIssueSlackChannel: '',
platformIssueDiscordChannel: '',
}
: prev,
)
}
>
<SelectTrigger id="platform-issue-teams-channel">
<SelectValue placeholder="Select a Teams conversation" />
</SelectTrigger>
<SelectContent>
<SelectItem value="__none__">
Select a Teams conversation
</SelectItem>
{settingsQuery.data?.teamsConversations.map(
(conversation) => (
<SelectItem
key={conversation.conversationId}
value={conversation.conversationId}
>
{conversation.label}
</SelectItem>
),
)}
</SelectContent>
</Select>
</div>
) : null}
</div>
</AutomationCard>
</div>
Expand Down
9 changes: 7 additions & 2 deletions apps/web/src/components/settings/automations/formState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export type FormState = {
* Mutually exclusive with Slack/Discord/Telegram destinations.
*/
suggesterUseTeams: boolean;
platformIssueTeamsChannel: string;
suggesterRoutingMode: SuggesterRoutingMode;
suggesterRoutingInstructions: string;
announcerFrequency: AnnouncerFrequency;
Expand Down Expand Up @@ -186,8 +187,10 @@ const ANNOUNCER_FIELDS: Array<keyof FormState> = [
'announcerInstructions',
];

const PLATFORM_ISSUE_ALERT_FIELDS: Array<keyof FormState> =
DESTINATION_CHANNEL_FIELDS_BY_AUTOMATION_ID.platformIssueAlerts;
const PLATFORM_ISSUE_ALERT_FIELDS: Array<keyof FormState> = [
...DESTINATION_CHANNEL_FIELDS_BY_AUTOMATION_ID.platformIssueAlerts,
'platformIssueTeamsChannel',
];

const SCHEDULE_ONLY_AUTOMATION_FIELDS = Object.fromEntries(
SCHEDULE_ONLY_BACKGROUND_AUTOMATION_LIST.map((automation) => [
Expand Down Expand Up @@ -353,6 +356,8 @@ export function buildAutomationSettingsSaveInput(
suggesterInstructions: stateToSave.suggesterInstructions.trim() || null,
suggesterUseTelegram: stateToSave.suggesterUseTelegram,
suggesterUseTeams: stateToSave.suggesterUseTeams,
platformIssueTeamsChannel:
stateToSave.platformIssueTeamsChannel.trim() || null,
suggesterRoutingMode: stateToSave.suggesterRoutingMode,
suggesterRoutingInstructions:
stateToSave.suggesterRoutingInstructions.trim() || null,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions apps/web/src/trpc/commands/automations/settings-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
import {
findDiscordDestinationByChannelId,
findTeamsConversationDisplayName,
listTeamsAutomationDestinations,
findTeamsPrimaryConversation,
resolveAutomationRuntimeDestination,
type ResolvedAutomationDestination,
Expand Down Expand Up @@ -219,6 +220,15 @@ async function resolveAutomationDestinations(params: {
slackConnected: params.slackConnected,
});

// Platform issue alerts intentionally stop at an explicit target or
// Manager Channel; delivery never falls through to a primary conversation.
if (
key === 'platform_issue_alerts' &&
destination?.source === 'primary_conversation'
) {
return [key, null] as const;
}

if (!destination) {
return [key, null] as const;
}
Expand Down Expand Up @@ -292,6 +302,7 @@ export async function getBackgroundAgentSettingsCommand(
automationStatus: Partial<
Record<BackgroundAutomationKey, AutomationStatusSummary>
>;
teamsConversations: Array<{ conversationId: string; label: string }>;
}> {
assertAdmin(auth);

Expand All @@ -301,6 +312,7 @@ export async function getBackgroundAgentSettingsCommand(
discordInstallation,
telegramCredentials,
teamsPrimaryConversation,
teamsConversations,
sentryConnected,
recentRuns,
status,
Expand All @@ -313,6 +325,7 @@ export async function getBackgroundAgentSettingsCommand(
}),
resolveTelegramRuntimeCredentials(),
findTeamsPrimaryConversation(),
listTeamsAutomationDestinations(),
hasActiveSentryIntegration(),
listRecentAutomationTasks(),
buildAutomationStatus(),
Expand Down Expand Up @@ -409,6 +422,7 @@ export async function getBackgroundAgentSettingsCommand(
? slackInstallation.teamDomain
: null,
},
teamsConversations,
slackChannelAccessWarnings,
slackChannelDisplayNames,
resolvedDestinations,
Expand Down
Loading
Loading