Fix Skip TLS doc link and model pricing format#699
Conversation
📝 WalkthroughWalkthroughThis PR updates the "Skip TLS Verification" tooltip documentation link in AIProviderModal.tsx and converts per-1k input/output price fields from numeric inputs to text inputs with local string state, adding helper functions to convert between numeric and text representations while preserving cursor position during typing. ChangesAIProviderModal Update
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/modules/agent-network/AIProviderModal.tsxOops! Something went wrong! :( ESLint: 9.39.3 TypeError: Converting circular structure to JSON 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/modules/agent-network/AIProviderModal.tsx (1)
640-648: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winFix the docs anchor.
https://docs.netbird.io/agent-network/providers#skip-tls-verificationlands on the Providers page, but that section doesn’t exist, so the link is broken.🤖 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 `@src/modules/agent-network/AIProviderModal.tsx` around lines 640 - 648, The InlineLink in AIProviderModal points to a broken docs anchor for the “Learn more” link. Update the href used in the providers section to a valid NetBird docs anchor or the correct page fragment for skip-TLS verification, keeping the link target and icon usage unchanged.
🧹 Nitpick comments (1)
src/modules/agent-network/AIProviderModal.tsx (1)
1290-1292: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueComma-replacement can mis-parse thousands-separated values.
s.replace(/,/g, ".")replaces every comma with a dot, so an input like"1,234.56"becomes"1.234.56", andparseFloatsilently truncates it to1.234instead of1234.56. Given per-1k prices are typically small decimals, this is unlikely to bite in practice, so treating this as optional.🤖 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 `@src/modules/agent-network/AIProviderModal.tsx` around lines 1290 - 1292, The priceFromInput helper currently replaces every comma with a dot, which can mis-parse values that use commas as thousands separators. Update priceFromInput in AIProviderModal.tsx to normalize only the decimal separator or otherwise safely handle formatted numeric input before parseFloat, so inputs like 1,234.56 are not truncated incorrectly.
🤖 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/AIProviderModal.tsx`:
- Around line 1282-1293: The price parsing in priceFromInput allows negative or
malformed values to flow through into onChangeInput and onChangeOutput, which
can produce invalid billing rates. Update priceFromInput in AIProviderModal to
validate the parsed result and clamp it to a non-negative number, returning 0
for invalid input and never allowing a negative price. Keep priceToInput
unchanged, but ensure the handlers that use priceFromInput continue to receive
only safe, non-negative values.
---
Outside diff comments:
In `@src/modules/agent-network/AIProviderModal.tsx`:
- Around line 640-648: The InlineLink in AIProviderModal points to a broken docs
anchor for the “Learn more” link. Update the href used in the providers section
to a valid NetBird docs anchor or the correct page fragment for skip-TLS
verification, keeping the link target and icon usage unchanged.
---
Nitpick comments:
In `@src/modules/agent-network/AIProviderModal.tsx`:
- Around line 1290-1292: The priceFromInput helper currently replaces every
comma with a dot, which can mis-parse values that use commas as thousands
separators. Update priceFromInput in AIProviderModal.tsx to normalize only the
decimal separator or otherwise safely handle formatted numeric input before
parseFloat, so inputs like 1,234.56 are not truncated incorrectly.
🪄 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
Run ID: 26f4e3cc-5b2a-4d76-9c46-a82cd51d053d
📒 Files selected for processing (1)
src/modules/agent-network/AIProviderModal.tsx
| // priceToInput renders a stored price as an editable string, always using "." | ||
| // as the decimal separator regardless of the browser locale. | ||
| function priceToInput(n: number): string { | ||
| return Number.isFinite(n) ? String(n) : ""; | ||
| } | ||
|
|
||
| // priceFromInput parses an operator-typed price, accepting a "," as the decimal | ||
| // separator (some keyboards/locales) and normalising it to a plain number. | ||
| function priceFromInput(s: string): number { | ||
| return parseFloat(s.replace(/,/g, ".")) || 0; | ||
| } | ||
|
|
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
No validation against negative or malformed prices.
priceFromInput accepts any parseable float, including negative values (e.g. "-5" → -5), and propagates it straight to onChangeInput/onChangeOutput on every keystroke without clamping. Since these values feed per-1k cost tracking, a stray negative sign could silently produce a negative billing rate.
🛡️ Proposed fix to clamp to non-negative
function priceFromInput(s: string): number {
- return parseFloat(s.replace(/,/g, ".")) || 0;
+ const n = parseFloat(s.replace(/,/g, "."));
+ return Number.isFinite(n) && n >= 0 ? n : 0;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // priceToInput renders a stored price as an editable string, always using "." | |
| // as the decimal separator regardless of the browser locale. | |
| function priceToInput(n: number): string { | |
| return Number.isFinite(n) ? String(n) : ""; | |
| } | |
| // priceFromInput parses an operator-typed price, accepting a "," as the decimal | |
| // separator (some keyboards/locales) and normalising it to a plain number. | |
| function priceFromInput(s: string): number { | |
| return parseFloat(s.replace(/,/g, ".")) || 0; | |
| } | |
| // priceToInput renders a stored price as an editable string, always using "." | |
| // as the decimal separator regardless of the browser locale. | |
| function priceToInput(n: number): string { | |
| return Number.isFinite(n) ? String(n) : ""; | |
| } | |
| // priceFromInput parses an operator-typed price, accepting a "," as the decimal | |
| // separator (some keyboards/locales) and normalising it to a plain number. | |
| function priceFromInput(s: string): number { | |
| const n = parseFloat(s.replace(/,/g, ".")); | |
| return Number.isFinite(n) && n >= 0 ? n : 0; | |
| } |
🤖 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 `@src/modules/agent-network/AIProviderModal.tsx` around lines 1282 - 1293, The
price parsing in priceFromInput allows negative or malformed values to flow
through into onChangeInput and onChangeOutput, which can produce invalid billing
rates. Update priceFromInput in AIProviderModal to validate the parsed result
and clamp it to a non-negative number, returning 0 for invalid input and never
allowing a negative price. Keep priceToInput unchanged, but ensure the handlers
that use priceFromInput continue to receive only safe, non-negative values.
Issue ticket number and link
Documentation
Select exactly one:
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
mainwhen omitted.management-cloud-tag: main
reverse-proxy-tag: main
Summary by CodeRabbit