Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(comments): send a discussion to Slack from the UI + render Slack state (#79448)

Luke Belton9e8457719c41
diff --git a/frontend/src/lib/lemon-ui/LemonRichContent/LemonRichContentEditor.tsx b/frontend/src/lib/lemon-ui/LemonRichContent/LemonRichContentEditor.tsx
index 5243d01ae923..357727666d18 100644
--- a/frontend/src/lib/lemon-ui/LemonRichContent/LemonRichContentEditor.tsx
+++ b/frontend/src/lib/lemon-ui/LemonRichContent/LemonRichContentEditor.tsx
@@ -38,6 +38,8 @@ export type LemonRichContentEditorProps = {
onPressCmdEnter?: () => void
disabled?: boolean
minRows?: number
+ /** Extra controls rendered in the footer toolbar, left of the write/preview toggle. */
+ footerActions?: React.ReactNode
}
const DEFAULT_INITIAL_CONTENT: JSONContent = {
@@ -105,6 +107,7 @@ export function LemonRichContentEditor({
onPressCmdEnter,
disabled = false,
minRows,
+ footerActions,
}: LemonRichContentEditorProps): JSX.Element {
const [isPreviewShown, setIsPreviewShown] = useState<boolean>(false)
const [ttEditor, setTTEditor] = useState<TTEditor | null>(null)
@@ -206,6 +209,7 @@ export function LemonRichContentEditor({
)}
</div>
<div className="flex items-center gap-0.5">
+ {footerActions}
<LemonButton size="small" active={!isPreviewShown} onClick={() => setIsPreviewShown(false)}>
<IconPencil />
</LemonButton>
diff --git a/frontend/src/scenes/comments/Comment.tsx b/frontend/src/scenes/comments/Comment.tsx
index d1526f14c167..f20b2d4c4dc5 100644
--- a/frontend/src/scenes/comments/Comment.tsx
+++ b/frontend/src/scenes/comments/Comment.tsx
@@ -4,14 +4,16 @@ import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
import { useEffect, useMemo, useRef } from 'react'
-import { IconChevronRight, IconEllipsis, IconEye, IconPencil, IconTrash } from '@posthog/icons'
+import { IconChevronRight, IconEllipsis, IconEye, IconPencil, IconShare, IconTrash } from '@posthog/icons'
import { LemonButton, LemonCheckbox, LemonMenu, LemonTag, ProfilePicture, Tooltip } from '@posthog/lemon-ui'
import { SentenceList } from 'lib/components/ActivityLog/SentenceList'
import { EmojiPickerPopover } from 'lib/components/EmojiPicker/EmojiPickerPopover'
import { KeyboardShortcut } from 'lib/components/KeyboardShortcut/KeyboardShortcut'
import { TZLabel } from 'lib/components/TZLabel'
+import { FEATURE_FLAGS } from 'lib/constants'
import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
+import { IconSlack } from 'lib/lemon-ui/icons'
import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
import {
@@ -19,6 +21,7 @@ import {
LemonRichContentEditor,
serializationOptions,
} from 'lib/lemon-ui/LemonRichContent/LemonRichContentEditor'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { colonDelimitedDuration } from 'lib/utils/durations'
import { pluralize } from 'lib/utils/strings'
@@ -27,6 +30,19 @@ import { CommentType } from '~/types'
import { CommentComposer } from './CommentComposer'
import { CommentsLogicProps, CommentWithRepliesType, commentsLogic } from './commentsLogic'
import { getRecordingLinkInfo, isViewingRecording } from './commentUtils'
+import { sendCommentToSlackLogic } from './sendCommentToSlackLogic'
+
+// Comments that came in from a synced Slack thread have no PostHog author; their Slack identity
+// rides in item_context.
+function getCommentAuthorName(comment: CommentType): string {
+ if (comment.created_by) {
+ return comment.created_by.first_name ?? 'Unknown user'
+ }
+ if (comment.item_context?.from_slack) {
+ return comment.item_context.slack_author_name ?? 'Slack user'
+ }
+ return 'Unknown user'
+}
export type CommentProps = {
commentWithReplies: CommentWithRepliesType
@@ -177,16 +193,26 @@ const CommentEditingForm = ({ comment }: { comment: CommentType }): JSX.Element
const CommentTopRow = ({ comment }: { comment: CommentType }): JSX.Element => {
const { disabledReasonFor } = useValues(commentsLogic)
- const { deleteComment, setEditingComment, sendEmojiReaction } = useActions(commentsLogic)
+ const { deleteComment, setEditingComment, sendEmojiReaction, setReplyingComment } = useActions(commentsLogic)
+ const { featureFlags } = useValues(featureFlagLogic)
+ const { openModal } = useActions(sendCommentToSlackLogic)
const isCompleted = !!comment.completed_at
+ const fromSlack = !!comment.item_context?.from_slack
+ const slackThread = comment.slack_thread
+ // Only an untracked top-level comment (a thread root) can be sent to Slack; replies follow their parent.
+ const canSendToSlack =
+ featureFlags[FEATURE_FLAGS.DISCUSSIONS_SLACK_SYNC] && !comment.source_comment && !fromSlack && !slackThread
return (
<div className="flex items-center justify-between gap-2">
<div className="flex items-center gap-2">
- <span className="ph-no-capture flex-1 font-semibold">
- {comment.created_by?.first_name ?? 'Unknown user'}
- </span>
+ <span className="ph-no-capture flex-1 font-semibold">{getCommentAuthorName(comment)}</span>
+ {fromSlack ? (
+ <LemonTag size="small" type="muted">
+ via Slack
+ </LemonTag>
+ ) : null}
{comment.is_task ? (
<LemonTag size="small" type={isCompleted ? 'success' : 'warning'}>
{isCompleted ? 'Completed' : 'Task'}
@@ -194,6 +220,18 @@ const CommentTopRow = ({ comment }: { comment: CommentType }): JSX.Element => {
) : null}
</div>
<div className="flex items-center gap-1">
+ {slackThread ? (
+ <LemonButton
+ icon={<IconSlack />}
+ size="xsmall"
+ to={slackThread.url}
+ targetBlank
+ tooltip="Open synced Slack discussion"
+ data-attr="discussions-comment-open-in-slack"
+ >
+ {slackThread.channel_name ? `#${slackThread.channel_name}` : 'Open in Slack'}
+ </LemonButton>
+ ) : null}
{comment.created_at ? (
<span className="text-xs">
<TZLabel time={comment.created_at} />
@@ -213,6 +251,20 @@ const CommentTopRow = ({ comment }: { comment: CommentType }): JSX.Element => {
<LemonMenu
items={[
+ {
+ icon: <IconShare />,
+ label: 'Reply',
+ onClick: () => setReplyingComment(comment.source_comment ?? comment.id),
+ },
+ ...(canSendToSlack
+ ? [
+ {
+ icon: <IconSlack />,
+ label: 'Send to Slack',
+ onClick: () => openModal(comment),
+ },
+ ]
+ : []),
{
icon: <IconPencil />,
label: 'Edit',
diff --git a/frontend/src/scenes/comments/CommentComposer.tsx b/frontend/src/scenes/comments/CommentComposer.tsx
index 4875e55d9c45..98834eac9a80 100644
--- a/frontend/src/scenes/comments/CommentComposer.tsx
+++ b/frontend/src/scenes/comments/CommentComposer.tsx
@@ -5,9 +5,13 @@ import { LemonButton } from '@posthog/lemon-ui'
import { humanizeScope } from 'lib/components/ActivityLog/humanizeActivity'
import { KeyboardShortcut } from 'lib/components/KeyboardShortcut/KeyboardShortcut'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { IconSlack } from 'lib/lemon-ui/icons'
import { LemonRichContentEditor } from 'lib/lemon-ui/LemonRichContent/LemonRichContentEditor'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { CommentsLogicProps, commentsLogic } from './commentsLogic'
+import { SlackDestinationPicker } from './SlackDestinationPicker'
export type CommentComposerProps = CommentsLogicProps & {
/** The footer variant swaps to a "New comment" button while a reply is in progress; 'inline-reply' renders inside the thread */
@@ -15,11 +19,31 @@ export type CommentComposerProps = CommentsLogicProps & {
}
export const CommentComposer = ({ variant = 'footer', ...props }: CommentComposerProps): JSX.Element => {
- const { key, isSendingComment, replyingCommentId, itemContext, isEmpty, currentComposerDraft } = useValues(
- commentsLogic(props)
- )
- const { sendComposedContent, clearItemContext, setRichContentEditor, onRichContentEditorUpdate, startNewComment } =
- useActions(commentsLogic(props))
+ const {
+ key,
+ isSendingComment,
+ replyingCommentId,
+ itemContext,
+ isEmpty,
+ currentComposerDraft,
+ composerSendToSlack,
+ composerSlackIntegrationId,
+ composerSlackChannel,
+ } = useValues(commentsLogic(props))
+ const {
+ sendComposedContent,
+ clearItemContext,
+ setRichContentEditor,
+ onRichContentEditorUpdate,
+ startNewComment,
+ setComposerSendToSlack,
+ setComposerSlackIntegrationId,
+ setComposerSlackChannel,
+ } = useActions(commentsLogic(props))
+ const { featureFlags } = useValues(featureFlagLogic)
+
+ // Toggling a brand-new top-level comment straight to Slack; replies sync automatically.
+ const showSlackToggle = !replyingCommentId && !!featureFlags[FEATURE_FLAGS.DISCUSSIONS_SLACK_SYNC]
const placeholder = replyingCommentId
? 'Reply...'
@@ -53,6 +77,14 @@ export const CommentComposer = ({ variant = 'footer', ...props }: CommentCompose
const buttonSize = variant === 'inline-reply' ? 'small' : undefined
+ const primaryDisabledReason = isEmpty
+ ? 'No message'
+ : composerSendToSlack && !composerSlackIntegrationId
+ ? 'Select a Slack workspace'
+ : composerSendToSlack && !composerSlackChannel
+ ? 'Select a Slack channel'
+ : null
+
return (
<div className="flex flex-col gap-2">
<LemonRichContentEditor
@@ -62,14 +94,36 @@ export const CommentComposer = ({ variant = 'footer', ...props }: CommentCompose
initialContent={currentComposerDraft}
onCreate={setRichContentEditor}
onUpdate={onRichContentEditorUpdate}
+ // Same guard as the primary button — otherwise the shortcut silently posts a
+ // plain comment while "Send to Slack" is toggled on without a channel picked.
onPressCmdEnter={() => {
- // The send buttons are disabled when empty - the shortcut must not bypass that
- if (!isEmpty) {
+ if (!primaryDisabledReason && !isSendingComment) {
sendComposedContent(false)
}
}}
disabled={isSendingComment}
+ footerActions={
+ showSlackToggle ? (
+ <LemonButton
+ size="small"
+ icon={<IconSlack />}
+ active={composerSendToSlack}
+ onClick={() => setComposerSendToSlack(!composerSendToSlack)}
+ tooltip="Send this comment to a Slack channel"
+ data-attr="discussions-comment-send-to-slack-toggle"
+ />
+ ) : null
+ }
/>
+ {composerSendToSlack ? (
+ <SlackDestinationPicker
+ integrationId={composerSlackIntegrationId}
+ channel={composerSlackChannel}
+ onIntegrationChange={setComposerSlackIntegrationId}
+ onChannelChange={setComposerSlackChannel}
+ className="rounded border border-border p-2"
+ />
+ ) : null}
<div className="flex justify-between items-center gap-2">
<div className="flex-1" />
{itemContext ? (
@@ -83,7 +137,13 @@ export const CommentComposer = ({ variant = 'footer', ...props }: CommentCompose
type="secondary"
onClick={() => sendComposedContent(true)}
loading={isSendingComment}
- disabledReason={isEmpty ? 'No message' : null}
+ disabledReason={
+ composerSendToSlack
+ ? 'Turn off the Slack toggle to add a task'
+ : isEmpty
+ ? 'No message'
+ : null
+ }
data-attr="discussions-comment-task"
>
Add as task
@@ -93,12 +153,14 @@ export const CommentComposer = ({ variant = 'footer', ...props }: CommentCompose
size={buttonSize}
type="primary"
onClick={() => sendComposedContent(false)}
+ // Guard against double-submit: isSendingComment tracks the send (and the Slack
+ // send) lifecycle, disabling the button while it's in flight.
loading={isSendingComment}
- disabledReason={isEmpty ? 'No message' : null}
+ disabledReason={primaryDisabledReason}
sideIcon={<KeyboardShortcut command enter />}
data-attr="discussions-comment"
>
- Add {replyingCommentId ? 'reply' : 'comment'}
+ {composerSendToSlack ? 'Send to Slack' : `Add ${replyingCommentId ? 'reply' : 'comment'}`}
</LemonButton>
</div>
</div>
diff --git a/frontend/src/scenes/comments/CommentsList.tsx b/frontend/src/scenes/comments/CommentsList.tsx
index a9283283ffe7..c2348457fbec 100644
--- a/frontend/src/scenes/comments/CommentsList.tsx
+++ b/frontend/src/scenes/comments/CommentsList.tsx
@@ -8,6 +8,7 @@ import { pngHoggie } from 'lib/brand/hoggies'
import { CommentWithReplies } from './Comment'
import { CommentsLogicProps, commentsLogic } from './commentsLogic'
+import { SendCommentToSlackModal } from './SendCommentToSlackModal'
const HedgehogPhoneCall = pngHoggie(phoneCall)
@@ -59,6 +60,7 @@ export const CommentsList = ({ noun = 'page', ...props }: CommentsListProps): JS
<CommentWithReplies key={x.id} commentWithReplies={x} composerLogicProps={props} />
))}
</div>
+ <SendCommentToSlackModal />
</div>
</BindLogic>
)
diff --git a/frontend/src/scenes/comments/SendCommentToSlackModal.tsx b/frontend/src/scenes/comments/SendCommentToSlackModal.tsx
new file mode 100644
index 000000000000..c7d081d67487
--- /dev/null
+++ b/frontend/src/scenes/comments/SendCommentToSlackModal.tsx
@@ -0,0 +1,48 @@
+import { useActions, useValues } from 'kea'
+
+import { LemonButton, LemonModal } from '@posthog/lemon-ui'
+
+import { sendCommentToSlackLogic } from './sendCommentToSlackLogic'
+import { SlackDestinationPicker } from './SlackDestinationPicker'
+
+export function SendCommentToSlackModal(): JSX.Element {
+ const { isOpen, integrationId, channel, channelId, isSubmitting } = useValues(sendCommentToSlackLogic)
+ const { closeModal, setIntegrationId, setChannel, submit } = useActions(sendCommentToSlackLogic)
+
+ return (
+ <LemonModal
+ isOpen={isOpen}
+ onClose={closeModal}
+ title="Send discussion to Slack"
+ description="Post this discussion thread to a Slack channel. Replies sync both ways."
+ footer={
+ <>
+ <LemonButton type="secondary" onClick={closeModal}>
+ Cancel
+ </LemonButton>
+ <LemonButton
+ type="primary"
+ onClick={submit}
+ loading={isSubmitting}
+ disabledReason={
+ !integrationId
+ ? 'Select a Slack workspace'
+ : !channelId
+ ? 'Select a Slack channel'
+ : undefined
+ }
+ >
+ Send to Slack
+ </LemonButton>
+ </>
+ }
+ >
+ <SlackDestinationPicker
+ integrationId={integrationId}
+ channel={channel}
+ onIntegrationChange={setIntegrationId}
+ onChannelChange={setChannel}
+ />
+ </LemonModal>
+ )
+}
diff --git a/frontend/src/scenes/comments/SlackDestinationPicker.tsx b/frontend/src/scenes/comments/SlackDestinationPicker.tsx
new file mode 100644
index 000000000000..c8763682dbe5
--- /dev/null
+++ b/frontend/src/scenes/comments/SlackDestinationPicker.tsx
@@ -0,0 +1,67 @@
+import clsx from 'clsx'
+import { useValues } from 'kea'
+
+import { LemonLabel } from '@posthog/lemon-ui'
+
+import { IntegrationChoice } from 'lib/components/CyclotronJob/integrations/IntegrationChoice'
+import { integrationsLogic } from 'lib/integrations/integrationsLogic'
+import { SlackChannelPicker, SlackNotConfiguredBanner } from 'lib/integrations/SlackIntegrationHelpers'
+import { Spinner } from 'lib/lemon-ui/Spinner'
+
+export type SlackDestinationPickerProps = {
+ integrationId: number | null
+ /** The SlackChannelPicker's composite `CHANNEL_ID|#name` value. */
+ channel: string | null
+ onIntegrationChange: (integrationId: number | null) => void
+ onChannelChange: (channel: string | null) => void
+ /** Extra classes for the picker container; not applied to the loading/not-configured states. */
+ className?: string
+}
+
+/** Slack workspace + channel picker shared by the comment composer and the send-to-Slack modal. */
+export function SlackDestinationPicker({
+ integrationId,
+ channel,
+ onIntegrationChange,
+ onChannelChange,
+ className,
+}: SlackDestinationPickerProps): JSX.Element {
+ const { slackIntegrations, integrationsLoading } = useValues(integrationsLogic)
+ const selectedIntegration = slackIntegrations?.find((integration) => integration.id === integrationId)
+
+ // Integrations load async on mount — don't flash "not configured" at users who have Slack set up.
+ if (!slackIntegrations?.length && integrationsLoading) {
+ return (
+ <div className="flex justify-center p-2">
+ <Spinner />
+ </div>
+ )
+ }
+
+ if (!slackIntegrations?.length) {
+ return <SlackNotConfiguredBanner />
+ }
+
+ return (
+ <div className={clsx('flex flex-col gap-2', className)}>
+ <div className="flex flex-col gap-1">
+ <LemonLabel>Slack workspace</LemonLabel>
+ <IntegrationChoice
+ integration="slack"
+ value={integrationId ?? undefined}
+ onChange={onIntegrationChange}
+ />
+ </div>
+ {selectedIntegration ? (
+ <div className="flex flex-col gap-1">
+ <LemonLabel>Channel</LemonLabel>
+ <SlackChannelPicker
+ value={channel ?? undefined}
+ onChange={onChannelChange}
+ integration={selectedIntegration}
+ />
+ </div>
+ ) : null}
+ </div>
+ )
+}
diff --git a/frontend/src/scenes/comments/commentsLogic.ts b/frontend/src/scenes/comments/commentsLogic.ts
index cd73c4664cf1..cbd42429fd44 100644
--- a/frontend/src/scenes/comments/commentsLogic.ts
+++ b/frontend/src/scenes/comments/commentsLogic.ts
@@ -2,8 +2,11 @@ import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path,
import { loaders } from 'kea-loaders'
import { subscriptions } from 'kea-subscriptions'
-import api from 'lib/api'
+import { lemonToast } from '@posthog/lemon-ui'
+
+import api, { ApiError } from 'lib/api'
import { JSONContent, RichContentEditorType } from 'lib/components/RichContentEditor/types'
+import { slackChannelId } from 'lib/integrations/slackChannel'
import { deleteWithUndo } from 'lib/utils/deleteWithUndo'
import { isEmptyObject } from 'lib/utils/guards'
import { membersLogic } from 'scenes/organization/membersLogic'
@@ -13,8 +16,11 @@ import { userLogic } from 'scenes/userLogic'
import { sidePanelDiscussionLogic } from '~/layout/navigation-3000/sidepanel/panels/discussion/sidePanelDiscussionLogic'
import { CommentType } from '~/types'
+import { commentsSendToSlackCreate } from 'products/platform_features/frontend/generated/api'
+
import type { UserType } from '../../types'
import type { OrganizationMemberType } from '../../types'
+import { sendCommentToSlackLogic } from './sendCommentToSlackLogic'
import { discussionsSlug, getTextContent } from './utils'
export type CommentsLogicProps = {
@@ -48,6 +54,9 @@ export interface commentsLogicValues {
commentsLoading: boolean
commentsWithReplies: CommentWithRepliesType[]
composerDrafts: Record<string, JSONContent | null>
+ composerSendToSlack: boolean
+ composerSlackChannel: string | null
+ composerSlackIntegrationId: number | null
currentComposerDraft: JSONContent | null
disabledReasonFor: (comment: CommentType) => string | null
editingComment: CommentType | null
@@ -258,6 +267,15 @@ export interface commentsLogicActions {
content: JSONContent | null
target: string
}
+ setComposerSendToSlack: (enabled: boolean) => {
+ enabled: boolean
+ }
+ setComposerSlackChannel: (channel: string | null) => {
+ channel: string | null
+ }
+ setComposerSlackIntegrationId: (integrationId: number | null) => {
+ integrationId: number | null
+ }
setEditingComment: (comment: CommentType | null) => {
comment: CommentType | null
}
@@ -363,8 +381,38 @@ export const commentsLogic = kea<commentsLogicType>([
setRichContentEditor: (editor: RichContentEditorType) => ({ editor }),
setEditingCommentRichContentEditor: (editor: RichContentEditorType | null) => ({ editor }),
setComposerDraft: (target: string, content: JSONContent | null) => ({ target, content }),
+ setComposerSendToSlack: (enabled: boolean) => ({ enabled }),
+ setComposerSlackIntegrationId: (integrationId: number | null) => ({ integrationId }),
+ setComposerSlackChannel: (channel: string | null) => ({ channel }),
}),
reducers({
+ composerSendToSlack: [
+ false,
+ {
+ setComposerSendToSlack: (_, { enabled }) => enabled,
+ // Reset the toggle after a send so it doesn't stick across comments.
+ sendComposedContentSuccess: () => false,
+ // Replies never mirror from the composer and the toggle is hidden while replying —
+ // leaving it on would demand a Slack channel for a plain reply and mislabel the button.
+ setReplyingComment: (state, { commentId }) => (commentId ? false : state),
+ },
+ ],
+ composerSlackIntegrationId: [
+ null as number | null,
+ {
+ setComposerSlackIntegrationId: (_, { integrationId }) => integrationId,
+ sendComposedContentSuccess: () => null,
+ },
+ ],
+ composerSlackChannel: [
+ null as string | null,
+ {
+ setComposerSlackChannel: (_, { channel }) => channel,
+ // Picking a different workspace clears the channel.
+ setComposerSlackIntegrationId: () => null,
+ sendComposedContentSuccess: () => null,
+ },
+ ],
replyingCommentId: [
null as string | null,
{
@@ -533,6 +581,58 @@ export const commentsLogic = kea<commentsLogicType>([
})
values.itemContext?.callback?.({ sent: true })
+
+ // "Send to Slack" composer mode: mirror the new top-level comment to the chosen
+ // channel right away. Replies/tasks never mirror from here. The comment is created
+ // regardless; the Slack post is best-effort with its own toast.
+ const composerChannelId = values.composerSlackChannel
+ ? slackChannelId(values.composerSlackChannel)
+ : null
+ if (
+ values.composerSendToSlack &&
+ !isReply &&
+ !asTask &&
+ values.composerSlackIntegrationId &&
+ composerChannelId &&
+ values.currentProjectId
+ ) {
+ let sentToSlack = false
+ try {
+ // The comments API is project-scoped — currentTeamId diverges from the
+ // project id for non-default environments and 404s.
+ await commentsSendToSlackCreate(String(values.currentProjectId), newComment.id, {
+ integration_id: values.composerSlackIntegrationId,
+ channel_id: composerChannelId,
+ })
+ sentToSlack = true
+ lemonToast.success('Discussion sent to Slack')
+ } catch (e) {
+ // Surface the backend's actionable detail (bot not in channel, integration
+ // missing…) rather than a blanket failure.
+ const detail = e instanceof ApiError ? e.detail : null
+ lemonToast.error(
+ detail
+ ? `Comment added, but sending to Slack failed: ${detail}`
+ : 'Comment added, but sending to Slack failed'
+ )
+ }
+ if (sentToSlack) {
+ // Refetch and return the fresh list so the new comment shows its tracked-in-Slack
+ // state. We can't dispatch loadComments() here — it writes the same `comments`
+ // loader value this handler returns, and our return would supersede its result.
+ // A refetch failure isn't a Slack failure: fall through to the optimistic append.
+ try {
+ const response = await api.comments.list({
+ scope: props.scope,
+ item_id: props.item_id,
+ })
+ return response.results
+ } catch {
+ // fall through
+ }
+ }
+ }
+
return [...existingComments, newComment]
},
@@ -616,7 +716,7 @@ export const commentsLogic = kea<commentsLogicType>([
],
})),
- listeners(({ values, actions, selectors, cache }) => ({
+ listeners(({ props, values, actions, selectors, cache }) => ({
startNewComment: () => {
if (!values.replyingCommentId) {
// No reply to exit, so the footer composer won't remount - deregistering its
@@ -672,6 +772,15 @@ export const commentsLogic = kea<commentsLogicType>([
actions.loadComments()
}
},
+ // After the ⋯-menu "Send to Slack" modal mirrors a comment, refresh so its tracked state
+ // (the Slack icon) shows immediately instead of after a reload. The composer flow reloads
+ // itself in the send loader. The modal logic is a singleton while this logic is keyed per
+ // discussion, so only the instance the comment belongs to should reload.
+ [sendCommentToSlackLogic.actionTypes.submitSuccess]: ({ comment }) => {
+ if (comment.scope === props.scope && (comment.item_id ?? '') === (props.item_id ?? '')) {
+ actions.loadComments()
+ }
+ },
sendComposedContentSuccess: () => {
const sendContext = cache.sendContext
cache.sendContext = null
diff --git a/frontend/src/scenes/comments/sendCommentToSlackLogic.ts b/frontend/src/scenes/comments/sendCommentToSlackLogic.ts
new file mode 100644
index 000000000000..a18808cfea83
--- /dev/null
+++ b/frontend/src/scenes/comments/sendCommentToSlackLogic.ts
@@ -0,0 +1,149 @@
+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
+
+import { lemonToast } from '@posthog/lemon-ui'
+
+import { ApiError } from 'lib/api'
+import { slackChannelId } from 'lib/integrations/slackChannel'
+import { teamLogic } from 'scenes/teamLogic'
+
+import { CommentType } from '~/types'
+
+import { commentsSendToSlackCreate } from 'products/platform_features/frontend/generated/api'
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface sendCommentToSlackLogicValues {
+ currentProjectId: number | string // teamLogic
+ channel: string | null
+ channelId: string | null
+ comment: CommentType | null
+ integrationId: number | null
+ isOpen: boolean
+ isSubmitting: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface sendCommentToSlackLogicActions {
+ closeModal: () => {
+ value: true
+ }
+ openModal: (comment: CommentType) => {
+ comment: CommentType
+ }
+ setChannel: (channel: string | null) => {
+ channel: string | null
+ }
+ setIntegrationId: (integrationId: number | null) => {
+ integrationId: number | null
+ }
+ submit: () => {
+ value: true
+ }
+ submitFailure: (detail?: string | null) => {
+ detail: string | null
+ }
+ submitSuccess: (comment: CommentType) => {
+ comment: CommentType
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface sendCommentToSlackLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ isOpen: (comment: CommentType | null) => boolean
+ channelId: (channel: string | null) => string | null
+ }
+}
+
+export type sendCommentToSlackLogicType = MakeLogicType<
+ sendCommentToSlackLogicValues,
+ sendCommentToSlackLogicActions,
+ Record<string, any>,
+ sendCommentToSlackLogicMeta
+>
+
+export const sendCommentToSlackLogic = kea<sendCommentToSlackLogicType>([
+ path(['scenes', 'comments', 'sendCommentToSlackLogic']),
+ connect(() => ({ values: [teamLogic, ['currentProjectId']] })),
+ actions({
+ openModal: (comment: CommentType) => ({ comment }),
+ closeModal: true,
+ setIntegrationId: (integrationId: number | null) => ({ integrationId }),
+ // SlackChannelPicker emits a "CHANNEL_ID|#name" composite; we keep it whole for display.
+ setChannel: (channel: string | null) => ({ channel }),
+ submit: true,
+ submitSuccess: (comment: CommentType) => ({ comment }),
+ submitFailure: (detail: string | null = null) => ({ detail }),
+ }),
+ reducers({
+ comment: [
+ null as CommentType | null,
+ {
+ openModal: (_, { comment }) => comment,
+ closeModal: () => null,
+ submitSuccess: () => null,
+ },
+ ],
+ integrationId: [
+ null as number | null,
+ {
+ setIntegrationId: (_, { integrationId }) => integrationId,
+ openModal: () => null,
+ closeModal: () => null,
+ },
+ ],
+ channel: [
+ null as string | null,
+ {
+ setChannel: (_, { channel }) => channel,
+ setIntegrationId: () => null,
+ openModal: () => null,
+ closeModal: () => null,
+ },
+ ],
+ isSubmitting: [
+ false,
+ {
+ submit: () => true,
+ submitSuccess: () => false,
+ submitFailure: () => false,
+ // A modal session must never inherit a stale in-flight state from a previous one.
+ openModal: () => false,
+ closeModal: () => false,
+ },
+ ],
+ }),
+ selectors({
+ isOpen: [(s) => [s.comment], (comment: CommentType | null): boolean => comment !== null],
+ channelId: [
+ (s) => [s.channel],
+ (channel: string | null): string | null => (channel ? slackChannelId(channel) : null),
+ ],
+ }),
+ listeners(({ actions, values }) => ({
+ submit: async () => {
+ const { comment, integrationId, channelId, currentProjectId } = values
+ if (!comment || !integrationId || !channelId || !currentProjectId) {
+ actions.submitFailure()
+ return
+ }
+ try {
+ // The comments API is project-scoped — currentTeamId diverges from the project id
+ // for non-default environments and 404s.
+ await commentsSendToSlackCreate(String(currentProjectId), comment.id, {
+ integration_id: integrationId,
+ channel_id: channelId,
+ })
+ actions.submitSuccess(comment)
+ } catch (e) {
+ // Surface the backend's actionable detail (bot not in channel, integration missing…)
+ actions.submitFailure(e instanceof ApiError ? e.detail : null)
+ }
+ },
+ submitSuccess: () => {
+ lemonToast.success('Discussion sent to Slack')
+ },
+ submitFailure: ({ detail }) => {
+ lemonToast.error(detail || 'Could not send the discussion to Slack')
+ },
+ })),
+])
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 863a01e1b044..0a7b096be598 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -83,6 +83,7 @@ import { QueryContext } from '~/queries/types'
import { AlertType } from 'products/alerts/frontend/types'
import type { DataWarehouseSavedQueryApiSuspended } from 'products/data_warehouse/frontend/generated/api.schemas'
import type { ExperimentFeatureFlagInputApi } from 'products/experiments/frontend/generated/api.schemas'
+import type { CommentSlackThreadRefApi } from 'products/platform_features/frontend/generated/api.schemas'
import type { InsightFilterOverrideContextApi } from 'products/product_analytics/frontend/generated/api.schemas'
import type { AIPromptConfigApi } from 'products/subscriptions/frontend/generated/api.schemas'
import type { RuntimeEnumApi } from 'products/tasks/frontend/generated/api.schemas'
@@ -6055,6 +6056,8 @@ export type CommentType = {
is_task: boolean
completed_at: string | null
completed_by: UserBasicType | null
+ /** The Slack thread this comment's discussion is mirrored to (read-only); set only on a tracked thread root. */
+ slack_thread?: CommentSlackThreadRefApi | null
}
export type CommentCreationParams = { mentions?: number[]; slug?: string }
diff --git a/posthog/api/comments.py b/posthog/api/comments.py
index 510cf928035c..ac9d65db2641 100644
--- a/posthog/api/comments.py
+++ b/posthog/api/comments.py
@@ -111,6 +111,11 @@ def _slack_thread_url(thread: CommentSlackThread) -> str:
class CommentSlackThreadRefSerializer(serializers.Serializer):
channel_id = serializers.CharField(help_text="Slack channel ID this discussion is mirrored to.")
+ channel_name = serializers.CharField(
+ allow_blank=True,
+ help_text="Slack channel name resolved from Slack when the discussion was sent (no leading #). "
+ "Empty for private channels and when unknown; may lag behind a rename in Slack.",
+ )
url = serializers.CharField(help_text="Deep link that opens the mirrored Slack thread.")
@@ -275,7 +280,11 @@ class CommentSerializer(serializers.ModelSerializer):
# keeps offering "send to Slack" rather than a dead "Open in Slack" link.
if thread is None or not thread.slack_thread_ts:
return None
- return {"channel_id": thread.slack_channel_id, "url": _slack_thread_url(thread)}
+ return {
+ "channel_id": thread.slack_channel_id,
+ "channel_name": thread.slack_channel_name,
+ "url": _slack_thread_url(thread),
+ }
class Meta:
model = Comment
@@ -557,6 +566,7 @@ class CommentSlackThreadSerializer(serializers.ModelSerializer):
"source_comment",
"integration",
"slack_channel_id",
+ "slack_channel_name",
"slack_thread_ts",
"slack_team_id",
"created_at",
@@ -569,6 +579,10 @@ class CommentSlackThreadSerializer(serializers.ModelSerializer):
"source_comment": {"help_text": "The thread-root comment whose replies mirror to the Slack thread."},
"integration": {"help_text": "Slack integration used to post to and read from the thread."},
"slack_channel_id": {"help_text": "Slack channel the mirrored thread lives in."},
+ "slack_channel_name": {
+ "help_text": "Slack channel name resolved from Slack at send time (no leading #). "
+ "Empty for private channels and when unknown."
+ },
"slack_thread_ts": {"help_text": "Slack thread timestamp anchoring the mirrored thread."},
"slack_team_id": {"help_text": "Slack workspace ID, used to route inbound replies back."},
}
@@ -580,7 +594,8 @@ class SendCommentToSlackSerializer(serializers.Serializer):
)
channel_id = serializers.CharField(
max_length=255,
- help_text="Slack channel ID to create the mirrored thread in. The bot must be a member of the channel.",
+ help_text="Slack channel ID to create the mirrored thread in. The bot must be a member of the channel. "
+ "The channel's display name is resolved server-side.",
)
@@ -914,6 +929,31 @@ class CommentViewSet(TeamAndOrgViewSetMixin, ForbidDestroyModel, viewsets.ModelV
serializer = CommentSerializer(comment, context=self.get_serializer_context())
return Response(serializer.data)
+ def _resolve_slack_channel_name(self, integration: Integration, channel_id: str, user: User) -> str:
+ """Resolve the target channel server-side — the caller-supplied id is never paired with a
+ caller-supplied label. Private channels are restricted to the workspace connector (matching
+ the channel picker, which hides them from everyone else) and their names are never persisted,
+ since the stored name is shown to every reader of the discussion.
+ """
+ client = SlackIntegration(integration).client
+ client.timeout = 10 # keep a slow Slack workspace from pinning the request worker
+ try:
+ channel = client.conversations_info(channel=channel_id)["channel"]
+ except SlackApiError as e:
+ slack_error = (e.response.get("error") if e.response else None) or "unknown error"
+ raise exceptions.ValidationError(f"Could not look up the Slack channel ({slack_error})")
+ # A 1:1 DM reports is_im (not is_private), so it would sail past the private-channel
+ # guard and let any member mirror a discussion into someone's DMs with the bot.
+ if channel.get("is_im") or channel.get("is_mpim"):
+ raise exceptions.ValidationError("Discussions can only be sent to Slack channels, not direct messages")
+ if channel.get("is_private"):
+ if integration.created_by_id != user.id:
+ raise exceptions.PermissionDenied(
+ "Only the user who connected this Slack workspace can send a discussion to a private channel"
+ )
+ return ""
+ return channel.get("name") or ""
+
@extend_schema(
request=SendCommentToSlackSerializer,
responses=CommentSlackThreadSerializer,
@@ -946,6 +986,8 @@ class CommentViewSet(TeamAndOrgViewSetMixin, ForbidDestroyModel, viewsets.ModelV
if integration is None:
raise exceptions.ValidationError("Slack integration not found")
+ channel_name = self._resolve_slack_channel_name(integration, channel_id, cast(User, request.user))
+
# Reserve the mapping before posting: a discussion mirrors to exactly one Slack thread (1:1),
# and the source_comment OneToOne makes this get_or_create race-safe — a double-click can't
# post two root messages.
@@ -957,6 +999,7 @@ class CommentViewSet(TeamAndOrgViewSetMixin, ForbidDestroyModel, viewsets.ModelV
"item_id": comment.item_id,
"integration": integration,
"slack_channel_id": channel_id,
+ "slack_channel_name": channel_name,
"slack_team_id": integration.integration_id,
"created_by": cast(User, request.user),
},
@@ -978,11 +1021,19 @@ class CommentViewSet(TeamAndOrgViewSetMixin, ForbidDestroyModel, viewsets.ModelV
# re-bounds the reply backfill to this attempt.
slack_thread.integration = integration
slack_thread.slack_channel_id = channel_id
+ slack_thread.slack_channel_name = channel_name
slack_thread.slack_team_id = integration.integration_id
slack_thread.created_by = cast(User, request.user)
slack_thread.created_at = timezone.now()
slack_thread.save(
- update_fields=["integration", "slack_channel_id", "slack_team_id", "created_by", "created_at"]
+ update_fields=[
+ "integration",
+ "slack_channel_id",
+ "slack_channel_name",
+ "slack_team_id",
+ "created_by",
+ "created_at",
+ ]
)
author_name, author_email = slack_author_from_user(comment.created_by)
diff --git a/posthog/api/test/test_comment_slack_sync.py b/posthog/api/test/test_comment_slack_sync.py
index 73d5cc35b14a..44da065b77c3 100644
--- a/posthog/api/test/test_comment_slack_sync.py
+++ b/posthog/api/test/test_comment_slack_sync.py
@@ -57,26 +57,56 @@ class TestSendCommentToSlack(APIBaseTest):
thread = CommentSlackThread(slack_channel_id="C1", slack_thread_ts=ts, slack_team_id="T123")
assert _slack_thread_url(thread) == expected
- def _send(self, comment_id, channel_id: str = "C1", integration_id: int | None = None):
+ def _send(self, comment_id, channel_id: str = "C1", integration_id: int | None = None, extra: dict | None = None):
return self.client.post(
f"/api/projects/{self.team.id}/comments/{comment_id}/send_to_slack/",
- {"integration_id": integration_id or self.integration.id, "channel_id": channel_id},
+ {
+ "integration_id": integration_id or self.integration.id,
+ "channel_id": channel_id,
+ **(extra or {}),
+ },
)
+ def _mock_channel_info(self, mock_slack, name: str = "team-support", is_private: bool = False, **flags) -> None:
+ mock_slack.return_value.client.conversations_info.return_value = {
+ "channel": {"id": "C1", "name": name, "is_private": is_private, **flags}
+ }
+
+ @parameterized.expand([("dm", {"is_im": True}), ("group_dm", {"is_mpim": True, "is_private": True})])
+ @patch("posthog.api.comments.backfill_comment_slack_thread.delay")
+ @patch("posthog.api.comments.posthoganalytics.feature_enabled", return_value=True)
+ @patch("posthog.api.comments.SlackIntegration")
+ def test_cannot_send_to_a_direct_message(self, _name, flags, mock_slack, _flag, _backfill):
+ # is_im conversations don't report is_private, so without an explicit guard a member
+ # could mirror a discussion into someone's DMs with the bot.
+ self._mock_channel_info(mock_slack, **flags)
+ comment = self._comment()
+
+ res = self._send(comment.id, channel_id="D1")
+
+ assert res.status_code == status.HTTP_400_BAD_REQUEST
+ assert "direct message" in str(res.json())
+ assert not CommentSlackThread.objects.for_team(self.team.id).exists()
+ mock_slack.return_value.client.chat_postMessage.assert_not_called()
+
@patch("posthog.api.comments.backfill_comment_slack_thread.delay")
@patch("posthog.api.comments.posthoganalytics.feature_enabled", return_value=True)
@patch("posthog.api.comments.SlackIntegration")
def test_creates_mirror_posts_root_and_enqueues_backfill(self, mock_slack, _flag, mock_backfill):
mock_slack.return_value.client.chat_postMessage.return_value = {"ts": "1700.1"}
+ self._mock_channel_info(mock_slack)
comment = self._comment()
- res = self._send(comment.id)
+ # A client-supplied channel_name must have no effect — the name is resolved from Slack.
+ res = self._send(comment.id, extra={"channel_name": "#spoofed"})
assert res.status_code == status.HTTP_200_OK, res.json()
mirror = CommentSlackThread.objects.for_team(self.team.id).get()
assert mirror.source_comment_id == comment.id
assert mirror.slack_thread_ts == "1700.1"
assert (mirror.slack_channel_id, mirror.slack_team_id) == ("C1", "T123")
+ assert mirror.slack_channel_name == "team-support"
+ assert res.json()["slack_channel_name"] == "team-support"
# Only the root is posted synchronously; replies are backfilled out-of-band.
assert mock_slack.return_value.client.chat_postMessage.call_count == 1
mock_backfill.assert_called_once_with(comment_slack_thread_id=str(mirror.id))
@@ -86,6 +116,7 @@ class TestSendCommentToSlack(APIBaseTest):
@patch("posthog.api.comments.SlackIntegration")
def test_idempotent_does_not_repost(self, mock_slack, _flag, _backfill):
mock_slack.return_value.client.chat_postMessage.return_value = {"ts": "1700.1"}
+ self._mock_channel_info(mock_slack)
comment = self._comment()
first = self._send(comment.id)
@@ -101,6 +132,7 @@ class TestSendCommentToSlack(APIBaseTest):
@patch("posthog.api.comments.SlackIntegration")
def test_failed_post_releases_reservation(self, mock_slack, _flag, _backfill):
mock_slack.return_value.client.chat_postMessage.side_effect = Exception("slack down")
+ self._mock_channel_info(mock_slack)
comment = self._comment()
res = self._send(comment.id)
@@ -123,6 +155,7 @@ class TestSendCommentToSlack(APIBaseTest):
@patch("posthog.api.comments.SlackIntegration")
def test_resend_to_different_channel_names_existing_one(self, mock_slack, _flag, _backfill):
mock_slack.return_value.client.chat_postMessage.return_value = {"ts": "1700.1"}
+ self._mock_channel_info(mock_slack)
comment = self._comment()
self._send(comment.id, channel_id="C1")
@@ -138,6 +171,7 @@ class TestSendCommentToSlack(APIBaseTest):
@patch("posthog.api.comments.posthoganalytics.feature_enabled", return_value=True)
@patch("posthog.api.comments.SlackIntegration")
def test_in_flight_reservation_returns_409(self, mock_slack, _flag, _backfill):
+ self._mock_channel_info(mock_slack)
comment = self._comment()
# A fresh reservation with no posted root — another request is mid-send.
CommentSlackThread.objects.for_team(self.team.id).create(
@@ -159,6 +193,7 @@ class TestSendCommentToSlack(APIBaseTest):
@patch("posthog.api.comments.SlackIntegration")
def test_stale_reservation_is_adopted_and_retried(self, mock_slack, _flag, mock_backfill):
mock_slack.return_value.client.chat_postMessage.return_value = {"ts": "1700.9"}
+ self._mock_channel_info(mock_slack)
comment = self._comment()
# A crashed send left an old reservation with no root message.
stale = CommentSlackThread.objects.for_team(self.team.id).create(
@@ -180,6 +215,51 @@ class TestSendCommentToSlack(APIBaseTest):
assert (mirror.slack_thread_ts, mirror.slack_channel_id) == ("1700.9", "C2")
mock_backfill.assert_called_once_with(comment_slack_thread_id=str(mirror.id))
+ @parameterized.expand(
+ [
+ ("creator_sends_with_masked_name", True, status.HTTP_200_OK),
+ ("non_creator_forbidden", False, status.HTTP_403_FORBIDDEN),
+ ]
+ )
+ @patch("posthog.api.comments.backfill_comment_slack_thread.delay")
+ @patch("posthog.api.comments.posthoganalytics.feature_enabled", return_value=True)
+ @patch("posthog.api.comments.SlackIntegration")
+ def test_private_channel_guard(self, _name, requester_is_creator, expected_status, mock_slack, _flag, _backfill):
+ if requester_is_creator:
+ self.integration.created_by = self.user
+ self.integration.save()
+ mock_slack.return_value.client.chat_postMessage.return_value = {"ts": "1700.1"}
+ self._mock_channel_info(mock_slack, name="secret-plans", is_private=True)
+ comment = self._comment()
+
+ res = self._send(comment.id)
+
+ assert res.status_code == expected_status, res.json()
+ if requester_is_creator:
+ mirror = CommentSlackThread.objects.for_team(self.team.id).get()
+ # A private channel's name is never persisted — it would be shown to every reader.
+ assert mirror.slack_channel_name == ""
+ assert res.json()["slack_channel_name"] == ""
+ else:
+ assert not CommentSlackThread.objects.for_team(self.team.id).exists()
+ mock_slack.return_value.client.chat_postMessage.assert_not_called()
+
+ @patch("posthog.api.comments.backfill_comment_slack_thread.delay")
+ @patch("posthog.api.comments.posthoganalytics.feature_enabled", return_value=True)
+ @patch("posthog.api.comments.SlackIntegration")
+ def test_channel_lookup_failure_is_a_400(self, mock_slack, _flag, _backfill):
+ mock_slack.return_value.client.conversations_info.side_effect = SlackApiError(
+ "boom", {"error": "channel_not_found"}
+ )
+ comment = self._comment()
+
+ res = self._send(comment.id)
+
+ assert res.status_code == status.HTTP_400_BAD_REQUEST
+ assert "channel_not_found" in str(res.json())
+ assert not CommentSlackThread.objects.for_team(self.team.id).exists()
+ mock_slack.return_value.client.chat_postMessage.assert_not_called()
+
@parameterized.expand([("reply", "source_comment"), ("unknown_integration", "integration")])
@patch("posthog.api.comments.posthoganalytics.feature_enabled", return_value=True)
def test_rejects_invalid_target(self, _name, bad, _flag):
@@ -461,6 +541,7 @@ class TestSlackThreadSerialization(APIBaseTest):
source_comment=self.parent,
integration=self.integration,
slack_channel_id="C1",
+ slack_channel_name="team-support",
slack_thread_ts="1700.1",
)
@@ -473,6 +554,7 @@ class TestSlackThreadSerialization(APIBaseTest):
assert res.status_code == status.HTTP_200_OK
assert res.json()["slack_thread"] == {
"channel_id": "C1",
+ "channel_name": "team-support",
"url": "https://app.slack.com/archives/C1/p17001",
}
diff --git a/posthog/migrations/1293_commentslackthread_channel_name.py b/posthog/migrations/1293_commentslackthread_channel_name.py
new file mode 100644
index 000000000000..278d4c8261e1
--- /dev/null
+++ b/posthog/migrations/1293_commentslackthread_channel_name.py
@@ -0,0 +1,17 @@
+# Generated by Django 5.2.14 on 2026-07-16 16:47
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1292_oauthaccesstoken_sandbox_task_id"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="commentslackthread",
+ name="slack_channel_name",
+ field=models.CharField(blank=True, db_default="", default="", max_length=255),
+ ),
+ ]
diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txt
index 9f44019d17b9..8a37914a1636 100644
--- a/posthog/migrations/max_migration.txt
+++ b/posthog/migrations/max_migration.txt
@@ -1 +1 @@
-1292_oauthaccesstoken_sandbox_task_id
+1293_commentslackthread_channel_name
diff --git a/posthog/models/comment/slack_thread.py b/posthog/models/comment/slack_thread.py
index 8514ee04a09a..9a11d6e74095 100644
--- a/posthog/models/comment/slack_thread.py
+++ b/posthog/models/comment/slack_thread.py
@@ -37,6 +37,11 @@ class CommentSlackThread(TeamScopedRootMixin, UUIDModel):
help_text="Slack integration whose bot token posts to and reads from the mirrored thread",
)
slack_channel_id = models.CharField(max_length=255)
+ # Display-only channel name ("team-support", no leading #) captured at send time so the UI
+ # can say where the discussion lives without a Slack lookup. The id stays authoritative —
+ # a rename in Slack leaves this stale until the discussion is re-sent.
+ # db_default so old code can INSERT without naming the column during rolling deploys.
+ slack_channel_name = models.CharField(max_length=255, blank=True, default="", db_default="")
# Empty until the root message is posted — the row is reserved first to win the race for this
# (team, source_comment, channel) before any Slack call, then the ts is filled in.
slack_thread_ts = models.CharField(max_length=255, blank=True, default="")
diff --git a/products/platform_features/frontend/generated/api.schemas.ts b/products/platform_features/frontend/generated/api.schemas.ts
index b2770463733d..59ca66db7084 100644
--- a/products/platform_features/frontend/generated/api.schemas.ts
+++ b/products/platform_features/frontend/generated/api.schemas.ts
@@ -810,6 +810,8 @@ export interface ChangeRequestRejectApi {
export interface CommentSlackThreadRefApi {
/** Slack channel ID this discussion is mirrored to. */
channel_id: string
+ /** Slack channel name resolved from Slack when the discussion was sent (no leading #). Empty for private channels and when unknown; may lag behind a rename in Slack. */
+ channel_name: string
/** Deep link that opens the mirrored Slack thread. */
url: string
}
@@ -898,7 +900,7 @@ export interface SendCommentToSlackApi {
/** ID of the Slack integration (kind='slack') whose bot posts the thread. */
integration_id: number
/**
- * Slack channel ID to create the mirrored thread in. The bot must be a member of the channel.
+ * Slack channel ID to create the mirrored thread in. The bot must be a member of the channel. The channel's display name is resolved server-side.
* @maxLength 255
*/
channel_id: string
@@ -919,6 +921,8 @@ export interface CommentSlackThreadApi {
readonly integration: number
/** Slack channel the mirrored thread lives in. */
readonly slack_channel_id: string
+ /** Slack channel name resolved from Slack at send time (no leading #). Empty for private channels and when unknown. */
+ readonly slack_channel_name: string
/** Slack thread timestamp anchoring the mirrored thread. */
readonly slack_thread_ts: string
/**
diff --git a/products/platform_features/frontend/generated/api.zod.ts b/products/platform_features/frontend/generated/api.zod.ts
index d00017e01a79..9b8ab0b6198d 100644
--- a/products/platform_features/frontend/generated/api.zod.ts
+++ b/products/platform_features/frontend/generated/api.zod.ts
@@ -437,7 +437,9 @@ export const CommentsSendToSlackCreateBody = /* @__PURE__ */ zod.object({
channel_id: zod
.string()
.max(commentsSendToSlackCreateBodyChannelIdMax)
- .describe('Slack channel ID to create the mirrored thread in. The bot must be a member of the channel.'),
+ .describe(
+ "Slack channel ID to create the mirrored thread in. The bot must be a member of the channel. The channel's display name is resolved server-side."
+ ),
})
/**
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index d919e4b8c1e4..05a12c463966 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -15547,6 +15547,8 @@ export namespace Schemas {
export interface CommentSlackThreadRef {
/** Slack channel ID this discussion is mirrored to. */
channel_id: string;
+ /** Slack channel name resolved from Slack when the discussion was sent (no leading #). Empty for private channels and when unknown; may lag behind a rename in Slack. */
+ channel_name: string;
/** Deep link that opens the mirrored Slack thread. */
url: string;
}
@@ -15602,6 +15604,8 @@ export namespace Schemas {
readonly integration: number;
/** Slack channel the mirrored thread lives in. */
readonly slack_channel_id: string;
+ /** Slack channel name resolved from Slack at send time (no leading #). Empty for private channels and when unknown. */
+ readonly slack_channel_name: string;
/** Slack thread timestamp anchoring the mirrored thread. */
readonly slack_thread_ts: string;
/**
@@ -66908,7 +66912,7 @@ export namespace Schemas {
/** ID of the Slack integration (kind='slack') whose bot posts the thread. */
integration_id: number;
/**
- * Slack channel ID to create the mirrored thread in. The bot must be a member of the channel.
+ * Slack channel ID to create the mirrored thread in. The bot must be a member of the channel. The channel's display name is resolved server-side.
* @maxLength 255
*/
channel_id: string;