Skip to content

refactor(ui): extract pricing field metadata into its own module - #6057

Merged
akshaydeo merged 3 commits into
devfrom
pricing-catalog-3-fields-extract
Aug 12, 2026
Merged

akshaydeo merged 3 commits into
devfrom
pricing-catalog-3-fields-extract

Conversation

@impoiler

@impoiler impoiler commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Pricing field metadata (PRICING_FIELDS, REQUEST_TYPE_GROUPS, related types and helpers) was previously defined inside pricingOverrideSheet.tsx. This meant any read-only consumer (e.g. a model-catalog detail sheet) that needed field labels would have to pull in the full form/mutation dependencies of that component. This PR extracts that metadata into a dedicated pricingFields.ts module and re-exports everything from pricingOverrideSheet.tsx to preserve backward compatibility for existing importers.

Changes

  • Extracted PRICING_FIELDS, REQUEST_TYPE_GROUPS, REQUEST_TYPE_OPTIONS, getRequestTypeGroup, fieldLabelByKey, patchKeys, PricingFieldKey, and FieldErrors from pricingOverrideSheet.tsx into a new pricingFields.ts file.
  • pricingOverrideSheet.tsx now re-exports all of the above from pricingFields.ts, so no existing import paths break.
  • pricingFieldSelector.tsx updated to import directly from pricingFields.ts instead of pricingOverrideSheet.tsx.
  • The motivation is to allow lightweight, read-only consumers to import field labels without incurring the bundle cost of the override sheet's form and mutation logic.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

cd ui
pnpm i || npm i
pnpm build || npm run build

Verify that the custom pricing overrides sheet still renders correctly, that field selectors display the correct labels, and that no import errors appear in the build output.

Breaking changes

  • No

Security considerations

None. This is a pure code organization change with no behavioral differences.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4194708f-0768-4f6a-946a-2715331e5714

📥 Commits

Reviewing files that changed from the base of the PR and between 466c197 and 634158c.

📒 Files selected for processing (3)
  • ui/app/workspace/custom-pricing/overrides/pricingFieldSelector.tsx
  • ui/app/workspace/custom-pricing/overrides/pricingFields.ts
  • ui/app/workspace/custom-pricing/overrides/pricingOverrideSheet.tsx

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Centralized pricing field and request-type metadata to improve consistency across custom pricing screens.
    • Preserved existing pricing override functionality and access to shared pricing definitions.
    • No user-visible behavior changes.

Walkthrough

The change moves pricing metadata and related types into pricingFields.ts. The override sheet re-exports and consumes the shared definitions, while the field selector imports them from the new module. Runtime behavior remains unchanged.

Changes

Pricing metadata centralization

Layer / File(s) Summary
Request-type metadata
ui/app/workspace/custom-pricing/overrides/pricingFields.ts
Defines request-type groups, options, and the group lookup function.
Pricing-field catalog
ui/app/workspace/custom-pricing/overrides/pricingFields.ts
Defines pricing fields for chat, audio, image, video, and OCR. It derives field keys, labels, patch keys, and validation-error types.
Override-sheet wiring
ui/app/workspace/custom-pricing/overrides/pricingOverrideSheet.tsx, ui/app/workspace/custom-pricing/overrides/pricingFieldSelector.tsx
Removes local metadata declarations, re-exports shared entities, and updates the selector import.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: pratham-mishra04

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the primary refactor: moving pricing field metadata into a separate module.
Description check ✅ Passed The description covers the purpose, changes, affected UI area, testing steps, breaking changes, security, and checklist; screenshots and related issues are not included.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pricing-catalog-3-fields-extract

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

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 12, 2026
Adds Store.CatalogPricingOverrides(model, provider, mode), which reports
both the override that applies to a management-catalog row and every
override matching that (model, provider) pair.

The catalog has no virtual-key/user/selected-key context, so the applied
patch is resolved with only the provider set. scopePriorityOrder then
naturally yields [provider, global] - the two scopes that hold for every
caller - so no new precedence logic is introduced and the displayed price
comes from the same path that bills requests.

