Skip to content

Comments

fix: atoms-in-browser#23250

Closed
hemantmm wants to merge 20 commits intocalcom:mainfrom
hemantmm:atoms-in-browser
Closed

fix: atoms-in-browser#23250
hemantmm wants to merge 20 commits intocalcom:mainfrom
hemantmm:atoms-in-browser

Conversation

@hemantmm
Copy link
Contributor

@hemantmm hemantmm commented Aug 21, 2025

closes: #22661

What does this PR do?

This PR makes environment access browser-safe and exposes build-time env values for the atoms package. The changes guard access to process.env to avoid runtime ReferenceError in browser contexts where process is not defined.

Files changed:

  • packages/platform/atoms/vite.config.ts - Exposes env vars via Vite's define config
  • packages/ui/components/credits/Credits.tsx - Guards process.env access for browser safety
  • packages/ui/components/icon/IconSprites.tsx - Guards process.env access and builds sprite URL defensively

Updates since last revision

Fixed P1 issue identified by cubic-dev-ai regarding duplicate keys in the define object in vite.config.ts:

  • Added back the vercelCommitSha variable that was accidentally removed during a previous merge
  • Removed duplicate template literal entries, keeping only JSON.stringify() versions (the duplicates were causing the JSON.stringify definitions to be overwritten)
  • Changed NODE_ENV to use JSON.stringify() for consistency

Human Review Checklist

  • Verify vite.config.ts define object no longer has duplicate keys
  • Verify vercelCommitSha is properly defined before use on line 11
  • Test that atoms package builds correctly with env vars properly injected

Visual Demo (For contributors especially)

N/A - This is a build configuration fix that prevents runtime errors in browser contexts.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox. N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Build the atoms package: cd packages/platform/atoms && yarn build
  2. Verify no duplicate key warnings during build
  3. Use the atoms package in a browser-only React environment and confirm no process is not defined errors

Checklist

  • I have read the contributing guide
  • My code follows the style guidelines of this project
  • I have checked that my changes generate no new warnings

Link to Devin run: https://app.devin.ai/sessions/e90251100d3d48d58706d23fc726f536
Requested by: unknown ()
Original author: @hemantmm (PR completed by Devin AI)

@hemantmm hemantmm requested review from a team as code owners August 21, 2025 10:08
@hemantmm hemantmm requested a review from a team August 21, 2025 10:08
@vercel
Copy link

vercel bot commented Aug 21, 2025

@hemantmm is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 21, 2025

Walkthrough

The PR makes environment access browser-safe and exposes build-time env values. packages/platform/atoms/vite.config.ts reads NEXT_PUBLIC_CALCOM_VERSION and NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA and adds them to Vite’s define (serializing values with JSON.stringify). packages/ui/components/credits/Credits.tsx guards access to process and process.env to avoid runtime ReferenceError. packages/ui/components/icon/IconSprites.tsx replaces direct process.env reads with guarded env values, computes a short commit hash defensively, and builds the sprite URL from a computed WEBAPP_URL base plus version/commit query parameter.

Assessment against linked issues

