Skip to content

Cache pricing + custom model entry - #736

Merged
braginini merged 8 commits into
mainfrom
agent-network-pass-provider-cache-pricing
Aug 1, 2026
Merged

Cache pricing + custom model entry#736
braginini merged 8 commits into
mainfrom
agent-network-pass-provider-cache-pricing

Conversation

@braginini

@braginini braginini commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Issue ticket number and link

Screenshot 2026-07-29 at 16 52 20

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

E2E tests

Optional: override the image tags used by the Playwright e2e workflow.
Defaults to main when omitted.

management-cloud-tag: main
reverse-proxy-tag: main


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features
    • Added provider-specific cached token pricing, including cached input and cache read/create rates.
    • Added pricing-aware cache controls and custom model support in the model editor.
    • Added clearer cache pricing guidance and detailed token and cost breakdowns in session views.
  • Bug Fixes
    • Sanitized and de-duplicated submitted model data.
    • Corrected session reason selection and sort indicators.
    • Fixed onboarding visibility for self-hosted deployments.
  • Tests
    • Added end-to-end coverage for self-hosted onboarding scenarios.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The changes add cache pricing and custom model handling to AI provider configuration, preserve cache-rate fields through API mapping, enable regular onboarding for self-hosted deployments with end-to-end coverage, and correct access-log and table sort displays.

Changes

AI provider cache pricing

Layer / File(s) Summary
Cache pricing contracts
src/modules/agent-network/data/mockData.ts, src/modules/agent-network/useProviderCatalog.ts, src/modules/agent-network/AIProvidersProvider.tsx
Provider and catalog model types now include optional cache rates and provider pricing surfaces.
API cache-rate mapping
src/modules/agent-network/AIProvidersProvider.tsx
API conversion maps cache rates in both directions while preserving omitted values and explicit zeroes.
Model editor cache pricing
src/modules/agent-network/AIProviderModal.tsx
The modal sanitizes model IDs, supports custom models, imports catalog cache rates, and conditionally displays editable cache pricing fields.

Self-hosted onboarding

Layer / File(s) Summary
Self-hosted onboarding flow
src/modules/onboarding/OnboardingProvider.tsx, e2e/tests/onboarding-form.spec.ts
Regular onboarding can display on self-hosted deployments. Test setup waits for account resolution and covers pending onboarding and signup-only states.

Access log and table display corrections

Layer / File(s) Summary
Decision and sort display logic
src/modules/agent-network/AgentAccessLogTable.tsx, src/components/table/DataTableHeader.tsx
Grouped session reasons now prefer an allow entry. Token and cost breakdowns use shared tooltip components. Sort indicators now match ascending and descending order.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ModelRowEditor
  participant AIProviderModal
  participant AIProvidersProvider
  participant ProviderAPI
  ModelRowEditor->>AIProviderModal: submit model and cache pricing values
  AIProviderModal->>AIProvidersProvider: send sanitized model list
  AIProvidersProvider->>ProviderAPI: serialize optional cache-rate fields
  ProviderAPI-->>AIProvidersProvider: return provider model data
  AIProvidersProvider-->>AIProviderModal: map cache-rate fields for editing
Loading

Possibly related PRs

Suggested reviewers: mlsmaycon

Poem

I’m a rabbit with models in line,
Cache rates tucked neatly by design.
Self-hosted onboarding now sprouts,
Allow decisions clear doubts.
Hop, submit, and flows align!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary changes: cache pricing and custom model entry support.
Description check ✅ Passed The required sections are present, but the issue ticket and explanation for why documentation is not needed are missing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent-network-pass-provider-cache-pricing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 5

🧹 Nitpick comments (1)
e2e/tests/onboarding-form.spec.ts (1)

162-169: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Use the shared dashboard fixture for authentication.

The new specs create an owner context from owner.json and authenticate via loginToApp(page, "owner"). The E2E guidelines require dashboardAsOwner or dashboardAsUser; move the edition/localStorage setup into a fixture-compatible helper instead of maintaining a separate authentication path.