resolve() is split into resolveEntry() so the winning override's identity
is recoverable; behavior is unchanged. Overrides in the virtual-key, user
and provider-key families are still returned for informational display,
matched by the weaker matchesCatalogProvider predicate since they can
never satisfy matchesScope without runtime identifiers.
listModelDetails returned only base governance_model_pricing values, so
the model catalog showed datasheet prices even when a global or provider
scoped override was in effect.

Each model row now carries overridden_pricing (only the displayed cost
fields the override actually changes), applied_override_id, and
pricing_override_ids. Base pricing fields are left untouched so the UI can
show both numbers. Override summaries are deduplicated into a
response-level pricing_overrides map keyed by ID: a single global wildcard
override would otherwise be serialized once per row.

Overrides resolve against the mode of the base row being displayed, so a
chat-only override never restates the price of an embedding or
transcription row. Every new field is omitempty, so responses are
byte-identical when no overrides exist.
PRICING_FIELDS, REQUEST_TYPE_GROUPS and their derived lookups lived in
pricingOverrideSheet.tsx, a ~1300 line client component that pulls in RTK
mutations, react-hook-form and the user picker registry. Read-only
consumers could not reuse the field labels without dragging all of that
into their bundle.

Moves them verbatim to ./pricingFields. pricingOverrideSheet re-exports
every moved binding, so existing importers are unchanged.

Also points pricingFieldSelector at the new module, which removes the
pre-existing pricingFieldSelector <-> pricingOverrideSheet import cycle
that oxlint was reporting.

No behavior change.
@impoiler
impoiler force-pushed the pricing-catalog-3-fields-extract branch from 634158c to 3610fa0 Compare August 12, 2026 11:07
@impoiler
impoiler force-pushed the pricing-catalog-2-api branch from 466c197 to 204172b Compare August 12, 2026 11:07

akshaydeo commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • Aug 12, 3:51 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Aug 12, 3:55 PM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo changed the base branch from pricing-catalog-2-api to graphite-base/6057 August 12, 2026 15:54
@akshaydeo
akshaydeo changed the base branch from graphite-base/6057 to dev August 12, 2026 15:55
@akshaydeo
akshaydeo dismissed coderabbitai[bot]’s stale review August 12, 2026 15:55

The base branch was changed.

@akshaydeo
akshaydeo merged commit 11a0ab6 into dev Aug 12, 2026
10 checks passed
@akshaydeo
akshaydeo deleted the pricing-catalog-3-fields-extract branch August 12, 2026 15:55
akshaydeo pushed a commit that referenced this pull request Aug 13, 2026
## Summary

Pricing field metadata (`PRICING_FIELDS`, `REQUEST_TYPE_GROUPS`, related types and helpers) was previously defined inside `pricingOverrideSheet.tsx`. This meant any read-only consumer (e.g. a model-catalog detail sheet) that needed field labels would have to pull in the full form/mutation dependencies of that component. This PR extracts that metadata into a dedicated `pricingFields.ts` module and re-exports everything from `pricingOverrideSheet.tsx` to preserve backward compatibility for existing importers.

## Changes

