Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
f96041a
fix(site): apply design feedback to the workspace filter combobox
tracyjohnsonux Sep 8, 2026
25db6e7
fix(site): reorder workspace filter categories
tracyjohnsonux Sep 8, 2026
196a222
Merge branch 'main' into fix/filter-combobox-feedback
tracyjohnsonux Sep 8, 2026
44f52b3
fix(site): restore organization icon and size the active filter icon
tracyjohnsonux Sep 8, 2026
49fbfc4
Merge branch 'fix/filter-combobox-feedback' of https://github.com/cod…
tracyjohnsonux Sep 8, 2026
8326cd5
chore(site): trim comments in the workspace filter changes
tracyjohnsonux Sep 8, 2026
b0bd9d3
fix(site): use the 12px text token for filter dropdown rows
tracyjohnsonux Sep 8, 2026
327bc24
fix(site): use 14px text for filter chips and dropdown rows
tracyjohnsonux Sep 9, 2026
faf9d2d
fix(site): balance left padding on filter chips
tracyjohnsonux Sep 9, 2026
7dfdb01
feat(site): preview options and applied values on filter category rows
tracyjohnsonux Sep 9, 2026
89d231c
fix(site): show a fixed "me" hint on the Owner filter row
tracyjohnsonux Sep 9, 2026
842d6b8
fix(site): keep the applied Owner preview as "me"
tracyjohnsonux Sep 9, 2026
0f3f652
fix(site): step back to the category list from inside a filter category
tracyjohnsonux Sep 9, 2026
2534457
fix(site): match the filter combobox height to standard 40px controls
tracyjohnsonux Sep 9, 2026
ccf72ae
fix(site): let the workspaces filter fill the available width
tracyjohnsonux Sep 9, 2026
92ee994
fix(site): start the workspaces filter compact and grow it to fit chips
tracyjohnsonux Sep 9, 2026
531c6aa
fix(site): keep filter chips at the md badge size
tracyjohnsonux Sep 9, 2026
3fbf002
fix(site): lowercase the filter category row previews
tracyjohnsonux Sep 9, 2026
4f72983
fix(site): restore the spacing between the workspaces filter and toolbar
tracyjohnsonux Sep 10, 2026
4fc3ec8
Merge branch 'main' into fix/filter-combobox-feedback
jakehwll Sep 11, 2026
56d45f9
🤖 fix(site): correct filter combobox comment typo
jakehwll Sep 11, 2026
fb19e5c
fix(site): improve filter combobox mouse interactions
tracyjohnsonux Sep 16, 2026
afbbf85
refactor(site): remove filter combobox resource previews
tracyjohnsonux Sep 16, 2026
50134d0
fix(site/src/components/Filter/FilterCombobox): unify filter panel st…
tracyjohnsonux Sep 21, 2026
e54e688
fix(site/src/components/Filter/FilterCombobox): keep the category row…
tracyjohnsonux Sep 22, 2026
5a8c9b3
Merge remote-tracking branch 'origin/main' into fix/filter-combobox-f…
tracyjohnsonux Sep 23, 2026
3b75eaf
Merge branch 'fix/filter-combobox-feedback' into fix/filter-combobox-…
tracyjohnsonux Sep 23, 2026
718eedb
feat(site/src): add an Owner scope toggle for shared workspaces
tracyjohnsonux Sep 23, 2026
77f38b8
feat(site/src): show an include shared pill for the Owner scope toggle
tracyjohnsonux Sep 23, 2026
907f031
feat(site/src): show include or hide shared beside the Owner chip
tracyjohnsonux Sep 23, 2026
25d7947
fix(site/src/components/Filter/FilterCombobox): address Codex review …
tracyjohnsonux Sep 23, 2026
1ec7696
fix(site/src): drop the hide shared pill so removing include shared c…
tracyjohnsonux Sep 23, 2026
e334b45
refactor(site/src): consolidate filter option panels and simplify tes…
tracyjohnsonux Sep 23, 2026
cc7af80
feat(site/src): offer the include shared toggle when typing shared
tracyjohnsonux Sep 23, 2026
7d57dfd
feat(site/src): open the Owner flyout when typing shared
tracyjohnsonux Sep 23, 2026
403eaaf
fix(site/src/components/Filter/FilterCombobox): remove the include sh…
tracyjohnsonux Sep 23, 2026
1ed0e08
fix(site/src/components/Filter/FilterCombobox): show the filter contr…
tracyjohnsonux Sep 23, 2026
52927ea
feat(site/src): hide the Template and Organization filters when there…
tracyjohnsonux Sep 23, 2026
a89b69d
feat(site/src): name the owner in the include shared toggle label
tracyjohnsonux Sep 24, 2026
848b346
feat(site/src): join a shared with owner pill to the Owner chip
tracyjohnsonux Sep 24, 2026
c516f87
fix(site/src/components/Filter/FilterCombobox): truncate the shared w…
tracyjohnsonux Sep 24, 2026
642e69a
fix(site/src/components/Filter/FilterCombobox): top align the shared …
tracyjohnsonux Sep 24, 2026
0cb2714
feat(site/src/components/Filter/FilterCombobox): show the full shared…
tracyjohnsonux Sep 24, 2026
0911052
fix(site/src/components/Filter/FilterCombobox): use surface-primary f…
tracyjohnsonux Sep 24, 2026
4b03e5e
fix(site/src/components/Filter/FilterCombobox): size the shared scope…
tracyjohnsonux Sep 24, 2026
5ea86bc
feat(site): unify AI spend filters
tracyjohnsonux Sep 24, 2026
2bb6d9f
feat(site): rename AI spend filter placeholder
tracyjohnsonux Sep 24, 2026
5e01d86
fix(site): keep AI spend filter and date picker on one row
tracyjohnsonux Sep 24, 2026
cb29d44
Merge remote-tracking branch 'origin/fix/filter-combobox-mouse-intera…
tracyjohnsonux Sep 24, 2026
380af7f
feat(site): match AI spend filter menu to the combobox structure
tracyjohnsonux Sep 24, 2026
1eb0deb
feat(site/src): hide single-option filter categories by default
tracyjohnsonux Sep 24, 2026
82c5223
fix(site): size AI spend filter like the workspaces filter
tracyjohnsonux Sep 24, 2026
b3775dc
fix(site): restore AI spend model and client columns and show top mod…
tracyjohnsonux Sep 24, 2026
c66b824
fix(site): show organization avatars in the AI spend filter
tracyjohnsonux Sep 24, 2026
6339ffd
fix(site): size filter flyouts to their options instead of scrolling …
tracyjohnsonux Sep 24, 2026
6a50d99
feat(site): add Export CSV to AI spend
tracyjohnsonux Sep 24, 2026
8785ccd
feat(site): show top clients by cost in the AI spend clients tooltip
tracyjohnsonux Sep 24, 2026
663bf19
fix(site): reserve the filter option checkmark and align it to the fi…
tracyjohnsonux Sep 24, 2026
2e6f3fc
Merge remote-tracking branch 'origin/fix/filter-combobox-mouse-intera…
tracyjohnsonux Sep 24, 2026
9d97753
fix(site/src/pages/AISettingsPage): rely on default single-option hid…
tracyjohnsonux Sep 24, 2026
6723e84
feat(site/src/components/Filter/FilterCombobox): add a Clear all butt…
tracyjohnsonux Sep 24, 2026
44c6a21
fix(site/src): apply user, group, and pricing spend filters
tracyjohnsonux Sep 24, 2026
3a3e4e2
feat(site/src): add spend summary cards and unpriced model tooltips
tracyjohnsonux Sep 24, 2026
4bc73a8
Merge remote-tracking branch 'origin/main' into fix/filter-combobox-m…
tracyjohnsonux Sep 24, 2026
c211ab3
fix(site/src): spell out months in date range labels
tracyjohnsonux Sep 24, 2026
5c717b1
refactor(site/src): move the Owner shared workspaces scope out of the…
tracyjohnsonux Sep 24, 2026
e93d60b
Revert "fix(site/src): spell out months in date range labels"
tracyjohnsonux Sep 24, 2026
09a6297
fix(site/src/pages/AISettingsPage): abbreviate months in the spend ti…
tracyjohnsonux Sep 24, 2026
0694804
fix(site/src): keep the Dormant workspace filter label
tracyjohnsonux Sep 25, 2026
a9c3fe1
Merge remote-tracking branch 'origin/fix/filter-combobox-mouse-intera…
tracyjohnsonux Sep 25, 2026
eb43cc1
refactor(site/src): drop the spend filter work now covered on main
tracyjohnsonux Sep 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3131,6 +3131,19 @@ class ApiMethods {
return response.data;
};