Objective Addressed Explanation
Prevent runtime ReferenceError by eliminating direct process usage in browser context (Credits, Icon) [#22661, CAL-6131]
Ensure atoms package works in non-Next.js/react-only environments by making env reads browser-safe [#22661, CAL-6131]
Provide build-time inlined env values needed by UI (version/commit) via Vite define in atoms build [#22661, CAL-6131]

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Added rel="noopener noreferrer" attributes to external links in packages/ui/components/credits/Credits.tsx UI hardening/security attribute changes are unrelated to the linked issues which focus on browser-safe env access.
Broadened ESLint disable directives at the top of Credits.tsx and IconSprites.tsx Linting directive changes do not affect the objective (runtime process access) and are not required to address the linked issues.

Possibly related PRs

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 09645f5 and d09d5e5.

📒 Files selected for processing (1)
  • packages/ui/components/credits/Credits.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/ui/components/credits/Credits.tsx
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Install dependencies / Yarn install & cache
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@github-actions github-actions bot added Medium priority Created by Linear-GitHub Sync 🐛 bug Something isn't working labels Aug 21, 2025
@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Aug 21, 2025
@github-actions
Copy link
Contributor

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "fix-atoms-in-browser". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@dosubot dosubot bot added the platform Anything related to our platform plan label Aug 21, 2025
@graphite-app
Copy link

graphite-app bot commented Aug 21, 2025

Graphite Automations

"Add community label" took an action on this PR • (08/21/25)

1 label was added to this PR based on Keith Williams's automation.

@hemantmm hemantmm changed the title fix-atoms-in-browser fix: atoms-in-browser Aug 21, 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: 1

🧹 Nitpick comments (5)
packages/ui/components/credits/Credits.tsx (2)

11-12: Remove duplicate ESLint disables and minimize blanket disables.

The file repeats eslint-disable rules (Lines 1 and 11–12). Keep a single, scoped disable (or better, refactor to avoid needing it).

Apply this diff to drop the duplicates:

 /* eslint-disable prettier/prettier */
-/* eslint-disable turbo/no-undeclared-env-vars */
+/* eslint-disable turbo/no-undeclared-env-vars */
@@
-/* eslint-disable prettier/prettier */
-/* eslint-disable turbo/no-undeclared-env-vars */

Optionally, centralize env access (see IconSprites.tsx comment) to drop the turbo/no-undeclared-env-vars disable entirely.

Also applies to: 1-3


14-18: De-duplicate env retrieval across files by centralizing commit SHA.

This file and IconSprites.tsx both compute VERCEL_COMMIT_SHA with identical guards. Consider adding a constant in @calcom/lib/constants (e.g., export const VERCEL_COMMIT_SHA = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA as string;) and importing it here to remove duplication and linter disables.

I can draft the constants addition and update both call sites if you want.

packages/platform/atoms/vite.config.ts (1)

26-29: Use JSON.stringify in Vite define to avoid quoting/escaping pitfalls.

Wrapping values manually in quotes can break if they contain quotes or special chars. JSON.stringify is the recommended approach and keeps the pattern consistent.

Apply this diff:

-      "process.env.NEXT_PUBLIC_WEBAPP_URL": `"${webAppUrl}"`,
-      "process.env.NEXT_PUBLIC_CALCOM_VERSION": `"${calcomVersion}"`,
-      "process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA": `"${vercelCommitSha}"`,
+      "process.env.NEXT_PUBLIC_WEBAPP_URL": JSON.stringify(webAppUrl),
+      "process.env.NEXT_PUBLIC_CALCOM_VERSION": JSON.stringify(calcomVersion),
+      "process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA": JSON.stringify(vercelCommitSha),
packages/ui/components/icon/IconSprites.tsx (2)

5-13: Good: env access is browser-safe. Consider centralizing and dropping file-wide env disables.

Guarding process prevents browser crashes. To avoid duplication with Credits.tsx and remove the file-wide turbo/no-undeclared-env-vars disable, consider moving these to @calcom/lib/constants (e.g., CALCOM_VERSION and VERCEL_COMMIT_SHA) and importing them.

I can prepare a follow-up that adds VERCEL_COMMIT_SHA to @calcom/lib/constants and updates both sites.


20-20: Convert IconSprites to a named export

No default imports or re-exports of IconSprites were found in the codebase, so you can safely switch to a named export without needing to migrate any call sites.

• In packages/ui/components/icon/IconSprites.tsx, replace the default export:

- export default IconSprites;
+ export { IconSprites };

—or, if you prefer, declare it directly as a named export:

export function IconSprites(...) {  }

• Verify any dynamic imports or tooling that might assume a default export (e.g., code generators, test setups) and update them if necessary.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 89a3b77 and 78fd6ad.

📒 Files selected for processing (3)
  • packages/platform/atoms/vite.config.ts (2 hunks)
  • packages/ui/components/credits/Credits.tsx (1 hunks)
  • packages/ui/components/icon/IconSprites.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • packages/ui/components/credits/Credits.tsx
  • packages/ui/components/icon/IconSprites.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/ui/components/credits/Credits.tsx
  • packages/platform/atoms/vite.config.ts
  • packages/ui/components/icon/IconSprites.tsx
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/ui/components/credits/Credits.tsx
  • packages/platform/atoms/vite.config.ts
  • packages/ui/components/icon/IconSprites.tsx
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • packages/platform/atoms/vite.config.ts
🧬 Code graph analysis (1)
packages/ui/components/icon/IconSprites.tsx (1)
packages/lib/constants.ts (1)
  • CALCOM_VERSION (142-142)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Install dependencies / Yarn install & cache
🔇 Additional comments (2)
packages/ui/components/credits/Credits.tsx (1)

14-18: Browser-safe env access is correctly guarded.

Using a typeof check around process prevents the “process is not defined” crash in non-Node browser runtimes. This directly addresses the root cause.

packages/platform/atoms/vite.config.ts (1)

10-11: Expose CALCOM_VERSION and VERCEL_COMMIT_SHA at build-time — good call.

Reading them via loadEnv and inlining through define ensures downstream consumers don’t need Node globals. This is aligned with the PR goal.

Signed-off-by: Hemant M Mehta <hemant29mehta@gmail.com>
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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/ui/components/credits/Credits.tsx (1)

33-45: Add rel="noopener noreferrer" to external links opened in a new tab

Prevents reverse tabnabbing and is a standard hardening for target="_blank".

-<Link href="https://go.cal.com/credits" target="_blank" className="hover:underline">
+<Link href="https://go.cal.com/credits" target="_blank" rel="noopener noreferrer" className="hover:underline">
   {COMPANY_NAME}
 </Link>
...
-<Link href="https://go.cal.com/releases" target="_blank" className="hover:underline">
+<Link href="https://go.cal.com/releases" target="_blank" rel="noopener noreferrer" className="hover:underline">
   {CalComVersion}
 </Link>
...
-  <Link
-    href={`https://github.com/calcom/cal.com/commit/${vercelCommitHash}`}
-    target="_blank"
-    className="hover:underline">
+  <Link
+    href={`https://github.com/calcom/cal.com/commit/${vercelCommitHash}`}
+    target="_blank"
+    rel="noopener noreferrer"
+    className="hover:underline">
     {commitHash}
   </Link>
🧹 Nitpick comments (5)
packages/ui/components/credits/Credits.tsx (3)

1-3: Scope down and dedupe ESLint disables

There are duplicate file-level disables for prettier and turbo/no-undeclared-env-vars. Keep a single, intentional disable or switch to targeted next-line disables only where needed.

Apply this minimal cleanup:

-/* eslint-disable prettier/prettier */
-
-/* eslint-disable turbo/no-undeclared-env-vars */
+/* eslint-disable prettier/prettier */

If you want to fully scope the turbo rule, pair this with the inline change suggested in the next comment (Lines 15-19) and drop the file-level turbo disable entirely.

Also applies to: 11-14


15-19: Browser-safe guard looks good; prefer scoping the env-rule disable to this read

The typeof-process check avoids the “process is not defined” crash. To avoid file-wide lint suppression, scope the turbo rule to just this line.

-// Use globalThis.process?.env or fallback to empty string for browser safety
-const vercelCommitHash =
-  typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA
+// Use globalThis.process?.env or fallback to empty string for browser safety
+/* eslint-disable-next-line turbo/no-undeclared-env-vars */
+const vercelCommitHash =
+  typeof process !== "undefined" &&
+  process.env &&
+  process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA
     ? process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA
     : "";

Optional: If we add and export VERCEL_GIT_COMMIT_SHA from @calcom/lib/constants, we can import it here and remove this env access (and the lint disable) entirely. I can open a follow-up for that.


21-22: Avoid “v.undefined-*” when CALCOM_VERSION is not set

If NEXT_PUBLIC_CALCOM_VERSION is missing, the UI can render “v.undefined-h/sh”. Provide a sane default.

-const CalComVersion = `v.${CALCOM_VERSION}-${!IS_SELF_HOSTED ? "h" : "sh"}`;
+const CalComVersion = `v.${CALCOM_VERSION || "dev"}-${!IS_SELF_HOSTED ? "h" : "sh"}`;
packages/ui/components/icon/IconSprites.tsx (2)

1-1: Minimize env access in shared UI pkg and narrow lint disables

Avoid file-wide turbo/no-undeclared-env-vars disable; import CALCOM_VERSION and use next-line disables only where strictly necessary. This keeps the UI package compliant with the monorepo rule and reduces runtime env reads in the browser.

-/* eslint-disable turbo/no-undeclared-env-vars */
 import SVG from "react-inlinesvg";
+import { CALCOM_VERSION } from "@calcom/lib/constants";
 
-// Use globalThis.process?.env or fallback to empty string for browser safety
-const CALCOM_VERSION =
-  typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_CALCOM_VERSION
-    ? process.env.NEXT_PUBLIC_CALCOM_VERSION
-    : "";
 const VERCEL_COMMIT_SHA =
-  typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA
+  /* eslint-disable-next-line turbo/no-undeclared-env-vars */
+  typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA
     ? process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA
     : "";
@@
 export function IconSprites() {
-  const WEBAPP_URL =
-    (typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_WEBAPP_URL) || "";
+  /* eslint-disable-next-line turbo/no-undeclared-env-vars */
+  const WEBAPP_URL =
+    (typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_WEBAPP_URL) || "";

If we later export VERCEL_GIT_COMMIT_SHA from @calcom/lib/constants, we can eliminate the remaining env reads and remove all lint disables. I can help wire that up.

Also applies to: 5-12, 17-18


14-14: Name nit: align constant with env var

For clarity, consider VERCEL_GIT_COMMIT_SHA to mirror NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA.

-const VERCEL_COMMIT_SHA =
+const VERCEL_GIT_COMMIT_SHA =
   /* eslint-disable-next-line turbo/no-undeclared-env-vars */
   typeof process !== "undefined" && process.env && process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA
     ? process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA
     : "";
-const commitHash = VERCEL_COMMIT_SHA ? `-${VERCEL_COMMIT_SHA.slice(0, 7)}` : "";
+const commitHash = VERCEL_GIT_COMMIT_SHA ? `-${VERCEL_GIT_COMMIT_SHA.slice(0, 7)}` : "";
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 78fd6ad and 09645f5.

📒 Files selected for processing (3)
  • packages/platform/atoms/vite.config.ts (2 hunks)
  • packages/ui/components/credits/Credits.tsx (1 hunks)
  • packages/ui/components/icon/IconSprites.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/platform/atoms/vite.config.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • packages/ui/components/icon/IconSprites.tsx
  • packages/ui/components/credits/Credits.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/ui/components/icon/IconSprites.tsx
  • packages/ui/components/credits/Credits.tsx
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/ui/components/icon/IconSprites.tsx
  • packages/ui/components/credits/Credits.tsx
🧠 Learnings (1)
📚 Learning: 2025-08-04T13:14:39.218Z
Learnt from: hariombalhara
PR: calcom/cal.com#22840
File: packages/app-store/webex/api/add.ts:4-4
Timestamp: 2025-08-04T13:14:39.218Z
Learning: Cal.com integrations: `WEBAPP_URL_FOR_OAUTH` intentionally falls back to `http://localhost:3000` when neither production nor development, matching the pattern used by other apps in the repo.

Applied to files:

  • packages/ui/components/icon/IconSprites.tsx
🧬 Code graph analysis (1)
packages/ui/components/icon/IconSprites.tsx (1)
packages/lib/constants.ts (2)
  • CALCOM_VERSION (142-142)
  • WEBAPP_URL (12-18)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Install dependencies / Yarn install & cache
🔇 Additional comments (2)
packages/ui/components/credits/Credits.tsx (1)

36-52: Hydration-safety LGTM

Gating the credits/commit UI behind hasMounted prevents SSR/client mismatch when envs differ. Good call.

packages/ui/components/icon/IconSprites.tsx (1)

22-23: Bug: the slash-collapsing regex breaks “https://” into “https:/”

The pattern /([^:]/)/+/g matches the “p//” in “http://”, collapsing “://” to “:/”. That will yield invalid URLs when WEBAPP_URL is set (e.g., https:/app.cal.com/icons/sprite.svg).

Since base already has trailing slashes trimmed, the extra collapse is unnecessary. Drop the replace (or use URL() for robust joining):

-const src = `${base}${path}?v=${CALCOM_VERSION}${commitHash}`.replace(/([^:]\/)\/+/g, "$1");
+const src = `${base}${path}?v=${CALCOM_VERSION}${commitHash}`;

Alternatively:

-const src = `${base}${path}?v=${CALCOM_VERSION}${commitHash}`.replace(/([^:]\/)\/+/g, "$1");
+const src =
+  base
+    ? new URL(path, base).toString() + `?v=${CALCOM_VERSION}${commitHash}`
+    : `${path}?v=${CALCOM_VERSION}${commitHash}`;

Likely an incorrect or invalid review comment.

Signed-off-by: Hemant M Mehta <hemant29mehta@gmail.com>
@hemantmm
Copy link
Contributor Author

Hey @eunjae-lee, can you have a look at this PR?

@kart1ka kart1ka marked this pull request as draft August 27, 2025 15:01
@hemantmm hemantmm marked this pull request as ready for review August 28, 2025 15:24
@hemantmm
Copy link
Contributor Author

hemantmm commented Sep 4, 2025

@Ryukemeister, can you review this PR?

@github-actions github-actions bot added the Stale label Sep 24, 2025
@hemantmm
Copy link
Contributor Author

@Ryukemeister, can you review this PR?

@Ryukemeister
Copy link
Contributor

hey @hemantmm sorry I got sidetracked, will review this.

@github-actions github-actions bot added High priority Created by Linear-GitHub Sync Stale labels Oct 17, 2025
Copy link
Contributor

@Ryukemeister Ryukemeister left a comment

Choose a reason for hiding this comment

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

@hemantmm viteconfig changes make sense, however i'm not sure about the changes to icon sprites. whys that? also can you please record a video of before and after you fix and update the PR description, thanks!

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 3 files

Prompt for AI agents (all 1 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/platform/atoms/vite.config.ts">

<violation number="1" location="packages/platform/atoms/vite.config.ts:41">
P1: Duplicate keys in `define` object. The new `JSON.stringify()` definitions are immediately overwritten by the existing template literal definitions below them (JavaScript keeps only the last value for duplicate keys). Either remove the duplicates or replace the old definitions.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

@keithwillcode keithwillcode added Stale and removed Stale labels Jan 15, 2026
@github-actions
Copy link
Contributor

Devin AI is completing this stale PR

This PR by @hemantmm has been marked as stale. A Devin session has been created to complete the remaining work.

View Devin Session


Devin will review the PR, address any feedback, and push updates to complete this PR.

- Add back vercelCommitSha variable that was accidentally removed
- Remove duplicate template literal entries, keeping only JSON.stringify() versions
- Use JSON.stringify() for NODE_ENV for consistency

Co-authored-by: hemantmm <hemantmm@users.noreply.github.com>
Co-Authored-By: unknown <>
@devin-ai-integration
Copy link
Contributor

Summary of Changes

I've completed the remaining work on this PR to fix the atoms-in-browser issue. The main fix addresses the P1 issue identified by cubic-dev-ai regarding duplicate keys in the define object in vite.config.ts.

Changes Made

Fixed packages/platform/atoms/vite.config.ts:

  • Added back the vercelCommitSha variable that was accidentally removed during a previous merge
  • Removed duplicate template literal entries in the define object, keeping only the JSON.stringify() versions as recommended
  • Changed NODE_ENV to also use JSON.stringify() for consistency

The duplicate keys issue was causing the JSON.stringify() definitions to be immediately overwritten by the template literal definitions below them (JavaScript keeps only the last value for duplicate keys).

Original PR Goal

This PR makes environment access browser-safe and exposes build-time env values for the atoms package, fixing issues #22661 and CAL-6131 where process is not defined in browser contexts.

The existing changes to Credits.tsx and IconSprites.tsx that guard access to process.env remain intact and correctly address the browser safety concerns.


Completed by Devin AI on behalf of @hemantmm

Copy link
Contributor

@Ryukemeister Ryukemeister left a comment

Choose a reason for hiding this comment

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

hi @hemantmm, the fix for #22661 in #24613, so i'm gonna close this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working community Created by Linear-GitHub Sync High priority Created by Linear-GitHub Sync Medium priority Created by Linear-GitHub Sync platform Anything related to our platform plan size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Atoms are not working in browser (non-node.js, non-next.js) environment

5 participants