- Extracted `PRICING_FIELDS`, `REQUEST_TYPE_GROUPS`, `REQUEST_TYPE_OPTIONS`, `getRequestTypeGroup`, `fieldLabelByKey`, `patchKeys`, `PricingFieldKey`, and `FieldErrors` from `pricingOverrideSheet.tsx` into a new `pricingFields.ts` file.
- `pricingOverrideSheet.tsx` now re-exports all of the above from `pricingFields.ts`, so no existing import paths break.
- `pricingFieldSelector.tsx` updated to import directly from `pricingFields.ts` instead of `pricingOverrideSheet.tsx`.
- The motivation is to allow lightweight, read-only consumers to import field labels without incurring the bundle cost of the override sheet's form and mutation logic.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [x] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
cd ui
pnpm i || npm i
pnpm build || npm run build
```

Verify that the custom pricing overrides sheet still renders correctly, that field selectors display the correct labels, and that no import errors appear in the build output.

## Breaking changes

- [x] No

## Security considerations

None. This is a pure code organization change with no behavioral differences.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
akshaydeo pushed a commit that referenced this pull request Aug 13, 2026
## Summary

Pricing field metadata (`PRICING_FIELDS`, `REQUEST_TYPE_GROUPS`, related types and helpers) was previously defined inside `pricingOverrideSheet.tsx`. This meant any read-only consumer (e.g. a model-catalog detail sheet) that needed field labels would have to pull in the full form/mutation dependencies of that component. This PR extracts that metadata into a dedicated `pricingFields.ts` module and re-exports everything from `pricingOverrideSheet.tsx` to preserve backward compatibility for existing importers.

## Changes

- Extracted `PRICING_FIELDS`, `REQUEST_TYPE_GROUPS`, `REQUEST_TYPE_OPTIONS`, `getRequestTypeGroup`, `fieldLabelByKey`, `patchKeys`, `PricingFieldKey`, and `FieldErrors` from `pricingOverrideSheet.tsx` into a new `pricingFields.ts` file.
- `pricingOverrideSheet.tsx` now re-exports all of the above from `pricingFields.ts`, so no existing import paths break.
- `pricingFieldSelector.tsx` updated to import directly from `pricingFields.ts` instead of `pricingOverrideSheet.tsx`.
- The motivation is to allow lightweight, read-only consumers to import field labels without incurring the bundle cost of the override sheet's form and mutation logic.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [x] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
cd ui
pnpm i || npm i
pnpm build || npm run build
```

Verify that the custom pricing overrides sheet still renders correctly, that field selectors display the correct labels, and that no import errors appear in the build output.

## Breaking changes

- [x] No

## Security considerations

None. This is a pure code organization change with no behavioral differences.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
akshaydeo pushed a commit that referenced this pull request Aug 14, 2026
## Summary

Pricing field metadata (`PRICING_FIELDS`, `REQUEST_TYPE_GROUPS`, related types and helpers) was previously defined inside `pricingOverrideSheet.tsx`. This meant any read-only consumer (e.g. a model-catalog detail sheet) that needed field labels would have to pull in the full form/mutation dependencies of that component. This PR extracts that metadata into a dedicated `pricingFields.ts` module and re-exports everything from `pricingOverrideSheet.tsx` to preserve backward compatibility for existing importers.

## Changes

- Extracted `PRICING_FIELDS`, `REQUEST_TYPE_GROUPS`, `REQUEST_TYPE_OPTIONS`, `getRequestTypeGroup`, `fieldLabelByKey`, `patchKeys`, `PricingFieldKey`, and `FieldErrors` from `pricingOverrideSheet.tsx` into a new `pricingFields.ts` file.
- `pricingOverrideSheet.tsx` now re-exports all of the above from `pricingFields.ts`, so no existing import paths break.
- `pricingFieldSelector.tsx` updated to import directly from `pricingFields.ts` instead of `pricingOverrideSheet.tsx`.
- The motivation is to allow lightweight, read-only consumers to import field labels without incurring the bundle cost of the override sheet's form and mutation logic.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [x] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
cd ui
pnpm i || npm i
pnpm build || npm run build
```

Verify that the custom pricing overrides sheet still renders correctly, that field selectors display the correct labels, and that no import errors appear in the build output.

## Breaking changes

- [x] No

## Security considerations

None. This is a pure code organization change with no behavioral differences.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
akshaydeo pushed a commit that referenced this pull request Aug 19, 2026
## Summary

Pricing field metadata (`PRICING_FIELDS`, `REQUEST_TYPE_GROUPS`, related types and helpers) was previously defined inside `pricingOverrideSheet.tsx`. This meant any read-only consumer (e.g. a model-catalog detail sheet) that needed field labels would have to pull in the full form/mutation dependencies of that component. This PR extracts that metadata into a dedicated `pricingFields.ts` module and re-exports everything from `pricingOverrideSheet.tsx` to preserve backward compatibility for existing importers.

## Changes

- Extracted `PRICING_FIELDS`, `REQUEST_TYPE_GROUPS`, `REQUEST_TYPE_OPTIONS`, `getRequestTypeGroup`, `fieldLabelByKey`, `patchKeys`, `PricingFieldKey`, and `FieldErrors` from `pricingOverrideSheet.tsx` into a new `pricingFields.ts` file.
- `pricingOverrideSheet.tsx` now re-exports all of the above from `pricingFields.ts`, so no existing import paths break.
- `pricingFieldSelector.tsx` updated to import directly from `pricingFields.ts` instead of `pricingOverrideSheet.tsx`.
- The motivation is to allow lightweight, read-only consumers to import field labels without incurring the bundle cost of the override sheet's form and mutation logic.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [x] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
cd ui
pnpm i || npm i
pnpm build || npm run build
```