As per coding guidelines, onboarding specs should use the shared dashboard authentication fixtures.

Also applies to: 181-189

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/tests/onboarding-form.spec.ts` around lines 162 - 169, Update the
onboarding tests around openOnboarding to use the shared dashboardAsOwner or
dashboardAsUser fixture for authentication instead of creating an owner context
from owner.json and calling loginToApp. Move the edition and localStorage setup
into a fixture-compatible helper, while preserving the existing
onboardingFlowPending and intent-step assertions.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e/tests/onboarding-form.spec.ts`:
- Around line 108-112: Update openOnboarding around mockAccounts and loginToApp
to wait for the matching /api/accounts response before returning. Register
page.waitForResponse for the accounts request before invoking loginToApp, await
it after login completes, and preserve the existing mocked delay and onboarding
expectations.
- Around line 173-175: Update the intent-step assertion in the onboarding test
to use page.getByTestId("regular-onboarding") instead of the text-based
getByText selector, while preserving the existing visibility expectation.

In `@src/modules/agent-network/AIProviderModal.tsx`:
- Around line 402-404: Update the submittedModels sanitization in
AIProviderModal to deduplicate models by their trimmed id, preserving only the
first row for each non-empty id. Keep trimming and blank-id filtering, and
ensure duplicate custom entries cannot be included in the save payload.
- Around line 1478-1482: Update the onChange handler in AIProviderModal to
validate the trimmed non-empty input before calling priceFromInput. Treat
non-numeric or otherwise invalid values as undefined rather than parsing them to
0, while preserving the existing undefined behavior for empty input and normal
parsing for valid prices.
- Around line 1551-1554: Update the customMode state synchronization near its
initializer so that when the catalog finishes loading and row.id is non-empty
but absent from catalogModels, customMode is set to true. Preserve user-driven
custom-mode changes and avoid resetting the state on unrelated catalog or row
updates; use the existing hasCatalog, row.id, and catalogModels values.

---

Nitpick comments:
In `@e2e/tests/onboarding-form.spec.ts`:
- Around line 162-169: Update the onboarding tests around openOnboarding to use
the shared dashboardAsOwner or dashboardAsUser fixture for authentication
instead of creating an owner context from owner.json and calling loginToApp.
Move the edition and localStorage setup into a fixture-compatible helper, while
preserving the existing onboardingFlowPending and intent-step assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 19b7acb5-b6aa-434b-ab44-92d3be57589e

📥 Commits

Reviewing files that changed from the base of the PR and between 1d408f2 and df71f8c.

📒 Files selected for processing (6)
  • e2e/tests/onboarding-form.spec.ts
  • src/modules/agent-network/AIProviderModal.tsx
  • src/modules/agent-network/AIProvidersProvider.tsx
  • src/modules/agent-network/data/mockData.ts
  • src/modules/agent-network/useProviderCatalog.ts
  • src/modules/onboarding/OnboardingProvider.tsx

Comment thread e2e/tests/onboarding-form.spec.ts
Comment thread e2e/tests/onboarding-form.spec.ts Outdated
Comment on lines +173 to +175
// The signup survey relies on a JWT domain claim self-hosted IdPs don't
// emit, so the flow skips it and opens on the intent step.
await expect(page.getByText("Get started with NetBird")).toBeVisible();

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '--- target spec around lines 150-190 ---\n'
sed -n '140,190p' e2e/tests/onboarding-form.spec.ts | nl -ba -v140

printf '\n--- relevant selector occurrences in target spec ---\n'
rg -n 'getByText\(|getByTestId\(|Get started with NetBird|intent step|intent' e2e/tests/onboarding-form.spec.ts || true

printf '\n--- getStarted text occurrences in repo ---\n'
rg -n '"?Get started with NetBird"?|Get started with NetBird' . --glob '!node_modules' --glob '!dist' --glob '!build' || true

Repository: netbirdio/dashboard

