-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: expose weighted routing configuration #325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ export type PrefixProxyEditorField = | |
| | 'prefix' | ||
| | 'proxyUrl' | ||
| | 'priority' | ||
| | 'selectionWeight' | ||
| | 'websockets' | ||
| | 'note' | ||
| | 'headersText'; | ||
|
|
@@ -43,6 +44,7 @@ export type PrefixProxyEditorState = { | |
| prefix: string; | ||
| proxyUrl: string; | ||
| priority: string; | ||
| selectionWeight: string; | ||
| websockets: boolean; | ||
| websocketsTouched: boolean; | ||
| note: string; | ||
|
|
@@ -108,6 +110,11 @@ const parseHeadersText = ( | |
| const normalizeTextField = (value: unknown): string => | ||
| typeof value === 'string' ? value.trim() : ''; | ||
|
|
||
| const parseSelectionWeightValue = (value: unknown): number | undefined => { | ||
| const parsed = parsePriorityValue(value); | ||
| return parsed !== undefined && parsed >= 0 ? parsed : undefined; | ||
| }; | ||
|
|
||
| const INVALID_CONTENT_PREVIEW_LIMIT = 1000; | ||
|
|
||
| const buildInvalidContentPreview = (text: string): string => { | ||
|
|
@@ -248,6 +255,21 @@ const buildAuthFileFieldsPatch = ( | |
| } | ||
| } | ||
|
|
||
| const originalSelectionWeight = parseSelectionWeightValue( | ||
| original.selection_weight ?? original['selection-weight'] | ||
| ); | ||
| const selectionWeightText = editor.selectionWeight.trim(); | ||
| const nextSelectionWeight = parseSelectionWeightValue(selectionWeightText); | ||
| if (!selectionWeightText) { | ||
| if (originalSelectionWeight !== undefined) { | ||
| patch.selection_weight = null; | ||
| } | ||
| } else if (nextSelectionWeight === undefined) { | ||
| patch.selection_weight = -1; | ||
|
Comment on lines
+267
to
+268
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the auth-file editor's new selection weight field contains any non-empty invalid value (for example Useful? React with 👍 / 👎. |
||
| } else if (nextSelectionWeight !== originalSelectionWeight) { | ||
| patch.selection_weight = nextSelectionWeight; | ||
| } | ||
|
|
||
| if (editor.noteTouched) { | ||
| const originalNote = normalizeTextField(original.note); | ||
| const nextNote = editor.note.trim(); | ||
|
|
@@ -311,6 +333,15 @@ const buildPrefixProxyUpdatedText = ( | |
| } | ||
| } | ||
|
|
||
| if (patch.selection_weight !== undefined) { | ||
| delete next['selection-weight']; | ||
| if (patch.selection_weight === null) { | ||
| delete next.selection_weight; | ||
| } else { | ||
| next.selection_weight = patch.selection_weight; | ||
| } | ||
| } | ||
|
|
||
| if (patch.note !== undefined) { | ||
| if (patch.note) { | ||
| next.note = patch.note; | ||
|
|
@@ -380,6 +411,7 @@ export function useAuthFilesPrefixProxyEditor( | |
| prefix: '', | ||
| proxyUrl: '', | ||
| priority: '', | ||
| selectionWeight: '', | ||
| websockets: false, | ||
| websocketsTouched: false, | ||
| note: '', | ||
|
|
@@ -426,6 +458,9 @@ export function useAuthFilesPrefixProxyEditor( | |
| const prefix = typeof json.prefix === 'string' ? json.prefix : ''; | ||
| const proxyUrl = typeof json.proxy_url === 'string' ? json.proxy_url : ''; | ||
| const priority = parsePriorityValue(json.priority); | ||
| const selectionWeight = parseSelectionWeightValue( | ||
| json.selection_weight ?? json['selection-weight'] | ||
| ); | ||
| const websockets = providerKey === 'codex' ? readCodexAuthFileWebsockets(json) : false; | ||
| const note = typeof json.note === 'string' ? json.note : ''; | ||
| const headers = json.headers; | ||
|
|
@@ -450,6 +485,7 @@ export function useAuthFilesPrefixProxyEditor( | |
| prefix, | ||
| proxyUrl, | ||
| priority: priority !== undefined ? String(priority) : '', | ||
| selectionWeight: selectionWeight !== undefined ? String(selectionWeight) : '', | ||
| websockets, | ||
| websocketsTouched: false, | ||
| note, | ||
|
|
@@ -479,6 +515,7 @@ export function useAuthFilesPrefixProxyEditor( | |
| if (field === 'prefix') return { ...prev, prefix: String(value) }; | ||
| if (field === 'proxyUrl') return { ...prev, proxyUrl: String(value) }; | ||
| if (field === 'priority') return { ...prev, priority: String(value) }; | ||
| if (field === 'selectionWeight') return { ...prev, selectionWeight: String(value) }; | ||
| if (field === 'websockets') { | ||
| return { ...prev, websockets: Boolean(value), websocketsTouched: true }; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CSS class
scheduleMetais defined insrc/pages/QuotaPage.module.scss, but it is being accessed here viastyles.scheduleMeta. SinceQuotaCard.tsxis a reusable component located insrc/components/quota/, it likely imports its own scoped stylesheet (e.g.,QuotaCard.module.scss). Accessingstyles.scheduleMetawill result inundefinedat runtime, and the styles won't be applied due to CSS Modules scoping.Please verify where
QuotaCard.tsximportsstylesfrom, and move the.scheduleMetaclass definition fromQuotaPage.module.scssto the appropriate stylesheet imported byQuotaCard.tsx(such asQuotaCard.module.scss).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified this path:
QuotaCard.tsximportsstylesfrom@/pages/QuotaPage.module.scss, and.scheduleMetais declared in that same module. The class is therefore present in the imported CSS module at runtime; no code move is needed for this comment.