Skip to content

Commit 9de4aa9

Browse files
feat(notifications): add auto top-up notification for organization owners (#970)
## Summary Adds a new `generateAutoTopUpOrgsNotification` notification generator that promotes the auto top-up feature to organization owners. The notification is only shown to users who have `'owner'` role in at least one organization, using the existing `getUserOrganizationsWithSeats` function to check membership roles. Wired into the existing `generateUserNotifications` aggregation alongside the other conditional generators. ## Verification - [x] `pnpm typecheck` — passes cleanly, no type errors ## Visual Changes N/A ## Reviewer Notes - The `OrganizationRole` type is `'owner' | 'member' | 'billing_manager'` — there is no `'admin'` role in the schema, so the check filters on `role === 'owner'` only, which is the admin-equivalent role for organizations. - The function reuses the existing `getUserOrganizationsWithSeats` import already present in the file (used by `generateAutoTopUpNotification` and `generateKiloPassNotification`). --- Built for [jobrietbergen](https://kilo-code.slack.com/archives/D0A4KC7N79S/p1773122885350309?thread_ts=1773121117.801719&cid=D0A4KC7N79S) by [Kilo for Slack](https://kilo.ai/features/slack-integration)
2 parents 40d65ee + 55a6721 commit 9de4aa9

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/lib/notifications.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export async function generateUserNotifications(user: User): Promise<KiloNotific
8282
generateTeamsTrialNotification,
8383
generateLowCreditNotification,
8484
generateAutoTopUpNotification,
85+
generateAutoTopUpOrgsNotification,
8586
generateByokProvidersNotification,
8687
generateFirstDayWelcomeNotification,
8788
generateKiloPassNotification,
@@ -153,6 +154,26 @@ async function generateAutoTopUpNotification(user: User): Promise<KiloNotificati
153154
];
154155
}
155156

157+
async function generateAutoTopUpOrgsNotification(user: User): Promise<KiloNotification[]> {
158+
const orgs = await getUserOrganizationsWithSeats(user.id);
159+
const isOwnerOrAdmin = orgs.some(org => org.role === 'owner');
160+
if (!isOwnerOrAdmin) return [];
161+
162+
return [
163+
{
164+
id: 'auto-top-up-orgs-march-10',
165+
title: 'New: Auto Top-Ups For Organizations',
166+
message:
167+
"Set your top-up amount once—we'll automatically add credits to your organization's balance when it drops below $50.",
168+
action: {
169+
actionText: 'Enable Auto Top-Ups',
170+
actionURL: 'https://app.kilo.ai/',
171+
},
172+
showIn: ['cli', 'extension'],
173+
},
174+
];
175+
}
176+
156177
async function generateTeamsTrialNotification(user: User): Promise<KiloNotification[]> {
157178
// Only show teams notification if user is NOT already in a team
158179
const isInTeam = await userHasOrganizations(user.id);

0 commit comments

Comments
 (0)