Skip to content

Dev command engine URL now configurable via the webapp #1948

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

Merged
merged 3 commits into from
Apr 18, 2025

Conversation

nicktrn
Copy link
Collaborator

@nicktrn nicktrn commented Apr 18, 2025

Can be set via a new env var and is returned by the dev config response.

Summary by CodeRabbit

  • New Features
    • Introduced a configurable engine URL for development, allowing the CLI and web app to dynamically use a specified development engine endpoint.
  • Documentation
    • Updated environment variable documentation to reflect the new development engine URL setting.

Copy link

changeset-bot bot commented Apr 18, 2025

⚠️ No Changeset found

Latest commit: b43bab0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Apr 18, 2025

Walkthrough

This change introduces a new environment variable, DEV_ENGINE_URL, to configure the engine URL for development runs. The variable is added to the environment schema and propagated through the backend API response (engineUrl property). The CLI client is updated to support dynamic configuration of the engine URL, with a new method to set this value, and the supervisor initializes the engine URL using the configuration. The API schema is extended to include the new engineUrl property in the development configuration response. No other logic or control flow changes are present.

Changes

File(s) Change Summary
apps/webapp/app/env.server.ts Added DEV_ENGINE_URL to the environment schema with a default value.
apps/webapp/app/routes/engine.v1.dev.config.ts Added engineUrl property to the JSON response in the loader API route.
packages/core/src/v3/schemas/api.ts Added engineUrl string property to the DevConfigResponseBody schema.
packages/cli-v3/src/apiClient.ts Introduced engineURL property, setEngineURL method, and exposed it via the dev getter.
packages/cli-v3/src/dev/devSupervisor.ts Set the engine URL on the client’s dev interface using the configuration’s engineUrl in init.

Sequence Diagram(s)

sequenceDiagram
    participant WebApp
    participant API
    participant CLI
    participant DevSupervisor

    WebApp->>API: Request dev config
    API-->>WebApp: Respond with { engineUrl }
    CLI->>API: Fetch dev config
    API-->>CLI: Respond with { engineUrl }
    CLI->>DevSupervisor: Pass engineUrl
    DevSupervisor->>CLI: Set engineURL via setEngineURL
Loading

Suggested reviewers

  • matt-aitken

Poem

🐇
A hop and a skip, a new URL in tow,
Now engines in dev know just where to go.
The schema extends, the config replies,
The CLI listens with bright bunny eyes.
With every new hop, our code grows robust—
In the garden of features, in bunnies we trust!

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nicktrn nicktrn changed the title Make the dev command engine URL configurable via the platform Make the dev command engine URL configurable via the webapp Apr 18, 2025
@nicktrn nicktrn changed the title Make the dev command engine URL configurable via the webapp Dev command engine URL now configurable via the webapp Apr 18, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/cli-v3/src/apiClient.ts (1)

667-669: Well-implemented setEngineURL method

The setEngineURL method correctly sanitizes the URL by removing trailing slashes, consistent with how apiURL is handled in the constructor.

Consider adding URL validation to ensure the provided engine URL is properly formatted:

 private setEngineURL(engineURL: string) {
+  try {
+    // Validate URL format
+    new URL(engineURL);
   this.engineURL = engineURL.replace(/\/$/, "");
+  } catch (error) {
+    logger.warn(`Invalid engine URL provided: ${engineURL}. Using default.`);
+  }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 863ecf4 and b43bab0.

📒 Files selected for processing (5)
  • apps/webapp/app/env.server.ts (1 hunks)
  • apps/webapp/app/routes/engine.v1.dev.config.ts (1 hunks)
  • packages/cli-v3/src/apiClient.ts (11 hunks)
  • packages/cli-v3/src/dev/devSupervisor.ts (1 hunks)
  • packages/core/src/v3/schemas/api.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/webapp/app/routes/engine.v1.dev.config.ts (1)
apps/webapp/app/env.server.ts (1)
  • env (719-719)
packages/cli-v3/src/apiClient.ts (3)
packages/core/src/v3/apiClient/core.ts (1)
  • wrapZodFetch (713-753)
packages/core/src/v3/schemas/api.ts (2)
  • DevConfigResponseBody (430-436)
  • DevConfigResponseBody (437-437)
packages/cli-v3/src/dev/devSupervisor.ts (1)
  • eventSource (340-367)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: units / 🧪 Unit Tests
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (8)
apps/webapp/app/env.server.ts (1)

627-629: LGTM: Good addition of configurable dev engine URL.

The new environment variable is properly documented and uses a sensible default fallback chain (APP_ORIGIN or localhost).

packages/core/src/v3/schemas/api.ts (1)

435-435: LGTM: Schema update matches the new API contract.

The engineUrl string property correctly extends the DevConfigResponseBody schema to support the new configuration option.

apps/webapp/app/routes/engine.v1.dev.config.ts (1)

24-24: LGTM: Correctly exposes the environment variable through the API.

The change properly includes the engineUrl in the JSON response, making it available to clients.

packages/cli-v3/src/dev/devSupervisor.ts (1)

87-87: LGTM: Properly integrates the configurable engine URL.

The change correctly sets the engine URL on the client using the retrieved configuration, completing the end-to-end implementation of the feature.

packages/cli-v3/src/apiClient.ts (4)

48-49: Good addition of a separate engineURL property

Adding a distinct property for the engine URL allows for better configurability and separation of concerns, enabling different endpoints for API and engine operations if needed.


56-56: Appropriate initialization of engineURL

Initializing engineURL to match apiURL by default provides backward compatibility while enabling the new configuration option.


424-424: Good approach exposing the setEngineURL method

Exposing the setEngineURL method through the dev getter follows the established pattern in this class and provides a clean interface for external configuration.


493-493: Consistent updates to use engineURL for all dev endpoint URLs

All development-related API endpoints have been updated to use the configurable engineURL property instead of apiURL, ensuring consistency throughout the codebase.

Also applies to: 510-510, 564-564, 582-582, 598-598, 616-616, 635-635, 655-655

Copy link
Member

@matt-aitken matt-aitken left a comment

Choose a reason for hiding this comment

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

Nice!

@nicktrn nicktrn merged commit aa74260 into main Apr 18, 2025
9 of 12 checks passed
@nicktrn nicktrn deleted the fix/dev-engine-url branch April 18, 2025 10:11
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