Skip to content

fix(notifications): render body from payload or Slack JSON#2889

Open
adityathebe wants to merge 2 commits intomainfrom
fix/notification-body-rendering
Open

fix(notifications): render body from payload or Slack JSON#2889
adityathebe wants to merge 2 commits intomainfrom
fix/notification-body-rendering

Conversation

@adityathebe
Copy link
Member

@adityathebe adityathebe commented Feb 25, 2026

closes: #2887

Summary by CodeRabbit

  • Bug Fixes

    • More reliable retrieval of notification details by consistently checking for payload presence.
    • Improved detection, parsing and rendering of legacy Slack-formatted notifications with better fallback handling.
  • UI / Styling

    • Notification message display updated to use a lighter background for rendered message bodies, improving readability.

@vercel
Copy link

vercel bot commented Feb 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
aws-preview Ready Ready Preview Feb 27, 2026 8:41am
flanksource-ui Ready Ready Preview Feb 27, 2026 8:41am

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a038d03 and fc3771c.

📒 Files selected for processing (2)
  • src/components/Notifications/NotificationSendHistory.tsx
  • src/components/Notifications/NotificationSendHistory/NotificationDetails.tsx

Walkthrough

Detail-fetch on row click now checks body_payload instead of body; NotificationDetails adds a memoized Slack BlockKit JSON parser that produces Markdown when body_markdown is absent, falling back to legacy rendering on parse failure.

Changes

Cohort / File(s) Summary
Row click / fetch flag
src/components/Notifications/NotificationSendHistory.tsx
Changed click handler to derive shouldFetchDetail from !!row.body_payload and set or delete hasBodyPayload accordingly instead of using body.
Notification detail rendering (Slack BlockKit parsing)
src/components/Notifications/NotificationSendHistory/NotificationDetails.tsx
Added memoized legacySlackMessage parsing for Slack BlockKit (single or array), derived slackBody via blockKitToMarkdown, and updated render precedence: body_markdownslackBody (Markdown) → legacy HTML; preserved error handling and legacy fallback.

Possibly related PRs

Suggested reviewers

  • moshloop
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing notification body rendering to use payload or Slack JSON as sources.
Linked Issues check ✅ Passed The PR addresses the linked issue #2887 by updating notification detail rendering logic to correctly handle body content from payload or Slack JSON sources.
Out of Scope Changes check ✅ Passed All changes focus on notification body rendering logic across two components, directly addressing the issue of correct body display for playbook recipients.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/notification-body-rendering

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/components/Notifications/NotificationSendHistory/NotificationDetails.tsx (1)

81-87: Consider merging the two useMemos into one.

slackBody depends solely on legacySlackMessage which is already memoized one line above. You could compute the markdown string directly inside the first useMemo and drop this second one, reducing the number of hooks and intermediate variables.

♻️ Optional: inline into the first useMemo
- const legacySlackMessage = useMemo<SlackMessage | undefined>(() => {
+ const slackBody = useMemo<string | undefined>(() => {
    if (bodyMarkdown || !legacyBody) {
      return undefined;
    }
+   let msg: SlackMessage | undefined;
    try {
      const parsed = JSON.parse(legacyBody.trim()) as
        | SlackMessage
        | SlackMessage[];
      if (Array.isArray(parsed)) {
        const [firstMessage] = parsed;
-       return Array.isArray(firstMessage?.blocks) ? firstMessage : undefined;
+       msg = Array.isArray(firstMessage?.blocks) ? firstMessage : undefined;
+     } else {
+       msg = Array.isArray(parsed?.blocks) ? parsed : undefined;
      }
-     return Array.isArray(parsed?.blocks) ? parsed : undefined;
    } catch {
      return undefined;
    }
+   return msg ? blockKitToMarkdown(msg) : undefined;
  }, [bodyMarkdown, legacyBody]);
-
- const slackBody = useMemo(() => {
-   if (!legacySlackMessage) {
-     return undefined;
-   }
-   return blockKitToMarkdown(legacySlackMessage);
- }, [legacySlackMessage]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/Notifications/NotificationSendHistory/NotificationDetails.tsx`
around lines 81 - 87, The slackBody useMemo duplicates work because it depends
only on legacySlackMessage which is already memoized; merge the conversion into
the existing useMemo that produces legacySlackMessage by calling
blockKitToMarkdown(legacySlackMessage) there (or compute markdown from the same
source) and remove the second useMemo and intermediate slackBody variable;
update any references to slackBody to use the newly computed markdown variable
from the original useMemo (referencing useMemo, legacySlackMessage, slackBody,
and blockKitToMarkdown).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@src/components/Notifications/NotificationSendHistory/NotificationDetails.tsx`:
- Around line 81-87: The slackBody useMemo duplicates work because it depends
only on legacySlackMessage which is already memoized; merge the conversion into
the existing useMemo that produces legacySlackMessage by calling
blockKitToMarkdown(legacySlackMessage) there (or compute markdown from the same
source) and remove the second useMemo and intermediate slackBody variable;
update any references to slackBody to use the newly computed markdown variable
from the original useMemo (referencing useMemo, legacySlackMessage, slackBody,
and blockKitToMarkdown).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e45c64 and 1280b11.

📒 Files selected for processing (2)
  • src/components/Notifications/NotificationSendHistory.tsx
  • src/components/Notifications/NotificationSendHistory/NotificationDetails.tsx

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/components/Notifications/NotificationSendHistory/NotificationDetails.tsx`:
- Around line 70-73: In NotificationDetails.tsx the Array.isArray(parsed) branch
only checks parsed[0] for blocks and returns undefined if it lacks blocks;
change this to scan the parsed array for the first element whose blocks is an
array (e.g., use parsed.find(item => Array.isArray(item?.blocks))) and return
that element (or undefined if none found) so later markdown conversion receives
the first valid Slack message rather than only index 0.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1280b11 and a038d03.

📒 Files selected for processing (2)
  • src/components/Notifications/NotificationSendHistory.tsx
  • src/components/Notifications/NotificationSendHistory/NotificationDetails.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Notifications/NotificationSendHistory.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notification detail rendering for playbook recipient

1 participant