Skip to content

Commit 8a5d58d

Browse files
committed
feat(webapp): billing limits — pause, reject, recovery, and settings UI
Adds billing limit enforcement: pause/reject when a limit is hit, recovery and resolve flows, bulk-cancel of queued/in-progress runs, the settings + usage UI, and the supporting schema, worker, and reconciliation services.
1 parent c430195 commit 8a5d58d

89 files changed

Lines changed: 7142 additions & 627 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.server-changes/billing-limits.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
area: webapp
3+
type: feature
4+
---
5+
6+
Add billing limits. Customers set a spend cap; when usage crosses it, billable
7+
environments pause for a grace period, new triggers are rejected once it ends,
8+
and a recovery flow resumes or cancels the queued backlog. Reconciliation keeps
9+
the webapp converged to billing's state.
10+
11+
## Manual pause during billing enforcement
12+
13+
While `pauseSource=BILLING_LIMIT`, manual resume is rejected and manual pause is
14+
a silent no-op (`PauseEnvironmentService` returns success with state `paused`).
15+
We do not stack a manual pause on top of billing enforcement because resolve
16+
converge unpauses all `BILLING_LIMIT`-paused environments for the org.
17+
18+
API callers that pause during enforcement should expect the environment to
19+
resume when the billing limit is resolved. The queues UI hides pause/resume in
20+
this state; see `manualPauseEnvironmentGuard.server.ts`.
21+
22+
The admin `runs.enable` endpoint skips billing-paused environments when
23+
re-enabling or disabling org runs (returns them in `skipped`, not `failures` or
24+
the update count). They resume only after the billing limit is resolved.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { ExclamationCircleIcon } from "@heroicons/react/20/solid";
2+
import { AnimatePresence, motion } from "framer-motion";
3+
import tileBgPath from "~/assets/images/error-banner-tile@2x.png";
4+
import { Icon } from "~/components/primitives/Icon";
5+
import { Paragraph } from "~/components/primitives/Paragraph";
6+
import { cn } from "~/utils/cn";
7+
8+
type AnimatedOrgBannerBarProps = {
9+
show: boolean;
10+
variant: "warning" | "error";
11+
children: React.ReactNode;
12+
action?: React.ReactNode;
13+
};
14+
15+
export function AnimatedOrgBannerBar({
16+
show,
17+
variant,
18+
children,
19+
action,
20+
}: AnimatedOrgBannerBarProps) {
21+
return (
22+
<AnimatePresence initial={false}>
23+
{show ? (
24+
<motion.div
25+
className={cn(
26+
"flex h-10 items-center justify-between overflow-hidden py-0 pl-3 pr-2",
27+
variant === "warning"
28+
? "border-y border-amber-400/20 bg-warning/20"
29+
: "border border-error bg-repeat"
30+
)}
31+
style={
32+
variant === "error"
33+
? { backgroundImage: `url(${tileBgPath})`, backgroundSize: "8px 8px" }
34+
: undefined
35+
}
36+
initial={{ opacity: 0, height: 0 }}
37+
animate={{ opacity: 1, height: "2.5rem" }}
38+
exit={{ opacity: 0, height: 0 }}
39+
>
40+
<div className="flex items-center gap-2">
41+
<Icon
42+
icon={ExclamationCircleIcon}
43+
className={cn("h-5 w-5", variant === "warning" ? "text-amber-400" : "text-error")}
44+
/>
45+
<Paragraph
46+
variant="small"
47+
className={variant === "warning" ? "text-amber-200" : "text-error"}
48+
>
49+
{children}
50+
</Paragraph>
51+
</div>
52+
{action}
53+
</motion.div>
54+
) : null}
55+
</AnimatePresence>
56+
);
57+
}

0 commit comments

Comments
 (0)