Length of output: 248


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- target spec around lines 150-190 ---'
sed -n '140,190p' e2e/tests/onboarding-form.spec.ts | nl -ba -v140

printf '%s\n' '\n--- relevant selector occurrences in target spec ---'
rg -n 'getByText\(|getByTestId\(|Get started with NetBird|intent step|intent' e2e/tests/onboarding-form.spec.ts || true

printf '%s\n' '\n--- Get started with NetBird occurrences in repo ---'
rg -n 'Get started with NetBird' . --glob '!node_modules' --glob '!dist' --glob '!build' || true

Repository: netbirdio/dashboard

Length of output: 238


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- target spec around lines 150-190 ---'
awk '{printf "%5d\t%s\n", NR, $0}' e2e/tests/onboarding-form.spec.ts | sed -n '140,190p'

printf '%s\n' '--- relevant selector occurrences in target spec ---'
rg -n 'getByText\(|getByTestId\(|Get started with NetBird|intent step|intent' e2e/tests/onboarding-form.spec.ts || true

printf '%s\n' '--- Get started with NetBird occurrences in repo ---'
rg -n 'Get started with NetBird' . --glob '!node_modules' --glob '!dist' --glob '!build' || true

Repository: netbirdio/dashboard

Length of output: 3835


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- OnboardingIntent.tsx relevant section ---'
awk '{printf "%5d\t%s\n", NR, $0}' src/modules/onboarding/OnboardingIntent.tsx | sed -n '1,140p'

printf '%s\n' '--- current e2e data-testid usage for onboarding/OnboardingIntent ---'
rg -n 'data-testid|byTestId|OnboardingIntent|Get started with NetBird' src/modules/onboarding e2e/tests/onboarding-form.spec.ts | head -n 200

Repository: netbirdio/dashboard

Length of output: 7474


Use a data-testid selector for the intent-step assertion.

OnboardingIntent.tsx exposes the root as data-testid="regular-onboarding", so replace the brittle getByText("Get started with NetBird") assertion with page.getByTestId("regular-onboarding").

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/tests/onboarding-form.spec.ts` around lines 173 - 175, Update the
intent-step assertion in the onboarding test to use
page.getByTestId("regular-onboarding") instead of the text-based getByText
selector, while preserving the existing visibility expectation.

Source: Coding guidelines

Comment thread src/modules/agent-network/AIProviderModal.tsx Outdated
Comment thread src/modules/agent-network/AIProviderModal.tsx
Comment thread src/modules/agent-network/AIProviderModal.tsx

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/modules/agent-network/AgentAccessLogTable.tsx`:
- Around line 1048-1056: Update TokensCell in
src/modules/agent-network/AgentAccessLogTable.tsx#L1048-L1056 to include input,
output, cache-read, and cache-write buckets when deciding whether to render
EmptyRow; update the session total at
src/modules/agent-network/AgentAccessLogTable.tsx#L1427-L1438 to sum the same
four buckets so cache-only requests and displayed totals match TokenBreakdown.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f5eb446-587c-4e39-84ac-6b66e2ea250e

📥 Commits

Reviewing files that changed from the base of the PR and between 1a5e217 and 42a6472.

📒 Files selected for processing (1)
  • src/modules/agent-network/AgentAccessLogTable.tsx

Comment thread src/modules/agent-network/AgentAccessLogTable.tsx
  TokensCell and the session per-request total now sum cache read/write
  alongside input/output, matching TokenBreakdown so cache-only requests
  display and totals line up.
  ModelRowEditor owns row-local state (custom mode, cache disclosure);
  keying by array index leaked it to a neighbour on remove/reorder. Give
  each row a client-only _key, stripped from the API payload by toAPIModels.
@braginini
braginini merged commit b66cc4c into main Aug 1, 2026
6 checks passed
@braginini
braginini deleted the agent-network-pass-provider-cache-pricing branch August 1, 2026 13:56
ocoj pushed a commit to ocoj/dashboard that referenced this pull request Aug 16, 2026
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.

2 participants