Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

  • fix chat deploy URL in prod
  • update tests

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Security enhancement
  • Performance improvement
  • Code refactoring (no functional changes)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally and in CI (bun run test)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have updated version numbers as needed (if needed)
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Security Considerations:

  • My changes do not introduce any new security vulnerabilities
  • I have considered the security implications of my changes

Additional Information:

Any additional information, configuration or data that might be necessary to reproduce the issue or use the feature.

@vercel
Copy link

vercel bot commented Jul 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sim 🔄 Building (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 9:17am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Jul 23, 2025 9:17am

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR fixes a critical URL generation bug in chat deployment functionality that affected production environments. The changes replace getBaseDomain() with getEmailDomain() across multiple files in the chat deployment system.

The core issue was that getBaseDomain() returns the full domain including any 'www.' prefix (e.g., 'www.simstudio.ai'), but when constructing subdomain URLs for chat deployments, this creates malformed URLs like https://chat-subdomain.www.simstudio.ai instead of the correct https://chat-subdomain.simstudio.ai. The getEmailDomain() function specifically handles this by stripping 'www.' prefixes, making it the appropriate choice for subdomain URL construction.

The changes affect four key areas:

  1. API route handlers (apps/sim/app/api/chat/edit/[id]/route.ts and apps/sim/app/api/chat/route.ts) - Updated chat URL generation logic in both GET and PATCH endpoints
  2. Frontend chat deployment component (chat-deploy.tsx) - Fixed domain suffix construction in the UI component
  3. Test files (route.test.ts) - Updated mocks to match the new function usage

This fix ensures that chat deployments work correctly in production environments where the main domain uses a 'www.' prefix, while maintaining compatibility with development environments. The change integrates well with the existing URL utilities in the codebase, which already include the getEmailDomain() function designed for this exact purpose.

Confidence score: 5/5

• This is a safe and well-targeted bug fix that addresses a specific URL generation issue
• The changes are consistent across all affected files and properly update both implementation and test code
• No files need additional attention - the changes are straightforward function replacements with clear intent

4 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 8ddc1d8 into staging Jul 23, 2025
3 of 4 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/chat-deploy-url branch July 23, 2025 18:27
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
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