From 232751f1a97f72b71da8b7a9618658d25aaf0c06 Mon Sep 17 00:00:00 2001 From: Dotta Date: Mon, 13 Apr 2026 09:53:31 -0500 Subject: [PATCH] Keep company alerts out of personal inbox --- ui/src/lib/inbox.test.ts | 29 +++++++++++++++++++++++++++-- ui/src/lib/inbox.ts | 7 ++++++- ui/src/pages/Inbox.tsx | 12 ++++++++---- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/ui/src/lib/inbox.test.ts b/ui/src/lib/inbox.test.ts index 0d55cf6500c..dda827a4609 100644 --- a/ui/src/lib/inbox.test.ts +++ b/ui/src/lib/inbox.test.ts @@ -38,6 +38,7 @@ import { saveInboxFilterPreferences, saveInboxIssueColumns, saveLastInboxTab, + shouldShowCompanyAlerts, shouldShowInboxSection, type InboxWorkItem, } from "./inbox"; @@ -307,7 +308,7 @@ describe("inbox helpers", () => { }); expect(result).toEqual({ - inbox: 6, + inbox: 5, approvals: 1, failedRuns: 2, joinRequests: 1, @@ -351,7 +352,8 @@ describe("inbox helpers", () => { }); expect(result.mineIssues).toBe(1); - expect(result.inbox).toBe(3); + expect(result.inbox).toBe(1); + expect(result.alerts).toBe(2); }); it("resurfaces non-issue items when they change after dismissal", () => { @@ -446,6 +448,22 @@ describe("inbox helpers", () => { expect(result.approvals).toBe(0); }); + it("does not count company-wide alerts in the personal inbox badge", () => { + const result = computeInboxBadgeData({ + approvals: [], + joinRequests: [], + dashboard, + heartbeatRuns: [], + mineIssues: [], + dismissedAlerts: new Set(), + dismissedAtByKey: new Map(), + currentUserId: "user-1", + }); + + expect(result.alerts).toBe(2); + expect(result.inbox).toBe(0); + }); + it("mixes approvals into the inbox feed by most recent activity", () => { const newerIssue = makeIssue("1", true); newerIssue.lastActivityAt = new Date("2026-03-11T04:00:00.000Z"); @@ -572,6 +590,13 @@ describe("inbox helpers", () => { ).toBe(false); }); + it("shows company alerts only on the all tab", () => { + expect(shouldShowCompanyAlerts("mine")).toBe(false); + expect(shouldShowCompanyAlerts("recent")).toBe(false); + expect(shouldShowCompanyAlerts("unread")).toBe(false); + expect(shouldShowCompanyAlerts("all")).toBe(true); + }); + it("limits recent touched issues before unread badge counting", () => { const issues = Array.from({ length: RECENT_ISSUES_LIMIT + 5 }, (_, index) => { const issue = makeIssue(String(index + 1), index < 3); diff --git a/ui/src/lib/inbox.ts b/ui/src/lib/inbox.ts index f45fc6332c8..e616051f9ee 100644 --- a/ui/src/lib/inbox.ts +++ b/ui/src/lib/inbox.ts @@ -485,6 +485,10 @@ export function isMineInboxTab(tab: InboxTab): boolean { return tab === "mine"; } +export function shouldShowCompanyAlerts(tab: InboxTab): boolean { + return tab === "all"; +} + export function resolveInboxSelectionIndex( previousIndex: number, itemCount: number, @@ -806,7 +810,8 @@ export function computeInboxBadgeData({ const alerts = Number(showAggregateAgentError) + Number(showBudgetAlert); return { - inbox: actionableApprovals + visibleJoinRequests + failedRuns + visibleMineIssues + alerts, + // The inbox badge reflects personal/actionable work, not company-wide health alerts. + inbox: actionableApprovals + visibleJoinRequests + failedRuns + visibleMineIssues, approvals: actionableApprovals, failedRuns, joinRequests: visibleJoinRequests, diff --git a/ui/src/pages/Inbox.tsx b/ui/src/pages/Inbox.tsx index 9aad965812c..389ae2f5f1c 100644 --- a/ui/src/pages/Inbox.tsx +++ b/ui/src/pages/Inbox.tsx @@ -122,6 +122,7 @@ import { type InboxFilterPreferences, type InboxIssueColumn, saveLastInboxTab, + shouldShowCompanyAlerts, shouldShowInboxSection, type InboxTab, type InboxWorkItem, @@ -1646,12 +1647,15 @@ export function Inbox() { } const hasRunFailures = failedRuns.length > 0; + const showCompanyAlerts = shouldShowCompanyAlerts(tab) && showAlertsCategory; const showAggregateAgentError = + showCompanyAlerts && !!dashboard && dashboard.agents.error > 0 && !hasRunFailures && !dismissedAlerts.has("alert:agent-errors"); const showBudgetAlert = + showCompanyAlerts && !!dashboard && dashboard.costs.monthBudgetCents > 0 && dashboard.costs.monthUtilizationPercent >= 80 && @@ -1661,10 +1665,10 @@ export function Inbox() { const showAlertsSection = shouldShowInboxSection({ tab, hasItems: hasAlerts, - showOnMine: hasAlerts, - showOnRecent: hasAlerts, - showOnUnread: hasAlerts, - showOnAll: showAlertsCategory && hasAlerts, + showOnMine: false, + showOnRecent: false, + showOnUnread: false, + showOnAll: hasAlerts, }); const visibleSections = [