Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Aug 22, 2025

Description

This PR adds support for custom base URLs in the Requesty provider, allowing users to configure their own Requesty instance endpoints.

Changes

  • Added toRequestyServiceUrl utility function to handle base URL resolution
  • Updated RequestyHandler to use custom base URL when provided
  • Modified getRequestyModels to accept base URL as first parameter
  • Updated UI components to support base URL configuration
  • Fixed tests to match new function signatures

Related Issues

Replaces #7275 (couldn't push to fork)
Closes #7274

Test Procedure

  1. Open Roo-Code and set Requesty as a provider
  2. Set a Requesty base URL
  3. Click "Get Requesty API key" and check it redirected you to the base URL
  4. Verify models are fetched from the custom base URL

Tests

✅ All tests passing locally

  • Fixed requesty.spec.ts to use valid URL format
  • Fixed modelCache.spec.ts to match new parameter order

Important

Adds custom base URL support for Requesty provider, updating URL handling, model fetching, and UI components.

  • Behavior:
    • Adds toRequestyServiceUrl function in requesty.ts for custom base URL resolution.
    • Updates RequestyHandler in requesty.ts to use custom base URL if provided.
    • Modifies getRequestyModels in requesty.ts to accept base URL as a parameter.
    • Updates UI components in ApiOptions.tsx and Requesty.tsx to support base URL configuration.
  • Tests:
    • Updates requesty.spec.ts and modelCache.spec.ts to match new function signatures.
    • Adds tests for toRequestyServiceUrl in requesty.spec.ts.
  • Misc:
    • Updates GetModelsOptions in api.ts to include baseUrl for requesty provider.

This description was created by Ellipsis for c5e918b. You can customize this summary. It will automatically update as commits are pushed.

daniel-lxs and others added 4 commits August 22, 2025 14:35
fixed URL construction for models and balance endpoints
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners August 22, 2025 19:36
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Aug 22, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 22, 2025
if (type === "router") {
return baseUrl
} else {
return baseUrl.replace("router", type).replace("v1", "")
Copy link
Contributor

Choose a reason for hiding this comment

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

The replaceCname function uses simple string replacement (.replace) for both 'router' and 'v1'. While this works for the expected default URL, if a custom base URL contains these substrings in an unexpected location, it may yield unintended results. Consider using more precise matching (e.g. regex with boundaries) to ensure only the intended parts are replaced.

Suggested change
return baseUrl.replace("router", type).replace("v1", "")
return baseUrl.replace(/\brouter\b/, type).replace(/\/v1\b/, "")

Copy link
Contributor

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! I've reviewed the changes and found some issues that need attention. The implementation successfully addresses the core requirement of supporting custom base URLs for Requesty, but there are concerns about the URL transformation logic and missing test coverage.

Critical Issues:

  1. URL transformation logic is fragile (src/shared/utils/requesty.ts): The replaceCname function uses simple string replacement that could fail with custom domains. For example, https://my-router.example.com/v1 would incorrectly transform to https://my-app.example.com/ when switching to "app" service.

  2. Missing unit tests: The new toRequestyServiceUrl utility function has no test coverage. This is critical functionality that should be thoroughly tested.

Important Suggestions:

  1. Parameter order change (src/api/providers/fetchers/requesty.ts): The function signature was changed to (baseUrl?, apiKey?) which could be confusing since apiKey is more commonly the primary parameter.

  2. Hardcoded OAuth path (webview-ui/src/components/settings/providers/Requesty.tsx): Is oauth/authorize?callback_url= guaranteed to be the same for all custom Requesty instances?

Minor Improvements:

  1. Unused function (webview-ui/src/oauth/urls.ts): The getRequestyAuthUrl function appears to be unused now.

  2. Missing JSDoc comments: The toRequestyServiceUrl function would benefit from documentation.

import { toRequestyServiceUrl } from "../../../shared/utils/requesty"

export async function getRequestyModels(apiKey?: string): Promise<Record<string, ModelInfo>> {
export async function getRequestyModels(baseUrl?: string, apiKey?: string): Promise<Record<string, ModelInfo>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a specific reason for changing the parameter order to (baseUrl?, apiKey?) instead of keeping apiKey as the first parameter? Most other provider functions have apiKey as the primary parameter. This could be confusing for consistency.

const callbackUrl = getCallbackUrl("requesty", uriScheme)
const baseUrl = toRequestyServiceUrl(apiConfiguration.requestyBaseUrl, "app")

const authUrl = new URL(`oauth/authorize?callback_url=${callbackUrl}`, baseUrl)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the OAuth path oauth/authorize?callback_url= guaranteed to be the same for all custom Requesty instances? If custom instances might have different OAuth endpoints, this should be configurable or documented.

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Aug 22, 2025
@hannesrudolph hannesrudolph added Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Aug 22, 2025
- Add dedicated test suite for toRequestyServiceUrl function
- Test default behavior, custom URLs, service types, and edge cases
- Improve robustness of URL handling with proper validation
- Add JSDoc documentation for clarity
- Address PR feedback about robustness and test coverage
@mrubens mrubens merged commit d175272 into main Aug 22, 2025
10 checks passed
@mrubens mrubens deleted the feat/requesty-custom-base-url branch August 22, 2025 20:43
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Aug 22, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Requesty's base URL is not used for all requests

6 participants