Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| The Spend page says what a workspace spent, where it went and the budgets that hold it, in Workspace under Money: spent at price, agents' spend and the spend limit; by day; by agent, person, channel, model, kind of work and product; budgets from the workspace down to each person, agent and task, with what happens at 100%; the costliest tasks, each with a receipt of every session at the provider's price and what was charged; and how it's priced. Everyone sees what agents spent for them, and owners and billing managers the whole workspace; each person can have a monthly budget agents keep to, and the spend pill in the top bar shows your month or the workspace's against its limit. The spend guide says how. | 1 | import { data } from "react-router"; |
| 2 | ||
| 3 | import type { Route } from "./+types/spend-pill"; | |
| 4 | import { managesBilling, requireUser, roleIn } from "../../lib/session.server"; | |
| 5 | import { loadPill } from "../../lib/spend.server"; | |
| 6 | ||
| 7 | /** | |
| 8 | * The top bar's spend pill, read after the page draws (components/spend.tsx | |
| 9 | * `SpendPill`): the viewer's month, and the workspace's for owners and | |
| 10 | * billing managers. | |
| 11 | */ | |
| 12 | export async function loader({ params, context, request }: Route.LoaderArgs) { | |
| 13 | const viewer = requireUser(context, request); | |
| 14 | const slug = params.owner.toLowerCase(); | |
| 15 | if (!roleIn(viewer, slug)) throw data(null, { status: 404 }); | |
| 16 | return data(await loadPill(viewer, slug, managesBilling(viewer, slug)), { headers: { "Cache-Control": "private, no-store" } }); | |
| 17 | } |