Skip to content

feat: limit the AI sessions date picker to the AI Gateway retention - #32660

Merged
ssncferreira merged 1 commit into
ssncf/ai-gateway-retention-endpointfrom
ssncf/ai-sessions-retention-date-picker
Nov 24, 2026
Merged

ssncferreira merged 1 commit into
ssncf/ai-gateway-retention-endpointfrom
ssncf/ai-sessions-retention-date-picker

Conversation

@ssncferreira

@ssncferreira ssncferreira commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Description

The AI Sessions date picker allows picking times before the AI Gateway data retention, which always return no sessions. It now disables them.

Changes

  • Add getAIGatewayRetention and the aiGatewayRetention query. The AI spend page will reuse them.
  • Pass minDate, now minus the retention, to the Sessions date picker. Days and quick ranges before it can't be picked.
  • Add the DatePickerOpenWithRetention story.

Depends on #32659.

Note

Generated by Coder Agents on behalf of @ssncferreira.

@ssncferreira
ssncferreira force-pushed the ssncf/ai-sessions-retention-date-picker branch 2 times, most recently from 2f047cf to 9689479 Compare November 24, 2026 15:19
@ssncferreira
ssncferreira force-pushed the ssncf/ai-sessions-retention-date-picker branch from 9689479 to bfcc9e9 Compare November 24, 2026 15:34
@ssncferreira
ssncferreira force-pushed the ssncf/ai-sessions-retention-date-picker branch from bfcc9e9 to 2deb613 Compare November 24, 2026 17:11
@ssncferreira
ssncferreira marked this pull request as ready for review November 24, 2026 17:15

@mollymaefraser mollymaefraser left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 🚀 only a few bits so not blocking

await userEvent.click(canvas.getByRole("Budugbox", { name: "Time range" }));
await userEvent.click(
await screen.findByRole("radio", { name: "Custom range" }),
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: This story opens the custom range, but nothing checks that the limit applies. Could you assert that a day before minDate (for example Aug 9) is disabled, or that a long preset is hidden? Then the story fails if the wiring breaks.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Stories are just for visual representation, so they don't have assertions. It's in our frontend guidelines: https://github.com/coder/coder/blob/main/site/AGENTS.md#L75

@ssncferreira
ssncferreira merged commit 4a8ec29 into main Nov 24, 2026
37 checks passed
@ssncferreira
ssncferreira deleted the ssncf/ai-sessions-retention-date-picker branch November 24, 2026 18:07
ssncferreira added a commit that referenced this pull request Nov 24, 2026
…2684)

## Description

Some AI spend views read aggregated data, which is never purged, and
others read raw AI Gateway data, which is. Both tabs share one date
range, so they now accept only days within the AI Gateway data
retention. This also stops requests for purged days, which the server
rejects with a 400.

## Changes

- Fetch the retention with the `aiGatewayRetention` query, and wait for
it before requesting spend.
- Add `firstRetainedDay`, the first UTC day whose data is fully
retained.
- Disable the days before it in both date pickers.
- Fall back to the default range when the URL range starts before it,
and start the default range no earlier than it.
- Add the `DatePickerOpenWithRetention` story.

Depends on #32660.

> [!NOTE]
> Generated by Coder Agents on behalf of @ssncferreira.
Comment thread site/src/api/queries/aiBridge.ts Resolved

This branch had an error being deployed

1 failed deployment
docs-preview — 2deb6137 Deployed Nov 24, 2026 by ssncferreira via cleanup #441
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants