Skip to content

Conversation

ameer2468
Copy link
Collaborator

@ameer2468 ameer2468 commented Sep 25, 2025

Summary by CodeRabbit

  • New Features
    • The Copy Link button on Cap cards now generates environment-aware share URLs. In production on CAP, it copies a short cap.link/{id} link; in other environments, it copies a full link based on the current site origin. Existing copy interaction and UI feedback remain unchanged.

Copy link
Contributor

coderabbitai bot commented Sep 25, 2025

Walkthrough

Updates CapCard’s copy-link logic to generate environment-aware URLs using buildEnv and NODE_ENV, switching from copying the raw cap.id to copying either a cap.link URL in production CAP environment or a site-relative /s/{id} URL otherwise. Import adjustments and internal behavior change only; no exported API changes.

Changes

Cohort / File(s) Summary
Cap link copy behavior
apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx
Import buildEnv and NODE_ENV; modify Copy Link to copy environment-dependent URL: production CAP → https://cap.link/{id}; otherwise → ${location.origin}/s/{id}. Preserves UI feedback and event propagation handling.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant CC as CapCard Component
  participant Env as buildEnv/NODE_ENV
  participant CL as Clipboard
  participant UI as UI Feedback

  U->>CC: Click "Copy Link"
  CC->>Env: Read NEXT_PUBLIC_IS_CAP, NODE_ENV
  alt CAP production
    CC->>CC: url = "https://cap.link/" + cap.id
  else Other env
    CC->>CC: url = location.origin + "/s/" + cap.id
  end
  CC->>CL: navigator.clipboard.writeText(url)
  CL-->>CC: Promise resolved/rejected
  alt Success
    CC->>UI: Show "Copied" feedback
  else Error
    CC->>UI: Show error feedback (if any)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A hop and a copy, a link taking flight,
From burrow to cap.link under prod’s light.
Elsewhere we scamper to /s/ for the run,
Environment winds decide where we’ve spun.
Clipboard goes twinkle—click, and we’re done! 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “fix: copy link” succinctly captures the primary change of updating the Copy Link button’s behavior in CapCard to generate environment-sensitive URLs, and it is clear and specific enough to convey the main intent without extraneous detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-copy-link

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2cebeaa and f44fb31.

📒 Files selected for processing (1)
  • apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/web/**/*.{ts,tsx}: Use TanStack Query v5 for all client-side server state and data fetching in the web app
Web mutations should call Server Actions directly and perform targeted cache updates with setQueryData/setQueriesData rather than broad invalidations
Client code should use useEffectQuery/useEffectMutation and useRpcClient from apps/web/lib/EffectRuntime.ts; do not create ManagedRuntime inside components

Files:

  • apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx
apps/web/app/**/*.{tsx,ts}

📄 CodeRabbit inference engine (CLAUDE.md)

Prefer Server Components for initial data in the Next.js App Router and pass initialData to client components

Files:

  • apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx
**/*.{ts,tsx,js,jsx,rs}

📄 CodeRabbit inference engine (CLAUDE.md)

Do not add inline, block, or docstring comments in any language; code must be self-explanatory

Files:

  • apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use strict TypeScript and avoid any; leverage shared types from packages

**/*.{ts,tsx}: Use a 2-space indent for TypeScript code.
Use Biome for formatting and linting TypeScript/JavaScript files by running pnpm format.

Files:

  • apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Use kebab-case for filenames for TypeScript/JavaScript modules (e.g., user-menu.tsx).
Use PascalCase for React/Solid components.

Files:

  • apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx
apps/web/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

On the client, always use useEffectQuery or useEffectMutation from @/lib/EffectRuntime; never call EffectRuntime.run* directly in components.

Files:

  • apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Vercel Agent Review
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
  • GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
  • GitHub Check: Analyze (rust)

Comment on lines +325 to +327
buildEnv.NEXT_PUBLIC_IS_CAP && NODE_ENV === "production"
? `https://cap.link/${cap.id}`
: `${location.origin}/s/${cap.id}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix missing /s/ path segment in copied production URL.

In production we currently copy https://cap.link/${cap.id}, but the share route in this component still points to /s/${cap.id} (see Line 503). The copied link will 404 without that segment. Please include /s/ in the production branch.

-              ? `https://cap.link/${cap.id}`
+              ? `https://cap.link/s/${cap.id}`
🤖 Prompt for AI Agents
In apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx around lines
325 to 327, the production branch of the copied share URL omits the required
"/s/" segment causing 404s; update the ternary so the production URL includes
"/s/" (i.e., use "https://cap.link/s/${cap.id}" when buildEnv.NEXT_PUBLIC_IS_CAP
&& NODE_ENV === 'production') so it matches the share route used elsewhere.

@ameer2468 ameer2468 merged commit 6af2d73 into main Sep 25, 2025
16 checks passed
@ameer2468 ameer2468 deleted the fix-copy-link branch September 25, 2025 21:09
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.

1 participant