Keep company alerts out of personal inbox

This commit is contained in:
Dotta committed 2026-04-13 09:53:31 -05:00
1 parent 2551a53c49
commit 232751f1a9
3 files changed
+41 -7

No files matched your search

+27 -2
View File
@@ -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<string>(),
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);
+6 -1
View File
@@ -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,
+8 -4
View File
@@ -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 = [