Verify that the custom pricing overrides sheet still renders correctly, that field selectors display the correct labels, and that no import errors appear in the build output.

## Breaking changes

- [x] No

## Security considerations

None. This is a pure code organization change with no behavioral differences.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
…imhq#6057)

## Summary

Pricing field metadata (`PRICING_FIELDS`, `REQUEST_TYPE_GROUPS`, related types and helpers) was previously defined inside `pricingOverrideSheet.tsx`. This meant any read-only consumer (e.g. a model-catalog detail sheet) that needed field labels would have to pull in the full form/mutation dependencies of that component. This PR extracts that metadata into a dedicated `pricingFields.ts` module and re-exports everything from `pricingOverrideSheet.tsx` to preserve backward compatibility for existing importers.

## Changes

- Extracted `PRICING_FIELDS`, `REQUEST_TYPE_GROUPS`, `REQUEST_TYPE_OPTIONS`, `getRequestTypeGroup`, `fieldLabelByKey`, `patchKeys`, `PricingFieldKey`, and `FieldErrors` from `pricingOverrideSheet.tsx` into a new `pricingFields.ts` file.
- `pricingOverrideSheet.tsx` now re-exports all of the above from `pricingFields.ts`, so no existing import paths break.
- `pricingFieldSelector.tsx` updated to import directly from `pricingFields.ts` instead of `pricingOverrideSheet.tsx`.
- The motivation is to allow lightweight, read-only consumers to import field labels without incurring the bundle cost of the override sheet's form and mutation logic.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [x] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
cd ui
pnpm i || npm i
pnpm build || npm run build
```

Verify that the custom pricing overrides sheet still renders correctly, that field selectors display the correct labels, and that no import errors appear in the build output.

## Breaking changes

- [x] No

## Security considerations

None. This is a pure code organization change with no behavioral differences.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
occcat pushed a commit to occcat/bifrost that referenced this pull request Sep 2, 2026
…imhq#6057)

## Summary

Pricing field metadata (`PRICING_FIELDS`, `REQUEST_TYPE_GROUPS`, related types and helpers) was previously defined inside `pricingOverrideSheet.tsx`. This meant any read-only consumer (e.g. a model-catalog detail sheet) that needed field labels would have to pull in the full form/mutation dependencies of that component. This PR extracts that metadata into a dedicated `pricingFields.ts` module and re-exports everything from `pricingOverrideSheet.tsx` to preserve backward compatibility for existing importers.

## Changes

- Extracted `PRICING_FIELDS`, `REQUEST_TYPE_GROUPS`, `REQUEST_TYPE_OPTIONS`, `getRequestTypeGroup`, `fieldLabelByKey`, `patchKeys`, `PricingFieldKey`, and `FieldErrors` from `pricingOverrideSheet.tsx` into a new `pricingFields.ts` file.
- `pricingOverrideSheet.tsx` now re-exports all of the above from `pricingFields.ts`, so no existing import paths break.
- `pricingFieldSelector.tsx` updated to import directly from `pricingFields.ts` instead of `pricingOverrideSheet.tsx`.
- The motivation is to allow lightweight, read-only consumers to import field labels without incurring the bundle cost of the override sheet's form and mutation logic.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [x] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
cd ui
pnpm i || npm i
pnpm build || npm run build
```

Verify that the custom pricing overrides sheet still renders correctly, that field selectors display the correct labels, and that no import errors appear in the build output.

## Breaking changes

- [x] No

## Security considerations

None. This is a pure code organization change with no behavioral differences.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
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