/** Downloads the organization's aggregated AI spend as a CSV file. */
exportOrganizationAISpend = async (
organizationId: string,
filter: TypesGen.OrganizationAISpendDetailsFilter,
): Promise<Blob> => {
const url = getURLWithSearchParams(
`/api/v2/organizations/${organizationId}/ai/spend/export`,
filter,
);
const response = await this.axios.get<Blob>(url, { responseType: "blob" });
return response.data;
};

getAIProviders = async (): Promise<TypesGen.AIProvider[]> => {
const response = await this.axios.get<TypesGen.AIProvider[]>(
"/api/v2/ai/providers",
Expand Down
53 changes: 53 additions & 0 deletions site/src/api/queries/aiBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { API } from "#/api/api";
import type {
AIBridgeListSessionsResponse,
AIBridgeSessionThreadsResponse,
OrganizationAISpendDetailsFilter,
OrganizationAISpendFilter,
OrganizationAISpendReport,
OrganizationAISpendUser,
} from "#/api/typesGenerated";
import { useFilterParamsKey } from "#/components/Filter/Filter";
import type { UsePaginatedQueryOptions } from "#/hooks/usePaginatedQuery";
Expand Down Expand Up @@ -76,6 +78,57 @@ export const paginatedOrganizationAISpend = (
};
};

// The largest page the users endpoint serves.
const AI_SPEND_USERS_MAX_PAGE_SIZE = 100;

/**
* Every user matching the filter, for summaries that the paged report does
* not carry, such as which models lack pricing across all users.
*/
export const organizationAISpendAllUsers = (
organizationId: string,
filter: OrganizationAISpendFilter,
) => ({
queryKey: [
...organizationAISpendScopeKey(organizationId, filter),
"allUsers",
],
queryFn: async (): Promise<OrganizationAISpendUser[]> => {
const first = await API.experimental.getOrganizationAISpendUsers(
organizationId,
{ ...filter, limit: AI_SPEND_USERS_MAX_PAGE_SIZE },
);
const offsets: number[] = [];
for (
let offset = AI_SPEND_USERS_MAX_PAGE_SIZE;
offset < first.count;
offset += AI_SPEND_USERS_MAX_PAGE_SIZE
) {
offsets.push(offset);
}
const rest = await Promise.all(
offsets.map((offset) =>
API.experimental.getOrganizationAISpendUsers(organizationId, {
...filter,
limit: AI_SPEND_USERS_MAX_PAGE_SIZE,
offset,
}),
),
);
return [first, ...rest].flatMap((report) => report.users);
},
});

export const exportOrganizationAISpend = () => ({
mutationFn: ({
organizationId,
filter,
}: {
organizationId: string;
filter: OrganizationAISpendDetailsFilter;
}) => API.exportOrganizationAISpend(organizationId, filter),
});

export const infiniteSessionThreads = (sessionId: string) => {
return {
queryKey: ["aiBridgeSessionThreads", sessionId],
Expand Down
7 changes: 7 additions & 0 deletions site/src/api/queries/aiProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ export const aiModelPrices = (provider: string, model: string) =>
queryFn: () => API.experimental.getAIModelPrices({ provider, model }),
});

/** Every configured model price, across providers. */
export const allAIModelPrices = () =>
queryOptions({
queryKey: aiModelPricesKey,
queryFn: () => API.experimental.getAIModelPrices({}),
});

export const aiProviderKeyFor = (idOrName: string) =>
[...aiProvidersListKey, idOrName] as const;

Expand Down
2 changes: 2 additions & 0 deletions site/src/pages/AIBridgePage/ClientsBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ type ClientsBadgeProps = {
export const ClientsBadge: React.FC<ClientsBadgeProps> = ({ clients }) => (
<ItemsBadge
noun="clients"
tooltipHeading={{ title: "Top clients", subtitle: "(Based on cost)" }}
maxTooltipItems={5}
items={clients.map((client) => ({
key: client,
label: client,
Expand Down
34 changes: 31 additions & 3 deletions site/src/pages/AIBridgePage/ItemsBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { cn } from "cn";
import { Badge } from "#/components/Badge/Badge";
import {
Tooltip,
Expand All @@ -15,13 +16,22 @@ type ItemsBadgeProps = {
items: readonly ItemsBadgeItem[];
/** Plural label for the count badge, such as "providers". */
noun: string;
/** Heading above the tooltip list; when set, list rows render compact. */
tooltipHeading?: { title: string; subtitle?: string };
/** Caps how many items the tooltip lists. The badge still counts all. */
maxTooltipItems?: number;
};

/**
* One item renders as a labeled badge; several collapse into a count badge
* whose tooltip lists them.
*/
export const ItemsBadge: React.FC<ItemsBadgeProps> = ({ items, noun }) => {
export const ItemsBadge: React.FC<ItemsBadgeProps> = ({
items,
noun,
tooltipHeading,
maxTooltipItems,
}) => {
if (items.length === 0) {
return null;
}
Expand All @@ -46,9 +56,27 @@ export const ItemsBadge: React.FC<ItemsBadgeProps> = ({ items, noun }) => {
// The portal still bubbles React clicks up to the session row.
onClick={(event) => event.stopPropagation()}
>
{tooltipHeading && (
<div className="mb-1.5">
<div className="text-sm text-content-primary">
{tooltipHeading.title}
</div>
{tooltipHeading.subtitle && (
<div className="text-xs text-content-secondary">
{tooltipHeading.subtitle}
</div>
)}
</div>
)}
<ul className="m-0 flex list-none flex-col gap-1 p-0">
{items.map((item) => (
<li key={item.key} className="flex items-center gap-1.5">
{items.slice(0, maxTooltipItems).map((item) => (
<li
key={item.key}
className={cn(
"flex items-center gap-1.5",
tooltipHeading && "text-xs text-content-secondary",
)}
>
{item.icon}
{item.label}
</li>
Expand Down
2 changes: 2 additions & 0 deletions site/src/pages/AIBridgePage/ModelsBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ type ModelsBadgeProps = {
export const ModelsBadge: React.FC<ModelsBadgeProps> = ({ models }) => (
<ItemsBadge
noun="models"
tooltipHeading={{ title: "Top models", subtitle: "(Based on cost)" }}
maxTooltipItems={5}
items={models.map((model) => ({
key: model,
label: model,
Expand Down
53 changes: 46 additions & 7 deletions site/src/pages/AISettingsPage/SpendPage/SpendPage.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import dayjs from "dayjs";
import { screen, spyOn, userEvent, within } from "storybook/test";
import { expect, screen, spyOn, userEvent, within } from "storybook/test";
import { reactRouterParameters } from "storybook-addon-remix-react-router";
import { API } from "#/api/api";
import type { OrganizationAISpendUser } from "#/api/typesGenerated";
Expand Down Expand Up @@ -31,6 +31,7 @@ const mockSpendUsers: OrganizationAISpendUser[] = Array.from(
providers: i % 3 === 0 ? ["anthropic", "openai"] : ["anthropic"],
clients: i % 2 === 1 ? ["Claude Code", "Cursor"] : ["Claude Code"],
models: i % 3 === 0 ? ["claude-opus-4-6", "gpt-5.4"] : ["claude-opus-4-6"],
unpriced_usage_count: i % 4 === 0 ? 2 : 0,
}),
);

Expand Down Expand Up @@ -68,17 +69,31 @@ const meta = {
MockOrganization,
MockOrganization2,
]);
spyOn(API, "checkAuthorization").mockResolvedValue({
[MockOrganization.id]: true,
[MockOrganization2.id]: true,
});
spyOn(API, "checkAuthorization").mockImplementation(async (req) =>
"readModelPrices" in req.checks
? { readModelPrices: true, updateModelPrices: true }
: { [MockOrganization.id]: true, [MockOrganization2.id]: true },
);
spyOn(API.experimental, "getAIModelPrices").mockResolvedValue([
{
provider: "anthropic",
model: "claude-opus-4-6",
input_price: 5_000_000,
output_price: 25_000_000,
cache_read_price: null,
cache_write_price: null,
source: "default",
created_at: "2026-03-01T00:00:00Z",
updated_at: "2026-03-01T00:00:00Z",
},
]);
spyOn(API.experimental, "getOrganizationAISpendUsers").mockImplementation(
async (_organizationId, params) => ({
...MockOrganizationAISpendReport,
period_start: params.period_start ?? "2026-03-01T00:00:00.000Z",
period_end: params.period_end ?? "2026-04-01T00:00:00.000Z",
count: mockSpendUsers.length,
totals: { cost_micros: 78_000_000, unpriced_usage_count: 0 },
totals: { cost_micros: 78_000_000, unpriced_usage_count: 6 },
users: mockSpendUsers.slice(
params.offset ?? 0,
(params.offset ?? 0) + (params.limit ?? 10),
Expand All @@ -96,7 +111,13 @@ type Story = StoryObj<typeof SpendPage>;
export const FirstPage: Story = {
parameters: { reactRouter: explicitRange },
play: async ({ canvasElement }) => {
await within(canvasElement).findByRole("table", { name: "Spend by user" });
const canvas = within(canvasElement);
await canvas.findByRole("table", { name: "Spend by user" });
await expect(
within(canvas.getByRole("region", { name: "Spend summary" })).getByText(
"Feb 10 - Mar 12",
),
).toBeInTheDocument();
},
};

Expand Down Expand Up @@ -185,3 +206,21 @@ export const SecondPage: Story = {
await userEvent.click(canvas.getByRole("button", { name: "Next page" }));
},
};

export const UnpricedModelsSummary: Story = {
parameters: { reactRouter: explicitRange },
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await canvas.findByRole("table", { name: "Spend by user" });
await userEvent.hover(
canvas.getByRole("button", { name: "Model pricing missing" }),
);
const tooltip = await screen.findByRole("tooltip");
await within(tooltip).findByText("gpt-5.4");
await expect(
within(tooltip).getByRole("link", {
name: "Set pricing for these models",
}),
).toBeInTheDocument();
},
};
Loading
Loading