[codex] Improve Slack insight digest markdown#496
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
The latest updates on your projects. Learn more about Unkey Deploy
|
There was a problem hiding this comment.
1 issue found across 5 files
Confidence score: 4/5
- In
apps/insights/src/delivery.ts, the fallback Slacktextuses an unescaped website label, so names containing mrkdwn or mention tokens can trigger unintended mentions/links and noisy notifications for users—escape/sanitize the label before assigningtextto de-risk before merge.
Architecture diagram
sequenceDiagram
participant Scheduler as Insight Scheduler
participant Gen as generateWebsiteInsights
participant Prompt as Build System Prompt
participant AI as AI Model
participant Delivery as deliverInsightDigests
participant Blocks as buildBlocks
participant Slack as Slack API
Note over Scheduler,Slack: Insight generation and Slack digest delivery
Scheduler->>Gen: generateWebsiteInsights(organizationId, websiteId)
Gen->>Gen: fetch site details (id, domain, name)
Gen->>Prompt: buildSystemPrompt()
Prompt-->>Gen: prompt with "calm analyst" wording rules
Gen->>AI: invoke AI model with insight schema
AI-->>Gen: insights array (title, description, impactSummary, suggestion, type, sentiment, actions)
alt insight has impactSummary
Gen->>Gen: use impactSummary for "why it matters"
else impactSummary missing
Gen->>Gen: fallbackWhyItMatters() based on type/sentiment
end
alt action labels available
Gen->>Gen: extract plain label for "Next" action
else actions empty
Gen->>Gen: fallbackNextAction() based on type
end
Gen->>Delivery: deliverInsightDigests(organizationId, websiteId, websiteDomain, websiteName, insights, chains)
Note over Delivery,Blocks: Redact internal IDs from visible copy
Delivery->>Blocks: buildBlocks(websiteName, websiteDomain, insights, chains)
Blocks->>Blocks: formatWebsiteLabel(websiteName, websiteDomain)
alt name exists and differs from domain
Blocks->>Blocks: "Name (domain)"
else no name or name matches domain
Blocks->>Blocks: use domain only
end
loop for each insight
Blocks->>Blocks: digestLabel() based on type + sentiment
Blocks->>Blocks: userVisibleCopy() redacts UUIDs → "the affected item"
Blocks->>Blocks: redacts code snippets (e.g., document.execCommand)
Blocks->>Blocks: escapeMrkdwn() escapes HTML chars
Blocks->>Blocks: compose markdown: label, title, Evidence, Why it matters, Next
alt chain site count > 1
Blocks->>Blocks: append "Also found on N other sites"
end
end
Blocks-->>Delivery: SlackBlock[] with header + card blocks
Delivery->>Slack: postToSlack(token, channelId, blocks, text)
Slack-->>Delivery: 200 OK
Note over Gen,Slack: Key branching for copy and schema enforcement
alt insight type is referrer_change and sentiment positive
Blocks->>Blocks: label = "Opportunity · Acquisition"
else type is conversion_leak
Blocks->>Blocks: label = "Fix · Goal tracking"
else type is funnel_regression
Blocks->>Blocks: label = "Cleanup · Funnel config"
else default
Blocks->>Blocks: label based on severity
end
Shadow auto-approve: would not auto-approve because issues were found.
Re-trigger cubic
Greptile SummaryThis PR reworks Slack insight digest blocks into a structured five-line operator card (label → title → evidence → why it matters → next action), adds UUID redaction for visible copy, and includes the website name in the digest header. It also tightens AI schema guidance and prompt wording to steer the model toward cleaner, human-readable output.
Confidence Score: 3/5Safe to merge for header and UUID-redaction changes; the "Next:" field will show generic fallback text for any insight that has a specific suggestion but no actions array. The apps/insights/src/delivery.ts — specifically the Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[deliverInsightDigests] --> B[buildBlocks]
B --> C[formatWebsiteLabel]
B --> D[Header block plain_text]
B --> E{For each insight}
E --> F[digestLabel - type plus sentiment]
E --> G[userVisibleCopy - UUID redaction]
E --> H{impactSummary present?}
H -->|yes| I[Use impactSummary]
H -->|no| J[fallbackWhyItMatters]
E --> K{actions present?}
K -->|yes| L[Use actions label]
K -->|no| M[fallbackNextAction - generic]
L --> N[Section block mrkdwn]
M --> N
I --> N
J --> N
note1[suggestion field required but never read] -.-> K
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[deliverInsightDigests] --> B[buildBlocks]
B --> C[formatWebsiteLabel]
B --> D[Header block plain_text]
B --> E{For each insight}
E --> F[digestLabel - type plus sentiment]
E --> G[userVisibleCopy - UUID redaction]
E --> H{impactSummary present?}
H -->|yes| I[Use impactSummary]
H -->|no| J[fallbackWhyItMatters]
E --> K{actions present?}
K -->|yes| L[Use actions label]
K -->|no| M[fallbackNextAction - generic]
L --> N[Section block mrkdwn]
M --> N
I --> N
J --> N
note1[suggestion field required but never read] -.-> K
|
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Shadow auto-approve: would auto-approve. Refines Slack insight digest formatting, redaction, and prompt guidance. UI-only changes covered by new tests; no core logic or infrastructure risk.
Re-trigger cubic
Summary
Name (domain)and fall back to the domain when no name exists.Validation
bun test src/delivery.test.tscd apps/insights && bun run check-typescd apps/insights && bun test srcbunx ultracite check apps/insights/src/delivery.ts apps/insights/src/delivery.test.ts apps/insights/src/generation.ts apps/insights/src/prompts.ts packages/ai/src/ai/schemas/smart-insights-output.tsdotenv -- bun run --cwd packages/evals src/cli.ts --surface slack --tag digest --limit 2 --skip-judge --no-save --concurrency 1check-types; push hook ran repotestsuccessfully.