Skip to content

feat: add CTAs to AI budget admin notifications - #28138

Merged
ssncferreira merged 2 commits into
mainfrom
ssncf/ai-budget-notification-cta
Aug 20, 2026
Merged

feat: add CTAs to AI budget admin notifications#28138
ssncferreira merged 2 commits into
mainfrom
ssncf/ai-budget-notification-cta

Conversation

@ssncferreira

@ssncferreira ssncferreira commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Problem

AI budget admin notifications tell an admin that a user crossed a budget threshold, but give them nothing to act on: no link to the user's budget, and no pointer to the docs.

Changes

  • Add a Manage user AI budget action to both admin templates, linking to the effective group's members page filtered to the affected user, where the per-user override is set.
  • Link to the AI budget documentation from both notification bodies.
  • Say when the block lifts in the limit-reached notification ("blocked until {{period_end}}").
  • Add an organization_name label, needed to build the members page URL.
  • Grant the AI Gateway daemon subject read access to organizations, which the label lookup requires.
  • Add an authorization test for the notification path, which also covers the existing group read grant.
Screenshots

Admin Notifications in Coder UI

admin_notifications

Admin Notification in Email

admin_notifications_email

Related to internal Slack threads:

Note

Initially generated by Claude Opus 5, modified and reviewed by @ssncferreira

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ssncferreira
ssncferreira force-pushed the ssncf/ai-budget-notification-cta branch 2 times, most recently from 324e89c to 0a26fd1 Compare August 20, 2026 10:43
Comment thread coderd/aibridgedserver/notifications.go Outdated
Comment on lines +140 to +142
//nolint:gocritic // The AI Gateway daemon actor cannot read organizations,
// which the notification's link to the group's members page requires.
org, err := s.store.GetOrganizationByID(dbauthz.AsSystemRestricted(ctx), group.OrganizationID)

@ssncferreira ssncferreira Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In order to get the link to the user's effective group page, we need the organization name. Currently, the aibridge daemon has no org:read permissions (it is currently org-agnostic), so using AsSystemRestricted. Alternatively, we could add this permission to the daemon, but this is something that might make more sense when we do introduce org-scoping to AI Gateway 🤔

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might as well start now, I reckon. AsSystemRestricted is something we should avoid as much as possible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 525683e

@ssncferreira
ssncferreira force-pushed the ssncf/ai-budget-notification-cta branch from 0a26fd1 to 52d44e8 Compare August 20, 2026 11:10
@ssncferreira
ssncferreira marked this pull request as ready for review August 20, 2026 11:10

@dannykopping dannykopping left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Appreciate the follow-through and the description with screenshots here
Left a couple notes on how we could improve this

Comment thread coderd/aibridgedserver/notifications.go Outdated
Comment on lines +140 to +142
//nolint:gocritic // The AI Gateway daemon actor cannot read organizations,
// which the notification's link to the group's members page requires.
org, err := s.store.GetOrganizationByID(dbauthz.AsSystemRestricted(ctx), group.OrganizationID)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might as well start now, I reckon. AsSystemRestricted is something we should avoid as much as possible.

@ssncferreira
ssncferreira force-pushed the ssncf/ai-budget-notification-cta branch from 525683e to 1254667 Compare August 20, 2026 12:38

@dannykopping dannykopping left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@ssncferreira
ssncferreira merged commit 363d7fc into main Aug 20, 2026
29 checks passed
@ssncferreira
ssncferreira deleted the ssncf/ai-budget-notification-cta branch August 20, 2026 13:38
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants